2022-03-04 02:03:34 +01:00
|
|
|
<template>
|
|
|
|
<div class="relative w-full h-9" v-click-outside="clickOutsideObj">
|
|
|
|
<p class="text-sm font-semibold">{{ label }}</p>
|
|
|
|
|
|
|
|
<button type="button" :disabled="disabled" class="relative h-full w-full border border-gray-600 rounded shadow-sm pl-3 pr-3 text-left focus:outline-none cursor-pointer bg-primary text-gray-100 hover:text-gray-200" aria-haspopup="listbox" aria-expanded="true" @click.stop.prevent="clickShowMenu">
|
2022-10-18 19:09:36 +02:00
|
|
|
<ui-library-icon :icon="selectedItem" />
|
2022-03-04 02:03:34 +01:00
|
|
|
</button>
|
|
|
|
|
|
|
|
<transition name="menu">
|
2022-10-18 19:09:36 +02:00
|
|
|
<div v-show="showMenu" class="absolute -left-[4.5rem] z-10 -mt-px bg-primary border border-black-200 shadow-lg max-h-56 w-48 rounded-md py-1 overflow-auto focus:outline-none sm:text-sm">
|
|
|
|
<div class="flex justify-center items-center flex-wrap">
|
|
|
|
<template v-for="icon in icons">
|
|
|
|
<div :key="icon" class="p-2">
|
|
|
|
<span class="abs-icons text-xl text-white text-opacity-80 hover:text-opacity-100 cursor-pointer" :class="`icon-${icon}`" @click="select(icon)"></span>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-03-04 02:03:34 +01:00
|
|
|
</transition>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
value: String,
|
|
|
|
disabled: Boolean,
|
|
|
|
label: {
|
|
|
|
type: String,
|
2022-03-18 23:09:17 +01:00
|
|
|
default: 'Icon'
|
2022-03-04 02:03:34 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
clickOutsideObj: {
|
|
|
|
handler: this.clickedOutside,
|
|
|
|
events: ['mousedown'],
|
|
|
|
isActive: true
|
|
|
|
},
|
2022-10-18 19:09:36 +02:00
|
|
|
showMenu: false
|
2022-03-04 02:03:34 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
selected: {
|
|
|
|
get() {
|
2022-04-15 00:15:52 +02:00
|
|
|
return this.value || 'database'
|
2022-03-04 02:03:34 +01:00
|
|
|
},
|
|
|
|
set(val) {
|
|
|
|
this.$emit('input', val)
|
|
|
|
}
|
|
|
|
},
|
2022-10-18 19:09:36 +02:00
|
|
|
icons() {
|
|
|
|
return this.$store.state.globals.libraryIcons
|
2022-03-04 02:03:34 +01:00
|
|
|
},
|
2022-10-18 19:09:36 +02:00
|
|
|
selectedItem() {
|
|
|
|
return this.icons.find((i) => i === this.selected) || 'audiobookshelf'
|
2022-03-04 02:03:34 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
clickShowMenu() {
|
|
|
|
if (this.disabled) return
|
|
|
|
this.showMenu = !this.showMenu
|
|
|
|
},
|
|
|
|
clickedOutside() {
|
|
|
|
this.showMenu = false
|
|
|
|
},
|
2022-10-18 19:09:36 +02:00
|
|
|
select(icon) {
|
2022-03-04 02:03:34 +01:00
|
|
|
if (this.disabled) return
|
2022-10-18 19:09:36 +02:00
|
|
|
this.selected = icon
|
2022-03-04 02:03:34 +01:00
|
|
|
this.showMenu = false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {}
|
|
|
|
}
|
|
|
|
</script>
|