mirror of
https://github.com/KevinMidboe/vue-js-modal.git
synced 2025-12-08 20:48:46 +00:00
Added new example
This commit is contained in:
@@ -2,6 +2,8 @@
|
|||||||
<div id="app">
|
<div id="app">
|
||||||
<demo-error-modal/>
|
<demo-error-modal/>
|
||||||
<demo-login-modal/>
|
<demo-login-modal/>
|
||||||
|
<demo-conditional-modal/>
|
||||||
|
|
||||||
<modal name="example-modal"
|
<modal name="example-modal"
|
||||||
transition="nice-modal-fade"
|
transition="nice-modal-fade"
|
||||||
:min-width="200"
|
:min-width="200"
|
||||||
@@ -42,6 +44,9 @@
|
|||||||
<br>
|
<br>
|
||||||
<button class="green" @click="$modal.show('error-modal')">Demo: Error handling</button>
|
<button class="green" @click="$modal.show('error-modal')">Demo: Error handling</button>
|
||||||
<button class="green" @click="$modal.show('demo-login')">Demo: Login</button>
|
<button class="green" @click="$modal.show('demo-login')">Demo: Login</button>
|
||||||
|
<button :class="canBeShown ? 'green' : 'red'" @click="conditionalShow">
|
||||||
|
Can <b v-if="!canBeShown">NOT</b> be shown
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<props-table />
|
<props-table />
|
||||||
@@ -49,10 +54,11 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import ModesTable from './components/ModesTable.vue'
|
import ModesTable from './components/ModesTable.vue'
|
||||||
import PropsTable from './components/PropsTable.vue'
|
import PropsTable from './components/PropsTable.vue'
|
||||||
import DemoErrorModal from './components/DemoErrorModal.vue'
|
import DemoErrorModal from './components/DemoErrorModal.vue'
|
||||||
import DemoLoginModal from './components/DemoLoginModal.vue'
|
import DemoLoginModal from './components/DemoLoginModal.vue'
|
||||||
|
import DemoConditionalModal from './components/ConditionalModal.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'app',
|
name: 'app',
|
||||||
@@ -60,15 +66,22 @@ export default {
|
|||||||
ModesTable,
|
ModesTable,
|
||||||
PropsTable,
|
PropsTable,
|
||||||
DemoErrorModal,
|
DemoErrorModal,
|
||||||
DemoLoginModal
|
DemoLoginModal,
|
||||||
|
DemoConditionalModal
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
resizable: false,
|
resizable: false,
|
||||||
adaptive: false,
|
adaptive: false,
|
||||||
draggable: false,
|
draggable: false,
|
||||||
|
canBeShown: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
created () {
|
||||||
|
setInterval(() => {
|
||||||
|
this.canBeShown = !this.canBeShown
|
||||||
|
}, 5000)
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
show(resizable, adaptive, draggable) {
|
show(resizable, adaptive, draggable) {
|
||||||
this.resizable = resizable
|
this.resizable = resizable
|
||||||
@@ -81,8 +94,12 @@ export default {
|
|||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$modal.show('example-modal')
|
this.$modal.show('example-modal')
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
|
||||||
|
conditionalShow () {
|
||||||
|
this.$modal.show('conditional-modal', { show: this.canBeShown })
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -144,14 +161,26 @@ button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
&.green {
|
&.green {
|
||||||
$green: #50C9BA;
|
$color: #50C9BA;
|
||||||
|
|
||||||
color: $green;
|
color: $color;
|
||||||
border: 1px solid $green;
|
border: 1px solid $color;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: mix($green, black, 95%);
|
color: mix($color, black, 95%);
|
||||||
border: 1px solid mix($green, black, 95%);
|
border: 1px solid mix($color, black, 95%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&.red {
|
||||||
|
$color: #F21368;
|
||||||
|
|
||||||
|
color: $color;
|
||||||
|
border: 1px solid $color;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
color: mix($color, black, 95%);
|
||||||
|
border: 1px solid mix($color, black, 95%);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
24
demo/src/components/ConditionalModal.vue
Normal file
24
demo/src/components/ConditionalModal.vue
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<template>
|
||||||
|
<modal name="conditional-modal"
|
||||||
|
:height="200"
|
||||||
|
@before-open="beforeOpen">
|
||||||
|
<div style="padding:30px; text-align: center">
|
||||||
|
Hello!
|
||||||
|
</div>
|
||||||
|
</modal>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
name: 'ConditionalModal',
|
||||||
|
methods: {
|
||||||
|
beforeOpen (event) {
|
||||||
|
console.log('Event:', event)
|
||||||
|
console.log('Params:', event.params)
|
||||||
|
|
||||||
|
if (event.params.show === false) {
|
||||||
|
event.stop()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -14,7 +14,9 @@
|
|||||||
<div style="padding: 10px;">
|
<div style="padding: 10px;">
|
||||||
You will be able to close the window only if you have fixed all the bugs :)
|
You will be able to close the window only if you have fixed all the bugs :)
|
||||||
</div>
|
</div>
|
||||||
<sub :style="{opacity: hasBugs ? 1 : 0}">{{bugCount}} bugs to fix</sub>
|
<sub :style="{opacity: hasBugs ? 1 : 0}">
|
||||||
|
{{bugCount}} bugs to fix
|
||||||
|
</sub>
|
||||||
</div>
|
</div>
|
||||||
</modal>
|
</modal>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<div v-if="visibility.overlay"
|
<div v-if="visibility.overlay"
|
||||||
ref="overlay"
|
ref="overlay"
|
||||||
class="v--modal-overlay"
|
class="v--modal-overlay"
|
||||||
|
:aria-expanded="visible.toString()"
|
||||||
:data-modal="name"
|
:data-modal="name"
|
||||||
@mousedown.stop="toggle(false)">
|
@mousedown.stop="toggle(false)">
|
||||||
<transition :name="transition">
|
<transition :name="transition">
|
||||||
|
|||||||
Reference in New Issue
Block a user