mirror of
https://github.com/KevinMidboe/vue-js-modal.git
synced 2025-10-29 18:00:20 +00:00
2
.babelrc
2
.babelrc
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"presets": ["es2015", "stage-2"],
|
"presets": ["env"],
|
||||||
"comments": false
|
"comments": false
|
||||||
}
|
}
|
||||||
|
|||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
node_modules/
|
node_modules/
|
||||||
npm-debug.log
|
npm-debug.log
|
||||||
|
package-lock.json
|
||||||
*.map
|
*.map
|
||||||
|
|||||||
31
README.md
31
README.md
@@ -18,7 +18,7 @@ npm install vue-js-modal --save
|
|||||||
|
|
||||||
### How to use
|
### How to use
|
||||||
|
|
||||||
Include plugin in your main.js file.
|
Include plugin in your `main.js` file.
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
import vmodal from 'vue-js-modal'
|
import vmodal from 'vue-js-modal'
|
||||||
@@ -26,13 +26,15 @@ import vmodal from 'vue-js-modal'
|
|||||||
Vue.use(vmodal)
|
Vue.use(vmodal)
|
||||||
```
|
```
|
||||||
|
|
||||||
Create modal
|
Create modal:
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<modal name="hello-world">
|
<modal name="hello-world">
|
||||||
hello, world!
|
hello, world!
|
||||||
</modal>
|
</modal>
|
||||||
```
|
```
|
||||||
Call it from anywhere in the app
|
Call it from anywhere in the app:
|
||||||
|
|
||||||
```javascript
|
```javascript
|
||||||
methods: {
|
methods: {
|
||||||
show () {
|
show () {
|
||||||
@@ -44,6 +46,27 @@ methods: {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### SSR
|
||||||
|
|
||||||
|
Include plugin in your `nuxt.config.js` file:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
module.exports = {
|
||||||
|
plugins: ['~plugins/vue-js-modal']
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
And your `plugins/vue-js-modal.js` will look like:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
import Vue from 'vue'
|
||||||
|
import VModal from 'vue-js-modal/dist/ssr.index'
|
||||||
|
|
||||||
|
Vue.use(VModal)
|
||||||
|
```
|
||||||
|
|
||||||
|
For full demo please look at `demo/server_side_rendering`
|
||||||
|
|
||||||
### Properties
|
### Properties
|
||||||
|
|
||||||
| Name | Required | Type | Default | Description |
|
| Name | Required | Type | Default | Description |
|
||||||
@@ -172,5 +195,3 @@ cd demo
|
|||||||
npm install
|
npm install
|
||||||
npm run dev
|
npm run dev
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
40
build/webpack.base.config.js
Normal file
40
build/webpack.base.config.js
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
const path = require('path')
|
||||||
|
const webpack = require('webpack')
|
||||||
|
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
|
||||||
|
|
||||||
|
// "build:client": "cross-env NODE_ENV=production webpack --config ./build/webpack.client.config.js --progress --hide-modules",
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
entry: path.resolve(__dirname, '../src/index.js'),
|
||||||
|
output: {
|
||||||
|
path: path.resolve(__dirname, '../dist'),
|
||||||
|
publicPath: '/dist/',
|
||||||
|
library:'VueJsModal',
|
||||||
|
libraryTarget: 'commonjs2'
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
{
|
||||||
|
test: /\.vue$/,
|
||||||
|
loader: 'vue-loader'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
test: /\.js$/,
|
||||||
|
loader: 'babel-loader',
|
||||||
|
exclude: /node_modules/
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
externals: {
|
||||||
|
vue: 'vue'
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'vue$': 'vue/dist/vue.esm.js'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
devtool: '#source-map',
|
||||||
|
plugins: [
|
||||||
|
// new UglifyJSPlugin()
|
||||||
|
]
|
||||||
|
}
|
||||||
10
build/webpack.client.config.js
Normal file
10
build/webpack.client.config.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
const path = require('path')
|
||||||
|
const webpack = require('webpack')
|
||||||
|
const merge = require('webpack-merge')
|
||||||
|
const base = require('./webpack.base.config')
|
||||||
|
|
||||||
|
module.exports = merge(base, {
|
||||||
|
output: {
|
||||||
|
filename: 'index.js'
|
||||||
|
}
|
||||||
|
})
|
||||||
11
build/webpack.server.config.js
Normal file
11
build/webpack.server.config.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
const path = require('path')
|
||||||
|
const webpack = require('webpack')
|
||||||
|
const merge = require('webpack-merge')
|
||||||
|
const base = require('./webpack.base.config')
|
||||||
|
|
||||||
|
module.exports = merge(base, {
|
||||||
|
target: 'node',
|
||||||
|
output: {
|
||||||
|
filename: 'ssr.index.js'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
Before Width: | Height: | Size: 1.2 MiB After Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 76 KiB After Width: | Height: | Size: 76 KiB |
@@ -37,7 +37,7 @@ module.exports = {
|
|||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'vue$': 'vue/dist/vue.esm.js',
|
'vue$': 'vue/dist/vue.esm.js',
|
||||||
'plugin': path.resolve(__dirname, "../dist/index.js")
|
'plugin': path.resolve(__dirname, "../../dist/index.js")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
devServer: {
|
devServer: {
|
||||||
1
demo/server_side_rendering/.gitignore
vendored
Normal file
1
demo/server_side_rendering/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.nuxt
|
||||||
3
demo/server_side_rendering/nuxt.config.js
Normal file
3
demo/server_side_rendering/nuxt.config.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
plugins: ['~plugins/vue-js-modal']
|
||||||
|
}
|
||||||
4044
demo/server_side_rendering/package-lock.json
generated
Normal file
4044
demo/server_side_rendering/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
10
demo/server_side_rendering/package.json
Normal file
10
demo/server_side_rendering/package.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"name": "nuxt-hello",
|
||||||
|
"scripts": {
|
||||||
|
"start": "nuxt"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"vue-js-modal": "github:euvl/vue-js-modal#dcf3291623d9fe54bcbf0ca48c0ed35865b8871a",
|
||||||
|
"nuxt": "^1.0.0-alpha.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
19
demo/server_side_rendering/pages/index.vue
Normal file
19
demo/server_side_rendering/pages/index.vue
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<modal name="foo">bar</modal>
|
||||||
|
<button @click="$modal.show('foo')">
|
||||||
|
Open modal
|
||||||
|
</button>
|
||||||
|
<p>Hi from {{ name }}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
asyncData ({ req }) {
|
||||||
|
return {
|
||||||
|
name: req ? 'server' : 'client'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
4
demo/server_side_rendering/plugins/vue-js-modal.js
Normal file
4
demo/server_side_rendering/plugins/vue-js-modal.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import Vue from 'vue'
|
||||||
|
import VModal from 'vue-js-modal/dist/ssr.index'
|
||||||
|
|
||||||
|
Vue.use(VModal)
|
||||||
1
dist/client.index.js
vendored
Normal file
1
dist/client.index.js
vendored
Normal file
File diff suppressed because one or more lines are too long
112
dist/index.js
vendored
112
dist/index.js
vendored
File diff suppressed because one or more lines are too long
978
dist/ssr.index.js
vendored
Normal file
978
dist/ssr.index.js
vendored
Normal file
File diff suppressed because one or more lines are too long
17
package.json
17
package.json
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "vue-js-modal",
|
"name": "vue-js-modal",
|
||||||
"description": "Modal Component for Vue.js",
|
"description": "Modal Component for Vue.js",
|
||||||
"version": "1.1.3",
|
"version": "1.2.0",
|
||||||
"author": "euvl <yev.vlasenko@gmail.com>",
|
"author": "euvl <yev.vlasenko@gmail.com>",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
@@ -18,27 +18,28 @@
|
|||||||
"url": "https://github.com/euvl/vue-js-modal/issues"
|
"url": "https://github.com/euvl/vue-js-modal/issues"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
|
"build:client": "webpack --config ./build/webpack.client.config.js --progress --hide-modules",
|
||||||
|
"build:server": "webpack --config ./build/webpack.server.config.js --progress --hide-modules"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-core": "^6.0.0",
|
"babel-core": "^6.25.0",
|
||||||
"babel-loader": "^6.2.10",
|
"babel-loader": "latest",
|
||||||
"babel-preset-es2015": "^6.0.0",
|
"babel-preset-env": "^1.5.2",
|
||||||
"babel-preset-latest": "^6.0.0",
|
|
||||||
"babel-preset-stage-2": "^6.24.1",
|
|
||||||
"cross-env": "^3.0.0",
|
"cross-env": "^3.0.0",
|
||||||
"css-loader": "^0.25.0",
|
"css-loader": "^0.25.0",
|
||||||
"file-loader": "^0.9.0",
|
"file-loader": "^0.9.0",
|
||||||
"node-sass": "^4.5.0",
|
"node-sass": "^4.5.0",
|
||||||
"sass-loader": "^5.0.1",
|
"sass-loader": "^5.0.1",
|
||||||
|
"uglifyjs-webpack-plugin": "^0.4.6",
|
||||||
"vue": "^2.2.6",
|
"vue": "^2.2.6",
|
||||||
"vue-hot-reload-api": "^2.0.8",
|
"vue-hot-reload-api": "^2.0.8",
|
||||||
"vue-loader": "^10.0.0",
|
"vue-loader": "^10.0.0",
|
||||||
"vue-style-loader": "^2.0.0",
|
"vue-style-loader": "^2.0.0",
|
||||||
"vue-template-compiler": "^2.1.0",
|
"vue-template-compiler": "^2.1.0",
|
||||||
"webpack": "^2.2.0",
|
"webpack": "^2.2.0",
|
||||||
"webpack-dev-server": "^2.2.0"
|
"webpack-dev-server": "^2.2.0",
|
||||||
|
"webpack-merge": "^4.1.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"vue": "^2.2.6"
|
"vue": "^2.2.6"
|
||||||
|
|||||||
@@ -149,8 +149,8 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
window: {
|
window: {
|
||||||
width: window.innerWidth,
|
width: 0,
|
||||||
height: window.innerWidth
|
height: 0
|
||||||
},
|
},
|
||||||
|
|
||||||
draggableElement: false
|
draggableElement: false
|
||||||
@@ -180,7 +180,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
beforeMount () {
|
||||||
Modal.event.$on('toggle', (name, state, params) => {
|
Modal.event.$on('toggle', (name, state, params) => {
|
||||||
if (name === this.name) {
|
if (name === this.name) {
|
||||||
if (typeof state === 'undefined') {
|
if (typeof state === 'undefined') {
|
||||||
@@ -192,13 +192,11 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
window.addEventListener('resize', this.onWindowResize)
|
window.addEventListener('resize', this.onWindowResize)
|
||||||
|
this.onWindowResize()
|
||||||
},
|
},
|
||||||
beforeDestroy () {
|
beforeDestroy () {
|
||||||
window.removeEventListener('resize', this.onWindowResize)
|
window.removeEventListener('resize', this.onWindowResize)
|
||||||
},
|
},
|
||||||
beforeMount () {
|
|
||||||
this.onWindowResize()
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
position () {
|
position () {
|
||||||
const { window, modal, shift } = this
|
const { window, modal, shift } = this
|
||||||
@@ -375,7 +373,7 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style scoped>
|
<style>
|
||||||
.v--modal-overlay {
|
.v--modal-overlay {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
var path = require('path')
|
|
||||||
var webpack = require('webpack')
|
|
||||||
|
|
||||||
module.exports = {
|
|
||||||
entry: './src/index.js',
|
|
||||||
output: {
|
|
||||||
path: path.resolve(__dirname, './dist'),
|
|
||||||
publicPath: '/dist/',
|
|
||||||
filename: 'index.js',
|
|
||||||
library:'VueJsModal',
|
|
||||||
libraryTarget: 'umd'
|
|
||||||
},
|
|
||||||
module: {
|
|
||||||
rules: [
|
|
||||||
{
|
|
||||||
test: /\.vue$/,
|
|
||||||
loader: 'vue-loader',
|
|
||||||
options: {
|
|
||||||
loaders: {
|
|
||||||
'scss': 'vue-style-loader!css-loader!sass-loader',
|
|
||||||
'sass': 'vue-style-loader!css-loader!sass-loader?indentedSyntax'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.js$/,
|
|
||||||
loader: 'babel-loader',
|
|
||||||
exclude: /node_modules/
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.(png|jpg|gif|svg)$/,
|
|
||||||
loader: 'file-loader',
|
|
||||||
options: {
|
|
||||||
name: '[name].[ext]?[hash]'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
externals: {
|
|
||||||
vue: 'vue'
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
'vue$': 'vue/dist/vue.esm.js'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
devServer: {
|
|
||||||
historyApiFallback: true,
|
|
||||||
noInfo: true
|
|
||||||
},
|
|
||||||
performance: {
|
|
||||||
hints: false
|
|
||||||
},
|
|
||||||
devtool: '#source-map',
|
|
||||||
plugins: [
|
|
||||||
new webpack.DefinePlugin({
|
|
||||||
'process.env': {
|
|
||||||
NODE_ENV: '"production"'
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
new webpack.LoaderOptionsPlugin({
|
|
||||||
minimize: true
|
|
||||||
})
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user