Skip to content

Instantly share code, notes, and snippets.

@DominikAngerer
Created October 8, 2018 20:58
Show Gist options
  • Select an option

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

Select an option

Save DominikAngerer/f8fa330ae078a7bde22761815f593279 to your computer and use it in GitHub Desktop.
const Fieldtype = {
mixins: [window.Storyblok.plugin],
template: `
<div>
<div class="uk-grid">
<div class="uk-width-1-5" v-if="has_image">
<img :src="model.src"/>
</div>
<div :class="{ 'uk-width-4-5': has_image, 'uk-width-1-1': !has_image }" >
<input class="uk-width-1-1" placeholder="Your image URL" v-model="model.src" />
</div>
</div>
<sb-asset-selector :uid="uid" field="src"></sb-asset-selector>
</div>`,
computed: {
has_image() {
return this.model.src !== ''
}
},
methods: {
initWith() {
return {
plugin: 'imagefieldtest',
src: ''
}
},
pluginCreated() {
console.log('plugin:created')
}
},
watch: {
'model': {
handler: function (value) {
this.$emit('changed-model', value);
},
deep: true
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment