bootstrap-vue
Version:
BootstrapVue provides one of the most comprehensive implementations of Bootstrap 4 components and grid system for Vue.js and with extensive and automated WAI-ARIA accessibility markup.
47 lines (45 loc) • 1.09 kB
JavaScript
import listenOnRootMixin from '../../mixins/listen-on-root';
export default {
mixins: [listenOnRootMixin],
render: function render(h) {
var t = this;
return h('button', {
class: ['navbar-toggler'],
attrs: {
type: 'button',
'aria-label': t.label,
'aria-controls': t.target,
'aria-expanded': t.toggleState ? 'true' : 'false'
},
on: { click: t.onClick }
}, [t.$slots.default || h('span', { class: ['navbar-toggler-icon'] })]);
},
data: function data() {
return {
toggleState: false
};
},
props: {
label: {
type: String,
default: 'Toggle navigation'
},
target: {
type: String,
required: true
}
},
methods: {
onClick: function onClick() {
this.$root.$emit('bv::toggle::collapse', this.target);
},
handleStateEvt: function handleStateEvt(id, state) {
if (id === this.target) {
this.toggleState = state;
}
}
},
created: function created() {
this.listenOnRoot('bv::collapse::state', this.handleStateEvt);
}
};