2
0
mirror of https://github.com/frappe/books.git synced 2025-01-28 01:28:28 +00:00
books/ui/components/Dropdown.vue

51 lines
1.1 KiB
Vue
Raw Normal View History

2018-07-14 20:11:31 +05:30
<template>
2018-09-28 18:40:48 +05:30
<div class="dropdown show" ref="dropdownMenu" v-on-outside-click="hideDropdown">
2018-07-15 12:30:47 +05:30
<button
:id="_uid"
2018-07-15 12:30:47 +05:30
class="btn btn-sm btn-light dropdown-toggle"
2018-07-14 20:31:44 +05:30
aria-haspopup="true"
2018-07-15 12:30:47 +05:30
:aria-expanded="isShown ? 'true' : 'false'"
@click="isShown = !isShown"
>
{{ label }}
2018-07-15 12:30:47 +05:30
</button>
<div :class="['dropdown-menu dropdown-menu-right', isShown ? 'show' : '']" :aria-labelledby="_uid">
<a
href="#"
class="dropdown-item"
2018-07-14 20:31:44 +05:30
v-for="option in options"
:key="option.label"
2018-07-15 12:30:47 +05:30
@click.prevent="option.handler"
>
{{ option.label }}
2018-07-14 20:31:44 +05:30
</a>
2018-07-14 20:11:31 +05:30
</div>
</div>
</template>
<script>
export default {
2018-07-15 12:30:47 +05:30
props: ['label', 'options'],
data() {
return {
isShown: false
2018-09-28 18:40:48 +05:30
};
},
2018-09-28 18:40:48 +05:30
methods: {
hideDropdown() {
this.isShown = false;
}
2018-09-28 18:40:48 +05:30
}
};
2018-07-14 20:11:31 +05:30
</script>
2018-07-15 12:30:47 +05:30
<style lang="scss">
2018-09-28 18:40:48 +05:30
@import '../styles/variables.scss';
2018-07-15 12:30:47 +05:30
$dropdown-link-active-bg: $gray-300;
.dropdown-item {
&.active,
&:active {
@include gradient-bg($dropdown-link-active-bg);
}
}
2018-07-14 20:11:31 +05:30
</style>