Updated examples

This commit is contained in:
euvl
2017-03-10 11:05:33 +00:00
parent c1913b0490
commit 0a46692303
3 changed files with 57 additions and 53 deletions

View File

@@ -3,7 +3,6 @@
</div> </div>
</template> </template>
<script> <script>
import util from '../util';
export default { export default {
name: 'Resizer', name: 'Resizer',
data() { data() {
@@ -26,7 +25,7 @@ export default {
window.addEventListener('mousemove', this.mousemove, false); window.addEventListener('mousemove', this.mousemove, false);
window.addEventListener('mouseup', this.stop, false); window.addEventListener('mouseup', this.stop, false);
util.stopEvent(event); event.stopPropagation();
}, },
stop() { stop() {
this.clicked = false; this.clicked = false;
@@ -54,10 +53,15 @@ export default {
var height = event.clientY - el.offsetTop; var height = event.clientY - el.offsetTop;
if (height < this.min.height) { if (height < this.min.height) {
return; height = this.min.height;
}
if (width < this.min.width) {
width = this.min.width;
} }
this.size = {width, height}; this.size = {width, height};
el.style.width = width + 'px'; el.style.width = width + 'px';
el.style.height = height + 'px'; el.style.height = height + 'px';

View File

@@ -20,7 +20,7 @@ const VueModal = {
get: () => $modal get: () => $modal
}); });
Vue.component('nice-modal', Modal); Vue.component('modal', Modal);
return null; return null;
}, },
}; };

View File

@@ -1,25 +1,11 @@
<template> <template>
<div id="app"> <div id="app">
<h2> <h2>Vue.js Modal</h2>
Beeper <modal name="example-modal"
<nice-beep class="inline-beep" color="#23d813" :frequency="1200"/>
</h2>
<div>
tl;dr
</div>
<h2>Notifications</h2>
<nice-notifications name="example-1" animation="fade"/>
<nice-notifications position="bottom left"/>
<button @click="notifyExample0">Example 1</button>
<button @click="notifyExample1">Example 2</button>
<h2>Modals</h2>
<nice-modal name="example-modal"
transition="nice-modal-fade" transition="nice-modal-fade"
:delay="200" :delay="200"
:adaptive="true" :adaptive="resizable"
:resizable="true"> :resizable="adaptive">
<div style="height: 100%; box-sizing: border-box; padding: 10px; font-size: 13px; overflow: auto"> <div style="height: 100%; box-sizing: border-box; padding: 10px; font-size: 13px; overflow: auto">
Appropriately exploit professional infrastructures rather than unique Appropriately exploit professional infrastructures rather than unique
growth strategies. Assertively build leveraged growth strategies growth strategies. Assertively build leveraged growth strategies
@@ -39,39 +25,58 @@
sources through equity invested mindshare. Globally redefine unique sources through equity invested mindshare. Globally redefine unique
best practices for. best practices for.
</div> </div>
</nice-modal> </modal>
<button @click="modalExample0">Example 1</button>
<table>
<tr>
<td style="width: 20%">Modes:</td>
<td></td>
</tr>
<tr>
<td><b>Simple</b></td>
<td>Yet another boring modal :)</td>
</tr>
<tr>
<td><b>Adaptive</b></td>
<td>Tries to adjust to the page size</td>
</tr>
<tr>
<td><b>Resizable</b></td>
<td>
Has a small arrow on the bottom-right corner
(customizable) that you can drag to change the size of the modal
</td>
</tr>
<tr>
<td><b>Mixed</b></td>
<td>
Is resizable, but if the size of the screen is changed
modal will return to its initial size as well as it will try to adapt to
the page size
</td>
</tr>
</table>
<button @click="show(false, false)">Simple</button>
<button @click="show(true, false)">Resizable</button>
<button @click="show(false, true)">Adaptive</button>
<button @click="show(true, true)">Mixed</button>
</div> </div>
</template> </template>
<script> <script>
const ID = ((i) => () => i++)(0);
export default { export default {
name: 'app', name: 'app',
data() {
return {
resizable: false,
adaptive: false
}
},
methods: { methods: {
notifyExample0() { show(resizable, adaptive) {
this.$notify({ this.resizable = resizable;
type: 'error', this.adaptive = adaptive;
group: 'example-1',
title: 'Error message',
text: 'This is error message #' + ID()
});
},
notifyExample1() {
this.$notify({
type: 'warn',
duration: 10000,
title: 'Warning message',
text:
`
Warning #${ID()} <br>
Notification will dissapear in 10 sec<br>
Rendering <b>HTML</b>
`
});
},
modalExample0() {
this.$modal.show('example-modal'); this.$modal.show('example-modal');
} }
} }
@@ -96,9 +101,4 @@ h1, h2 {
font-weight: normal; font-weight: normal;
} }
.inline-beep {
display: inline-block;
position: relative !important;
}
</style> </style>