Leisten-Dropdowns in Design: Sort-/Gruppieren-Iconknöpfe mit thematischen Popover-Menüs (✓-Markierung, akkordierter Akzent statt GTK-Grau)
This commit is contained in:
@ -327,6 +327,36 @@
|
|||||||
.sort((a, b) => a.key.localeCompare(b.key, 'de'))
|
.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> {
|
async function loadSeries(): Promise<void> {
|
||||||
if (seriesLoaded || seriesLoading || groupBy !== 'serie') return
|
if (seriesLoaded || seriesLoading || groupBy !== 'serie') return
|
||||||
seriesLoading = true
|
seriesLoading = true
|
||||||
@ -609,6 +639,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.addEventListener('keydown', onKey)
|
window.addEventListener('keydown', onKey)
|
||||||
|
document.addEventListener('click', onDocClick)
|
||||||
checkAuth()
|
checkAuth()
|
||||||
const unlistenLogin = onLoginUrl((u) => { loginUrl = u })
|
const unlistenLogin = onLoginUrl((u) => { loginUrl = u })
|
||||||
const unlisten = onDownloadUpdate((it) => {
|
const unlisten = onDownloadUpdate((it) => {
|
||||||
@ -636,6 +667,7 @@
|
|||||||
clearPoll()
|
clearPoll()
|
||||||
clearInterval(syncId)
|
clearInterval(syncId)
|
||||||
window.removeEventListener('keydown', onKey)
|
window.removeEventListener('keydown', onKey)
|
||||||
|
document.removeEventListener('click', onDocClick)
|
||||||
unlisten.then((f) => f())
|
unlisten.then((f) => f())
|
||||||
unlistenPlayer.then((f) => f())
|
unlistenPlayer.then((f) => f())
|
||||||
unlistenLogin.then((f: () => void) => f())
|
unlistenLogin.then((f: () => void) => f())
|
||||||
@ -723,28 +755,45 @@
|
|||||||
placeholder="Suche Titel, Autor, Sprecher…"
|
placeholder="Suche Titel, Autor, Sprecher…"
|
||||||
bind:value={query}
|
bind:value={query}
|
||||||
/>
|
/>
|
||||||
<select bind:value={sortBy}>
|
<div class="hwdropdown">
|
||||||
<option value="added">Zuletzt hinzugefügt</option>
|
<button
|
||||||
<option value="title">Titel A–Z</option>
|
class="ghost barbtn"
|
||||||
<option value="author">Autor</option>
|
class:activebtn={menuOpen === 'sort'}
|
||||||
<option value="runtime">Laufzeit</option>
|
title={sortLabel}
|
||||||
<option value="percent">Fortschritt</option>
|
aria-haspopup="listbox"
|
||||||
</select>
|
onclick={() => (menuOpen = menuOpen === 'sort' ? null : 'sort')}
|
||||||
<select
|
>
|
||||||
class="speedsel"
|
<Icon name={sortIcon} size={15} />
|
||||||
title="Gruppieren"
|
</button>
|
||||||
value={groupBy}
|
{#if menuOpen === 'sort'}
|
||||||
onchange={(e) => {
|
<div class="menu" role="listbox">
|
||||||
const v = e.currentTarget.value as typeof groupBy
|
{#each SORTS as o (o.key)}
|
||||||
groupBy = v
|
<button type="button" class:sel={o.key === sortBy} onclick={() => { sortBy = o.key; menuOpen = null }}>
|
||||||
if (groupBy === 'serie') loadSeries()
|
<Icon name={o.icon} size={14} /> {o.label}
|
||||||
}}
|
</button>
|
||||||
>
|
{/each}
|
||||||
<option value="aus">Gruppieren: aus</option>
|
</div>
|
||||||
<option value="autor">nach Autor</option>
|
{/if}
|
||||||
<option value="serie">{seriesLoading ? 'nach Serie (lade…)' : 'nach Serie'}</option>
|
</div>
|
||||||
<option value="genre">nach Genre</option>
|
<div class="hwdropdown">
|
||||||
</select>
|
<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
|
<button
|
||||||
class="ghost barbtn"
|
class="ghost barbtn"
|
||||||
class:activebtn={onlyLocal}
|
class:activebtn={onlyLocal}
|
||||||
|
|||||||
45
src/app.css
45
src/app.css
@ -718,3 +718,48 @@ code {
|
|||||||
.hw-icon svg {
|
.hw-icon svg {
|
||||||
display: block;
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@ -4,6 +4,22 @@
|
|||||||
home: '<path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h5v-6h4v6h5V9.5"/>',
|
home: '<path d="M3 10.5 12 3l9 7.5"/><path d="M5 9.5V21h5v-6h4v6h5V9.5"/>',
|
||||||
refresh:
|
refresh:
|
||||||
'<path d="M21 12a9 9 0 1 1-3-6.7"/><path d="M21 3v6h-6"/>',
|
'<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:
|
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"/>',
|
'<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"/>',
|
download: '<path d="M12 3v12"/><path d="m7 10 5 5 5-5"/><path d="M5 21h14"/>',
|
||||||
|
|||||||
Reference in New Issue
Block a user