atst/js/components/toggler.js
2018-09-25 13:17:24 -04:00

33 lines
536 B
JavaScript

export default {
name: 'toggler',
props: {
defaultVisible: {
type: Boolean,
default: () => false
}
},
data: function () {
return {
isVisible: this.defaultVisible
}
},
render: function (createElement) {
return createElement( this.$vnode.data.tag, [
this.$scopedSlots.default({
isVisible: this.isVisible,
toggle: this.toggle
})
])
},
methods: {
toggle: function (e) {
e.preventDefault()
this.isVisible = !this.isVisible
}
}
}