Added groups to dropdown menu

This commit is contained in:
lucast committed 2026-03-08 11:24:46 +01:00
1 parent aa93320215
commit 4eb7c6d5a9
2 files changed
+33 -7

No files matched your search

+3 -1
View File
@@ -14,7 +14,8 @@ const hovering = ref(false)
const toast = useToast() const toast = useToast()
const dropdownMenuItems: DropdownMenuItem[] = [ const dropdownMenuItems: DropdownMenuItem[][] = [
[
{ {
label: "Play only this", label: "Play only this",
icon: "lucide:play", icon: "lucide:play",
@@ -34,6 +35,7 @@ const dropdownMenuItems: DropdownMenuItem[] = [
toast.show("Added to queue") toast.show("Added to queue")
}, },
}, },
],
] ]
const durationFormatted = computed(() => const durationFormatted = computed(() =>
+30 -6
View File
@@ -6,7 +6,7 @@ export interface DropdownMenuItem {
} }
interface DropdownMenuProps { interface DropdownMenuProps {
items: DropdownMenuItem[] items: DropdownMenuItem[][]
} }
const props = defineProps<DropdownMenuProps>() const props = defineProps<DropdownMenuProps>()
@@ -85,9 +85,14 @@ onBeforeMount(() => {
<Transition name="dropdown"> <Transition name="dropdown">
<div v-show="open" class="menu" :class="placement"> <div v-show="open" class="menu" :class="placement">
<div
v-for="(group, i) in items"
:key="`group-${i}`"
class="group"
>
<button <button
v-for="(item, i) in items" v-for="(item, i) in group"
:key="i" :key="`item-${i}`"
class="item" class="item"
@click=" @click="
() => { () => {
@@ -100,6 +105,7 @@ onBeforeMount(() => {
<span>{{ item.label }}</span> <span>{{ item.label }}</span>
</button> </button>
</div> </div>
</div>
</Transition> </Transition>
</div> </div>
</template> </template>
@@ -113,11 +119,10 @@ onBeforeMount(() => {
.menu { .menu {
position: absolute; position: absolute;
right: 0; right: 0;
min-width: 180px;
padding: 0.5rem; padding: 0.5rem;
min-width: 180px;
background-color: $color-secondary-background; background-color: $color-secondary-background;
border-radius: $border-radius-standard; border-radius: $border-radius-standard;
@@ -125,7 +130,6 @@ onBeforeMount(() => {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 2px;
z-index: 1000; z-index: 1000;
@@ -140,6 +144,26 @@ onBeforeMount(() => {
} }
} }
.group {
width: 100%;
display: flex;
flex-direction: column;
gap: 4px;
padding: 0.4rem 0;
border-bottom: 1px solid $color-border;
&:first-child {
padding-top: 0;
}
&:last-child {
border-bottom: none;
padding-bottom: 0;
}
}
.item { .item {
display: flex; display: flex;
align-items: center; align-items: center;