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:
Mohammed Abad committed 2026-05-25 04:42:24 +01:00
1 parent 070aea3c51
commit 8641e55362
13 files changed
+749 -1077

No files matched your search

+161 -63
View File
@@ -1,3 +1,4 @@
import { useState, useEffect } from 'react';
import {
useTrendingMovies,
useTrendingTv,
@@ -8,18 +9,18 @@ import {
useUpcomingMovies,
} from '@/hooks/useTmdb';
import { useLibrary } from '@/hooks/useEntries';
import { TrendingGrid } from '@/components/entries/TrendingGrid';
import { TrendingSlider } from '@/components/entries/TrendingSlider';
import { Input } from '@/components/ui/input';
import { Search } from 'lucide-react';
import { useNavigate } from 'react-router-dom';
import { useState } from 'react';
import { TrendingUp, Play, Award, Calendar } from 'lucide-react';
import {
HeroSlider,
BackdropCard,
NumberedListItem,
MiniPosterCard,
UpcomingCard,
SectionHeader,
PopularBelt,
} from '@/components/home';
export function HomePage() {
const navigate = useNavigate();
const [searchInput, setSearchInput] = useState('');
// Pre-load library
useLibrary();
const trendingMovies = useTrendingMovies();
@@ -38,66 +39,163 @@ export function HomePage() {
const topRatedTvEntries = topRatedTv.data?.pages.flatMap((p) => p.results) ?? [];
const upcomingMovieEntries = upcomingMovies.data?.pages.flatMap((p) => p.results) ?? [];
const handleSearchSubmit = () => {
const q = searchInput.trim();
if (q) {
navigate(`/search?q=${encodeURIComponent(q)}`);
}
};
// Trending grid auto-rotation: exit -> swap -> enter
const [trendingIdx, setTrendingIdx] = useState(0);
const [trendingPhase, setTrendingPhase] = useState<'idle' | 'exit' | 'enter'>('idle');
const trendingPool = trendingMovieEntries.slice(2);
const visibleTrending =
trendingPool.length >= 4
? [0, 1, 2, 3].map((offset) => trendingPool[(trendingIdx + offset) % trendingPool.length])
: trendingPool;
useEffect(() => {
if (trendingPool.length <= 4) return;
const timer = setInterval(() => {
setTrendingPhase('exit');
setTimeout(() => {
setTrendingIdx((i) => i + 1);
setTrendingPhase('enter');
setTimeout(() => setTrendingPhase('idle'), 600);
}, 380);
}, 7000);
return () => clearInterval(timer);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [trendingPool.length]);
const isLoading =
trendingMovies.isLoading ||
popularMovies.isLoading ||
topRatedMovies.isLoading ||
upcomingMovies.isLoading;
if (isLoading) {
return <HomeLoadingSkeleton />;
}
return (
<div className="space-y-8 animate-page-enter">
{/* Trending Slider Hero */}
<TrendingSlider
entries={trendingMovieEntries}
isLoading={trendingMovies.isLoading}
/>
{/* Search */}
<div className="relative max-w-md">
<Search className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground" />
<Input
placeholder="Search movies, TV shows & people..."
value={searchInput}
onChange={(e) => setSearchInput(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter') handleSearchSubmit();
}}
className="pl-10"
/>
<div className="animate-page-enter space-y-12 pb-12">
{/* Hero Slider — full bleed */}
<div className="-mx-4 -mt-18 md:-mx-6 md:-mt-6">
<HeroSlider entries={trendingMovieEntries} />
</div>
<TrendingGrid
title="Trending"
movieEntries={trendingMovieEntries}
tvEntries={trendingTvEntries}
isLoading={trendingMovies.isLoading || trendingTv.isLoading}
category="trending"
/>
{/* Trending Now */}
<section className="space-y-5">
<SectionHeader
icon={<TrendingUp className="h-5 w-5 text-rose-500" />}
title="Trending Now"
category="trending"
/>
<div className="grid grid-cols-1 xl:grid-cols-3 gap-6">
{/* Rotating 2x2 backdrop grid */}
<div
className="xl:col-span-2 grid grid-cols-1 sm:grid-cols-2 gap-4 overflow-hidden"
style={{
opacity: trendingPhase === 'exit' ? 0 : 1,
transform: trendingPhase === 'exit' ? 'translateX(-28px)' : 'translateX(0)',
transition: trendingPhase === 'exit'
? 'opacity 380ms ease, transform 380ms ease'
: 'none',
}}
>
{visibleTrending.map((item, i) => (
<BackdropCard
key={`${item.id}-${trendingIdx}`}
entry={item}
animClass={trendingPhase === 'enter' ? 'animate-slide-from-right' : undefined}
animDelay={trendingPhase === 'enter' ? i * 90 : 0}
/>
))}
</div>
{/* Numbered TV list */}
<div className="space-y-1">
<p className="text-xs uppercase tracking-widest text-muted-foreground font-semibold mb-3">
Trending TV
</p>
{trendingTvEntries.slice(0, 8).map((item, i) => (
<NumberedListItem key={item.id} entry={item} rank={i + 1} />
))}
</div>
</div>
</section>
<TrendingGrid
title="Popular"
movieEntries={popularMovieEntries}
tvEntries={popularTvEntries}
isLoading={popularMovies.isLoading || popularTv.isLoading}
category="popular"
/>
{/* Popular Right Now — infinite belt */}
<section className="space-y-5">
<SectionHeader
icon={<Play className="h-5 w-5 text-blue-500" />}
title="Popular Right Now"
category="popular"
/>
<PopularBelt movieEntries={popularMovieEntries} tvEntries={popularTvEntries} />
</section>
<TrendingGrid
title="Top Rated"
movieEntries={topRatedMovieEntries}
tvEntries={topRatedTvEntries}
isLoading={topRatedMovies.isLoading || topRatedTv.isLoading}
category="top-rated"
/>
{/* Top Rated */}
<section className="space-y-5">
<SectionHeader
icon={<Award className="h-5 w-5 text-yellow-500" />}
title="Top Rated"
category="top-rated"
/>
<div className="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div className="space-y-4">
<p className="text-xs uppercase tracking-widest text-muted-foreground font-semibold">
Movies
</p>
{topRatedMovieEntries[0] && (
<BackdropCard entry={topRatedMovieEntries[0]} showRating />
)}
<div className="grid grid-cols-4 gap-3">
{topRatedMovieEntries.slice(1, 5).map((item) => (
<MiniPosterCard key={item.id} entry={item} hideTitle />
))}
</div>
</div>
<div className="space-y-4">
<p className="text-xs uppercase tracking-widest text-muted-foreground font-semibold">
TV Shows
</p>
<div className="space-y-1">
{topRatedTvEntries.slice(0, 10).map((item, i) => (
<NumberedListItem key={item.id} entry={item} rank={i + 1} />
))}
</div>
</div>
</div>
</section>
<TrendingGrid
title="Upcoming"
movieEntries={upcomingMovieEntries}
tvEntries={[]}
isLoading={upcomingMovies.isLoading}
category="upcoming"
/>
{/* Coming Soon */}
<section className="space-y-5">
<SectionHeader
icon={<Calendar className="h-5 w-5 text-emerald-500" />}
title="Coming Soon"
category="upcoming"
/>
<div
className="flex gap-3 overflow-x-auto pb-2"
style={{ scrollbarWidth: 'none', msOverflowStyle: 'none' } as React.CSSProperties}
>
{upcomingMovieEntries.slice(0, 14).map((item) => (
<UpcomingCard key={item.id} entry={item} />
))}
</div>
</section>
</div>
);
}
function HomeLoadingSkeleton() {
return (
<div className="animate-pulse space-y-12 pb-12">
<div className="-mx-4 -mt-18 md:-mx-6 md:-mt-6">
<div className="w-full bg-muted" style={{ aspectRatio: '16/9', maxHeight: '70vh' }} />
</div>
<div className="space-y-4">
<div className="h-6 w-48 rounded bg-muted" />
<div className="grid grid-cols-2 gap-4">
<div className="rounded-xl bg-muted" style={{ aspectRatio: '16/9' }} />
<div className="rounded-xl bg-muted" style={{ aspectRatio: '16/9' }} />
</div>
</div>
</div>
);
}