Skip to content

Instantly share code, notes, and snippets.

@DominikAngerer
Last active January 17, 2019 21:50
Show Gist options
  • Select an option

  • Save DominikAngerer/eed8920dabbfae23b2c898ba7198fe85 to your computer and use it in GitHub Desktop.

Select an option

Save DominikAngerer/eed8920dabbfae23b2c898ba7198fe85 to your computer and use it in GitHub Desktop.
Storyblok: Custom Field Modal Demo
<template>
<div>
<div v-show="!modalIsOpen">
Custom field is in sidebar / not in modal
<button @click=openModal>Open</button>
</div>
<div v-if="modalIsOpen">
Custom field is in not in sidebar but in a modal
<button @click=closeModal>Close</button>
</div>
</div>
</template>
<script>
export default {
mixins: [window.Storyblok.plugin],
data() {
return {
modalIsOpen: false
}
},
methods: {
initWith() {
return {
// needs to be equal to your storyblok plugin name
plugin: 'my-plugin-name'
}
},
pluginCreated() {
// eslint-disable-next-line
console.log('plugin:created')
},
openModal(){
this.$emit('toggle-modal', true)
this.modalIsOpen = true
},
closeModal(){
this.$emit('toggle-modal', false)
this.modalIsOpen = false
}
},
watch: {
'model': {
handler: function (value) {
this.$emit('changed-model', value);
},
deep: true
}
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment