Leisten-Dropdowns in Design: Sort-/Gruppieren-Iconknöpfe mit thematischen Popover-Menüs (✓-Markierung, akkordierter Akzent statt GTK-Grau)

This commit is contained in:
2026-11-09 18:12:57 +01:00
parent 5526f1533e
commit 0b964c9697
3 changed files with 132 additions and 22 deletions

View File

@ -327,6 +327,36 @@
.sort((a, b) => a.key.localeCompare(b.key, 'de'))
})
let menuOpen = $state<'sort' | 'group' | null>(null)
const SORTS: { key: SortKey; label: string; icon: string }[] = [
{ key: 'added', label: 'Zuletzt hinzugefügt', icon: 'clock' },
{ key: 'title', label: 'Titel A–Z', icon: 'alpha' },
{ key: 'author', label: 'Autor', icon: 'user' },
{ key: 'runtime', label: 'Laufzeit', icon: 'hourglass' },
{ key: 'percent', label: 'Fortschritt', icon: 'chart' },
]
const GROUPS: { key: typeof groupBy; label: string; icon: string }[] = [
{ key: 'aus', label: 'Gruppieren: aus', icon: 'x' },
{ key: 'autor', label: 'nach Autor', icon: 'user' },
{ key: 'serie', label: 'nach Serie', icon: 'stack' },
{ key: 'genre', label: 'nach Genre', icon: 'tag' },
]
const sortIcon = $derived(SORTS.find((o) => o.key === sortBy)?.icon ?? 'clock')
const sortLabel = $derived('Sortierung: ' + (SORTS.find((o) => o.key === sortBy)?.label ?? ''))
const groupLabel = $derived(
groupBy === 'aus'
? 'Gruppieren: aus'
: 'Gruppierung: ' + (GROUPS.find((o) => o.key === groupBy)?.label ?? '')
)
// Schließen bei Klick außerhalb
function onDocClick(ev: MouseEvent): void {
const t = ev.target as HTMLElement | null
if (!t?.closest('.hwdropdown') && menuOpen) menuOpen = null
}
async function loadSeries(): Promise<void> {
if (seriesLoaded || seriesLoading || groupBy !== 'serie') return
seriesLoading = true
@ -609,6 +639,7 @@
}
}
window.addEventListener('keydown', onKey)
document.addEventListener('click', onDocClick)
checkAuth()
const unlistenLogin = onLoginUrl((u) => { loginUrl = u })
const unlisten = onDownloadUpdate((it) => {
@ -636,6 +667,7 @@
clearPoll()
clearInterval(syncId)
window.removeEventListener('keydown', onKey)
document.removeEventListener('click', onDocClick)
unlisten.then((f) => f())
unlistenPlayer.then((f) => f())
unlistenLogin.then((f: () => void) => f())
@ -723,28 +755,45 @@
placeholder="Suche Titel, Autor, Sprecher…"
bind:value={query}
/>
<select bind:value={sortBy}>
<option value="added">Zuletzt hinzugefügt</option>
<option value="title">Titel A–Z</option>
<option value="author">Autor</option>
<option value="runtime">Laufzeit</option>
<option value="percent">Fortschritt</option>
</select>
<select
class="speedsel"
title="Gruppieren"
value={groupBy}
onchange={(e) => {
const v = e.currentTarget.value as typeof groupBy
groupBy = v
if (groupBy === 'serie') loadSeries()
}}
<div class="hwdropdown">
<button
class="ghost barbtn"
class:activebtn={menuOpen === 'sort'}
title={sortLabel}
aria-haspopup="listbox"
onclick={() => (menuOpen = menuOpen === 'sort' ? null : 'sort')}
>
<option value="aus">Gruppieren: aus</option>
<option value="autor">nach Autor</option>
<option value="serie">{seriesLoading ? 'nach Serie (lade…)' : 'nach Serie'}</option>
<option value="genre">nach Genre</option>
</select>
<Icon name={sortIcon} size={15} />
</button>
{#if menuOpen === 'sort'}
<div class="menu" role="listbox">
{#each SORTS as o (o.key)}
<button type="button" class:sel={o.key === sortBy} onclick={() => { sortBy = o.key; menuOpen = null }}>
<Icon name={o.icon} size={14} /> {o.label}
</button>
{/each}
</div>
{/if}
</div>
<div class="hwdropdown">
<button
class="ghost barbtn"
class:activebtn={menuOpen === 'group' || groupBy !== 'aus'}
title={groupLabel}
onclick={() => (menuOpen = menuOpen === 'group' ? null : 'group')}
>
<Icon name="list" size={15} />
</button>
{#if menuOpen === 'group'}
<div class="menu" role="listbox">
{#each GROUPS as o (o.key)}
<button type="button" class:sel={o.key === groupBy} onclick={() => { groupBy = o.key; menuOpen = null; if (groupBy === 'serie') loadSeries() }}>
<Icon name={o.key === 'aus' ? 'x' : o.icon} size={14} /> {o.label}
</button>
{/each}
</div>
{/if}
</div>
<button
class="ghost barbtn"
class:activebtn={onlyLocal}

View File

@ -718,3 +718,48 @@ code {
.hw-icon svg {
display: block;
}
/* Themendropdowns (Iconknopf + Popover) */
.hwdropdown {
position: relative;
display: inline-flex;
}
.hwdropdown .menu {
position: absolute;
top: calc(100% + 6px);
right: 0;
min-width: 13rem;
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow);
padding: 0.35rem;
display: flex;
flex-direction: column;
z-index: 8;
}
.hwdropdown .menu button {
display: inline-flex;
align-items: center;
gap: 0.45rem;
background: transparent;
border: none;
border-radius: 8px;
padding: 0.35rem 0.55rem;
font-size: 0.92rem;
text-align: left;
}
.hwdropdown .menu button:hover {
background: var(--accent-soft);
color: var(--accent);
}
.hwdropdown .menu button.sel {
color: var(--accent);
font-weight: 600;
background: var(--accent-soft);
}

View File

@ -4,6 +4,22 @@
home: '<path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h5v-6h4v6h5V9.5"/>',
refresh:
'<path d="M21 12a9 9 0 1 1-3-6.7"/><path d="M21 3v6h-6"/>',
clock:
'<circle cx="12" cy="12" r="8"/><path d="M12 8v4l2.5 2.5"/>',
user:
'<circle cx="12" cy="8" r="4"/><path d="M4 20a8 8 0 0 1 16 0"/>',
hourglass:
'<path d="M7 3h10M7 21h10"/><path d="M8 3v3l4 4 4-4V3"/><path d="M8 21v-3l4-4 4 4v3"/>',
chart:
'<path d="M4 20h16"/><path d="M7 16v-5M12 16V8M17 16v-8"/>',
stack:
'<path d="M12 3 3 8l9 5 9-5-9-5z"/><path d="m3 13 9 5 9-5"/>',
tag:
'<path d="M3 12V4h8l10 10-8 8L3 12z"/><circle cx="7.5" cy="7.5" r="1.5"/>',
list:
'<path d="M4 6h16M4 12h16M4 18h16"/><circle cx="4" cy="6" r="0.5"/>',
alpha:
'<path d="M6 4h9a3.5 3.5 0 0 1 0 7H6z"/><path d="M6 11h10a3.5 3.5 0 0 1 0 7H6z"/>',
cloud:
'<path d="M6.5 19a4.5 4.5 0 1 1 .42-8.98 6 6 0 0 1 11.6 1.4A4 4 0 0 1 18 19H6.5z"/>',
download: '<path d="M12 3v12"/><path d="m7 10 5 5 5-5"/><path d="M5 21h14"/>',