Add history page with list, timeline and year in review
- Backend: /history/years and /history/:year return every movie and episode watch in a year, with entry posters, genres, networks and buddies - History tab: watches by month and day, back-to-back episodes grouped - Timeline tab: latest to oldest, month dividers, stacked binge sessions - Year in Review tab: hours, top shows and genres, streaks, busiest day, biggest binge, monthly and weekday charts, buddies and new shows - Year picker, movies/TV filter, state kept in the URL; unknown-date watches badged and excluded from the review by default - History link in the sidebar and command palette
This commit is contained in:
1 parent
c4aa0488d4
commit
760afd8e84
13 files changed
+1724
No files matched your search
@@ -16,6 +16,7 @@ import {
|
||||
ArrowDown,
|
||||
CornerDownLeft,
|
||||
ArrowRight,
|
||||
History,
|
||||
} from "lucide-react";
|
||||
import { tmdbApi } from "@/api/tmdb";
|
||||
import { useLibraryStore } from "@/stores/useLibraryStore";
|
||||
@@ -53,6 +54,12 @@ const NAVIGATION_COMMANDS: CommandItem[] = [
|
||||
title: "Go to Watchlist",
|
||||
icon: <BookOpen className="h-4 w-4" />,
|
||||
},
|
||||
{
|
||||
id: "cmd-history",
|
||||
type: "command",
|
||||
title: "Go to History",
|
||||
icon: <History className="h-4 w-4" />,
|
||||
},
|
||||
{
|
||||
id: "cmd-stats",
|
||||
type: "command",
|
||||
@@ -88,6 +95,7 @@ const NAVIGATION_COMMANDS: CommandItem[] = [
|
||||
const COMMAND_ROUTES: Record<string, string> = {
|
||||
"cmd-library": "/library",
|
||||
"cmd-watchlist": "/watchlist",
|
||||
"cmd-history": "/history",
|
||||
"cmd-stats": "/dashboard",
|
||||
"cmd-calendar": "/calendar",
|
||||
"cmd-people": "/people",
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
import { Link } from "react-router-dom";
|
||||
import { Film, Tv, Users } from "lucide-react";
|
||||
import {
|
||||
MONTH_NAMES,
|
||||
formatMinutes,
|
||||
posterUrl,
|
||||
sessionEpisodeLabel,
|
||||
sessionLink,
|
||||
type HistorySession,
|
||||
type MonthGroup,
|
||||
} from "@/lib/history";
|
||||
|
||||
/** Month sections (newest first), each split into days. */
|
||||
export function HistoryList({ months }: { months: MonthGroup[] }) {
|
||||
return (
|
||||
<div className="space-y-10">
|
||||
{months.map((m) => (
|
||||
<section key={m.month} className="space-y-3">
|
||||
<header className="sticky top-0 z-10 -mx-1 flex flex-wrap items-baseline justify-between gap-2 border-b border-border/60 bg-background/90 px-1 py-2 backdrop-blur">
|
||||
<h2 className="text-xl font-bold tracking-tight">
|
||||
{MONTH_NAMES[m.month]}
|
||||
</h2>
|
||||
<p className="text-xs text-muted-foreground tabular-nums">
|
||||
{[
|
||||
m.movies > 0 &&
|
||||
`${m.movies} ${m.movies === 1 ? "movie" : "movies"}`,
|
||||
m.episodes > 0 &&
|
||||
`${m.episodes} ${m.episodes === 1 ? "episode" : "episodes"}`,
|
||||
m.minutes > 0 && formatMinutes(m.minutes),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.join(" · ")}
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<div className="space-y-5">
|
||||
{groupByDay(m.sessions).map(([day, sessions]) => (
|
||||
<div key={day} className="grid gap-2 sm:grid-cols-[7rem_1fr]">
|
||||
<p className="pt-2 text-sm font-medium text-muted-foreground">
|
||||
{new Date(sessions[0].date).toLocaleDateString("en-US", {
|
||||
weekday: "short",
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
})}
|
||||
</p>
|
||||
<div className="space-y-1.5">
|
||||
{sessions.map((s) => (
|
||||
<HistoryRow key={s.key} session={s} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function groupByDay(sessions: HistorySession[]) {
|
||||
const days = new Map<string, HistorySession[]>();
|
||||
for (const s of sessions) {
|
||||
const list = days.get(s.day) ?? [];
|
||||
list.push(s);
|
||||
days.set(s.day, list);
|
||||
}
|
||||
return [...days.entries()];
|
||||
}
|
||||
|
||||
function HistoryRow({ session }: { session: HistorySession }) {
|
||||
const entry = session.entry;
|
||||
const isMovie = session.kind === "movie";
|
||||
const single = session.events.length === 1 ? session.events[0] : null;
|
||||
const buddies = [
|
||||
...new Map(
|
||||
session.events.flatMap((e) => e.buddies).map((b) => [b.id, b]),
|
||||
).values(),
|
||||
];
|
||||
|
||||
return (
|
||||
<Link
|
||||
to={sessionLink(session)}
|
||||
className="group flex items-center gap-3 rounded-lg border border-transparent p-1.5 transition-colors hover:border-border/60 hover:bg-accent/40"
|
||||
>
|
||||
<img
|
||||
src={posterUrl(entry)}
|
||||
alt=""
|
||||
loading="lazy"
|
||||
className="h-16 w-11 shrink-0 rounded-md object-cover ring-1 ring-border/60"
|
||||
/>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="line-clamp-1 font-medium">
|
||||
{entry?.title ?? "Unknown title"}
|
||||
</p>
|
||||
<p className="line-clamp-1 text-xs text-muted-foreground">
|
||||
{isMovie ? (
|
||||
<span className="inline-flex items-center gap-1">
|
||||
<Film className="h-3 w-3" /> Movie
|
||||
{entry?.release_date &&
|
||||
` · ${new Date(entry.release_date).getFullYear()}`}
|
||||
</span>
|
||||
) : (
|
||||
<span className="inline-flex items-center gap-1">
|
||||
<Tv className="h-3 w-3" />
|
||||
{sessionEpisodeLabel(session)}
|
||||
{single?.episode?.name
|
||||
? ` · ${single.episode.name}`
|
||||
: ` · ${session.events.length} episodes`}
|
||||
</span>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex shrink-0 flex-col items-end gap-1 text-xs text-muted-foreground">
|
||||
{session.minutes > 0 && (
|
||||
<span className="tabular-nums">{formatMinutes(session.minutes)}</span>
|
||||
)}
|
||||
{session.unknownDate && (
|
||||
<span className="rounded bg-amber-500/15 px-1.5 py-px text-[10px] font-medium text-amber-600 dark:text-amber-400">
|
||||
Date unknown
|
||||
</span>
|
||||
)}
|
||||
{buddies.length > 0 && (
|
||||
<span
|
||||
className="inline-flex items-center gap-1"
|
||||
title={buddies.map((b) => b.name).join(", ")}
|
||||
>
|
||||
<Users className="h-3 w-3" />
|
||||
<span className="max-w-28 truncate">
|
||||
{buddies.map((b) => b.name).join(", ")}
|
||||
</span>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
import { Link } from "react-router-dom";
|
||||
import { Film, Tv } from "lucide-react";
|
||||
import {
|
||||
MONTH_NAMES,
|
||||
formatMinutes,
|
||||
posterUrl,
|
||||
sessionEpisodeLabel,
|
||||
sessionLink,
|
||||
type HistorySession,
|
||||
type MonthGroup,
|
||||
} from "@/lib/history";
|
||||
|
||||
/**
|
||||
* Vertical timeline, latest watch at the top down to January. Episodes of a
|
||||
* show watched back to back on the same day are stacked into one card.
|
||||
*/
|
||||
export function HistoryTimeline({ months }: { months: MonthGroup[] }) {
|
||||
let index = 0; // alternates sides across the whole year
|
||||
|
||||
return (
|
||||
<div className="relative mx-auto max-w-4xl pb-6">
|
||||
{/* The line */}
|
||||
<div className="absolute bottom-0 left-4 top-0 w-px bg-border md:left-1/2 md:-translate-x-1/2" />
|
||||
|
||||
{months.map((m) => (
|
||||
<section key={m.month} className="relative">
|
||||
{/* Month divider */}
|
||||
<div className="relative flex items-center py-6 md:justify-center">
|
||||
<div className="absolute inset-x-0 top-1/2 h-px bg-linear-to-r from-transparent via-border to-transparent" />
|
||||
<span className="relative ml-8 rounded-full border border-border bg-background px-4 py-1 text-sm font-semibold shadow-sm md:ml-0">
|
||||
{MONTH_NAMES[m.month]}
|
||||
<span className="ml-2 text-xs font-normal text-muted-foreground tabular-nums">
|
||||
{m.movies + m.episodes} watched
|
||||
</span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<ol className="space-y-6">
|
||||
{m.sessions.map((s) => {
|
||||
const side = index++ % 2 === 0 ? "left" : "right";
|
||||
return <TimelineItem key={s.key} session={s} side={side} />;
|
||||
})}
|
||||
</ol>
|
||||
</section>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TimelineItem({
|
||||
session,
|
||||
side,
|
||||
}: {
|
||||
session: HistorySession;
|
||||
side: "left" | "right";
|
||||
}) {
|
||||
const entry = session.entry;
|
||||
const count = session.events.length;
|
||||
const isMovie = session.kind === "movie";
|
||||
const date = new Date(session.date).toLocaleDateString("en-US", {
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
});
|
||||
|
||||
return (
|
||||
<li
|
||||
className={`relative flex pl-12 md:w-1/2 md:pl-0 ${
|
||||
side === "left"
|
||||
? "md:mr-auto md:justify-end md:pr-10"
|
||||
: "md:ml-auto md:pl-10"
|
||||
}`}
|
||||
>
|
||||
{/* Dot on the line */}
|
||||
<span
|
||||
className={`absolute top-6 left-4 h-3 w-3 -translate-x-1/2 rounded-full ring-4 ring-background ${
|
||||
isMovie ? "bg-amber-500" : "bg-sky-500"
|
||||
} ${side === "left" ? "md:right-0 md:left-auto md:translate-x-1/2" : "md:left-0"}`}
|
||||
/>
|
||||
|
||||
<Link
|
||||
to={sessionLink(session)}
|
||||
className={`group flex w-full max-w-sm items-start gap-3 rounded-xl border border-border/60 bg-card/60 p-2.5 transition-colors hover:bg-accent/40 ${
|
||||
side === "left" ? "md:flex-row-reverse md:text-right" : ""
|
||||
}`}
|
||||
>
|
||||
{/* Poster, stacked for multi-episode sessions */}
|
||||
<div className="relative shrink-0">
|
||||
{count > 1 && (
|
||||
<>
|
||||
<img
|
||||
src={posterUrl(entry)}
|
||||
alt=""
|
||||
className="absolute inset-0 h-full w-full translate-x-2 -translate-y-1 rotate-6 rounded-lg object-cover opacity-40"
|
||||
/>
|
||||
<img
|
||||
src={posterUrl(entry)}
|
||||
alt=""
|
||||
className="absolute inset-0 h-full w-full translate-x-1 rotate-3 rounded-lg object-cover opacity-70"
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
<img
|
||||
src={posterUrl(entry, "w342")}
|
||||
alt=""
|
||||
loading="lazy"
|
||||
className="relative h-28 w-[4.7rem] rounded-lg object-cover shadow-md ring-1 ring-border/60 transition-transform group-hover:scale-[1.03]"
|
||||
/>
|
||||
{count > 1 && (
|
||||
<span className="absolute -bottom-1.5 -right-1.5 rounded-full bg-sky-500 px-1.5 py-0.5 text-[10px] font-bold text-white shadow">
|
||||
×{count}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="min-w-0 flex-1 space-y-1 py-0.5">
|
||||
<p className="text-xs font-medium text-muted-foreground">
|
||||
{date}
|
||||
{session.unknownDate && (
|
||||
<span className="ml-1.5 rounded bg-amber-500/15 px-1 py-px text-[10px] text-amber-600 dark:text-amber-400">
|
||||
date unknown
|
||||
</span>
|
||||
)}
|
||||
</p>
|
||||
<p className="line-clamp-2 font-semibold leading-tight">
|
||||
{entry?.title ?? "Unknown title"}
|
||||
</p>
|
||||
<p
|
||||
className={`flex items-center gap-1 text-xs text-muted-foreground ${
|
||||
side === "left" ? "md:justify-end" : ""
|
||||
}`}
|
||||
>
|
||||
{isMovie ? (
|
||||
<Film className="h-3 w-3" />
|
||||
) : (
|
||||
<Tv className="h-3 w-3" />
|
||||
)}
|
||||
{isMovie
|
||||
? "Movie"
|
||||
: count > 1
|
||||
? `${sessionEpisodeLabel(session)} · ${count} episodes`
|
||||
: `${sessionEpisodeLabel(session)} · ${session.events[0].episode?.name ?? ""}`}
|
||||
</p>
|
||||
{session.minutes > 0 && (
|
||||
<p className="text-[11px] text-muted-foreground/80 tabular-nums">
|
||||
{formatMinutes(session.minutes)}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
</Link>
|
||||
</li>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,496 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { Link } from "react-router-dom";
|
||||
import {
|
||||
CalendarDays,
|
||||
Clapperboard,
|
||||
Flame,
|
||||
Popcorn,
|
||||
Repeat,
|
||||
Sparkles,
|
||||
Star,
|
||||
Tv,
|
||||
Users,
|
||||
Zap,
|
||||
} from "lucide-react";
|
||||
import { getTmdbImageUrl } from "@/lib/api";
|
||||
import {
|
||||
MONTH_NAMES,
|
||||
WEEKDAY_NAMES,
|
||||
episodeCode,
|
||||
formatMinutes,
|
||||
posterUrl,
|
||||
type YearReview,
|
||||
} from "@/lib/history";
|
||||
import type { HistoryEntry, HistoryEvent } from "@/api/history";
|
||||
|
||||
const formatDay = (day: string) =>
|
||||
new Date(`${day}T12:00:00`).toLocaleDateString("en-US", {
|
||||
weekday: "long",
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
});
|
||||
|
||||
export function YearInReview({
|
||||
year,
|
||||
review,
|
||||
entries,
|
||||
}: {
|
||||
year: number;
|
||||
review: YearReview;
|
||||
entries: Record<number, HistoryEntry>;
|
||||
}) {
|
||||
const hours = Math.round(review.totalMinutes / 60);
|
||||
const maxMonth = Math.max(1, ...review.monthly.map((m) => m.minutes));
|
||||
const maxWeekday = Math.max(1, ...review.weekdays);
|
||||
const topWeekday = review.weekdays.indexOf(Math.max(...review.weekdays));
|
||||
const topMonth = review.monthly.findIndex((m) => m.minutes === maxMonth);
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
{/* Hero */}
|
||||
<section className="relative overflow-hidden rounded-3xl bg-linear-to-br from-fuchsia-600 via-violet-600 to-indigo-700 p-8 text-white shadow-xl sm:p-10">
|
||||
<div className="absolute -right-16 -top-16 h-64 w-64 rounded-full bg-white/10 blur-2xl" />
|
||||
<div className="absolute -bottom-20 left-1/3 h-56 w-56 rounded-full bg-amber-300/20 blur-3xl" />
|
||||
<div className="relative space-y-6">
|
||||
<p className="inline-flex items-center gap-2 text-sm font-medium uppercase tracking-[0.2em] text-white/80">
|
||||
<Sparkles className="h-4 w-4" /> Your {year} in review
|
||||
</p>
|
||||
<div>
|
||||
<p className="text-6xl font-black tracking-tight tabular-nums sm:text-8xl">
|
||||
{hours.toLocaleString()}
|
||||
</p>
|
||||
<p className="text-lg font-medium text-white/85">
|
||||
hours of movies and TV
|
||||
{hours >= 24 && (
|
||||
<span className="text-white/70">
|
||||
{" "}
|
||||
— that's {Math.round(hours / 24)} full days
|
||||
</span>
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid grid-cols-2 gap-3 sm:grid-cols-4">
|
||||
<HeroStat label="Movies" value={review.uniqueMovies} />
|
||||
<HeroStat label="Episodes" value={review.episodeWatches} />
|
||||
<HeroStat label="Shows" value={review.uniqueShows} />
|
||||
<HeroStat label="Days watching" value={review.activeDays} />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* Highlights */}
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||
{review.longestStreak && review.longestStreak.days > 1 && (
|
||||
<HighlightCard
|
||||
icon={<Flame />}
|
||||
tone="from-orange-500/20 to-red-500/10"
|
||||
label="Longest streak"
|
||||
value={`${review.longestStreak.days} days`}
|
||||
detail={`${shortDay(review.longestStreak.start)} – ${shortDay(review.longestStreak.end)}`}
|
||||
/>
|
||||
)}
|
||||
{review.busiestDay && (
|
||||
<HighlightCard
|
||||
icon={<CalendarDays />}
|
||||
tone="from-sky-500/20 to-cyan-500/10"
|
||||
label="Busiest day"
|
||||
value={formatMinutes(review.busiestDay.minutes)}
|
||||
detail={`${formatDay(review.busiestDay.day)} · ${review.busiestDay.watches} watched`}
|
||||
/>
|
||||
)}
|
||||
{review.biggestBinge && (
|
||||
<HighlightCard
|
||||
icon={<Zap />}
|
||||
tone="from-violet-500/20 to-fuchsia-500/10"
|
||||
label="Biggest binge"
|
||||
value={`${review.biggestBinge.episodes} episodes`}
|
||||
detail={`${review.biggestBinge.entry.title} · ${shortDay(review.biggestBinge.day)}`}
|
||||
poster={posterUrl(review.biggestBinge.entry)}
|
||||
/>
|
||||
)}
|
||||
<HighlightCard
|
||||
icon={<Star />}
|
||||
tone="from-amber-500/20 to-yellow-500/10"
|
||||
label="Favorite day"
|
||||
value={WEEKDAY_NAMES[topWeekday]}
|
||||
detail={`and ${MONTH_NAMES[topMonth]} was your biggest month`}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-6 lg:grid-cols-2">
|
||||
{/* Top shows */}
|
||||
{review.topShows.length > 0 && (
|
||||
<Card title="Top shows" icon={<Tv />}>
|
||||
<ol className="space-y-2.5">
|
||||
{review.topShows.map((s, i) => (
|
||||
<li key={s.entry.id}>
|
||||
<Link
|
||||
to={`/entry/${s.entry.id}`}
|
||||
className="flex items-center gap-3 rounded-lg p-1 transition-colors hover:bg-accent/50"
|
||||
>
|
||||
<span className="w-7 text-center text-2xl font-black text-muted-foreground/60 tabular-nums">
|
||||
{i + 1}
|
||||
</span>
|
||||
<img
|
||||
src={posterUrl(s.entry)}
|
||||
alt=""
|
||||
className="h-14 w-10 rounded object-cover ring-1 ring-border/60"
|
||||
/>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="line-clamp-1 font-semibold">
|
||||
{s.entry.title}
|
||||
</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{s.episodes} episodes · {formatMinutes(s.minutes)}
|
||||
</p>
|
||||
</div>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* Genres */}
|
||||
{review.topGenres.length > 0 && (
|
||||
<Card title="Top genres" icon={<Clapperboard />}>
|
||||
<div className="space-y-3">
|
||||
{review.topGenres.map((g, i) => (
|
||||
<div key={g.name} className="space-y-1">
|
||||
<div className="flex justify-between text-sm">
|
||||
<span className="font-medium">{g.name}</span>
|
||||
<span className="text-muted-foreground tabular-nums">
|
||||
{Math.round(g.share * 100)}%
|
||||
</span>
|
||||
</div>
|
||||
<div className="h-2 overflow-hidden rounded-full bg-muted">
|
||||
<div
|
||||
className="h-full rounded-full bg-linear-to-r from-violet-500 to-fuchsia-500"
|
||||
style={{
|
||||
width: `${(g.minutes / review.topGenres[0].minutes) * 100}%`,
|
||||
opacity: 1 - i * 0.1,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Monthly activity */}
|
||||
<Card title="Month by month" icon={<CalendarDays />}>
|
||||
<div className="flex h-44 items-end gap-1.5 sm:gap-3">
|
||||
{review.monthly.map((m, i) => (
|
||||
<div key={i} className="flex flex-1 flex-col items-center gap-1.5">
|
||||
<div className="flex h-36 w-full items-end">
|
||||
<div
|
||||
title={`${MONTH_NAMES[i]}: ${formatMinutes(m.minutes)} · ${m.movies} movies · ${m.episodes} episodes`}
|
||||
className={`w-full rounded-t-md transition-all ${
|
||||
i === topMonth
|
||||
? "bg-linear-to-t from-fuchsia-600 to-violet-400"
|
||||
: "bg-linear-to-t from-violet-500/50 to-violet-400/30"
|
||||
}`}
|
||||
style={{
|
||||
height: `${Math.max(2, (m.minutes / maxMonth) * 100)}%`,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<span className="text-[10px] font-medium text-muted-foreground">
|
||||
{MONTH_NAMES[i].slice(0, 3)}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<div className="grid gap-6 lg:grid-cols-3">
|
||||
{/* Top rated movies */}
|
||||
{review.topMovies.length > 0 && (
|
||||
<Card
|
||||
title="Your top-rated movies"
|
||||
icon={<Popcorn />}
|
||||
className="lg:col-span-2"
|
||||
>
|
||||
<div className="grid grid-cols-3 gap-3 sm:grid-cols-5">
|
||||
{review.topMovies.map((m) => (
|
||||
<Link
|
||||
key={m.entry.id}
|
||||
to={`/entry/${m.entry.id}`}
|
||||
className="group space-y-1.5"
|
||||
>
|
||||
<img
|
||||
src={posterUrl(m.entry, "w342")}
|
||||
alt={m.entry.title}
|
||||
className="aspect-2/3 w-full rounded-lg object-cover ring-1 ring-border/60 transition-transform group-hover:scale-[1.03]"
|
||||
/>
|
||||
<p className="line-clamp-1 text-xs font-medium">
|
||||
{m.entry.title}
|
||||
</p>
|
||||
<p className="inline-flex items-center gap-0.5 text-xs text-muted-foreground tabular-nums">
|
||||
<Star className="h-3 w-3 fill-yellow-400 text-yellow-400" />
|
||||
{m.rating}/10
|
||||
</p>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* Weekdays */}
|
||||
<Card title="When you watch" icon={<CalendarDays />}>
|
||||
<div className="space-y-2">
|
||||
{review.weekdays.map((n, d) => (
|
||||
<div key={d} className="flex items-center gap-2 text-xs">
|
||||
<span className="w-8 text-muted-foreground">
|
||||
{WEEKDAY_NAMES[d]}
|
||||
</span>
|
||||
<div className="h-2 flex-1 overflow-hidden rounded-full bg-muted">
|
||||
<div
|
||||
className={`h-full rounded-full ${d === topWeekday ? "bg-amber-500" : "bg-amber-500/40"}`}
|
||||
style={{ width: `${(n / maxWeekday) * 100}%` }}
|
||||
/>
|
||||
</div>
|
||||
<span className="w-8 text-right tabular-nums text-muted-foreground">
|
||||
{n}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{review.rewatches.length > 0 && (
|
||||
<Card title="On repeat" icon={<Repeat />}>
|
||||
<ul className="space-y-2">
|
||||
{review.rewatches.map((r) => (
|
||||
<li
|
||||
key={r.entry.id}
|
||||
className="flex items-center justify-between gap-2 text-sm"
|
||||
>
|
||||
<Link
|
||||
to={`/entry/${r.entry.id}`}
|
||||
className="line-clamp-1 hover:underline"
|
||||
>
|
||||
{r.entry.title}
|
||||
</Link>
|
||||
<span className="shrink-0 rounded-full bg-muted px-2 py-0.5 text-xs tabular-nums">
|
||||
×{r.watches}
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{review.topNetworks.length > 0 && (
|
||||
<Card title="Top networks" icon={<Tv />}>
|
||||
<ul className="space-y-2.5">
|
||||
{review.topNetworks.map((n) => (
|
||||
<li
|
||||
key={n.name}
|
||||
className="flex items-center justify-between gap-2 text-sm"
|
||||
>
|
||||
{n.logo_path ? (
|
||||
<img
|
||||
src={getTmdbImageUrl(n.logo_path, "w92")}
|
||||
alt={n.name}
|
||||
title={n.name}
|
||||
className="h-5 max-w-24 object-contain dark:invert dark:brightness-200"
|
||||
/>
|
||||
) : (
|
||||
<span>{n.name}</span>
|
||||
)}
|
||||
<span className="text-xs text-muted-foreground tabular-nums">
|
||||
{n.episodes} eps
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{review.topBuddies.length > 0 && (
|
||||
<Card title="Watched together" icon={<Users />}>
|
||||
<ul className="space-y-2">
|
||||
{review.topBuddies.map((b) => (
|
||||
<li
|
||||
key={b.id}
|
||||
className="flex items-center justify-between gap-2 text-sm"
|
||||
>
|
||||
<Link
|
||||
to={`/watch-buddies/${b.id}`}
|
||||
className="hover:underline"
|
||||
>
|
||||
{b.name}
|
||||
</Link>
|
||||
<span className="text-xs text-muted-foreground tabular-nums">
|
||||
{b.watches} watches
|
||||
</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Started shows */}
|
||||
{review.startedShows.length > 0 && (
|
||||
<Card
|
||||
title={`New shows you started (${review.startedShows.length})`}
|
||||
icon={<Sparkles />}
|
||||
>
|
||||
<div className="flex gap-3 overflow-x-auto pb-2">
|
||||
{review.startedShows.map((e) => (
|
||||
<Link
|
||||
key={e.id}
|
||||
to={`/entry/${e.id}`}
|
||||
className="w-24 shrink-0 space-y-1"
|
||||
>
|
||||
<img
|
||||
src={posterUrl(e, "w342")}
|
||||
alt={e.title}
|
||||
className="aspect-2/3 w-full rounded-lg object-cover ring-1 ring-border/60"
|
||||
/>
|
||||
<p className="line-clamp-1 text-xs">{e.title}</p>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
|
||||
{/* Bookends */}
|
||||
{review.first && review.last && (
|
||||
<div className="grid gap-4 sm:grid-cols-2">
|
||||
<BookendCard
|
||||
label={`First watch of ${year}`}
|
||||
event={review.first}
|
||||
entries={entries}
|
||||
/>
|
||||
<BookendCard
|
||||
label={`Last watch of ${year}`}
|
||||
event={review.last}
|
||||
entries={entries}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
const shortDay = (day: string) =>
|
||||
new Date(`${day}T12:00:00`).toLocaleDateString("en-US", {
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
});
|
||||
|
||||
function HeroStat({ label, value }: { label: string; value: number }) {
|
||||
return (
|
||||
<div className="rounded-2xl bg-white/10 px-4 py-3 backdrop-blur">
|
||||
<p className="text-3xl font-bold tabular-nums">
|
||||
{value.toLocaleString()}
|
||||
</p>
|
||||
<p className="text-xs font-medium uppercase tracking-wider text-white/75">
|
||||
{label}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function HighlightCard({
|
||||
icon,
|
||||
tone,
|
||||
label,
|
||||
value,
|
||||
detail,
|
||||
poster,
|
||||
}: {
|
||||
icon: ReactNode;
|
||||
tone: string;
|
||||
label: string;
|
||||
value: string;
|
||||
detail: string;
|
||||
poster?: string;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
className={`relative overflow-hidden rounded-2xl border border-border/60 bg-linear-to-br ${tone} p-5`}
|
||||
>
|
||||
{poster && (
|
||||
<img
|
||||
src={poster}
|
||||
alt=""
|
||||
className="absolute -right-4 -bottom-6 h-32 w-24 rotate-12 rounded-lg object-cover opacity-30"
|
||||
/>
|
||||
)}
|
||||
<div className="relative space-y-1">
|
||||
<p className="flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wider text-muted-foreground [&_svg]:h-3.5 [&_svg]:w-3.5">
|
||||
{icon}
|
||||
{label}
|
||||
</p>
|
||||
<p className="text-3xl font-black tracking-tight">{value}</p>
|
||||
<p className="line-clamp-2 text-xs text-muted-foreground">{detail}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Card({
|
||||
title,
|
||||
icon,
|
||||
children,
|
||||
className = "",
|
||||
}: {
|
||||
title: string;
|
||||
icon: ReactNode;
|
||||
children: ReactNode;
|
||||
className?: string;
|
||||
}) {
|
||||
return (
|
||||
<section
|
||||
className={`rounded-2xl border border-border/60 bg-card/60 p-5 ${className}`}
|
||||
>
|
||||
<h3 className="mb-4 flex items-center gap-2 text-sm font-semibold [&_svg]:h-4 [&_svg]:w-4 [&_svg]:text-muted-foreground">
|
||||
{icon}
|
||||
{title}
|
||||
</h3>
|
||||
{children}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function BookendCard({
|
||||
label,
|
||||
event,
|
||||
entries,
|
||||
}: {
|
||||
label: string;
|
||||
event: HistoryEvent;
|
||||
entries: Record<number, HistoryEntry>;
|
||||
}) {
|
||||
const entry = entries[event.entry_id];
|
||||
return (
|
||||
<div className="flex items-center gap-4 rounded-2xl border border-border/60 bg-card/60 p-4">
|
||||
<img
|
||||
src={posterUrl(entry, "w342")}
|
||||
alt=""
|
||||
className="h-24 w-16 rounded-lg object-cover ring-1 ring-border/60"
|
||||
/>
|
||||
<div className="min-w-0 space-y-0.5">
|
||||
<p className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">
|
||||
{label}
|
||||
</p>
|
||||
<p className="line-clamp-1 text-lg font-bold">{entry?.title}</p>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
{event.kind === "episode" && `${episodeCode(event.episode)} · `}
|
||||
{new Date(event.date_seen).toLocaleDateString("en-US", {
|
||||
month: "long",
|
||||
day: "numeric",
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
Sun,
|
||||
Film,
|
||||
Video,
|
||||
History,
|
||||
} from "lucide-react";
|
||||
import { useThemeStore } from "@/stores/useThemeStore";
|
||||
import { Separator } from "@/components/ui/separator";
|
||||
@@ -26,6 +27,7 @@ const mainNav = [
|
||||
const libraryNav = [
|
||||
{ to: "/library", icon: Library, label: "Library" },
|
||||
{ to: "/watchlist", icon: ListVideo, label: "Watchlist" },
|
||||
{ to: "/history", icon: History, label: "History" },
|
||||
{ to: "/collections", icon: FolderOpen, label: "Collections" },
|
||||
{ to: "/media", icon: Image, label: "Media" },
|
||||
{ to: "/discovery-videos", icon: Video, label: "Discover" },
|
||||
|
||||
Reference in new issue
Block a user