2020-10-08 00:01:17 -04:00
|
|
|
<template>
|
2022-02-19 00:18:01 -05:00
|
|
|
<div class="dropdown" :class="{ 'is-active': is_active }" v-click-away="onClickOutside">
|
2020-10-08 00:01:17 -04:00
|
|
|
<div class="dropdown-trigger">
|
|
|
|
<button class="button" aria-haspopup="true" aria-controls="dropdown-menu" @click="is_active = !is_active">
|
2022-02-19 00:18:01 -05:00
|
|
|
<span>{{ modelValue }}</span>
|
2020-10-08 00:01:17 -04:00
|
|
|
<span class="icon is-small">
|
|
|
|
<i class="mdi mdi-chevron-down" aria-hidden="true"></i>
|
|
|
|
</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="dropdown-menu" id="dropdown-menu" role="menu">
|
|
|
|
<div class="dropdown-content">
|
|
|
|
<a class="dropdown-item"
|
|
|
|
v-for="option in options" :key="option"
|
2022-02-19 00:18:01 -05:00
|
|
|
:class="{'is-active': modelValue === option}"
|
2020-10-08 00:01:17 -04:00
|
|
|
@click="select(option)">
|
|
|
|
{{ option }}
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: 'DropdownMenu',
|
|
|
|
|
2022-02-19 00:18:01 -05:00
|
|
|
props: ['modelValue', 'options'],
|
|
|
|
emits: ['update:modelValue'],
|
2020-10-08 00:01:17 -04:00
|
|
|
|
|
|
|
data () {
|
|
|
|
return {
|
|
|
|
is_active: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
onClickOutside (event) {
|
|
|
|
this.is_active = false
|
|
|
|
},
|
|
|
|
|
|
|
|
select (option) {
|
|
|
|
this.is_active = false
|
2022-02-19 00:18:01 -05:00
|
|
|
this.$emit('update:modelValue', option)
|
2020-10-08 00:01:17 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style>
|
|
|
|
</style>
|