Fix home page navigation and add TMDB cast page
Home page cards now check library store and link directly to EntryDetailsPage when the entry is already added. Created useTmdbEntryLink hook for shared library-check logic. Added TmdbCastsPage with filter/search/sort for TMDB preview cast & crew, and limited credits to 12 on TmdbPreviewPage.
This commit is contained in:
1 parent
6c2fd3837b
commit
8671184dc5
9 files changed
+540
-136
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Star } from 'lucide-react';
|
||||
import type { TmdbEntry } from '@/types';
|
||||
import { Link } from "react-router-dom";
|
||||
import { Star } from "lucide-react";
|
||||
import type { TmdbEntry } from "@/types";
|
||||
import { useTmdbEntryLink } from "@/hooks/useTmdbEntryLink";
|
||||
|
||||
interface BackdropCardProps {
|
||||
entry: TmdbEntry;
|
||||
@@ -9,19 +10,26 @@ interface BackdropCardProps {
|
||||
animDelay?: number;
|
||||
}
|
||||
|
||||
export function BackdropCard({ entry, showRating, animClass, animDelay }: BackdropCardProps) {
|
||||
const title = entry.title || entry.name || 'Untitled';
|
||||
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}`;
|
||||
const { linkTo } = useTmdbEntryLink(entry);
|
||||
|
||||
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 }}
|
||||
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
|
||||
@@ -51,18 +59,17 @@ interface BackdropScrollCardProps {
|
||||
}
|
||||
|
||||
export function BackdropScrollCard({ entry }: BackdropScrollCardProps) {
|
||||
const title = entry.title || entry.name || 'Untitled';
|
||||
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}`;
|
||||
const { linkTo } = useTmdbEntryLink(entry);
|
||||
|
||||
return (
|
||||
<Link
|
||||
to={linkTo}
|
||||
className="group relative block shrink-0 overflow-hidden rounded-xl bg-muted"
|
||||
style={{ width: '260px', aspectRatio: '16/9' }}
|
||||
style={{ width: "260px", aspectRatio: "16/9" }}
|
||||
>
|
||||
{backdrop ? (
|
||||
<img
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
import type { TmdbEntry } from '@/types';
|
||||
import { Link } from "react-router-dom";
|
||||
import type { TmdbEntry } from "@/types";
|
||||
import { useTmdbEntryLink } from "@/hooks/useTmdbEntryLink";
|
||||
|
||||
interface MiniPosterCardProps {
|
||||
entry: TmdbEntry;
|
||||
@@ -7,16 +8,18 @@ interface MiniPosterCardProps {
|
||||
}
|
||||
|
||||
export function MiniPosterCard({ entry, hideTitle }: MiniPosterCardProps) {
|
||||
const title = entry.title || entry.name || 'Untitled';
|
||||
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}`;
|
||||
const { linkTo } = useTmdbEntryLink(entry);
|
||||
|
||||
return (
|
||||
<Link to={linkTo} className="group space-y-2">
|
||||
<div className="relative overflow-hidden rounded-lg bg-muted" style={{ aspectRatio: '2/3' }}>
|
||||
<div
|
||||
className="relative overflow-hidden rounded-lg bg-muted"
|
||||
style={{ aspectRatio: "2/3" }}
|
||||
>
|
||||
{poster ? (
|
||||
<img
|
||||
src={poster}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
import { Star } from 'lucide-react';
|
||||
import type { TmdbEntry } from '@/types';
|
||||
import { Link } from "react-router-dom";
|
||||
import { Star } from "lucide-react";
|
||||
import type { TmdbEntry } from "@/types";
|
||||
import { useTmdbEntryLink } from "@/hooks/useTmdbEntryLink";
|
||||
|
||||
interface NumberedListItemProps {
|
||||
entry: TmdbEntry;
|
||||
@@ -8,12 +9,11 @@ interface NumberedListItemProps {
|
||||
}
|
||||
|
||||
export function NumberedListItem({ entry, rank }: NumberedListItemProps) {
|
||||
const title = entry.title || entry.name || 'Untitled';
|
||||
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}`;
|
||||
const { linkTo } = useTmdbEntryLink(entry);
|
||||
|
||||
return (
|
||||
<Link
|
||||
@@ -24,7 +24,9 @@ export function NumberedListItem({ entry, rank }: NumberedListItemProps) {
|
||||
{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" />}
|
||||
{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>
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
import { Link } from 'react-router-dom';
|
||||
import type { TmdbEntry } from '@/types';
|
||||
import { Link } from "react-router-dom";
|
||||
import type { TmdbEntry } from "@/types";
|
||||
import { useTmdbEntryLink } from "@/hooks/useTmdbEntryLink";
|
||||
|
||||
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';
|
||||
if (diffMs <= 0) return "Out now";
|
||||
const totalMinutes = Math.floor(diffMs / 60000);
|
||||
const totalHours = Math.floor(totalMinutes / 60);
|
||||
const totalDays = Math.floor(totalHours / 24);
|
||||
@@ -13,10 +14,11 @@ function formatRelativeTime(dateStr: string): string {
|
||||
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 (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';
|
||||
return "Very soon";
|
||||
}
|
||||
|
||||
interface UpcomingCardProps {
|
||||
@@ -24,12 +26,11 @@ interface UpcomingCardProps {
|
||||
}
|
||||
|
||||
export function UpcomingCard({ entry }: UpcomingCardProps) {
|
||||
const title = entry.title || entry.name || 'Untitled';
|
||||
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 { linkTo } = useTmdbEntryLink(entry);
|
||||
const releaseDate = entry.release_date || entry.first_air_date;
|
||||
const relativeTime = releaseDate ? formatRelativeTime(releaseDate) : null;
|
||||
|
||||
@@ -37,9 +38,9 @@ export function UpcomingCard({ entry }: UpcomingCardProps) {
|
||||
<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' }}
|
||||
style={{ width: "110px" }}
|
||||
>
|
||||
<div className="relative overflow-hidden" style={{ aspectRatio: '2/3' }}>
|
||||
<div className="relative overflow-hidden" style={{ aspectRatio: "2/3" }}>
|
||||
{poster ? (
|
||||
<img
|
||||
src={poster}
|
||||
@@ -55,10 +56,10 @@ export function UpcomingCard({ entry }: UpcomingCardProps) {
|
||||
{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',
|
||||
{new Date(releaseDate).toLocaleDateString("en-US", {
|
||||
month: "short",
|
||||
day: "numeric",
|
||||
year: "numeric",
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user