feat: UI improvements across Calendar, Cast, People, and Entry Details pages
Calendar: - Add list/agenda view for mobile with view toggle button (defaults to list on small screens) - Grid view: show entry poster cards (not episode stills) with S01E04 label for TV, title for movies - Grid cells use grid-rows-6 to fill exact viewport height with no scrolling on desktop - Clicking a day opens a dialog showing all episodes as a poster grid - Cap grid cells to 3 visible posters with overflow badge - Hide episodes with no known entry title Cast & Crew Page: - Increase people card size (h-32 w-32 avatar, larger text, fewer columns) - Add search box filtering by name and role - Restructure controls: search + count on left, filter + sort on right - Default filter to "Cast", default sort to "Episode Count" People Page: - Mobile layout: search input takes full width, switch & filter move to second line Entry Details Page: - Remove favorite heart icon overlay from poster - Add favorite pill in ratings row (gold background/star when active, dashed border when inactive) Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
1 parent
5fa2556b43
commit
3b882c9c35
4 files changed
+281
-54
No files matched your search
@@ -1,8 +1,9 @@
|
|||||||
import { useState, useMemo } from 'react';
|
import { useState, useMemo } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { format, startOfMonth, endOfMonth, eachDayOfInterval, getDay, addMonths, subMonths, isSameDay } from 'date-fns';
|
import { format, startOfMonth, endOfMonth, eachDayOfInterval, getDay, addMonths, subMonths, isSameDay } from 'date-fns';
|
||||||
import { ChevronLeft, ChevronRight } from 'lucide-react';
|
import { ChevronLeft, ChevronRight, LayoutGrid, List } from 'lucide-react';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
||||||
import { useEpisodesByMonth } from '@/hooks/useEpisodes';
|
import { useEpisodesByMonth } from '@/hooks/useEpisodes';
|
||||||
import { Tooltip, TooltipContent, TooltipTrigger, TooltipProvider } from '@/components/ui/tooltip';
|
import { Tooltip, TooltipContent, TooltipTrigger, TooltipProvider } from '@/components/ui/tooltip';
|
||||||
import { getTmdbPosterUrl } from '@/lib/media-utils';
|
import { getTmdbPosterUrl } from '@/lib/media-utils';
|
||||||
@@ -12,6 +13,10 @@ const DAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|||||||
|
|
||||||
export function CalendarPage() {
|
export function CalendarPage() {
|
||||||
const [currentDate, setCurrentDate] = useState(new Date());
|
const [currentDate, setCurrentDate] = useState(new Date());
|
||||||
|
const [viewMode, setViewMode] = useState<'grid' | 'list'>(
|
||||||
|
() => (typeof window !== 'undefined' && window.innerWidth < 640 ? 'list' : 'grid')
|
||||||
|
);
|
||||||
|
const [selectedDay, setSelectedDay] = useState<{ date: Date; episodes: Episode[] } | null>(null);
|
||||||
const monthStart = startOfMonth(currentDate);
|
const monthStart = startOfMonth(currentDate);
|
||||||
const monthEnd = endOfMonth(currentDate);
|
const monthEnd = endOfMonth(currentDate);
|
||||||
|
|
||||||
@@ -37,7 +42,7 @@ export function CalendarPage() {
|
|||||||
}, [episodes]);
|
}, [episodes]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col h-[calc(100vh-7rem)]">
|
<div className="flex flex-col h-[calc(100vh-3rem)]">
|
||||||
<div className="flex items-center justify-between mb-4 shrink-0">
|
<div className="flex items-center justify-between mb-4 shrink-0">
|
||||||
<h1 className="text-2xl font-bold">Calendar</h1>
|
<h1 className="text-2xl font-bold">Calendar</h1>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
@@ -58,11 +63,28 @@ export function CalendarPage() {
|
|||||||
>
|
>
|
||||||
<ChevronRight className="h-4 w-4" />
|
<ChevronRight className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
variant="outline"
|
||||||
|
size="icon"
|
||||||
|
onClick={() => setViewMode((v) => (v === 'grid' ? 'list' : 'grid'))}
|
||||||
|
title={viewMode === 'grid' ? 'Switch to list view' : 'Switch to grid view'}
|
||||||
|
>
|
||||||
|
{viewMode === 'grid' ? <List className="h-4 w-4" /> : <LayoutGrid className="h-4 w-4" />}
|
||||||
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Calendar Grid — fills remaining height */}
|
{/* Calendar Grid / List — fills remaining height */}
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
|
{selectedDay && (
|
||||||
|
<DayDialog
|
||||||
|
date={selectedDay.date}
|
||||||
|
episodes={selectedDay.episodes}
|
||||||
|
onClose={() => setSelectedDay(null)}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{viewMode === 'grid' ? (
|
||||||
<div className="flex flex-col flex-1 rounded-lg border border-border overflow-hidden min-h-0">
|
<div className="flex flex-col flex-1 rounded-lg border border-border overflow-hidden min-h-0">
|
||||||
{/* Day headers */}
|
{/* Day headers */}
|
||||||
<div className="grid grid-cols-7 bg-muted/50 shrink-0">
|
<div className="grid grid-cols-7 bg-muted/50 shrink-0">
|
||||||
@@ -73,8 +95,8 @@ export function CalendarPage() {
|
|||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Day cells */}
|
{/* Day cells — no scroll, rows share the remaining height equally */}
|
||||||
<div className="grid grid-cols-7 flex-1 overflow-y-auto">
|
<div className="grid grid-cols-7 grid-rows-6 flex-1 min-h-0">
|
||||||
{/* Empty cells for offset */}
|
{/* Empty cells for offset */}
|
||||||
{Array.from({ length: startDayOfWeek }).map((_, i) => (
|
{Array.from({ length: startDayOfWeek }).map((_, i) => (
|
||||||
<div key={`empty-${i}`} className="border-t border-r border-border bg-muted/20" />
|
<div key={`empty-${i}`} className="border-t border-r border-border bg-muted/20" />
|
||||||
@@ -88,12 +110,13 @@ export function CalendarPage() {
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={key}
|
key={key}
|
||||||
className={`border-t border-r border-border p-1.5 ${
|
onClick={() => dayEpisodes.length > 0 && setSelectedDay({ date: day, episodes: dayEpisodes })}
|
||||||
|
className={`border-t border-r border-border p-1 overflow-hidden flex flex-col min-h-0 ${
|
||||||
isToday ? 'bg-primary/5' : ''
|
isToday ? 'bg-primary/5' : ''
|
||||||
}`}
|
} ${dayEpisodes.length > 0 ? 'cursor-pointer hover:bg-accent/30 transition-colors' : ''}`}
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
className={`inline-flex h-6 w-6 items-center justify-center rounded-full text-xs mb-1 ${
|
className={`inline-flex h-5 w-5 shrink-0 items-center justify-center rounded-full text-[10px] mb-0.5 ${
|
||||||
isToday
|
isToday
|
||||||
? 'bg-primary text-primary-foreground font-bold'
|
? 'bg-primary text-primary-foreground font-bold'
|
||||||
: 'text-muted-foreground'
|
: 'text-muted-foreground'
|
||||||
@@ -101,13 +124,13 @@ export function CalendarPage() {
|
|||||||
>
|
>
|
||||||
{format(day, 'd')}
|
{format(day, 'd')}
|
||||||
</span>
|
</span>
|
||||||
<div className="space-y-1">
|
<div className="flex gap-0.5 flex-1 min-h-0 overflow-hidden items-start">
|
||||||
{dayEpisodes.slice(0, 4).map((ep) => (
|
{dayEpisodes.slice(0, 3).map((ep) => (
|
||||||
<EpisodeCalendarItem key={ep.id} episode={ep} />
|
<EpisodeCalendarItem key={ep.id} episode={ep} variant="grid" />
|
||||||
))}
|
))}
|
||||||
{dayEpisodes.length > 4 && (
|
{dayEpisodes.length > 3 && (
|
||||||
<span className="text-[10px] text-muted-foreground pl-1">
|
<span className="text-[9px] text-muted-foreground shrink-0 self-end pb-0.5">
|
||||||
+{dayEpisodes.length - 4} more
|
+{dayEpisodes.length - 3}
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@@ -116,12 +139,68 @@ export function CalendarPage() {
|
|||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
) : (
|
||||||
|
/* List / Agenda view */
|
||||||
|
<div className="flex flex-col flex-1 overflow-y-auto min-h-0 gap-1">
|
||||||
|
{days.map((day) => {
|
||||||
|
const key = format(day, 'yyyy-MM-dd');
|
||||||
|
const dayEpisodes = episodesByDate.get(key) || [];
|
||||||
|
const isToday = isSameDay(day, new Date());
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={key}
|
||||||
|
className={`rounded-lg border ${
|
||||||
|
isToday
|
||||||
|
? 'border-primary/30 bg-primary/5'
|
||||||
|
: dayEpisodes.length > 0
|
||||||
|
? 'border-border'
|
||||||
|
: 'border-transparent'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
className={`flex items-center gap-3 px-3 py-2 ${
|
||||||
|
dayEpisodes.length > 0 ? 'border-b border-border/40' : ''
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
className={`inline-flex h-7 w-7 shrink-0 items-center justify-center rounded-full text-sm ${
|
||||||
|
isToday
|
||||||
|
? 'bg-primary text-primary-foreground font-bold'
|
||||||
|
: 'text-muted-foreground'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
{format(day, 'd')}
|
||||||
|
</span>
|
||||||
|
<span className={`text-sm ${
|
||||||
|
isToday ? 'font-medium text-foreground' : 'text-muted-foreground'
|
||||||
|
}`}>
|
||||||
|
{format(day, 'EEEE, MMM d')}
|
||||||
|
</span>
|
||||||
|
{dayEpisodes.length > 0 && (
|
||||||
|
<span className="ml-auto text-xs text-muted-foreground">
|
||||||
|
{dayEpisodes.length} ep{dayEpisodes.length !== 1 ? 's' : ''}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{dayEpisodes.length > 0 && (
|
||||||
|
<div className="p-2 space-y-1">
|
||||||
|
{dayEpisodes.map((ep) => (
|
||||||
|
<EpisodeCalendarItem key={ep.id} episode={ep} />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</TooltipProvider>
|
</TooltipProvider>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function EpisodeCalendarItem({ episode }: { episode: Episode }) {
|
function EpisodeCalendarItem({ episode, variant = 'list' }: { episode: Episode; variant?: 'grid' | 'list' | 'dialog' }) {
|
||||||
type EpisodeWithEntry = Episode & {
|
type EpisodeWithEntry = Episode & {
|
||||||
entry?: { id: number; title?: string; poster_path?: string | null };
|
entry?: { id: number; title?: string; poster_path?: string | null };
|
||||||
};
|
};
|
||||||
@@ -129,6 +208,10 @@ function EpisodeCalendarItem({ episode }: { episode: Episode }) {
|
|||||||
const entry = ep.entry;
|
const entry = ep.entry;
|
||||||
const entryId = entry?.id;
|
const entryId = entry?.id;
|
||||||
const entryTitle = entry?.title ?? '';
|
const entryTitle = entry?.title ?? '';
|
||||||
|
|
||||||
|
// Hide episodes with no known entry title
|
||||||
|
if (!entryTitle) return null;
|
||||||
|
|
||||||
const seasonId = episode.season_id;
|
const seasonId = episode.season_id;
|
||||||
const seasonNumber = episode.season?.season_number ?? null;
|
const seasonNumber = episode.season?.season_number ?? null;
|
||||||
|
|
||||||
@@ -137,28 +220,115 @@ function EpisodeCalendarItem({ episode }: { episode: Episode }) {
|
|||||||
: '';
|
: '';
|
||||||
const episodeLabel = `E${String(episode.episode_number).padStart(2, '0')}`;
|
const episodeLabel = `E${String(episode.episode_number).padStart(2, '0')}`;
|
||||||
|
|
||||||
const thumbSrc = episode.still_path
|
const thumbSrc = entry?.poster_path
|
||||||
? getTmdbPosterUrl(episode.still_path, 'w92')
|
|
||||||
: entry?.poster_path
|
|
||||||
? getTmdbPosterUrl(entry.poster_path, 'w92')
|
? getTmdbPosterUrl(entry.poster_path, 'w92')
|
||||||
: undefined;
|
: undefined;
|
||||||
|
|
||||||
|
const isMovie = entry && !(entry as any).is_tvseries;
|
||||||
|
|
||||||
|
if (variant === 'grid') {
|
||||||
|
const gridContent = (
|
||||||
|
<div className="w-14 shrink-0 rounded overflow-hidden bg-primary/10 hover:bg-primary/20 transition-colors cursor-pointer">
|
||||||
|
{thumbSrc ? (
|
||||||
|
<img
|
||||||
|
src={thumbSrc}
|
||||||
|
alt={entryTitle}
|
||||||
|
className="w-full aspect-2/3 object-cover"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="w-full aspect-2/3 bg-muted/40 flex items-center justify-center">
|
||||||
|
<span className="text-[7px] text-muted-foreground text-center px-0.5 leading-tight">{entryTitle}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<p className="text-[7px] text-center text-muted-foreground tabular-nums py-0.5 leading-tight truncate px-0.5">
|
||||||
|
{isMovie ? entryTitle : `${seasonLabel}${episodeLabel}`}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger asChild>
|
||||||
|
{entryId ? (
|
||||||
|
<Link to={`/entry/${entryId}/season/${seasonId}/episode/${episode.id}`} className="block">
|
||||||
|
{gridContent}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<div>{gridContent}</div>
|
||||||
|
)}
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent side="right" className="max-w-50">
|
||||||
|
<div className="space-y-0.5">
|
||||||
|
<p className="text-xs font-semibold">{entryTitle}</p>
|
||||||
|
{episode.name && (
|
||||||
|
<p className="text-xs text-muted-foreground">{episode.name}</p>
|
||||||
|
)}
|
||||||
|
{!isMovie && (
|
||||||
|
<p className="text-xs text-muted-foreground tabular-nums">
|
||||||
|
{seasonLabel} {episodeLabel}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (variant === 'dialog') {
|
||||||
|
const dialogContent = (
|
||||||
|
<div className="rounded-lg overflow-hidden bg-primary/10 hover:bg-primary/20 transition-colors cursor-pointer">
|
||||||
|
{thumbSrc ? (
|
||||||
|
<img
|
||||||
|
src={thumbSrc}
|
||||||
|
alt={entryTitle}
|
||||||
|
className="w-full aspect-2/3 object-cover"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<div className="w-full aspect-2/3 bg-muted/40 flex items-center justify-center p-2">
|
||||||
|
<span className="text-xs text-muted-foreground text-center leading-tight">{entryTitle}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
<div className="p-1.5">
|
||||||
|
<p className="text-xs font-medium leading-tight truncate">{entryTitle}</p>
|
||||||
|
{!isMovie && (
|
||||||
|
<p className="text-[10px] text-muted-foreground tabular-nums leading-tight mt-0.5">
|
||||||
|
{seasonLabel}{episodeLabel}
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
{episode.name && (
|
||||||
|
<p className="text-[10px] text-muted-foreground leading-tight truncate mt-0.5">{episode.name}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
return entryId ? (
|
||||||
|
<Link to={`/entry/${entryId}/season/${seasonId}/episode/${episode.id}`} className="block">
|
||||||
|
{dialogContent}
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<div>{dialogContent}</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const content = (
|
const content = (
|
||||||
<div className="flex items-stretch gap-1 rounded bg-primary/10 hover:bg-primary/20 px-1 py-0.5 transition-colors cursor-pointer overflow-hidden">
|
<div className="flex items-stretch gap-2 rounded bg-primary/10 hover:bg-primary/20 px-1.5 py-1 transition-colors cursor-pointer overflow-hidden">
|
||||||
{thumbSrc && (
|
{thumbSrc && (
|
||||||
<img
|
<img
|
||||||
src={thumbSrc}
|
src={thumbSrc}
|
||||||
alt=""
|
alt=""
|
||||||
className="h-8 w-5 rounded-sm object-cover shrink-0"
|
className="h-14 w-9 rounded-sm object-cover shrink-0"
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className="min-w-0 flex flex-col justify-center">
|
<div className="min-w-0 flex flex-col justify-center">
|
||||||
<p className="text-[10px] font-medium truncate leading-tight">
|
<p className="text-xs font-medium truncate leading-tight">
|
||||||
{entryTitle || 'Unknown'}
|
{entryTitle}
|
||||||
</p>
|
</p>
|
||||||
<p className="text-[9px] text-muted-foreground tabular-nums leading-tight">
|
{!isMovie && (
|
||||||
|
<p className="text-[10px] text-muted-foreground tabular-nums leading-tight mt-0.5">
|
||||||
{seasonLabel} {episodeLabel}
|
{seasonLabel} {episodeLabel}
|
||||||
</p>
|
</p>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -191,3 +361,20 @@ function EpisodeCalendarItem({ episode }: { episode: Episode }) {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function DayDialog({ date, episodes, onClose }: { date: Date; episodes: Episode[]; onClose: () => void }) {
|
||||||
|
return (
|
||||||
|
<Dialog open onOpenChange={(open) => !open && onClose()}>
|
||||||
|
<DialogContent className="max-w-2xl">
|
||||||
|
<DialogHeader>
|
||||||
|
<DialogTitle>{format(date, 'EEEE, MMMM d')}</DialogTitle>
|
||||||
|
</DialogHeader>
|
||||||
|
<div className="grid grid-cols-2 sm:grid-cols-3 gap-3 max-h-[70vh] overflow-y-auto pr-1">
|
||||||
|
{episodes.map((ep) => (
|
||||||
|
<EpisodeCalendarItem key={ep.id} episode={ep} variant="dialog" />
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
</DialogContent>
|
||||||
|
</Dialog>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -4,6 +4,7 @@ import { useEntry, useEntryCredits } from '@/hooks/useEntries';
|
|||||||
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
|
||||||
import { Skeleton } from '@/components/ui/skeleton';
|
import { Skeleton } from '@/components/ui/skeleton';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
|
import { Input } from '@/components/ui/input';
|
||||||
import {
|
import {
|
||||||
Select,
|
Select,
|
||||||
SelectContent,
|
SelectContent,
|
||||||
@@ -72,24 +73,34 @@ export function EntryCastsPage() {
|
|||||||
const { data: entry, isLoading } = useEntry(entryId);
|
const { data: entry, isLoading } = useEntry(entryId);
|
||||||
const { data: allCredits = [], isLoading: creditsLoading } = useEntryCredits(entryId);
|
const { data: allCredits = [], isLoading: creditsLoading } = useEntryCredits(entryId);
|
||||||
|
|
||||||
const [sortField, setSortField] = useState<SortField>('order');
|
const [sortField, setSortField] = useState<SortField>('episode_count');
|
||||||
const [sortDir, setSortDir] = useState<SortDir>('asc');
|
const [sortDir, setSortDir] = useState<SortDir>('asc');
|
||||||
const [filter, setFilter] = useState<CastFilter>('all');
|
const [filter, setFilter] = useState<CastFilter>('cast');
|
||||||
|
const [search, setSearch] = useState('');
|
||||||
const [visibleCount, setVisibleCount] = useState(PAGE_SIZE);
|
const [visibleCount, setVisibleCount] = useState(PAGE_SIZE);
|
||||||
|
|
||||||
const filtered = useMemo(() => {
|
const filtered = useMemo(() => {
|
||||||
if (!allCredits) return [];
|
if (!allCredits) return [];
|
||||||
if (filter === 'cast') return allCredits.filter((c) => c.cast_type === 'cast');
|
let result = allCredits;
|
||||||
if (filter === 'crew') return allCredits.filter((c) => c.cast_type === 'crew');
|
if (filter === 'cast') result = result.filter((c) => c.cast_type === 'cast');
|
||||||
return allCredits;
|
else if (filter === 'crew') result = result.filter((c) => c.cast_type === 'crew');
|
||||||
}, [allCredits, filter]);
|
if (search.trim()) {
|
||||||
|
const q = search.trim().toLowerCase();
|
||||||
|
result = result.filter((c) => {
|
||||||
|
const name = c.people?.name?.toLowerCase() ?? '';
|
||||||
|
const role = (c.cast_type === 'cast' ? c.character : (c.job || c.department))?.toLowerCase() ?? '';
|
||||||
|
return name.includes(q) || role.includes(q);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}, [allCredits, filter, search]);
|
||||||
|
|
||||||
const sorted = useMemo(() => sortCredits(filtered, sortField, sortDir), [filtered, sortField, sortDir]);
|
const sorted = useMemo(() => sortCredits(filtered, sortField, sortDir), [filtered, sortField, sortDir]);
|
||||||
|
|
||||||
// Reset visible window whenever filter/sort changes
|
// Reset visible window whenever filter/sort/search changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setVisibleCount(PAGE_SIZE);
|
setVisibleCount(PAGE_SIZE);
|
||||||
}, [filter, sortField, sortDir]);
|
}, [filter, sortField, sortDir, search]);
|
||||||
|
|
||||||
const visible = useMemo(() => sorted.slice(0, visibleCount), [sorted, visibleCount]);
|
const visible = useMemo(() => sorted.slice(0, visibleCount), [sorted, visibleCount]);
|
||||||
const hasMore = visibleCount < sorted.length;
|
const hasMore = visibleCount < sorted.length;
|
||||||
@@ -116,10 +127,10 @@ export function EntryCastsPage() {
|
|||||||
return (
|
return (
|
||||||
<div className="space-y-6 mx-auto max-w-4xl">
|
<div className="space-y-6 mx-auto max-w-4xl">
|
||||||
<Skeleton className="h-5 w-64" />
|
<Skeleton className="h-5 w-64" />
|
||||||
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6">
|
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5">
|
||||||
{Array.from({ length: 18 }).map((_, i) => (
|
{Array.from({ length: 18 }).map((_, i) => (
|
||||||
<div key={i} className="flex flex-col items-center gap-2">
|
<div key={i} className="flex flex-col items-center gap-2">
|
||||||
<Skeleton className="h-24 w-24 rounded-full" />
|
<Skeleton className="h-32 w-32 rounded-full" />
|
||||||
<Skeleton className="h-4 w-20" />
|
<Skeleton className="h-4 w-20" />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -146,6 +157,19 @@ export function EntryCastsPage() {
|
|||||||
|
|
||||||
{/* Controls */}
|
{/* Controls */}
|
||||||
<div className="flex flex-wrap items-center gap-3">
|
<div className="flex flex-wrap items-center gap-3">
|
||||||
|
{/* Left: search + count */}
|
||||||
|
<Input
|
||||||
|
placeholder="Search people…"
|
||||||
|
value={search}
|
||||||
|
onChange={(e) => setSearch(e.target.value)}
|
||||||
|
className="w-48"
|
||||||
|
/>
|
||||||
|
<span className="text-sm text-muted-foreground whitespace-nowrap">
|
||||||
|
{sorted.length} {sorted.length === 1 ? 'credit' : 'credits'}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{/* Right: filter + sort */}
|
||||||
|
<div className="flex items-center gap-3 ml-auto">
|
||||||
<Select value={filter} onValueChange={(v) => setFilter(v as CastFilter)}>
|
<Select value={filter} onValueChange={(v) => setFilter(v as CastFilter)}>
|
||||||
<SelectTrigger className="w-32">
|
<SelectTrigger className="w-32">
|
||||||
<SelectValue>{FILTER_LABELS[filter]}</SelectValue>
|
<SelectValue>{FILTER_LABELS[filter]}</SelectValue>
|
||||||
@@ -179,10 +203,7 @@ export function EntryCastsPage() {
|
|||||||
>
|
>
|
||||||
<ArrowUpDown className="h-4 w-4" />
|
<ArrowUpDown className="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
|
</div>
|
||||||
<span className="text-sm text-muted-foreground ml-auto">
|
|
||||||
{sorted.length} {sorted.length === 1 ? 'credit' : 'credits'}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Grid */}
|
{/* Grid */}
|
||||||
@@ -190,17 +211,17 @@ export function EntryCastsPage() {
|
|||||||
<p className="text-center text-muted-foreground py-12">No credits found.</p>
|
<p className="text-center text-muted-foreground py-12">No credits found.</p>
|
||||||
) : (
|
) : (
|
||||||
<>
|
<>
|
||||||
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6">
|
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5">
|
||||||
{visible.map((credit) => (
|
{visible.map((credit) => (
|
||||||
<CreditCard key={credit.id} credit={credit} isTv={isTv} />
|
<CreditCard key={credit.id} credit={credit} isTv={isTv} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
{hasMore && (
|
{hasMore && (
|
||||||
<div ref={sentinelRef} className="flex justify-center py-6">
|
<div ref={sentinelRef} className="flex justify-center py-6">
|
||||||
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 w-full">
|
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 w-full">
|
||||||
{Array.from({ length: Math.min(PAGE_SIZE, sorted.length - visibleCount) }).map((_, i) => (
|
{Array.from({ length: Math.min(PAGE_SIZE, sorted.length - visibleCount) }).map((_, i) => (
|
||||||
<div key={i} className="flex flex-col items-center gap-2 p-2">
|
<div key={i} className="flex flex-col items-center gap-2 p-2">
|
||||||
<Skeleton className="h-20 w-20 rounded-full" />
|
<Skeleton className="h-32 w-32 rounded-full" />
|
||||||
<Skeleton className="h-3 w-16" />
|
<Skeleton className="h-3 w-16" />
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
@@ -230,11 +251,11 @@ function CreditCard({ credit, isTv }: { credit: Credit; isTv: boolean }) {
|
|||||||
return (
|
return (
|
||||||
<Link
|
<Link
|
||||||
to={personLink}
|
to={personLink}
|
||||||
className="group flex flex-col items-center gap-2 text-center p-2 rounded-lg hover:bg-accent/50 transition-colors"
|
className="group flex flex-col items-center gap-3 text-center p-3 rounded-lg hover:bg-accent/50 transition-colors"
|
||||||
>
|
>
|
||||||
<Avatar className="h-20 w-20 transition-transform group-hover:scale-105">
|
<Avatar className="h-32 w-32 transition-transform group-hover:scale-105">
|
||||||
<AvatarImage src={profileUrl} alt={credit.people?.name} />
|
<AvatarImage src={profileUrl} alt={credit.people?.name} />
|
||||||
<AvatarFallback className="text-xs">
|
<AvatarFallback className="text-sm">
|
||||||
{credit.people?.name
|
{credit.people?.name
|
||||||
?.split(' ')
|
?.split(' ')
|
||||||
.map((n) => n[0])
|
.map((n) => n[0])
|
||||||
@@ -242,14 +263,14 @@ function CreditCard({ credit, isTv }: { credit: Credit; isTv: boolean }) {
|
|||||||
</AvatarFallback>
|
</AvatarFallback>
|
||||||
</Avatar>
|
</Avatar>
|
||||||
<div className="min-w-0 w-full">
|
<div className="min-w-0 w-full">
|
||||||
<p className="text-xs font-medium leading-tight line-clamp-2">{credit.people?.name}</p>
|
<p className="text-sm font-medium leading-tight line-clamp-2">{credit.people?.name}</p>
|
||||||
{roleLabel && (
|
{roleLabel && (
|
||||||
<p className="text-[10px] text-muted-foreground leading-tight line-clamp-1 mt-0.5">
|
<p className="text-xs text-muted-foreground leading-tight line-clamp-1 mt-0.5">
|
||||||
{roleLabel}
|
{roleLabel}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
{isTv && credit.episode_count != null && credit.episode_count > 0 && (
|
{isTv && credit.episode_count != null && credit.episode_count > 0 && (
|
||||||
<p className="text-[10px] text-muted-foreground/70 leading-tight mt-0.5">
|
<p className="text-xs text-muted-foreground/70 leading-tight mt-0.5">
|
||||||
{credit.episode_count} {credit.episode_count === 1 ? 'episode' : 'episodes'}
|
{credit.episode_count} {credit.episode_count === 1 ? 'episode' : 'episodes'}
|
||||||
</p>
|
</p>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -190,11 +190,6 @@ export function EntryDetailsPage() {
|
|||||||
{/* LEFT: Sticky poster */}
|
{/* LEFT: Sticky poster */}
|
||||||
<div className="sm:sticky sm:top-20 w-32 sm:w-44 shrink-0 self-start mx-auto sm:mx-0">
|
<div className="sm:sticky sm:top-20 w-32 sm:w-44 shrink-0 self-start mx-auto sm:mx-0">
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
{e.favorit && (
|
|
||||||
<div className="absolute top-2 left-2 z-10 rounded-full bg-background/80 p-1 backdrop-blur-sm">
|
|
||||||
<Heart className="h-4 w-4 fill-red-500 text-red-500" />
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
<img
|
<img
|
||||||
src={poster}
|
src={poster}
|
||||||
alt={e.title}
|
alt={e.title}
|
||||||
@@ -364,6 +359,28 @@ export function EntryDetailsPage() {
|
|||||||
Rate
|
Rate
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
{/* Favorite pill */}
|
||||||
|
<TooltipProvider>
|
||||||
|
<Tooltip>
|
||||||
|
<TooltipTrigger asChild>
|
||||||
|
<button
|
||||||
|
onClick={toggleFavorite}
|
||||||
|
disabled={updateEntry.isPending}
|
||||||
|
className={`inline-flex items-center gap-1 rounded-full border px-3 py-1 text-sm font-medium transition-colors ${
|
||||||
|
e.favorit
|
||||||
|
? 'bg-yellow-500/15 border-yellow-500/30 text-yellow-600 dark:text-yellow-400 hover:bg-yellow-500/25'
|
||||||
|
: 'border-dashed border-border text-muted-foreground hover:border-yellow-500/40 hover:text-yellow-500'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<Star className={`h-3.5 w-3.5 ${e.favorit ? 'fill-yellow-400 text-yellow-400' : ''}`} />
|
||||||
|
Favorit
|
||||||
|
</button>
|
||||||
|
</TooltipTrigger>
|
||||||
|
<TooltipContent>
|
||||||
|
<p>{e.favorit ? 'Remove from favorites' : 'Add to favorites'}</p>
|
||||||
|
</TooltipContent>
|
||||||
|
</Tooltip>
|
||||||
|
</TooltipProvider>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Storyline */}
|
{/* Storyline */}
|
||||||
|
|||||||
@@ -93,8 +93,8 @@ export function PeoplePage() {
|
|||||||
<h1 className="text-2xl font-bold">People</h1>
|
<h1 className="text-2xl font-bold">People</h1>
|
||||||
|
|
||||||
{/* Controls row */}
|
{/* Controls row */}
|
||||||
<div className="flex flex-wrap items-center gap-3">
|
<div className="flex flex-col gap-3 sm:flex-row sm:flex-wrap sm:items-center">
|
||||||
<div className="relative flex-1 max-w-xs">
|
<div className="relative w-full sm:flex-1 sm:max-w-xs">
|
||||||
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
|
||||||
<Input
|
<Input
|
||||||
placeholder="Search people..."
|
placeholder="Search people..."
|
||||||
@@ -104,6 +104,7 @@ export function PeoplePage() {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="flex items-center gap-3 sm:contents">
|
||||||
{/* Local DB toggle */}
|
{/* Local DB toggle */}
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
<Switch
|
<Switch
|
||||||
@@ -117,7 +118,7 @@ export function PeoplePage() {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Filter tabs: All / Favorite — always visible, disabled when not local */}
|
{/* Filter tabs: All / Favorite — always visible, disabled when not local */}
|
||||||
<div className="ml-auto">
|
<div className="sm:ml-auto">
|
||||||
<Tabs
|
<Tabs
|
||||||
value={filter}
|
value={filter}
|
||||||
onValueChange={(v) => setFilter(v as PeopleFilter)}
|
onValueChange={(v) => setFilter(v as PeopleFilter)}
|
||||||
@@ -134,6 +135,7 @@ export function PeoplePage() {
|
|||||||
</Tabs>
|
</Tabs>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<div className="grid grid-cols-3 gap-4 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-8">
|
<div className="grid grid-cols-3 gap-4 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-8">
|
||||||
|
|||||||
Reference in new issue
Block a user