/
navbar-toggle.vue
executable file
·59 lines (57 loc) · 1.33 KB
/
navbar-toggle.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<template>
<button :class="classObject"
type="button"
:aria-label="label"
:aria-controls="target.id ? target.id : target"
:aria-expanded="toggleState ? 'true' : 'false'"
@click="onclick"
>
<slot><span class="navbar-toggler-icon"></span></slot>
</button>
</template>
<script>
import { listenOnRootMixin } from '../../mixins';
export default {
mixins: [listenOnRootMixin],
computed: {
classObject() {
return [
'navbar-toggler',
'navbar-toggler-' + this.position
];
}
},
data() {
return {
toggleState: false
};
},
props: {
label: {
type: String,
default: 'Toggle navigation'
},
position: {
type: String,
default: 'right'
},
target: {
type: String,
required: true
}
},
methods: {
onclick() {
this.$root.$emit('bv::toggle::collapse', this.target);
},
handleStateEvt(id, state) {
if (id === this.target) {
this.toggleState = state;
}
}
},
created() {
this.listenOnRoot('bv::collapse::state', this.handleStateEvt);
}
};
</script>