atst/js/components/toggler.js
2019-01-24 09:38:43 -05:00

33 lines
539 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
},
},
}