fix: standardize watchlist filter tabs and empty state

This commit is contained in:
2026-05-25 01:43:56 +02:00
parent f9c1fc9391
commit fe39e094d8

View File

@@ -2,52 +2,51 @@
{{define "content"}}
{{if .WatchlistIDs}}<script>window.__WATCHLIST_IDS__={{.WatchlistIDs}}</script>{{end}}
<div id="watchlist-content" class="flex w-full flex-col gap-6">
<h1 class="font-[family:var(--font-serif)] tracking-[-0.03em] leading-[1.15] text-xl font-normal text-foreground">Watchlist</h1>
<h1 class="text-xl font-normal tracking-[-0.02em] text-foreground">Watchlist</h1>
<div class="flex flex-wrap items-center justify-between gap-4">
<div class="flex flex-wrap items-center gap-6">
<button data-unstyled-button class="text-sm transition-colors text-foreground" onclick="filterWatchlist('all', this)">All</button>
<button data-unstyled-button class="text-sm transition-colors text-foreground-muted hover:text-foreground" onclick="filterWatchlist('watching', this)">Watching</button>
<button data-unstyled-button class="text-sm transition-colors text-foreground-muted hover:text-foreground" onclick="filterWatchlist('plan_to_watch', this)">Plan to Watch</button>
<button data-unstyled-button class="text-sm transition-colors text-foreground-muted hover:text-foreground" onclick="filterWatchlist('completed', this)">Completed</button>
<button data-unstyled-button class="text-sm transition-colors text-foreground-muted hover:text-foreground" onclick="filterWatchlist('dropped', this)">Dropped</button>
<div class="flex flex-wrap items-center gap-4">
<button data-unstyled-button class="border-b border-accent pb-1 text-sm font-normal text-foreground transition-colors" onclick="filterWatchlist('all', this)">All</button>
<button data-unstyled-button class="border-b border-transparent pb-1 text-sm font-normal text-foreground-muted transition-colors hover:text-foreground" onclick="filterWatchlist('watching', this)">Watching</button>
<button data-unstyled-button class="border-b border-transparent pb-1 text-sm font-normal text-foreground-muted transition-colors hover:text-foreground" onclick="filterWatchlist('plan_to_watch', this)">Plan to Watch</button>
<button data-unstyled-button class="border-b border-transparent pb-1 text-sm font-normal text-foreground-muted transition-colors hover:text-foreground" onclick="filterWatchlist('completed', this)">Completed</button>
<button data-unstyled-button class="border-b border-transparent pb-1 text-sm font-normal text-foreground-muted transition-colors hover:text-foreground" onclick="filterWatchlist('dropped', this)">Dropped</button>
</div>
<div class="flex items-center gap-4">
<button type="button" data-unstyled-button class="text-foreground-muted transition-colors hover:text-foreground" onclick="exportWatchlistCsv()" title="Export to CSV" aria-label="Export to CSV">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<div class="flex items-center gap-4">
<button type="button" data-unstyled-button class="text-foreground-muted transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent" onclick="exportWatchlistCsv()" title="Export to CSV" aria-label="Export to CSV">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/>
<path d="M7 10l5 5 5-5"/>
<path d="M12 15V3"/>
</svg>
</button>
</button>
<ui-dropdown class="relative block" data-align="right" data-width="min-w-[150px]">
<div data-trigger>
<button type="button" data-unstyled-button class="flex items-center gap-2 text-sm text-foreground-muted transition-colors hover:text-foreground">
<span>Sort by: <span id="sort-by-display">Date Added</span></span>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>
</button>
<ui-dropdown class="relative block" data-align="right" data-width="min-w-[150px]">
<div data-trigger>
<button type="button" data-unstyled-button class="flex items-center gap-2 text-sm font-normal text-foreground-muted transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent">
<span>Sort by: <span id="sort-by-display">Date Added</span></span>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="m6 9 6 6 6-6"/></svg>
</button>
</div>
<div data-content class="hidden absolute z-50 min-w-[150px] bg-background-button rounded-none shadow-[var(--shadow-card)] ring-1 ring-black/10 right-0 top-full mt-2">
<div class="flex flex-col py-1">
<button class="flex w-full items-center px-4 py-2 text-sm font-normal text-foreground transition-colors hover:bg-surface-hover focus-visible:ring-1 focus-visible:ring-accent" onclick="setSortBy('date', this)">Date Added</button>
<button class="flex w-full items-center px-4 py-2 text-sm font-normal text-foreground-muted transition-colors hover:bg-surface-hover hover:text-foreground focus-visible:ring-1 focus-visible:ring-accent" onclick="setSortBy('title', this)">Title</button>
</div>
<div data-content class="hidden absolute z-50 min-w-[150px] bg-background-button rounded-none shadow-[var(--shadow-card)] right-0 top-full mt-2">
<div class="flex flex-col py-1">
<button class="flex w-full items-center px-4 py-2 text-sm text-foreground transition-colors hover:bg-surface-hover" onclick="setSortBy('date', this)">Date Added</button>
<button class="flex w-full items-center px-4 py-2 text-sm text-foreground-muted transition-colors hover:bg-surface-hover hover:text-foreground" onclick="setSortBy('title', this)">Title</button>
</div>
</div>
</ui-dropdown>
</div>
</ui-dropdown>
<button type="button" id="sort-order-btn" data-unstyled-button class="text-foreground-muted transition-colors hover:text-foreground" onclick="toggleSortOrder(this)">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="transition-transform duration-200 rotate-0"><path d="m21 16-4 4-4-4"></path><path d="M17 20V4"></path><path d="m3 8 4-4 4 4"></path><path d="M7 4v16"></path></svg>
</button>
</div>
<button type="button" id="sort-order-btn" data-unstyled-button class="text-foreground-muted transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent" onclick="toggleSortOrder(this)">
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" class="transition-transform duration-200 rotate-0"><path d="m21 16-4 4-4-4"></path><path d="M17 20V4"></path><path d="m3 8 4-4 4 4"></path><path d="M7 4v16"></path></svg>
</button>
</div>
</div>
<div id="watchlist-items" class="grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-4 2xl:grid-cols-6 mt-6">
{{range $.AllEntries}}
<div class="watchlist-item flex w-full flex-col gap-2" data-mal-id="{{.AnimeID}}" data-status="{{.Status}}" data-updated-at="{{.UpdatedAt.Unix}}" data-episode="{{.CurrentEpisode.Int64}}" data-time="{{.CurrentTimeSeconds}}" data-title="{{.DisplayTitle}}">
<div class="group relative flex aspect-2/3 w-full flex-col overflow-hidden bg-background-surface after:absolute after:inset-0 after:bg-black/80 after:opacity-0 hover:after:opacity-100 after:transition-opacity">
<div class="group relative flex aspect-2/3 w-full flex-col overflow-hidden bg-background-surface after:absolute after:inset-0 after:bg-black/60 after:opacity-0 hover:after:opacity-100 after:transition-opacity">
<a href="/anime/{{.AnimeID}}" class="absolute inset-0 z-10"></a>
<img src="{{.ImageUrl}}" alt="{{.DisplayTitle}}" class="h-full w-full object-cover" loading="lazy" />
@@ -59,7 +58,7 @@
data-watchlist-remove
data-mal-id="{{.AnimeID}}"
data-watchlist-title="{{.DisplayTitle}}"
class="text-white/70 transition-colors hover:text-white focus:outline-none pointer-events-auto disabled:opacity-50"
class="text-white/70 transition-colors hover:text-white focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-white/70 pointer-events-auto disabled:opacity-50"
aria-label="Remove from Watchlist"
>
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="size-5"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
@@ -76,13 +75,13 @@
{{end}}
{{if eq (len $.AllEntries) 0}}
<div class="col-span-full flex flex-col items-center justify-center gap-4 py-24 text-foreground-muted">
<svg class="h-16 w-16 opacity-30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" /></svg>
<p class="text-lg text-foreground font-medium">Your watchlist is empty</p>
<p class="text-sm text-foreground-muted">Start adding anime to keep track of what you want to watch</p>
<div class="flex gap-3 mt-2">
<a href="/" class="px-5 py-2.5 text-sm font-medium bg-accent/20 hover:bg-accent/30 text-accent transition-colors">Browse anime</a>
<a href="/discover" class="px-5 py-2.5 text-sm font-medium bg-background-surface hover:bg-background-button-hover text-foreground transition-colors">Discover new</a>
<div class="col-span-full flex flex-col items-center justify-center gap-3 py-24 text-foreground-muted">
<svg class="h-12 w-12 opacity-30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10" /></svg>
<p class="text-sm text-foreground">Your watchlist is empty.</p>
<p class="text-sm text-foreground-muted">Start adding anime to keep track of what you want to watch.</p>
<div class="mt-2 flex gap-3">
<a href="/" class="!rounded-none inline-flex h-10 items-center justify-center bg-background-button px-4 text-sm font-normal text-foreground transition-colors hover:bg-background-button-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent">Browse anime</a>
<a href="/discover" class="!rounded-none inline-flex h-10 items-center justify-center bg-background-button px-4 text-sm font-normal text-foreground transition-colors hover:bg-background-button-hover focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent">Discover new</a>
</div>
</div>
{{end}}
@@ -99,9 +98,13 @@
parent.querySelectorAll('button').forEach(function(b) {
b.classList.remove('text-foreground')
b.classList.add('text-foreground-muted')
b.classList.remove('border-accent')
b.classList.add('border-transparent')
})
btn.classList.remove('text-foreground-muted')
btn.classList.add('text-foreground')
btn.classList.remove('border-transparent')
btn.classList.add('border-accent')
// Show/hide items
document.querySelectorAll('.watchlist-item').forEach(function(item) {