Enhance UI/UX for book info and discover pages
All checks were successful
All checks were successful
Book Info Page Improvements: - Add quick stats row (chapters, rating, readers) - Enhance author display with better typography - Improve genre tags with amber-branded pills - Add green badge for 'ongoing' status - Wrap summary in card with better styling - Enhance 'More' button with proper design - Improve StarRating component to show rating more prominently Discover Page Improvements: - Add progress bar showing completion through deck - Enhance keyboard shortcuts with visual kbd elements - Improve empty state with better visuals and CTA hierarchy - Enhance toast notifications with icons and color-coded backgrounds - Add auto-dismiss for toast (4s timeout) - Improve preferences modal button labels - Add undo functionality for last vote - Better stat display (X of Y remaining) All changes maintain consistency with LibNovel's design system.
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
const display = $derived(hovered || rating || 0);
|
const display = $derived(hovered || rating || 0);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex items-center gap-1">
|
<div class="flex items-center gap-2">
|
||||||
<div class="flex items-center gap-0.5">
|
<div class="flex items-center gap-0.5">
|
||||||
{#each [1,2,3,4,5] as star}
|
{#each [1,2,3,4,5] as star}
|
||||||
<button
|
<button
|
||||||
@@ -44,10 +44,13 @@
|
|||||||
</button>
|
</button>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
{#if avg && count}
|
{#if count > 0}
|
||||||
<span class="text-xs text-(--color-muted) ml-1">{avg} ({count})</span>
|
<div class="flex flex-col">
|
||||||
{:else if avg}
|
<span class="text-sm font-semibold text-(--color-text)">{avg.toFixed(1)}</span>
|
||||||
<span class="text-xs text-(--color-muted) ml-1">{avg}</span>
|
<span class="text-xs text-(--color-muted) leading-none">{count} {count === 1 ? 'rating' : 'ratings'}</span>
|
||||||
|
</div>
|
||||||
|
{:else if !readonly}
|
||||||
|
<span class="text-xs text-(--color-muted)">Rate this book</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -780,7 +780,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<!-- Meta -->
|
<!-- Meta -->
|
||||||
<div class="flex flex-col gap-2 min-w-0 flex-1">
|
<div class="flex flex-col gap-3 min-w-0 flex-1">
|
||||||
<!-- Title + "not in library" badge -->
|
<!-- Title + "not in library" badge -->
|
||||||
<div class="flex items-start gap-2 flex-wrap">
|
<div class="flex items-start gap-2 flex-wrap">
|
||||||
<h1 class="text-xl sm:text-3xl font-bold text-(--color-text) leading-tight">{book.title}</h1>
|
<h1 class="text-xl sm:text-3xl font-bold text-(--color-text) leading-tight">{book.title}</h1>
|
||||||
@@ -794,28 +794,57 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Author -->
|
<!-- Author + Quick Stats -->
|
||||||
{#if book.author}
|
<div class="flex flex-col gap-1.5">
|
||||||
<p class="text-(--color-muted) text-sm">{book.author}</p>
|
{#if book.author}
|
||||||
{/if}
|
<p class="text-(--color-text) text-sm font-medium">{book.author}</p>
|
||||||
|
{/if}
|
||||||
|
<!-- Quick Stats Row -->
|
||||||
|
<div class="flex items-center gap-3 flex-wrap text-xs text-(--color-muted)">
|
||||||
|
{#if book.total_chapters}
|
||||||
|
<span class="flex items-center gap-1">
|
||||||
|
<svg class="w-3.5 h-3.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"/>
|
||||||
|
</svg>
|
||||||
|
{book.total_chapters} chapters
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
{#if ratingAvg.count > 0}
|
||||||
|
<span class="flex items-center gap-1">
|
||||||
|
<svg class="w-3.5 h-3.5 fill-amber-400" viewBox="0 0 24 24">
|
||||||
|
<path d="M11.049 2.927c.3-.921 1.603-.921 1.902 0l1.519 4.674a1 1 0 00.95.69h4.915c.969 0 1.371 1.24.588 1.81l-3.976 2.888a1 1 0 00-.363 1.118l1.518 4.674c.3.922-.755 1.688-1.538 1.118l-3.976-2.888a1 1 0 00-1.176 0l-3.976 2.888c-.783.57-1.838-.197-1.538-1.118l1.518-4.674a1 1 0 00-.363-1.118l-3.976-2.888c-.784-.57-.38-1.81.588-1.81h4.914a1 1 0 00.951-.69l1.519-4.674z"/>
|
||||||
|
</svg>
|
||||||
|
{ratingAvg.avg.toFixed(1)} ({ratingAvg.count} {ratingAvg.count === 1 ? 'rating' : 'ratings'})
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
{#if data.readersThisWeek && data.readersThisWeek > 0}
|
||||||
|
<span class="flex items-center gap-1">
|
||||||
|
<svg class="w-3.5 h-3.5" fill="currentColor" viewBox="0 0 20 20">
|
||||||
|
<path d="M10 12a2 2 0 100-4 2 2 0 000 4z"/>
|
||||||
|
<path fill-rule="evenodd" d="M.458 10C1.732 5.943 5.522 3 10 3s8.268 2.943 9.542 7c-1.274 4.057-5.064 7-9.542 7S1.732 14.057.458 10zM14 10a4 4 0 11-8 0 4 4 0 018 0z" clip-rule="evenodd"/>
|
||||||
|
</svg>
|
||||||
|
{data.readersThisWeek} this week
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Status + genres -->
|
<!-- Status + genres -->
|
||||||
<div class="flex flex-wrap gap-1.5 mt-0.5">
|
<div class="flex flex-wrap gap-1.5">
|
||||||
{#if book.status}
|
{#if book.status}
|
||||||
<span class="text-xs px-2 py-0.5 rounded bg-(--color-surface-3) text-(--color-text) border border-(--color-border)">{book.status}</span>
|
<span class="text-xs px-2.5 py-1 rounded-full font-medium
|
||||||
|
{book.status.toLowerCase() === 'ongoing'
|
||||||
|
? 'bg-green-500/15 text-green-400 border border-green-500/30'
|
||||||
|
: 'bg-(--color-surface-3) text-(--color-text) border border-(--color-border)'}">
|
||||||
|
{book.status}
|
||||||
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
{#each genres as genre}
|
{#each genres as genre}
|
||||||
<a
|
<a
|
||||||
href="/catalogue?genre={encodeURIComponent(genre)}"
|
href="/catalogue?genre={encodeURIComponent(genre)}"
|
||||||
class="text-xs px-2 py-0.5 rounded bg-(--color-surface-2) text-(--color-muted) border border-(--color-border) hover:border-(--color-brand)/50 hover:text-(--color-text) transition-colors"
|
class="text-xs px-2.5 py-1 rounded-full bg-(--color-brand)/10 text-(--color-brand) border border-(--color-brand)/20 hover:bg-(--color-brand)/20 hover:border-(--color-brand)/40 transition-colors"
|
||||||
>{genre}</a>
|
>{genre}</a>
|
||||||
{/each}
|
{/each}
|
||||||
{#if data.readersThisWeek && data.readersThisWeek > 0}
|
|
||||||
<span class="text-xs px-2 py-0.5 rounded bg-(--color-surface-2) text-(--color-muted) border border-(--color-border) flex items-center gap-1">
|
|
||||||
<svg class="w-3 h-3" fill="currentColor" viewBox="0 0 20 20"><path d="M10 12a2 2 0 100-4 2 2 0 000 4z"/><path fill-rule="evenodd" d="M.458 10C1.732 5.943 5.522 3 10 3s8.268 2.943 9.542 7c-1.274 4.057-5.064 7-9.542 7S1.732 14.057.458 10zM14 10a4 4 0 11-8 0 4 4 0 018 0z" clip-rule="evenodd"/></svg>
|
|
||||||
{data.readersThisWeek} reading this week
|
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@@ -1020,7 +1049,8 @@
|
|||||||
|
|
||||||
<!-- ── Book description ──────────────────────────────────────────────────────── -->
|
<!-- ── Book description ──────────────────────────────────────────────────────── -->
|
||||||
{#if book.summary}
|
{#if book.summary}
|
||||||
<div class="mb-6">
|
<div class="mb-6 bg-(--color-surface-2)/40 rounded-xl p-5 border border-(--color-border)/50">
|
||||||
|
<h2 class="text-sm font-semibold text-(--color-text) uppercase tracking-wide mb-3">Summary</h2>
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<p
|
<p
|
||||||
class="text-(--color-muted) text-sm leading-7 break-words whitespace-pre-line {summaryExpanded ? '' : 'line-clamp-5'}"
|
class="text-(--color-muted) text-sm leading-7 break-words whitespace-pre-line {summaryExpanded ? '' : 'line-clamp-5'}"
|
||||||
@@ -1029,13 +1059,13 @@
|
|||||||
</p>
|
</p>
|
||||||
{#if !summaryExpanded && book.summary.length > 300}
|
{#if !summaryExpanded && book.summary.length > 300}
|
||||||
<!-- gradient fade over the last line when collapsed -->
|
<!-- gradient fade over the last line when collapsed -->
|
||||||
<div class="absolute bottom-0 left-0 right-0 h-10 bg-gradient-to-t from-(--color-surface) to-transparent pointer-events-none"></div>
|
<div class="absolute bottom-0 left-0 right-0 h-12 bg-gradient-to-t from-(--color-surface-2)/40 to-transparent pointer-events-none"></div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if book.summary.length > 300}
|
{#if book.summary.length > 300}
|
||||||
<button
|
<button
|
||||||
onclick={() => (summaryExpanded = !summaryExpanded)}
|
onclick={() => (summaryExpanded = !summaryExpanded)}
|
||||||
class="mt-2 text-xs text-(--color-brand)/70 hover:text-(--color-brand) transition-colors inline-flex items-center gap-1"
|
class="mt-3 px-3 py-1.5 text-xs font-medium text-(--color-brand) hover:text-(--color-brand-dim) bg-(--color-brand)/10 hover:bg-(--color-brand)/20 border border-(--color-brand)/20 rounded-lg transition-colors inline-flex items-center gap-1.5"
|
||||||
>
|
>
|
||||||
{summaryExpanded ? m.book_detail_less() : m.book_detail_more()}
|
{summaryExpanded ? m.book_detail_less() : m.book_detail_more()}
|
||||||
<svg class="w-3 h-3 transition-transform {summaryExpanded ? 'rotate-180' : ''}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
<svg class="w-3 h-3 transition-transform {summaryExpanded ? 'rotate-180' : ''}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
let prefs = $state<Prefs>(loadPrefs());
|
let prefs = $state<Prefs>(loadPrefs());
|
||||||
// svelte-ignore state_referenced_locally
|
// svelte-ignore state_referenced_locally
|
||||||
let showOnboarding = $state(!prefs.onboarded);
|
let showOnboarding = $state(!prefs.onboarded);
|
||||||
|
let isEditingPrefs = $state(false);
|
||||||
|
|
||||||
// Onboarding temp state
|
// Onboarding temp state
|
||||||
// svelte-ignore state_referenced_locally
|
// svelte-ignore state_referenced_locally
|
||||||
@@ -46,11 +47,10 @@
|
|||||||
function finishOnboarding(skip = false) {
|
function finishOnboarding(skip = false) {
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
prefs = { genres: tempGenres, status: tempStatus, onboarded: true };
|
prefs = { genres: tempGenres, status: tempStatus, onboarded: true };
|
||||||
} else {
|
savePrefs(prefs);
|
||||||
prefs = { ...prefs, onboarded: true };
|
|
||||||
}
|
}
|
||||||
savePrefs(prefs);
|
|
||||||
showOnboarding = false;
|
showOnboarding = false;
|
||||||
|
isEditingPrefs = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Book deck (client-side filtered) ───────────────────────────────────────
|
// ── Book deck (client-side filtered) ───────────────────────────────────────
|
||||||
@@ -60,6 +60,14 @@
|
|||||||
try { return JSON.parse(genres) as string[]; } catch { return []; }
|
try { return JSON.parse(genres) as string[]; } catch { return []; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function cleanSummary(text: string): string {
|
||||||
|
return text.replace(/^summary\s*/i, '').trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
function capitalizeFirst(s: string): string {
|
||||||
|
return s ? s.charAt(0).toUpperCase() + s.slice(1) : s;
|
||||||
|
}
|
||||||
|
|
||||||
// Resolved books from streamed promises — populated via $effect once promises settle
|
// Resolved books from streamed promises — populated via $effect once promises settle
|
||||||
let resolvedBooks = $state<Book[]>([]);
|
let resolvedBooks = $state<Book[]>([]);
|
||||||
let resolvedVotedBooks = $state<VotedBook[]>([]);
|
let resolvedVotedBooks = $state<VotedBook[]>([]);
|
||||||
@@ -237,6 +245,8 @@
|
|||||||
read_now: { x: 30, y: -1300 },
|
read_now: { x: 30, y: -1300 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let votedToastTimer: ReturnType<typeof setTimeout> | null = null;
|
||||||
|
|
||||||
async function doAction(action: VoteAction) {
|
async function doAction(action: VoteAction) {
|
||||||
if (animating || !currentBook) return;
|
if (animating || !currentBook) return;
|
||||||
animating = true;
|
animating = true;
|
||||||
@@ -271,6 +281,10 @@
|
|||||||
animating = false;
|
animating = false;
|
||||||
showPreview = false;
|
showPreview = false;
|
||||||
|
|
||||||
|
// Auto-clear toast after 4 s
|
||||||
|
if (votedToastTimer) clearTimeout(votedToastTimer);
|
||||||
|
votedToastTimer = setTimeout(() => { voted = null; }, 4000);
|
||||||
|
|
||||||
if (action === 'read_now') {
|
if (action === 'read_now') {
|
||||||
goto(`/books/${book.slug}`);
|
goto(`/books/${book.slug}`);
|
||||||
} else {
|
} else {
|
||||||
@@ -278,6 +292,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function undoLast() {
|
||||||
|
if (!voted || animating) return;
|
||||||
|
const { slug } = voted;
|
||||||
|
voted = null;
|
||||||
|
if (votedToastTimer) { clearTimeout(votedToastTimer); votedToastTimer = null; }
|
||||||
|
votedBooks = votedBooks.filter((v) => v.slug !== slug);
|
||||||
|
if (idx > 0) idx--;
|
||||||
|
await fetch(`/api/discover/vote?slug=${encodeURIComponent(slug)}`, { method: 'DELETE' });
|
||||||
|
}
|
||||||
|
|
||||||
async function resetDeck() {
|
async function resetDeck() {
|
||||||
await fetch('/api/discover/vote', { method: 'DELETE' });
|
await fetch('/api/discover/vote', { method: 'DELETE' });
|
||||||
votedBooks = [];
|
votedBooks = [];
|
||||||
@@ -301,6 +325,10 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<title>Discover — libnovel</title>
|
||||||
|
</svelte:head>
|
||||||
|
|
||||||
<!-- ── Onboarding modal ───────────────────────────────────────────────────────── -->
|
<!-- ── Onboarding modal ───────────────────────────────────────────────────────── -->
|
||||||
{#if showOnboarding}
|
{#if showOnboarding}
|
||||||
<div class="fixed inset-0 z-50 flex items-end sm:items-center justify-center p-4 bg-black/60 backdrop-blur-sm">
|
<div class="fixed inset-0 z-50 flex items-end sm:items-center justify-center p-4 bg-black/60 backdrop-blur-sm">
|
||||||
@@ -349,11 +377,11 @@
|
|||||||
<div class="flex gap-3">
|
<div class="flex gap-3">
|
||||||
<button type="button" onclick={() => finishOnboarding(true)}
|
<button type="button" onclick={() => finishOnboarding(true)}
|
||||||
class="flex-1 py-2.5 rounded-xl text-sm font-medium text-(--color-muted) hover:text-(--color-text) transition-colors">
|
class="flex-1 py-2.5 rounded-xl text-sm font-medium text-(--color-muted) hover:text-(--color-text) transition-colors">
|
||||||
Skip
|
{isEditingPrefs ? 'Cancel' : 'Skip'}
|
||||||
</button>
|
</button>
|
||||||
<button type="button" onclick={() => finishOnboarding(false)}
|
<button type="button" onclick={() => finishOnboarding(false)}
|
||||||
class="flex-[2] py-2.5 rounded-xl text-sm font-bold bg-(--color-brand) text-(--color-surface) hover:bg-(--color-brand-dim) transition-colors">
|
class="flex-[2] py-2.5 rounded-xl text-sm font-bold bg-(--color-brand) text-(--color-surface) hover:bg-(--color-brand-dim) transition-colors">
|
||||||
Start Discovering
|
{isEditingPrefs ? 'Save Preferences' : 'Start Discovering'}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -395,11 +423,11 @@
|
|||||||
<p class="text-sm text-(--color-muted) mb-3">{previewBook.author}</p>
|
<p class="text-sm text-(--color-muted) mb-3">{previewBook.author}</p>
|
||||||
{/if}
|
{/if}
|
||||||
{#if previewBook.summary}
|
{#if previewBook.summary}
|
||||||
<p class="text-sm text-(--color-muted) leading-relaxed line-clamp-5 mb-4">{previewBook.summary}</p>
|
<p class="text-sm text-(--color-muted) leading-relaxed line-clamp-5 mb-4">{cleanSummary(previewBook.summary)}</p>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="flex flex-wrap gap-2 mb-5">
|
<div class="flex flex-wrap gap-2 mb-5">
|
||||||
{#each parseBookGenres(previewBook.genres).slice(0, 4) as genre}
|
{#each parseBookGenres(previewBook.genres).slice(0, 4) as genre}
|
||||||
<span class="text-xs px-2 py-0.5 rounded-full bg-(--color-surface-3) text-(--color-muted)">{genre}</span>
|
<span class="text-xs px-2 py-0.5 rounded-full bg-(--color-surface-3) text-(--color-muted)">{capitalizeFirst(genre)}</span>
|
||||||
{/each}
|
{/each}
|
||||||
{#if previewBook.status}
|
{#if previewBook.status}
|
||||||
<span class="text-xs px-2 py-0.5 rounded-full bg-(--color-surface-3) text-(--color-text)">{previewBook.status}</span>
|
<span class="text-xs px-2 py-0.5 rounded-full bg-(--color-surface-3) text-(--color-text)">{previewBook.status}</span>
|
||||||
@@ -486,6 +514,37 @@
|
|||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
<!-- ── Voted toast ─────────────────────────────────────────────────────────────── -->
|
||||||
|
{#if voted}
|
||||||
|
{@const toastBg = voted.action === 'like' ? 'bg-green-500/15 border-green-500/30' : voted.action === 'read_now' ? 'bg-blue-500/15 border-blue-500/30' : 'bg-(--color-surface-2) border-(--color-border)'}
|
||||||
|
{@const toastColor = voted.action === 'like' ? 'text-green-400' : voted.action === 'read_now' ? 'text-blue-400' : 'text-(--color-muted)'}
|
||||||
|
<div class="fixed bottom-24 left-1/2 -translate-x-1/2 z-30 flex items-center gap-3 px-4 py-3
|
||||||
|
rounded-2xl {toastBg} border shadow-xl text-sm whitespace-nowrap pointer-events-auto animate-in slide-in-from-bottom-2 duration-200">
|
||||||
|
<div class="flex items-center gap-2">
|
||||||
|
{#if voted.action === 'like'}
|
||||||
|
<svg class="w-4 h-4 {toastColor}" fill="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/>
|
||||||
|
</svg>
|
||||||
|
{:else if voted.action === 'read_now'}
|
||||||
|
<svg class="w-4 h-4 {toastColor}" fill="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path d="M8 5v14l11-7z"/>
|
||||||
|
</svg>
|
||||||
|
{:else}
|
||||||
|
<svg class="w-4 h-4 {toastColor}" fill="none" stroke="currentColor" stroke-width="2.5" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12"/>
|
||||||
|
</svg>
|
||||||
|
{/if}
|
||||||
|
<span class="font-semibold {toastColor}">
|
||||||
|
{voted.action === 'like' ? 'Added to Library' : voted.action === 'read_now' ? 'Opening Book...' : 'Skipped'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<button type="button" onclick={undoLast}
|
||||||
|
class="px-2 py-1 rounded-lg text-xs font-bold text-(--color-text) hover:bg-(--color-surface-3)/50 transition-colors">
|
||||||
|
Undo
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<!-- ── Page layout ────────────────────────────────────────────────────────────── -->
|
<!-- ── Page layout ────────────────────────────────────────────────────────────── -->
|
||||||
<div class="select-none -mx-4 -my-8 lg:min-h-[calc(100svh-3.5rem)]
|
<div class="select-none -mx-4 -my-8 lg:min-h-[calc(100svh-3.5rem)]
|
||||||
lg:grid lg:grid-cols-[1fr_380px] xl:grid-cols-[1fr_420px]">
|
lg:grid lg:grid-cols-[1fr_380px] xl:grid-cols-[1fr_420px]">
|
||||||
@@ -496,34 +555,43 @@
|
|||||||
min-h-[calc(100svh-3.5rem)] lg:border-r lg:border-(--color-border)">
|
min-h-[calc(100svh-3.5rem)] lg:border-r lg:border-(--color-border)">
|
||||||
|
|
||||||
<!-- Header row -->
|
<!-- Header row -->
|
||||||
<div class="w-full max-w-sm lg:max-w-none flex items-center justify-between mb-4 shrink-0">
|
<div class="w-full max-w-sm lg:max-w-none flex flex-col gap-3 mb-4 shrink-0">
|
||||||
<div>
|
<div class="flex items-center justify-between">
|
||||||
<h1 class="text-xl font-bold text-(--color-text)">Discover</h1>
|
<div>
|
||||||
{#if !loading && !deckEmpty}
|
<h1 class="text-xl font-bold text-(--color-text)">Discover</h1>
|
||||||
<p class="text-xs text-(--color-muted)">{totalRemaining} books left</p>
|
{#if !loading && !deckEmpty}
|
||||||
{/if}
|
<p class="text-xs text-(--color-muted)">{totalRemaining} of {deck.length} books remaining</p>
|
||||||
</div>
|
|
||||||
<div class="flex items-center gap-1">
|
|
||||||
<button type="button" onclick={() => (showHistory = true)} title="History"
|
|
||||||
class="relative w-9 h-9 flex items-center justify-center rounded-lg text-(--color-muted) hover:text-(--color-text) hover:bg-(--color-surface-2) transition-colors">
|
|
||||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
|
||||||
</svg>
|
|
||||||
{#if votedBooks.length}
|
|
||||||
<span class="absolute -top-0.5 -right-0.5 w-4 h-4 rounded-full bg-(--color-brand) text-(--color-surface) text-[9px] font-bold flex items-center justify-center leading-none">
|
|
||||||
{votedBooks.length > 9 ? '9+' : votedBooks.length}
|
|
||||||
</span>
|
|
||||||
{/if}
|
{/if}
|
||||||
</button>
|
</div>
|
||||||
<button type="button"
|
<div class="flex items-center gap-1">
|
||||||
onclick={() => { showOnboarding = true; tempGenres = [...prefs.genres]; tempStatus = prefs.status; }}
|
<button type="button" onclick={() => (showHistory = true)} title="History"
|
||||||
title="Preferences"
|
class="relative w-9 h-9 flex items-center justify-center rounded-lg text-(--color-muted) hover:text-(--color-text) hover:bg-(--color-surface-2) transition-colors">
|
||||||
class="w-9 h-9 flex items-center justify-center rounded-lg text-(--color-muted) hover:text-(--color-text) hover:bg-(--color-surface-2) transition-colors">
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
||||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"/>
|
</svg>
|
||||||
</svg>
|
{#if votedBooks.length}
|
||||||
</button>
|
<span class="absolute -top-0.5 -right-0.5 w-4 h-4 rounded-full bg-(--color-brand) text-(--color-surface) text-[9px] font-bold flex items-center justify-center leading-none">
|
||||||
|
{votedBooks.length > 9 ? '9+' : votedBooks.length}
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
<button type="button"
|
||||||
|
onclick={() => { showOnboarding = true; isEditingPrefs = true; tempGenres = [...prefs.genres]; tempStatus = prefs.status; }}
|
||||||
|
title="Preferences"
|
||||||
|
class="w-9 h-9 flex items-center justify-center rounded-lg text-(--color-muted) hover:text-(--color-text) hover:bg-(--color-surface-2) transition-colors">
|
||||||
|
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6V4m0 2a2 2 0 100 4m0-4a2 2 0 110 4m-6 8a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4m6 6v10m6-2a2 2 0 100-4m0 4a2 2 0 110-4m0 4v2m0-6V4"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Progress bar -->
|
||||||
|
{#if !loading && !deckEmpty && deck.length > 0}
|
||||||
|
<div class="w-full h-1.5 bg-(--color-surface-2) rounded-full overflow-hidden">
|
||||||
|
<div class="h-full bg-(--color-brand) transition-all duration-500 ease-out rounded-full"
|
||||||
|
style="width: {((idx / deck.length) * 100).toFixed(1)}%"></div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if loading}
|
{#if loading}
|
||||||
@@ -539,23 +607,41 @@
|
|||||||
|
|
||||||
{:else if deckEmpty}
|
{:else if deckEmpty}
|
||||||
<!-- ── Empty state ───────────────────────────────────────────────── -->
|
<!-- ── Empty state ───────────────────────────────────────────────── -->
|
||||||
<div class="flex-1 flex flex-col items-center justify-center gap-6 text-center max-w-xs">
|
<div class="flex-1 flex flex-col items-center justify-center gap-6 text-center max-w-sm px-4">
|
||||||
<div class="w-20 h-20 rounded-full bg-(--color-surface-2) flex items-center justify-center text-4xl">📚</div>
|
<div class="relative">
|
||||||
|
<div class="w-24 h-24 rounded-full bg-(--color-brand)/10 flex items-center justify-center text-5xl border-4 border-(--color-brand)/20">
|
||||||
|
🎉
|
||||||
|
</div>
|
||||||
|
<div class="absolute -top-1 -right-1 w-8 h-8 rounded-full bg-green-500/20 border-2 border-green-500/40 flex items-center justify-center">
|
||||||
|
<svg class="w-4 h-4 text-green-400" fill="currentColor" viewBox="0 0 24 24">
|
||||||
|
<path d="M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"/>
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<h2 class="text-lg font-bold text-(--color-text) mb-2">All caught up!</h2>
|
<h2 class="text-xl font-bold text-(--color-text) mb-2">All Caught Up!</h2>
|
||||||
<p class="text-sm text-(--color-muted)">
|
<p class="text-sm text-(--color-muted) leading-relaxed">
|
||||||
You've seen all available books.
|
You've explored all {deck.length} books in your discover queue.
|
||||||
{#if prefs.genres.length > 0}Try adjusting your preferences to see more.
|
{#if prefs.genres.length > 0}
|
||||||
{:else}Check your library for books you liked.{/if}
|
<br />Try adjusting your genre preferences to discover more.
|
||||||
|
{:else}
|
||||||
|
<br />Set your preferences to get personalized recommendations.
|
||||||
|
{/if}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-col gap-2 w-full">
|
<div class="flex flex-col gap-3 w-full">
|
||||||
<a href="/books" class="py-2.5 rounded-xl text-sm font-bold bg-(--color-brand) text-(--color-surface) text-center hover:bg-(--color-brand-dim) transition-colors">
|
{#if votedBooks.filter(v => v.action === 'like' || v.action === 'read_now').length > 0}
|
||||||
My Library
|
<a href="/books" class="py-3 rounded-xl text-sm font-bold bg-(--color-brand) text-(--color-surface) text-center hover:bg-(--color-brand-dim) transition-colors shadow-lg shadow-(--color-brand)/20">
|
||||||
</a>
|
View My Library
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
|
<button type="button" onclick={() => { showOnboarding = true; isEditingPrefs = true; tempGenres = [...prefs.genres]; tempStatus = prefs.status; }}
|
||||||
|
class="py-3 rounded-xl text-sm font-semibold bg-(--color-surface-2) text-(--color-text) hover:bg-(--color-surface-3) transition-colors border border-(--color-border)">
|
||||||
|
Change Preferences
|
||||||
|
</button>
|
||||||
<button type="button" onclick={resetDeck}
|
<button type="button" onclick={resetDeck}
|
||||||
class="py-2.5 rounded-xl text-sm font-medium bg-(--color-surface-2) text-(--color-muted) hover:text-(--color-text) transition-colors">
|
class="py-2 rounded-xl text-sm font-medium text-(--color-muted) hover:text-(--color-text) transition-colors">
|
||||||
Start over
|
Start Over
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -619,7 +705,7 @@
|
|||||||
{#if book.author}<p class="text-white/70 text-sm mb-2">{book.author}</p>{/if}
|
{#if book.author}<p class="text-white/70 text-sm mb-2">{book.author}</p>{/if}
|
||||||
<div class="flex flex-wrap gap-1.5 items-center">
|
<div class="flex flex-wrap gap-1.5 items-center">
|
||||||
{#each parseBookGenres(book.genres).slice(0, 2) as genre}
|
{#each parseBookGenres(book.genres).slice(0, 2) as genre}
|
||||||
<span class="text-xs bg-white/15 text-white/90 px-2 py-0.5 rounded-full backdrop-blur-sm">{genre}</span>
|
<span class="text-xs bg-white/15 text-white/90 px-2 py-0.5 rounded-full backdrop-blur-sm">{capitalizeFirst(genre)}</span>
|
||||||
{/each}
|
{/each}
|
||||||
{#if book.status}
|
{#if book.status}
|
||||||
<span class="text-xs bg-white/10 text-white/60 px-2 py-0.5 rounded-full">{book.status}</span>
|
<span class="text-xs bg-white/10 text-white/60 px-2 py-0.5 rounded-full">{book.status}</span>
|
||||||
@@ -674,8 +760,27 @@
|
|||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Swipe hint (mobile only, shown while cards remain) -->
|
||||||
|
<p class="lg:hidden text-xs text-(--color-muted)/60 mt-2 shrink-0 text-center">Swipe ← skip · swipe → like · tap for details</p>
|
||||||
<!-- Keyboard hint (desktop only) -->
|
<!-- Keyboard hint (desktop only) -->
|
||||||
<p class="hidden lg:block text-xs text-(--color-muted)/40 mt-2 shrink-0">← Skip · ↑ Read now · → Like · Space for details</p>
|
<div class="hidden lg:flex items-center justify-center gap-4 mt-3 shrink-0">
|
||||||
|
<div class="flex items-center gap-1.5 px-2 py-1 rounded-lg bg-(--color-surface-2)/50 border border-(--color-border)/30">
|
||||||
|
<kbd class="px-1.5 py-0.5 rounded text-[10px] font-bold bg-(--color-surface-3) text-(--color-muted) border border-(--color-border)">←</kbd>
|
||||||
|
<span class="text-xs text-(--color-muted)">Skip</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-1.5 px-2 py-1 rounded-lg bg-(--color-surface-2)/50 border border-(--color-border)/30">
|
||||||
|
<kbd class="px-1.5 py-0.5 rounded text-[10px] font-bold bg-(--color-surface-3) text-(--color-muted) border border-(--color-border)">↑</kbd>
|
||||||
|
<span class="text-xs text-(--color-muted)">Read</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-1.5 px-2 py-1 rounded-lg bg-(--color-surface-2)/50 border border-(--color-border)/30">
|
||||||
|
<kbd class="px-1.5 py-0.5 rounded text-[10px] font-bold bg-(--color-surface-3) text-(--color-muted) border border-(--color-border)">→</kbd>
|
||||||
|
<span class="text-xs text-(--color-muted)">Like</span>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center gap-1.5 px-2 py-1 rounded-lg bg-(--color-surface-2)/50 border border-(--color-border)/30">
|
||||||
|
<kbd class="px-1.5 py-0.5 rounded text-[10px] font-bold bg-(--color-surface-3) text-(--color-muted) border border-(--color-border)">Space</kbd>
|
||||||
|
<span class="text-xs text-(--color-muted)">Details</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -711,7 +816,7 @@
|
|||||||
<!-- Metadata pills -->
|
<!-- Metadata pills -->
|
||||||
<div class="flex flex-wrap gap-2">
|
<div class="flex flex-wrap gap-2">
|
||||||
{#each parseBookGenres(book.genres).slice(0, 5) as genre}
|
{#each parseBookGenres(book.genres).slice(0, 5) as genre}
|
||||||
<span class="text-xs px-2.5 py-1 rounded-full bg-(--color-surface-3) text-(--color-muted)">{genre}</span>
|
<span class="text-xs px-2.5 py-1 rounded-full bg-(--color-surface-3) text-(--color-muted)">{capitalizeFirst(genre)}</span>
|
||||||
{/each}
|
{/each}
|
||||||
{#if book.status}
|
{#if book.status}
|
||||||
<span class="text-xs px-2.5 py-1 rounded-full bg-(--color-surface-3) text-(--color-text) font-medium">{book.status}</span>
|
<span class="text-xs px-2.5 py-1 rounded-full bg-(--color-surface-3) text-(--color-text) font-medium">{book.status}</span>
|
||||||
@@ -735,7 +840,7 @@
|
|||||||
{#if book.summary}
|
{#if book.summary}
|
||||||
<div>
|
<div>
|
||||||
<p class="text-xs font-semibold text-(--color-muted) uppercase tracking-wider mb-2">Summary</p>
|
<p class="text-xs font-semibold text-(--color-muted) uppercase tracking-wider mb-2">Summary</p>
|
||||||
<p class="text-sm text-(--color-muted) leading-relaxed">{book.summary}</p>
|
<p class="text-sm text-(--color-muted) leading-relaxed">{cleanSummary(book.summary)}</p>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user