This commit is contained in:
Julian Freeman
2026-04-16 16:42:41 -04:00
parent dabd8789f4
commit 1131712d4d
3 changed files with 144 additions and 68 deletions

View File

@@ -4,6 +4,7 @@ import { computed, onBeforeUnmount, ref } from "vue";
type Option = {
label: string;
value: string;
iconSrc?: string | null;
};
const props = defineProps<{
@@ -63,7 +64,15 @@ onBeforeUnmount(() => {
type="button"
@click="toggle"
>
<span>{{ selectedLabel }}</span>
<span class="sort-dropdown-trigger-label">
<img
v-if="options.find((option) => option.value === modelValue)?.iconSrc"
class="sort-dropdown-option-icon"
:src="options.find((option) => option.value === modelValue)?.iconSrc ?? undefined"
:alt="selectedLabel"
/>
<span>{{ selectedLabel }}</span>
</span>
<span class="sort-dropdown-caret" aria-hidden="true"></span>
</button>
<div v-if="open" class="sort-dropdown-menu">
@@ -75,7 +84,15 @@ onBeforeUnmount(() => {
type="button"
@click="select(option.value)"
>
{{ option.label }}
<span class="sort-dropdown-option-content">
<img
v-if="option.iconSrc"
class="sort-dropdown-option-icon"
:src="option.iconSrc"
:alt="option.label"
/>
<span>{{ option.label }}</span>
</span>
</button>
</div>
</div>