feat(react): add toasts, loading states, skeletons, animations, and mobile responsiveness

- Toast notifications (sonner): success/error toasts on all mutations
- Loading spinners: EntryCard add/remove, ConfirmDialog, EntrySeenDialog, favorite/refresh buttons
- Page skeletons: 13 page-specific Suspense fallbacks replacing generic skeleton
- CSS animations: card-enter (staggered), page-enter, slide-up-fade keyframes
- Mobile layout: hamburger menu with sheet sidebar, responsive entry details
- Mobile controls: separate compact filter/sort popovers for Library and Watchlist
- Desktop sort: popover menu replacing Select dropdown on Library and Watchlist
- Filter ranges: year 1950-2100, rating 0-10
This commit is contained in:
Mohammed Abad committed 2026-04-02 03:00:49 +01:00
1 parent ae67663623
commit d60d142d17
29 files changed
+1008 -226

No files matched your search

@@ -63,8 +63,14 @@ export function CollectionsGrid({
return (
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6">
{collections.map((collection) => (
<CollectionCard key={collection.id} collection={collection} />
{collections.map((collection, index) => (
<div
key={collection.id}
className="animate-card-enter"
style={{ animationDelay: `${Math.min(index * 30, 300)}ms` }}
>
<CollectionCard collection={collection} />
</div>
))}
</div>
);
@@ -7,6 +7,7 @@ import {
DialogTitle,
} from '@/components/ui/dialog';
import { Button } from '@/components/ui/button';
import { Loader2 } from 'lucide-react';
interface ConfirmDialogProps {
open: boolean;
@@ -17,6 +18,7 @@ interface ConfirmDialogProps {
cancelLabel?: string;
onConfirm: () => void;
variant?: 'default' | 'destructive';
isLoading?: boolean;
}
export function ConfirmDialog({
@@ -28,6 +30,7 @@ export function ConfirmDialog({
cancelLabel = 'Cancel',
onConfirm,
variant = 'default',
isLoading = false,
}: ConfirmDialogProps) {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
@@ -37,13 +40,15 @@ export function ConfirmDialog({
<DialogDescription>{description}</DialogDescription>
</DialogHeader>
<DialogFooter>
<Button variant="outline" onClick={() => onOpenChange(false)}>
<Button variant="outline" onClick={() => onOpenChange(false)} disabled={isLoading}>
{cancelLabel}
</Button>
<Button
variant={variant === 'destructive' ? 'destructive' : 'default'}
onClick={onConfirm}
disabled={isLoading}
>
{isLoading && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
{confirmLabel}
</Button>
</DialogFooter>
@@ -3,7 +3,7 @@ import { useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { z } from 'zod';
import { format } from 'date-fns';
import { CalendarIcon } from 'lucide-react';
import { CalendarIcon, Loader2 } from 'lucide-react';
import {
Dialog,
DialogContent,
@@ -239,10 +239,17 @@ export function EntrySeenDialog({
type="button"
variant="outline"
onClick={() => onOpenChange(false)}
disabled={createEntrySeen.isPending || updateEntrySeen.isPending || createEpisodeSeen.isPending}
>
Cancel
</Button>
<Button type="submit">
<Button
type="submit"
disabled={createEntrySeen.isPending || updateEntrySeen.isPending || createEpisodeSeen.isPending}
>
{(createEntrySeen.isPending || updateEntrySeen.isPending || createEpisodeSeen.isPending) && (
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
)}
{mode === 'edit' ? 'Save Changes' : 'Mark as Watched'}
</Button>
</DialogFooter>
@@ -1,6 +1,6 @@
import { useState } from 'react';
import { Link } from 'react-router-dom';
import { Plus, Trash2, Star } from 'lucide-react';
import { Plus, Trash2, Star, Loader2 } from 'lucide-react';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Skeleton } from '@/components/ui/skeleton';
@@ -76,13 +76,14 @@ export function EntryCard({ entry, tmdbEntry }: EntryCardProps) {
const confirmRemove = () => {
if (libraryEntry) {
deleteEntry.mutate(libraryEntry.id);
deleteEntry.mutate(libraryEntry.id, {
onSettled: () => setShowConfirm(false),
});
}
setShowConfirm(false);
};
const card = (
<div className="group relative overflow-hidden rounded-lg transition-all duration-200 hover:scale-[1.02] hover:shadow-xl">
<div className="group relative overflow-hidden rounded-lg transition-all duration-300 hover:scale-[1.02] hover:shadow-xl animate-in fade-in zoom-in-95">
{/* Poster */}
<div className="relative aspect-[2/3] w-full overflow-hidden rounded-lg bg-muted">
<img
@@ -129,9 +130,14 @@ export function EntryCard({ entry, tmdbEntry }: EntryCardProps) {
variant="destructive"
className="h-7 w-full text-xs"
onClick={handleRemove}
disabled={deleteEntry.isPending}
>
<Trash2 className="mr-1 h-3 w-3" />
Remove
{deleteEntry.isPending ? (
<Loader2 className="mr-1 h-3 w-3 animate-spin" />
) : (
<Trash2 className="mr-1 h-3 w-3" />
)}
{deleteEntry.isPending ? 'Removing...' : 'Remove'}
</Button>
) : tmdbEntry ? (
<Button
@@ -140,7 +146,11 @@ export function EntryCard({ entry, tmdbEntry }: EntryCardProps) {
onClick={handleAdd}
disabled={createEntry.isPending}
>
<Plus className="mr-1 h-3 w-3" />
{createEntry.isPending ? (
<Loader2 className="mr-1 h-3 w-3 animate-spin" />
) : (
<Plus className="mr-1 h-3 w-3" />
)}
{createEntry.isPending ? 'Adding...' : 'Add to Library'}
</Button>
) : null}
@@ -59,6 +59,8 @@ export function EntryLibraryGrid({
<div
key={entry.id}
ref={index === entries.length - 1 ? lastEntryRef : undefined}
className="animate-card-enter"
style={{ animationDelay: `${Math.min(index * 30, 300)}ms` }}
>
<EntryCard entry={entry} />
</div>
@@ -61,8 +61,14 @@ export function TrendingGrid({
</div>
) : (
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 2xl:grid-cols-7">
{displayEntries.map((tmdbEntry) => (
<EntryCard key={tmdbEntry.id} tmdbEntry={tmdbEntry} />
{displayEntries.map((tmdbEntry, index) => (
<div
key={tmdbEntry.id}
className="animate-card-enter"
style={{ animationDelay: `${Math.min(index * 30, 300)}ms` }}
>
<EntryCard tmdbEntry={tmdbEntry} />
</div>
))}
</div>
)}
@@ -1,12 +1,45 @@
import { Outlet } from 'react-router-dom';
import { Sidebar } from './Sidebar';
import { useState } from 'react';
import { Menu } from 'lucide-react';
import { Button } from '@/components/ui/button';
import {
Sheet,
SheetContent,
SheetHeader,
SheetTitle,
} from '@/components/ui/sheet';
import { Sidebar, MobileSidebarContent } from './Sidebar';
export function AppLayout() {
const [mobileOpen, setMobileOpen] = useState(false);
return (
<div className="flex min-h-screen">
<Sidebar />
<main className="ml-56 flex-1 overflow-y-auto">
<div className="container mx-auto px-6 py-6">
{/* Desktop sidebar */}
<div className="hidden md:block">
<Sidebar />
</div>
{/* Mobile header */}
<div className="fixed inset-x-0 top-0 z-40 flex h-14 items-center gap-3 border-b border-border bg-background px-4 md:hidden">
<Button variant="ghost" size="icon" onClick={() => setMobileOpen(true)}>
<Menu className="h-5 w-5" />
</Button>
<span className="text-lg font-bold">Showy</span>
</div>
{/* Mobile sidebar sheet */}
<Sheet open={mobileOpen} onOpenChange={setMobileOpen}>
<SheetContent side="left" className="w-64 p-0" showCloseButton={false}>
<SheetHeader className="sr-only">
<SheetTitle>Navigation</SheetTitle>
</SheetHeader>
<MobileSidebarContent onNavigate={() => setMobileOpen(false)} />
</SheetContent>
</Sheet>
<main className="flex-1 overflow-y-auto md:ml-56">
<div className="container mx-auto px-4 py-4 pt-18 md:px-6 md:py-6 md:pt-6">
<Outlet />
</div>
</main>
@@ -75,7 +75,7 @@ export function Sidebar() {
const { theme, toggleTheme } = useThemeStore();
return (
<aside className="fixed inset-y-0 left-0 z-50 flex w-56 flex-col border-r border-sidebar-border bg-sidebar">
<aside className="fixed inset-y-0 left-0 z-50 hidden md:flex w-56 flex-col border-r border-sidebar-border bg-sidebar">
{/* Logo */}
<div className="flex h-14 items-center gap-2 px-4">
<Film className="h-6 w-6 text-sidebar-primary" />
@@ -134,3 +134,95 @@ export function Sidebar() {
</aside>
);
}
function MobileNavItem({
to,
icon: Icon,
label,
onClick,
}: {
to: string;
icon: React.ComponentType<{ className?: string }>;
label: string;
onClick?: () => void;
}) {
return (
<NavLink
to={to}
end={to === '/'}
onClick={onClick}
className={({ isActive }) =>
`flex items-center gap-3 rounded-lg px-3 py-2.5 text-sm transition-colors ${
isActive
? 'bg-sidebar-accent text-sidebar-primary font-medium'
: 'text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground'
}`
}
>
<Icon className="h-4 w-4 shrink-0" />
<span>{label}</span>
</NavLink>
);
}
export function MobileSidebarContent({ onNavigate }: { onNavigate: () => void }) {
const { theme, toggleTheme } = useThemeStore();
return (
<div className="flex h-full flex-col bg-sidebar">
{/* Logo */}
<div className="flex h-14 items-center gap-2 px-4">
<Film className="h-6 w-6 text-sidebar-primary" />
<span className="text-lg font-bold text-sidebar-foreground">Showy</span>
</div>
<Separator className="bg-sidebar-border" />
{/* Nav */}
<nav className="flex-1 space-y-1 overflow-y-auto px-3 py-4">
<p className="mb-2 px-3 text-xs font-semibold uppercase tracking-wider text-sidebar-foreground/50">
Main
</p>
{mainNav.map((item) => (
<MobileNavItem key={item.to} {...item} onClick={onNavigate} />
))}
<Separator className="my-3 bg-sidebar-border" />
<p className="mb-2 px-3 text-xs font-semibold uppercase tracking-wider text-sidebar-foreground/50">
Library
</p>
{libraryNav.map((item) => (
<MobileNavItem key={item.to} {...item} onClick={onNavigate} />
))}
<Separator className="my-3 bg-sidebar-border" />
<p className="mb-2 px-3 text-xs font-semibold uppercase tracking-wider text-sidebar-foreground/50">
Other
</p>
{otherNav.map((item) => (
<MobileNavItem key={item.to} {...item} onClick={onNavigate} />
))}
</nav>
{/* Bottom actions */}
<div className="border-t border-sidebar-border px-3 py-3 space-y-1">
<Button
variant="ghost"
size="sm"
className="w-full justify-start gap-3 text-sidebar-foreground/70 hover:bg-sidebar-accent/50 hover:text-sidebar-foreground"
onClick={toggleTheme}
>
{theme === 'dark' ? (
<Sun className="h-4 w-4" />
) : (
<Moon className="h-4 w-4" />
)}
<span>{theme === 'dark' ? 'Light Mode' : 'Dark Mode'}</span>
</Button>
<MobileNavItem to="/settings" icon={Settings} label="Settings" onClick={onNavigate} />
</div>
</div>
);
}
@@ -0,0 +1,313 @@
import { Skeleton } from '@/components/ui/skeleton';
import { Card, CardContent, CardHeader } from '@/components/ui/card';
export function DashboardSkeleton() {
return (
<div className="space-y-8 animate-in fade-in duration-300">
<Skeleton className="h-8 w-48" />
{/* Stats cards */}
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5">
{Array.from({ length: 5 }).map((_, i) => (
<Card key={i}>
<CardHeader className="flex flex-row items-center justify-between pb-2">
<Skeleton className="h-4 w-20" />
<Skeleton className="h-5 w-5 rounded" />
</CardHeader>
<CardContent>
<Skeleton className="h-8 w-16" />
</CardContent>
</Card>
))}
</div>
{/* Chart skeletons */}
<Skeleton className="h-80 w-full rounded-xl" />
<Skeleton className="h-64 w-full rounded-xl" />
<div className="grid gap-4 lg:grid-cols-2">
<Skeleton className="h-64 rounded-xl" />
<Skeleton className="h-64 rounded-xl" />
</div>
{/* Recently Watched */}
<div className="space-y-4">
<Skeleton className="h-6 w-40" />
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 2xl:grid-cols-7">
{Array.from({ length: 7 }).map((_, i) => (
<div key={i} className="space-y-2">
<Skeleton className="aspect-[2/3] w-full rounded-lg" />
<Skeleton className="h-3 w-3/4" />
</div>
))}
</div>
</div>
</div>
);
}
export function HomeSkeleton() {
return (
<div className="space-y-8 animate-in fade-in duration-300">
{/* Search */}
<Skeleton className="h-10 max-w-md rounded-lg" />
{/* Trending section */}
{[1, 2].map((section) => (
<div key={section} className="space-y-4">
<div className="flex items-center justify-between">
<Skeleton className="h-6 w-32" />
<div className="flex items-center gap-3">
<Skeleton className="h-8 w-40 rounded-lg" />
<Skeleton className="h-8 w-16" />
</div>
</div>
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 2xl:grid-cols-7">
{Array.from({ length: 14 }).map((_, i) => (
<Skeleton key={i} className="aspect-[2/3] w-full rounded-lg" />
))}
</div>
</div>
))}
</div>
);
}
export function LibrarySkeleton() {
return (
<div className="space-y-6 animate-in fade-in duration-300">
<Skeleton className="h-8 w-32" />
{/* Controls */}
<div className="flex flex-wrap items-center gap-3">
<Skeleton className="h-10 w-64 rounded-lg" />
<div className="flex-1" />
<Skeleton className="h-9 w-44" />
<Skeleton className="h-9 w-24" />
<Skeleton className="h-9 w-64 rounded-lg" />
</div>
{/* Grid */}
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 2xl:grid-cols-7">
{Array.from({ length: 21 }).map((_, i) => (
<Skeleton key={i} className="aspect-[2/3] w-full rounded-lg" />
))}
</div>
</div>
);
}
export function WatchlistSkeleton() {
return (
<div className="space-y-6 animate-in fade-in duration-300">
<Skeleton className="h-8 w-36" />
<div className="flex flex-wrap items-center gap-3">
<Skeleton className="h-10 w-64 rounded-lg" />
<div className="flex-1" />
<Skeleton className="h-9 w-44" />
<Skeleton className="h-9 w-24" />
</div>
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 2xl:grid-cols-7">
{Array.from({ length: 14 }).map((_, i) => (
<Skeleton key={i} className="aspect-[2/3] w-full rounded-lg" />
))}
</div>
</div>
);
}
export function CollectionsSkeleton() {
return (
<div className="space-y-6 animate-in fade-in duration-300">
<Skeleton className="h-8 w-40" />
<div className="flex flex-wrap items-center gap-3">
<Skeleton className="h-9 w-56 rounded-lg" />
<Skeleton className="h-10 w-64 rounded-lg" />
</div>
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6">
{Array.from({ length: 12 }).map((_, i) => (
<Skeleton key={i} className="aspect-[2/3] w-full rounded-lg" />
))}
</div>
</div>
);
}
export function CollectionDetailsSkeleton() {
return (
<div className="space-y-6 animate-in fade-in duration-300">
<Skeleton className="h-48 w-full rounded-xl sm:h-64" />
<Skeleton className="h-8 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">
{Array.from({ length: 6 }).map((_, i) => (
<Skeleton key={i} className="aspect-[2/3] w-full rounded-lg" />
))}
</div>
</div>
);
}
export function EntryDetailsSkeleton() {
return (
<div className="animate-in fade-in duration-300">
<div className="h-52 -mx-6 -mt-6 bg-muted animate-pulse rounded-b-lg" />
<div className="max-w-4xl mx-auto flex gap-8 -mt-24">
<div className="w-44 shrink-0 space-y-3">
<Skeleton className="aspect-[2/3] w-full rounded-xl" />
<Skeleton className="h-9 w-full rounded-lg" />
<Skeleton className="h-9 w-full rounded-lg" />
<Skeleton className="h-9 w-full rounded-lg" />
</div>
<div className="flex-1 space-y-4 pt-24">
<Skeleton className="h-9 w-72" />
<Skeleton className="h-4 w-32" />
<div className="flex gap-2">
<Skeleton className="h-5 w-12" />
<Skeleton className="h-5 w-16" />
<Skeleton className="h-5 w-20" />
</div>
<div className="flex gap-2">
<Skeleton className="h-8 w-24 rounded-full" />
<Skeleton className="h-8 w-24 rounded-full" />
<Skeleton className="h-8 w-20 rounded-full" />
</div>
<Skeleton className="h-20 w-full" />
</div>
</div>
</div>
);
}
export function PeopleSkeleton() {
return (
<div className="space-y-6 animate-in fade-in duration-300">
<Skeleton className="h-8 w-28" />
<Skeleton className="h-10 max-w-xs rounded-lg" />
<div className="grid grid-cols-3 gap-4 sm:grid-cols-4 md:grid-cols-5 lg:grid-cols-6 xl:grid-cols-8">
{Array.from({ length: 24 }).map((_, i) => (
<div key={i} className="flex flex-col items-center gap-2">
<Skeleton className="h-24 w-24 rounded-full" />
<Skeleton className="h-4 w-20" />
</div>
))}
</div>
</div>
);
}
export function PersonDetailsSkeleton() {
return (
<div className="space-y-8 animate-in fade-in duration-300">
<div className="flex gap-6">
<Skeleton className="h-48 w-36 shrink-0 rounded-xl" />
<div className="flex-1 space-y-3">
<Skeleton className="h-8 w-48" />
<Skeleton className="h-4 w-32" />
<Skeleton className="h-4 w-24" />
<Skeleton className="h-16 w-full" />
</div>
</div>
<Skeleton className="h-6 w-32" />
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 xl:grid-cols-6 2xl:grid-cols-7">
{Array.from({ length: 7 }).map((_, i) => (
<Skeleton key={i} className="aspect-[2/3] w-full rounded-lg" />
))}
</div>
</div>
);
}
export function SeasonSkeleton() {
return (
<div className="space-y-8 animate-in fade-in duration-300">
<div className="flex gap-6">
<Skeleton className="h-56 w-36 shrink-0 rounded-lg" />
<div className="flex-1 space-y-3">
<Skeleton className="h-7 w-48" />
<Skeleton className="h-4 w-32" />
<Skeleton className="h-2 w-48 rounded-full" />
<Skeleton className="h-12 w-full" />
</div>
</div>
<Skeleton className="h-6 w-28" />
<div className="space-y-2">
{Array.from({ length: 8 }).map((_, i) => (
<div key={i} className="flex gap-4 rounded-lg border border-border p-3">
<Skeleton className="h-16 w-28 shrink-0 rounded" />
<div className="flex-1 space-y-2">
<Skeleton className="h-4 w-40" />
<Skeleton className="h-3 w-24" />
<Skeleton className="h-3 w-full" />
</div>
</div>
))}
</div>
</div>
);
}
export function EpisodeSkeleton() {
return (
<div className="space-y-6 animate-in fade-in duration-300">
<Skeleton className="aspect-video w-full max-w-2xl rounded-xl" />
<div className="space-y-3">
<Skeleton className="h-8 w-64" />
<Skeleton className="h-4 w-32" />
<Skeleton className="h-16 w-full max-w-prose" />
</div>
<Skeleton className="h-6 w-32" />
<div className="space-y-2">
{Array.from({ length: 3 }).map((_, i) => (
<Skeleton key={i} className="h-12 w-full rounded-lg" />
))}
</div>
</div>
);
}
export function MediaSkeleton() {
return (
<div className="space-y-6 animate-in fade-in duration-300">
<Skeleton className="h-8 w-24" />
<div className="grid grid-cols-2 gap-4 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5">
{Array.from({ length: 10 }).map((_, i) => (
<Skeleton key={i} className="aspect-[2/3] w-full rounded-lg" />
))}
</div>
</div>
);
}
export function CalendarSkeleton() {
return (
<div className="space-y-6 animate-in fade-in duration-300">
<Skeleton className="h-8 w-32" />
<Skeleton className="h-10 w-48" />
<div className="grid grid-cols-7 gap-2">
{Array.from({ length: 35 }).map((_, i) => (
<Skeleton key={i} className="h-24 rounded-lg" />
))}
</div>
</div>
);
}
export function SettingsSkeleton() {
return (
<div className="space-y-8 animate-in fade-in duration-300">
<Skeleton className="h-8 w-28" />
<div className="space-y-6 max-w-2xl">
{Array.from({ length: 4 }).map((_, i) => (
<div key={i} className="space-y-2">
<Skeleton className="h-5 w-32" />
<Skeleton className="h-10 w-full rounded-lg" />
</div>
))}
</div>
</div>
);
}
@@ -0,0 +1,29 @@
import { Toaster as Sonner, type ToasterProps } from "sonner"
import { useThemeStore } from "@/stores/useThemeStore"
function Toaster({ ...props }: ToasterProps) {
const theme = useThemeStore((s) => s.theme)
return (
<Sonner
theme={theme}
className="toaster group"
toastOptions={{
classNames: {
toast:
"group toast group-[.toaster]:bg-card group-[.toaster]:text-card-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg group-[.toaster]:rounded-xl",
description: "group-[.toast]:text-muted-foreground",
actionButton:
"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
cancelButton:
"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",
success: "group-[.toaster]:!bg-green-500/10 group-[.toaster]:!border-green-500/20 group-[.toaster]:!text-green-600 dark:group-[.toaster]:!text-green-400",
error: "group-[.toaster]:!bg-destructive/10 group-[.toaster]:!border-destructive/20 group-[.toaster]:!text-destructive",
},
}}
{...props}
/>
)
}
export { Toaster }