Files
Showy/react_frontend/src/components/home/UpcomingCard.tsx
T
Mohammed Abad 8641e55362 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
2026-05-25 04:42:24 +01:00

78 lines
3.0 KiB
TypeScript

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>
);
}