2
0
mirror of https://github.com/frappe/books.git synced 2024-12-25 12:10:06 +00:00
books/ui/components/Dropdown.vue

51 lines
1.1 KiB
Vue
Raw Normal View History

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