feat(home): implement new homepage design with full-bleed hero slider and component refactor
- Replace old HomePage layout with Apple TV+/Hulu-inspired design (HomePage3) - Extract all home UI into reusable components under src/components/home/: HeroSlider, BackdropCard, BackdropScrollCard, PopularBelt, NumberedListItem, MiniPosterCard, UpcomingCard, SectionHeader - Hero slider: true slide-track animation, embedded search bar, autoplay with dot indicators - Trending Now: rotating 2x2 backdrop grid with slide-out/slide-in stagger animation (7s interval) - Popular Right Now: infinite CSS marquee belt, pauses on hover - Top Rated: 16:9 featured backdrop + 4 poster cards, no labels - Coming Soon: compact horizontal scroll, date overlay, relative countdown on hover - Fix sidebar ml offset in AppLayout (md:ml-56 -> md:ml-20) to re-center all pages - Move Collections page filters to top-right, search input to left
This commit is contained in:
1 parent
070aea3c51
commit
8641e55362
13 files changed
+749
-1077
No files matched your search
@@ -0,0 +1,88 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Star } from 'lucide-react';
|
||||
import type { TmdbEntry } from '@/types';
|
||||
|
||||
interface BackdropCardProps {
|
||||
entry: TmdbEntry;
|
||||
showRating?: boolean;
|
||||
animClass?: string;
|
||||
animDelay?: number;
|
||||
}
|
||||
|
||||
export function BackdropCard({ entry, showRating, animClass, animDelay }: BackdropCardProps) {
|
||||
const title = entry.title || entry.name || 'Untitled';
|
||||
const backdrop = entry.backdrop_path
|
||||
? `https://image.tmdb.org/t/p/w780${entry.backdrop_path}`
|
||||
: null;
|
||||
const isTv = entry.media_type === 'tv' || !!entry.name;
|
||||
const linkTo = `/entry/tmdb/${isTv ? 'tv' : 'movie'}/${entry.id}`;
|
||||
|
||||
return (
|
||||
<Link
|
||||
to={linkTo}
|
||||
className={`group relative block overflow-hidden rounded-xl bg-muted ${animClass ?? 'animate-page-enter'}`}
|
||||
style={{ aspectRatio: '16/9', animationDelay: animDelay ? `${animDelay}ms` : undefined }}
|
||||
>
|
||||
{backdrop ? (
|
||||
<img
|
||||
src={backdrop}
|
||||
alt={title}
|
||||
className="absolute inset-0 h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"
|
||||
/>
|
||||
) : (
|
||||
<div className="absolute inset-0 bg-linear-to-br from-muted-foreground/20 to-muted" />
|
||||
)}
|
||||
<div className="absolute inset-0 bg-linear-to-t from-black/80 via-black/10 to-transparent" />
|
||||
<div className="absolute bottom-0 left-0 right-0 p-3">
|
||||
<p className="truncate text-sm font-semibold text-white">{title}</p>
|
||||
{showRating && entry.vote_average > 0 && (
|
||||
<span className="mt-0.5 flex items-center gap-1 text-xs text-yellow-400">
|
||||
<Star className="h-3 w-3 fill-current" />
|
||||
{entry.vote_average.toFixed(1)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
interface BackdropScrollCardProps {
|
||||
entry: TmdbEntry;
|
||||
}
|
||||
|
||||
export function BackdropScrollCard({ entry }: BackdropScrollCardProps) {
|
||||
const title = entry.title || entry.name || 'Untitled';
|
||||
const backdrop = entry.backdrop_path
|
||||
? `https://image.tmdb.org/t/p/w780${entry.backdrop_path}`
|
||||
: null;
|
||||
const isTv = entry.media_type === 'tv' || !!entry.name;
|
||||
const linkTo = `/entry/tmdb/${isTv ? 'tv' : 'movie'}/${entry.id}`;
|
||||
|
||||
return (
|
||||
<Link
|
||||
to={linkTo}
|
||||
className="group relative block shrink-0 overflow-hidden rounded-xl bg-muted"
|
||||
style={{ width: '260px', aspectRatio: '16/9' }}
|
||||
>
|
||||
{backdrop ? (
|
||||
<img
|
||||
src={backdrop}
|
||||
alt={title}
|
||||
className="absolute inset-0 h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"
|
||||
/>
|
||||
) : (
|
||||
<div className="absolute inset-0 bg-linear-to-br from-muted-foreground/20 to-muted" />
|
||||
)}
|
||||
<div className="absolute inset-0 bg-linear-to-t from-black/80 via-black/10 to-transparent" />
|
||||
<div className="absolute bottom-0 left-0 right-0 p-3">
|
||||
<p className="truncate text-sm font-semibold text-white">{title}</p>
|
||||
{entry.vote_average > 0 && (
|
||||
<span className="mt-0.5 flex items-center gap-1 text-xs text-yellow-400">
|
||||
<Star className="h-3 w-3 fill-current" />
|
||||
{entry.vote_average.toFixed(1)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
import { useState, useEffect, useRef } from 'react';
|
||||
import { Link, useNavigate } from 'react-router-dom';
|
||||
import { useCreateEntry } from '@/hooks/useEntries';
|
||||
import { useLibraryStore } from '@/stores/useLibraryStore';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Star, Plus, Play, Search, ChevronLeft, ChevronRight } from 'lucide-react';
|
||||
import type { TmdbEntry } from '@/types';
|
||||
|
||||
interface HeroSliderProps {
|
||||
entries: TmdbEntry[];
|
||||
}
|
||||
|
||||
export function HeroSlider({ entries }: HeroSliderProps) {
|
||||
const navigate = useNavigate();
|
||||
const [activeIndex, setActiveIndex] = useState(0);
|
||||
const [searchInput, setSearchInput] = useState('');
|
||||
const intervalRef = useRef<ReturnType<typeof setInterval> | null>(null);
|
||||
const createEntry = useCreateEntry();
|
||||
const libraryEntries = useLibraryStore((s) => s.entries);
|
||||
|
||||
const slides = entries.slice(0, 8);
|
||||
|
||||
const go = (idx: number) => {
|
||||
setActiveIndex((idx + slides.length) % slides.length);
|
||||
};
|
||||
|
||||
const startAutoplay = () => {
|
||||
if (intervalRef.current) clearInterval(intervalRef.current);
|
||||
if (slides.length === 0) return;
|
||||
intervalRef.current = setInterval(
|
||||
() => setActiveIndex((i) => (i + 1) % slides.length),
|
||||
6000,
|
||||
);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
startAutoplay();
|
||||
return () => {
|
||||
if (intervalRef.current) clearInterval(intervalRef.current);
|
||||
};
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [slides.length]);
|
||||
|
||||
const handleSearch = () => {
|
||||
const q = searchInput.trim();
|
||||
if (q) navigate(`/search?q=${encodeURIComponent(q)}`);
|
||||
};
|
||||
|
||||
if (slides.length === 0) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
className="relative w-full overflow-hidden"
|
||||
style={{ aspectRatio: '16/9', maxHeight: '70vh' }}
|
||||
>
|
||||
{/* Slide track */}
|
||||
<div
|
||||
className="flex h-full transition-transform duration-700 ease-in-out will-change-transform"
|
||||
style={{
|
||||
width: `${slides.length * 100}%`,
|
||||
transform: `translateX(calc(-${activeIndex} / ${slides.length} * 100%))`,
|
||||
}}
|
||||
>
|
||||
{slides.map((entry) => {
|
||||
const title = entry.title || entry.name || 'Untitled';
|
||||
const backdrop = entry.backdrop_path
|
||||
? `https://image.tmdb.org/t/p/original${entry.backdrop_path}`
|
||||
: null;
|
||||
const isTv = entry.media_type === 'tv' || !!entry.name;
|
||||
const matchedEntry = Array.from(libraryEntries.values()).find(
|
||||
(e) => e.entryIds?.tmdb_id === entry.id,
|
||||
);
|
||||
return (
|
||||
<div
|
||||
key={entry.id}
|
||||
className="relative h-full shrink-0"
|
||||
style={{ width: `${100 / slides.length}%` }}
|
||||
>
|
||||
{backdrop ? (
|
||||
<img
|
||||
src={backdrop}
|
||||
alt=""
|
||||
className="absolute inset-0 h-full w-full object-cover rounded-none"
|
||||
/>
|
||||
) : (
|
||||
<div className="absolute inset-0 bg-linear-to-br from-primary/20 to-muted" />
|
||||
)}
|
||||
<div className="absolute inset-0 bg-linear-to-t from-black/90 via-black/20 to-black/50" />
|
||||
|
||||
{/* Per-slide info */}
|
||||
<div className="absolute bottom-0 left-0 right-0 z-10 space-y-2 px-4 pb-5 md:px-6 md:pb-8">
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="rounded-full bg-white/10 px-2 py-0.5 text-[10px] font-bold uppercase tracking-widest text-white/60 backdrop-blur-sm">
|
||||
{isTv ? 'Series' : 'Movie'}
|
||||
</span>
|
||||
{entry.vote_average > 0 && (
|
||||
<span className="flex items-center gap-1 text-xs text-yellow-400">
|
||||
<Star className="h-3 w-3 fill-current" />
|
||||
{entry.vote_average.toFixed(1)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<h2 className="text-2xl font-black leading-tight text-white drop-shadow-lg md:text-4xl">
|
||||
{title}
|
||||
</h2>
|
||||
{entry.overview && (
|
||||
<p className="line-clamp-2 max-w-lg text-xs text-white/60 md:text-sm">
|
||||
{entry.overview}
|
||||
</p>
|
||||
)}
|
||||
<div className="flex gap-2 pt-1">
|
||||
{matchedEntry ? (
|
||||
<Link to={`/entry/${matchedEntry.id}`}>
|
||||
<Button size="sm" variant="secondary" className="rounded-full gap-1.5 text-xs">
|
||||
<Play className="h-3 w-3 fill-current" />
|
||||
Details
|
||||
</Button>
|
||||
</Link>
|
||||
) : (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="secondary"
|
||||
className="rounded-full gap-1.5 text-xs"
|
||||
onClick={() => createEntry.mutate({ tmdb_id: entry.id, is_tvserie: isTv })}
|
||||
disabled={createEntry.isPending}
|
||||
>
|
||||
<Plus className="h-3 w-3" />
|
||||
Add
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* Search bar */}
|
||||
<div className="absolute top-5 left-1/2 z-20 w-full max-w-sm -translate-x-1/2 px-4">
|
||||
<div className="relative">
|
||||
<Search className="pointer-events-none absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-white/60" />
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search movies, TV shows..."
|
||||
value={searchInput}
|
||||
onChange={(e) => setSearchInput(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && handleSearch()}
|
||||
className="w-full rounded-full border border-white/20 bg-black/40 py-2.5 pl-9 pr-4 text-sm text-white backdrop-blur-md placeholder-white/50 transition-colors focus:border-white/50 focus:outline-none"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Left arrow */}
|
||||
<button
|
||||
className="absolute left-3 top-1/2 z-20 flex h-9 w-9 -translate-y-1/2 items-center justify-center rounded-full border border-white/10 bg-black/30 text-white backdrop-blur-sm transition-colors hover:bg-black/60"
|
||||
onClick={() => { go(activeIndex - 1); startAutoplay(); }}
|
||||
aria-label="Previous"
|
||||
>
|
||||
<ChevronLeft className="h-5 w-5" />
|
||||
</button>
|
||||
|
||||
{/* Right arrow */}
|
||||
<button
|
||||
className="absolute right-3 top-1/2 z-20 flex h-9 w-9 -translate-y-1/2 items-center justify-center rounded-full border border-white/10 bg-black/30 text-white backdrop-blur-sm transition-colors hover:bg-black/60"
|
||||
onClick={() => { go(activeIndex + 1); startAutoplay(); }}
|
||||
aria-label="Next"
|
||||
>
|
||||
<ChevronRight className="h-5 w-5" />
|
||||
</button>
|
||||
|
||||
{/* Dot indicators */}
|
||||
<div className="absolute bottom-5 right-4 z-20 flex items-center gap-1.5 md:bottom-8 md:right-6">
|
||||
{slides.map((_, i) => (
|
||||
<button
|
||||
key={i}
|
||||
onClick={() => { go(i); startAutoplay(); }}
|
||||
aria-label={`Go to slide ${i + 1}`}
|
||||
className={`rounded-full transition-all duration-300 ${
|
||||
i === activeIndex
|
||||
? 'h-1.5 w-6 bg-white'
|
||||
: 'h-1.5 w-1.5 bg-white/30 hover:bg-white/60'
|
||||
}`}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
import type { TmdbEntry } from '@/types';
|
||||
|
||||
interface MiniPosterCardProps {
|
||||
entry: TmdbEntry;
|
||||
hideTitle?: boolean;
|
||||
}
|
||||
|
||||
export function MiniPosterCard({ entry, hideTitle }: MiniPosterCardProps) {
|
||||
const title = entry.title || entry.name || 'Untitled';
|
||||
const poster = entry.poster_path
|
||||
? `https://image.tmdb.org/t/p/w342${entry.poster_path}`
|
||||
: null;
|
||||
const isTv = entry.media_type === 'tv' || !!entry.name;
|
||||
const linkTo = `/entry/tmdb/${isTv ? 'tv' : 'movie'}/${entry.id}`;
|
||||
|
||||
return (
|
||||
<Link to={linkTo} className="group space-y-2">
|
||||
<div className="relative overflow-hidden rounded-lg bg-muted" style={{ aspectRatio: '2/3' }}>
|
||||
{poster ? (
|
||||
<img
|
||||
src={poster}
|
||||
alt={title}
|
||||
className="h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"
|
||||
/>
|
||||
) : (
|
||||
<div className="flex h-full w-full items-center justify-center text-xs text-muted-foreground">
|
||||
No Image
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
{!hideTitle && <p className="truncate text-xs font-medium">{title}</p>}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Star } from 'lucide-react';
|
||||
import type { TmdbEntry } from '@/types';
|
||||
|
||||
interface NumberedListItemProps {
|
||||
entry: TmdbEntry;
|
||||
rank: number;
|
||||
}
|
||||
|
||||
export function NumberedListItem({ entry, rank }: NumberedListItemProps) {
|
||||
const title = entry.title || entry.name || 'Untitled';
|
||||
const poster = entry.poster_path
|
||||
? `https://image.tmdb.org/t/p/w92${entry.poster_path}`
|
||||
: null;
|
||||
const isTv = entry.media_type === 'tv' || !!entry.name;
|
||||
const linkTo = `/entry/tmdb/${isTv ? 'tv' : 'movie'}/${entry.id}`;
|
||||
|
||||
return (
|
||||
<Link
|
||||
to={linkTo}
|
||||
className="group flex items-center gap-3 rounded-lg p-2 transition-colors hover:bg-accent/50"
|
||||
>
|
||||
<span className="w-8 text-center text-2xl font-black tabular-nums text-muted-foreground/40 transition-colors group-hover:text-foreground/60">
|
||||
{rank}
|
||||
</span>
|
||||
<div className="h-12 w-8 shrink-0 overflow-hidden rounded bg-muted">
|
||||
{poster && <img src={poster} alt="" className="h-full w-full object-cover" />}
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<p className="truncate text-sm font-medium">{title}</p>
|
||||
{entry.vote_average > 0 && (
|
||||
<span className="flex items-center gap-1 text-xs text-muted-foreground">
|
||||
<Star className="h-2.5 w-2.5 fill-yellow-400 text-yellow-400" />
|
||||
{entry.vote_average.toFixed(1)}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import { BackdropScrollCard } from './BackdropCard';
|
||||
import type { TmdbEntry } from '@/types';
|
||||
|
||||
interface PopularBeltProps {
|
||||
movieEntries: TmdbEntry[];
|
||||
tvEntries: TmdbEntry[];
|
||||
}
|
||||
|
||||
export function PopularBelt({ movieEntries, tvEntries }: PopularBeltProps) {
|
||||
const items = [...movieEntries.slice(0, 8), ...tvEntries.slice(0, 6)];
|
||||
|
||||
if (items.length === 0) return null;
|
||||
|
||||
return (
|
||||
<div className="overflow-hidden">
|
||||
<div
|
||||
className="flex gap-4"
|
||||
style={{
|
||||
animation: 'marquee-left 40s linear infinite',
|
||||
width: 'max-content',
|
||||
}}
|
||||
onMouseEnter={(e) => ((e.currentTarget as HTMLDivElement).style.animationPlayState = 'paused')}
|
||||
onMouseLeave={(e) => ((e.currentTarget as HTMLDivElement).style.animationPlayState = 'running')}
|
||||
>
|
||||
{/* Original + duplicate for seamless loop */}
|
||||
{[...Array(2)].flatMap((_, pass) =>
|
||||
items.map((item) => (
|
||||
<BackdropScrollCard key={`${pass}-${item.id}`} entry={item} />
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
|
||||
interface SectionHeaderProps {
|
||||
icon: React.ReactNode;
|
||||
title: string;
|
||||
category: string;
|
||||
}
|
||||
|
||||
export function SectionHeader({ icon, title, category }: SectionHeaderProps) {
|
||||
return (
|
||||
<div className="flex items-center justify-between">
|
||||
<div className="flex items-center gap-2">
|
||||
{icon}
|
||||
<h2 className="text-xl font-bold">{title}</h2>
|
||||
</div>
|
||||
<Link
|
||||
to={`/discover/${category}`}
|
||||
className="text-sm text-muted-foreground transition-colors hover:text-foreground"
|
||||
>
|
||||
Explore All →
|
||||
</Link>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
import type { TmdbEntry } from '@/types';
|
||||
|
||||
function formatRelativeTime(dateStr: string): string {
|
||||
const now = new Date();
|
||||
const release = new Date(dateStr);
|
||||
const diffMs = release.getTime() - now.getTime();
|
||||
if (diffMs <= 0) return 'Out now';
|
||||
const totalMinutes = Math.floor(diffMs / 60000);
|
||||
const totalHours = Math.floor(totalMinutes / 60);
|
||||
const totalDays = Math.floor(totalHours / 24);
|
||||
const months = Math.floor(totalDays / 30);
|
||||
const remDays = totalDays % 30;
|
||||
if (months > 0 && remDays > 0) return `in ${months}m ${remDays}d`;
|
||||
if (months > 0) return `in ${months}m`;
|
||||
if (totalDays > 0) return `in ${totalDays} day${totalDays !== 1 ? 's' : ''}`;
|
||||
if (totalHours > 0) return `in ${totalHours} hour${totalHours !== 1 ? 's' : ''}`;
|
||||
if (totalMinutes > 0) return `in ${totalMinutes} min`;
|
||||
return 'Very soon';
|
||||
}
|
||||
|
||||
interface UpcomingCardProps {
|
||||
entry: TmdbEntry;
|
||||
}
|
||||
|
||||
export function UpcomingCard({ entry }: UpcomingCardProps) {
|
||||
const title = entry.title || entry.name || 'Untitled';
|
||||
const poster = entry.poster_path
|
||||
? `https://image.tmdb.org/t/p/w185${entry.poster_path}`
|
||||
: null;
|
||||
const isTv = entry.media_type === 'tv' || !!entry.name;
|
||||
const linkTo = `/entry/tmdb/${isTv ? 'tv' : 'movie'}/${entry.id}`;
|
||||
const releaseDate = entry.release_date || entry.first_air_date;
|
||||
const relativeTime = releaseDate ? formatRelativeTime(releaseDate) : null;
|
||||
|
||||
return (
|
||||
<Link
|
||||
to={linkTo}
|
||||
className="group relative shrink-0 overflow-hidden rounded-xl border border-border/50 bg-card transition-colors hover:border-border"
|
||||
style={{ width: '110px' }}
|
||||
>
|
||||
<div className="relative overflow-hidden" style={{ aspectRatio: '2/3' }}>
|
||||
{poster ? (
|
||||
<img
|
||||
src={poster}
|
||||
alt={title}
|
||||
className="h-full w-full object-cover transition-transform duration-300 group-hover:scale-105"
|
||||
/>
|
||||
) : (
|
||||
<div className="flex h-full w-full items-center justify-center bg-muted text-xs text-muted-foreground">
|
||||
No Image
|
||||
</div>
|
||||
)}
|
||||
{/* Date overlay */}
|
||||
{releaseDate && (
|
||||
<div className="absolute bottom-0 left-0 right-0 bg-linear-to-t from-black/80 to-transparent px-2 py-2">
|
||||
<p className="text-[9px] font-semibold leading-tight text-white/90">
|
||||
{new Date(releaseDate).toLocaleDateString('en-US', {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
year: 'numeric',
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
{/* Hover overlay — relative countdown */}
|
||||
{relativeTime && (
|
||||
<div className="absolute inset-0 flex items-center justify-center bg-black/50 opacity-0 backdrop-blur-[1px] transition-opacity duration-200 group-hover:opacity-100">
|
||||
<span className="rounded-full bg-white/15 px-2.5 py-1 text-[10px] font-bold text-white backdrop-blur-sm">
|
||||
{relativeTime}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
export { HeroSlider } from './HeroSlider';
|
||||
export { BackdropCard, BackdropScrollCard } from './BackdropCard';
|
||||
export { NumberedListItem } from './NumberedListItem';
|
||||
export { MiniPosterCard } from './MiniPosterCard';
|
||||
export { UpcomingCard } from './UpcomingCard';
|
||||
export { SectionHeader } from './SectionHeader';
|
||||
export { PopularBelt } from './PopularBelt';
|
||||
Reference in new issue
Block a user