diff --git a/README.md b/README.md index f99cf42..c767b0d 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,7 @@ this.$modal.show('dialog', { title: 'Alert!', text: 'You are too awesome', buttons: [ - { + { title: 'Deal with it', handler: () => { alert('Woot!') } }, @@ -122,7 +122,7 @@ this.$modal.show('dialog', { default: true, // Will be triggered by default if 'Enter' pressed. handler: () => {} // Button click handler }, - { + { title: 'Close' } ] @@ -133,6 +133,50 @@ this.$modal.show('dialog', {

+### Dynamic Modals + +In order to instantiate modals at runtime (for lazy-loading or decluttering templates), it is possible to create modals dynamically. + +To start using this feature you must set `dynamic: true` in plugin configuration: + +```js +Vue.use(VModal, { dynamic: true }) +``` + +And include the `` component it in your project: + +```vue + +``` + +Call it (the first argument is the component definition, the second are component properties, and the third modal parameters): + +```javascript +this.$modal.show({ + template: ` +
+

This is created inline

+

{{ text }}

+
+ `, + props: ['text'] +}, { + text: 'This text is passed as a property' +}) +``` + +It can also be used with `.vue` files: + +```javascript +import MyComponent from './MyComponent.vue' + +this.$modal.show(MyComponent, { + text: 'This text is passed as a property' +}, { + draggable: true +}) +``` + For more examples please take a look at [vue-js-modal.yev.io](http://vue-js-modal.yev.io). ### SSR @@ -156,6 +200,10 @@ Vue.use(VModal) For full demo please look at `demo/server_side_rendering` +### Extracted CSS + +There is also a ssr build with css file extracted. Take a look in /dist folder. + ### Properties | Name | Required | Type | Default | Description | @@ -172,8 +220,10 @@ For full demo please look at `demo/server_side_rendering` | classes | false | [String, Array] | 'v--modal'| Classes that will be applied to the actual modal box, if not specified, the default 'vue--modal' class will be applied | | width | false | [String, Number] | 600 | Width in pixels or percents (e.g. 50 or "50px", "50%") | | height | false | [String, Number] | 300 | Height in pixels or percents (e.g. 50 or "50px", "50%") or `"auto"` | -| minWidth | false | Number | 0 | The minimum width to which modal can be resized | -| minHeight | false | Number | 0 | The minimum height to which modal can be resized | +| minWidth | false | Number (px) | 0 | The minimum width to which modal can be resized | +| minHeight | false | Number (px) | 0 | The minimum height to which modal can be resized | +| maxWidth | false | Number (px) | Infinity | The maximum width of the modal (if the value is greater than window width, window width will be used instead | +| maxHeight | false | Number (px) | Infinity | The maximum height of the modal (if the value is greater than window height, window height will be used instead | | pivotX | false | Number (0 - 1.0) | 0.5 | Horizontal position in %, default is 0.5 (meaning that modal box will be in the middle (50% from left) of the window | | pivotY | false | Number (0 - 1.0) | 0.5 | Vertical position in %, default is 0.5 (meaning that modal box will be in the middle (50% from top) of the window | @@ -319,6 +369,15 @@ Dont forget about close button :) ``` +### Check out + +Check out my other projects: + +* https://github.com/euvl/vue-notification +* https://github.com/euvl/vue-js-toggle-button +* https://github.com/euvl/vue-js-popover +* https://github.com/euvl/v-clipboard + ### Developers To run an example: diff --git a/demo/client_side_rendering/src/App.vue b/demo/client_side_rendering/src/App.vue index 5772188..b49fcc5 100644 --- a/demo/client_side_rendering/src/App.vue +++ b/demo/client_side_rendering/src/App.vue @@ -7,6 +7,8 @@ + + Dialog: buttons +
+ + + @@ -118,6 +136,7 @@ import DemoLoginModal from './components/DemoLoginModal.vue' import DemoDogProfileModal from './components/DogProfileModal.vue' import DemoConditionalModal from './components/ConditionalModal.vue' import DemoSizeModal from './components/SizeModal.vue' +import CustomComponentModal from './components/CustomComponentModal.vue' export default { name: 'app', @@ -203,6 +222,36 @@ export default { }) }, + showDynamicRuntimeModal () { + this.$modal.show({ + template: ` +
+

This is created inline

+

{{ text }}

+
+ `, + props: ['text'] + }, { + text: 'This text is passed as a property' + }) + }, + + showDynamicComponentModal () { + this.$modal.show(CustomComponentModal, { + text: 'This text is passed as a property' + }) + }, + + showDynamicComponentModalWithModalParams () { + this.$modal.show(CustomComponentModal, { + text: 'This text is passed as a property' + }, { + resizable: true, + adaptive: true, + draggable: true, + }) + }, + dialogEvent (eventName) { console.log('Dialog event: ' + eventName) } diff --git a/demo/client_side_rendering/src/components/ConditionalModal.vue b/demo/client_side_rendering/src/components/ConditionalModal.vue index 98475a8..eae93b9 100644 --- a/demo/client_side_rendering/src/components/ConditionalModal.vue +++ b/demo/client_side_rendering/src/components/ConditionalModal.vue @@ -1,6 +1,10 @@