mirror of
https://github.com/KevinMidboe/vue-js-modal.git
synced 2025-10-29 18:00:20 +00:00
Added new demo, sorted out default class names
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
|
<demo-error-modal/>
|
||||||
<modal name="example-modal"
|
<modal name="example-modal"
|
||||||
transition="nice-modal-fade"
|
transition="nice-modal-fade"
|
||||||
:min-width="200"
|
:min-width="200"
|
||||||
@@ -29,39 +30,15 @@
|
|||||||
Vue.use(vmodal)
|
Vue.use(vmodal)
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
<table>
|
<modes-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>
|
|
||||||
|
|
||||||
<div style="margin-top: 20px; margin-bottom: 20px;">
|
<div style="margin-top: 20px; margin-bottom: 15px;">
|
||||||
<button @click="show(false, false, false)">Simple</button>
|
<button @click="show(false, false, false)">Simple</button>
|
||||||
<button @click="show(true, false, false)">Resizable</button>
|
<button @click="show(true, false, false)">Resizable</button>
|
||||||
<button @click="show(false, true, false)">Adaptive</button>
|
<button @click="show(false, true, false)">Adaptive</button>
|
||||||
<button @click="show(true, true, false)">Mixed</button>
|
<button @click="show(true, true, false)">Mixed</button>
|
||||||
<button @click="show(false, false, true)">Draggable</button>
|
<button @click="show(false, false, true)">Draggable</button>
|
||||||
|
<button @click="showErrorModal">Demo: Error handling</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<props-table />
|
<props-table />
|
||||||
@@ -69,12 +46,17 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import PropsTable from './PropsTable.vue'
|
import ModesTable from './components/ModesTable.vue'
|
||||||
//<props-table/>
|
import PropsTable from './components/PropsTable.vue'
|
||||||
|
import DemoErrorModal from './components/DemoErrorModal.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'app',
|
name: 'app',
|
||||||
components: {PropsTable},
|
components: {
|
||||||
|
ModesTable,
|
||||||
|
PropsTable,
|
||||||
|
DemoErrorModal
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
resizable: false,
|
resizable: false,
|
||||||
@@ -87,7 +69,6 @@ export default {
|
|||||||
this.resizable = resizable
|
this.resizable = resizable
|
||||||
this.adaptive = adaptive
|
this.adaptive = adaptive
|
||||||
this.draggable = draggable
|
this.draggable = draggable
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$nextTick is required because the data model with new
|
$nextTick is required because the data model with new
|
||||||
"resizable, adaptive, draggable" values is not updated yet.. eh
|
"resizable, adaptive, draggable" values is not updated yet.. eh
|
||||||
@@ -95,6 +76,10 @@ export default {
|
|||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$modal.show('example-modal')
|
this.$modal.show('example-modal')
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
showErrorModal () {
|
||||||
|
this.$modal.show('error-modal')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
82
demo/src/components/DemoErrorModal.vue
Normal file
82
demo/src/components/DemoErrorModal.vue
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
<template>
|
||||||
|
<modal name="error-modal"
|
||||||
|
:classes="['v--modal', 'error-modal', hasBugs && 'has-bugs']"
|
||||||
|
:pivot-y="0.2"
|
||||||
|
:width="400"
|
||||||
|
:height="300"
|
||||||
|
@before-close="beforeClose">
|
||||||
|
<div class="error-modal-content">
|
||||||
|
<div class="bugs-label">bugs: {{bugCount}}</div>
|
||||||
|
<button @click="createBug">Create a bug</button>
|
||||||
|
<button @click="fixBug">Fix a bug</button>
|
||||||
|
|
||||||
|
<div style="padding: 10px;">
|
||||||
|
You will be able to close the window only if you have fixed all the bugs :)
|
||||||
|
</div>
|
||||||
|
<sub :style="{opacity: hasBugs ? 1 : 0}">{{bugCount}} bugs to fix</sub>
|
||||||
|
</div>
|
||||||
|
</modal>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'DemoErrorModal',
|
||||||
|
data () {
|
||||||
|
return {
|
||||||
|
bugCount: 0,
|
||||||
|
message: '',
|
||||||
|
hasBugs: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
createBug () {
|
||||||
|
this.bugCount++
|
||||||
|
},
|
||||||
|
|
||||||
|
fixBug () {
|
||||||
|
this.bugCount = Math.max(this.bugCount - 1, 0)
|
||||||
|
this.hasBugs = false
|
||||||
|
},
|
||||||
|
|
||||||
|
beforeClose (event) {
|
||||||
|
if (this.bugCount > 0) {
|
||||||
|
this.hasBugs = true
|
||||||
|
/*
|
||||||
|
Stopping close event execution
|
||||||
|
*/
|
||||||
|
event.stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style lang="scss">
|
||||||
|
.modal.error-modal {
|
||||||
|
transition: box-shadow 1s;
|
||||||
|
|
||||||
|
&.has-bugs {
|
||||||
|
box-shadow: 0 24px 80px -2px rgba(255, 0, 0, .6) !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.error-modal-content {
|
||||||
|
padding: 10px;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
.bugs-label {
|
||||||
|
text-transform: uppercase;
|
||||||
|
font-size: 60px;
|
||||||
|
font-weight: 300;
|
||||||
|
letter-spacing: 2px;
|
||||||
|
padding: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
width: 180px;
|
||||||
|
}
|
||||||
|
|
||||||
|
sub {
|
||||||
|
color: #EC625F;
|
||||||
|
transition: opacity 0.25s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
33
demo/src/components/ModesTable.vue
Normal file
33
demo/src/components/ModesTable.vue
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<template>
|
||||||
|
<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>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'ModesTable'
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<transition name="overlay-fade">
|
<transition name="overlay-fade">
|
||||||
<div v-if="visibility.overlay"
|
<div v-if="visibility.overlay"
|
||||||
ref="overlay"
|
ref="overlay"
|
||||||
class="v-j-modal-overlay"
|
class="v--modal-overlay"
|
||||||
:data-modal="name"
|
:data-modal="name"
|
||||||
@mousedown.stop="toggle(false)">
|
@mousedown.stop="toggle(false)">
|
||||||
<transition :name="transition">
|
<transition :name="transition">
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
},
|
},
|
||||||
classes: {
|
classes: {
|
||||||
type: [String, Array],
|
type: [String, Array],
|
||||||
default: 'v-j-modal',
|
default: 'v--modal',
|
||||||
},
|
},
|
||||||
minWidth: {
|
minWidth: {
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -286,7 +286,7 @@
|
|||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.v-j-modal-overlay {
|
.v--modal-overlay {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
@@ -322,7 +322,7 @@
|
|||||||
transform: translateY(-20px);
|
transform: translateY(-20px);
|
||||||
}
|
}
|
||||||
|
|
||||||
.v-j-modal {
|
.v--modal {
|
||||||
background: white;
|
background: white;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
@@ -331,7 +331,7 @@
|
|||||||
|
|
||||||
//background: yellow !important;
|
//background: yellow !important;
|
||||||
|
|
||||||
&.v-j-modal-fullscreen {
|
&.v--modal-fullscreen {
|
||||||
width: 100vw;
|
width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user