Recherche unifiée (titres, personnes, membres) et pages des acteurs / réalisateurs
deploy / deploy (push) Successful in 36s
deploy / deploy (push) Successful in 36s
- « Ajouter » devient « Rechercher » : un seul champ, onglets Tout / Titres /
Personnes / Membres (pseudo), ajout manuel conservé.
- Page d'une personne : photo, naissance, biographie, filmographie par métier
(jeu, doublage, réalisation, scénario, production, autres), tri populaires /
récents, titres déjà dans la bibliothèque marqués ; TMDB et AniList (doubleurs,
staff d'anime).
- Casting et réalisateur·rice cliquables sur la fiche ; pile de fenêtres
(titre → personne → titre…) avec retour cran par cran.
- Proxy tmdb : /search/person, /person/{id}, combined_credits (redéployé).
- 18 langues.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YVo1qxKoBQCaMd7Ue8PGbe
This commit is contained in:
28 files changed
+1676
-112
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { t } from '../i18n'
|
||||
import { BarChart3, Home, LibraryBig, Plus, Settings } from 'lucide-react'
|
||||
import { BarChart3, Home, LibraryBig, Search, Settings } from 'lucide-react'
|
||||
import { cx } from '../lib/utils'
|
||||
|
||||
export type Tab = 'home' | 'catalog' | 'stats' | 'settings'
|
||||
@@ -44,10 +44,10 @@ export default function BottomNav({ current, onChange, onAdd }: Props) {
|
||||
<div className="flex flex-1 justify-center">
|
||||
<button
|
||||
onClick={onAdd}
|
||||
aria-label={t('nav.addTitle')}
|
||||
aria-label={t('search.title')}
|
||||
className="grid size-12 place-items-center rounded-full bg-accent-fill text-on-accent transition active:scale-95"
|
||||
>
|
||||
<Plus size={24} strokeWidth={2.2} />
|
||||
<Search size={22} strokeWidth={2.4} />
|
||||
</button>
|
||||
</div>
|
||||
{ITEMS.slice(2).map(button)}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { type Tab } from './BottomNav'
|
||||
import { t } from '../i18n'
|
||||
import { BarChart3, Home, LibraryBig, Plus, Settings } from 'lucide-react'
|
||||
import { BarChart3, Home, LibraryBig, Search, Settings } from 'lucide-react'
|
||||
import { cx } from '../lib/utils'
|
||||
|
||||
const ITEMS: { tab: Tab; readonly label: string; Icon: typeof Home }[] = [
|
||||
@@ -27,8 +27,8 @@ export default function SideNav({ current, onChange, onAdd }: Props) {
|
||||
onClick={onAdd}
|
||||
className="mt-6 flex w-full items-center justify-center gap-2 rounded-full bg-accent-fill px-4 py-2.5 text-sm font-semibold text-on-accent transition active:scale-95"
|
||||
>
|
||||
<Plus size={18} strokeWidth={2.2} />
|
||||
{t('nav.addTitle')}
|
||||
<Search size={17} strokeWidth={2.4} />
|
||||
{t('search.title')}
|
||||
</button>
|
||||
|
||||
<div className="mt-6 flex flex-col gap-1">
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
import { ArrowLeft, Check, Loader2 } from 'lucide-react'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { t } from '../../i18n'
|
||||
import { useBackToClose } from '../../lib/backNav'
|
||||
import type { SearchResult } from '../../lib/catalogApi'
|
||||
import { STATUS_BY_VALUE } from '../../lib/constants'
|
||||
import { useEscape } from '../../lib/escape'
|
||||
import { findFranchiseItem } from '../../lib/franchise'
|
||||
import { CREDIT_GROUPS, getPerson, groupLabel, type CreditGroup, type PersonCredit, type PersonDetails } from '../../lib/people'
|
||||
import { useScrollLock } from '../../lib/scrollLock'
|
||||
import { cx, formatDate } from '../../lib/utils'
|
||||
import { useMedia } from '../../store'
|
||||
import type { MediaItem } from '../../types'
|
||||
import Poster from '../Poster'
|
||||
|
||||
type Sort = 'popular' | 'recent'
|
||||
|
||||
/**
|
||||
* Page d'une personne (acteur·rice, réalisateur·rice, doubleur·se…) : photo, biographie,
|
||||
* et toute sa filmographie, rangée par métier. Un titre s'ouvre en fiche (déjà dans ma bibliothèque ou non).
|
||||
*/
|
||||
export default function PersonSheet({
|
||||
personId,
|
||||
name: initialName,
|
||||
photo: initialPhoto,
|
||||
onClose,
|
||||
onOpenItem,
|
||||
onOpenSeed,
|
||||
}: {
|
||||
personId: string
|
||||
name?: string
|
||||
photo?: string
|
||||
onClose: () => void
|
||||
onOpenItem: (item: MediaItem) => void
|
||||
onOpenSeed: (seed: SearchResult) => void
|
||||
}) {
|
||||
const { items, settings } = useMedia()
|
||||
useScrollLock()
|
||||
useEscape(onClose)
|
||||
useBackToClose(onClose)
|
||||
|
||||
const [person, setPerson] = useState<PersonDetails>()
|
||||
const [error, setError] = useState<string>()
|
||||
const [group, setGroup] = useState<CreditGroup>()
|
||||
const [sort, setSort] = useState<Sort>('popular')
|
||||
const [bioOpen, setBioOpen] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
let alive = true
|
||||
setError(undefined)
|
||||
getPerson(personId, settings.tmdbKey)
|
||||
.then((p) => {
|
||||
if (!alive) return
|
||||
setPerson(p)
|
||||
setGroup((g) => g ?? p.mainGroup)
|
||||
})
|
||||
.catch((e: Error) => alive && setError(navigator.onLine ? e.message : t('search.offline')))
|
||||
return () => {
|
||||
alive = false
|
||||
}
|
||||
}, [personId, settings.tmdbKey])
|
||||
|
||||
const mine = (r: SearchResult) =>
|
||||
items.find((i) => i.externalId === r.externalId) ?? (r.typeGuess !== 'film' ? findFranchiseItem(items, [r.title, r.originalTitle, ...(r.altTitles ?? [])], { type: r.typeGuess }) : undefined)
|
||||
|
||||
const groups = useMemo(() => {
|
||||
const counts = new Map<CreditGroup, number>()
|
||||
for (const c of person?.credits ?? []) counts.set(c.group, (counts.get(c.group) ?? 0) + 1)
|
||||
return CREDIT_GROUPS.filter((g) => counts.has(g)).map((g) => ({ g, n: counts.get(g)! }))
|
||||
}, [person])
|
||||
|
||||
const shown = useMemo(() => {
|
||||
const list = (person?.credits ?? []).filter((c) => c.group === group)
|
||||
const byYear = (a: PersonCredit, b: PersonCredit) => (b.year ?? 0) - (a.year ?? 0)
|
||||
return [...list].sort(sort === 'recent' ? byYear : (a, b) => b.popularity - a.popularity || byYear(a, b))
|
||||
}, [person, group, sort])
|
||||
|
||||
// Combien de ses titres sont déjà dans ma bibliothèque (tous métiers confondus, sans doublon)
|
||||
const library = useMemo(() => {
|
||||
const all = new Map<string, SearchResult>()
|
||||
for (const c of person?.credits ?? []) all.set(c.result.externalId, c.result)
|
||||
let n = 0
|
||||
for (const r of all.values()) if (mine(r)) n++
|
||||
return { n, total: all.size }
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [person, items])
|
||||
|
||||
const name = person?.name ?? initialName ?? ''
|
||||
const photo = person?.photo ?? initialPhoto
|
||||
const life = person && [person.birthday && t('person.born', { date: formatDate(person.birthday) }), person.deathday && t('person.died', { date: formatDate(person.deathday) }), person.place].filter(Boolean)
|
||||
|
||||
return (
|
||||
<div className="sheet sheet-in" role="dialog" aria-modal="true" aria-label={name || t('person.title')}>
|
||||
<header className="safe-top border-b border-line">
|
||||
<div className="mx-auto flex max-w-2xl items-center gap-2 px-3 py-2.5 lg:max-w-none lg:px-10">
|
||||
<button onClick={onClose} className="grid size-10 shrink-0 place-items-center rounded-full text-ink-2" aria-label={t('common.close')}>
|
||||
<ArrowLeft size={22} className="rtl:-scale-x-100" />
|
||||
</button>
|
||||
<h2 className="min-w-0 flex-1 truncate text-center text-base font-semibold">{name}</h2>
|
||||
<span className="size-10 shrink-0" />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className="sheet-scroll">
|
||||
<div className="mx-auto max-w-2xl px-4 pb-[calc(10rem+env(safe-area-inset-bottom))] pt-6 lg:max-w-none lg:px-10">
|
||||
{/* En-tête : photo + identité */}
|
||||
<div className="flex items-start gap-4 lg:gap-8">
|
||||
<div className="w-28 shrink-0 lg:w-48">
|
||||
{photo ? (
|
||||
<img src={photo} alt={name} className="aspect-[2/3] w-full rounded-xl border border-line bg-surface-2 object-cover" />
|
||||
) : (
|
||||
<div className="grid aspect-[2/3] w-full place-items-center rounded-xl border border-line bg-surface-2 text-4xl font-bold text-ink-3" aria-hidden="true">
|
||||
{name.charAt(0) || '?'}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div className="min-w-0 flex-1">
|
||||
<h1 className="text-2xl leading-tight lg:text-5xl">{name}</h1>
|
||||
{person?.department && <p className="eyebrow mt-2 text-accent">{person.department}</p>}
|
||||
{life && life.length > 0 && <p className="mt-2 text-sm text-ink-2">{life.join(' · ')}</p>}
|
||||
{person && library.n > 0 && (
|
||||
<p className="mt-3 inline-flex items-center gap-1.5 rounded-full border border-line px-3 py-1 text-xs text-ink-2">
|
||||
<Check size={13} className="text-accent" /> {t('person.inLibrary', { count: library.n, total: library.total })}
|
||||
</p>
|
||||
)}
|
||||
{/* Biographie (bureau : à côté de la photo) */}
|
||||
{person?.bio && (
|
||||
<div className="mt-4 hidden max-w-3xl lg:block">
|
||||
<Bio text={person.bio} open={bioOpen} onToggle={() => setBioOpen((v) => !v)} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{person?.bio && (
|
||||
<div className="mt-5 lg:hidden">
|
||||
<Bio text={person.bio} open={bioOpen} onToggle={() => setBioOpen((v) => !v)} />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{error && <p className="mt-6 text-sm text-accent">{error}</p>}
|
||||
{!person && !error && (
|
||||
<p className="mt-10 flex items-center justify-center gap-2 text-sm text-ink-3">
|
||||
<Loader2 size={16} className="animate-spin" /> {t('social.loading')}
|
||||
</p>
|
||||
)}
|
||||
|
||||
{person && (
|
||||
<section className="mt-8" aria-label={t('person.filmography')}>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{groups.map(({ g, n }) => (
|
||||
<button key={g} onClick={() => setGroup(g)} className={cx('chip', group === g && 'chip-on')} aria-pressed={group === g}>
|
||||
{groupLabel(g)} <span className="opacity-60">{n}</span>
|
||||
</button>
|
||||
))}
|
||||
<div className="ms-auto flex gap-1 rounded-full border border-line p-0.5 text-xs">
|
||||
{(['popular', 'recent'] as const).map((s) => (
|
||||
<button
|
||||
key={s}
|
||||
onClick={() => setSort(s)}
|
||||
aria-pressed={sort === s}
|
||||
className={cx('rounded-full px-3 py-1.5 font-medium transition-colors', sort === s ? 'bg-ink text-bg' : 'text-ink-3')}
|
||||
>
|
||||
{s === 'popular' ? t('person.sortPopular') : t('person.sortRecent')}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{shown.length === 0 ? (
|
||||
<p className="mt-8 text-center text-sm text-ink-3">{t('person.empty')}</p>
|
||||
) : (
|
||||
<ul className="mt-5 grid grid-cols-3 gap-x-3 gap-y-5 sm:grid-cols-4 lg:grid-cols-6 xl:grid-cols-8 2xl:grid-cols-10">
|
||||
{shown.map((c) => {
|
||||
const it = mine(c.result)
|
||||
return (
|
||||
<li key={c.group + c.result.externalId}>
|
||||
<button onClick={() => (it ? onOpenItem(it) : onOpenSeed(c.result))} className="group block w-full text-start">
|
||||
<div className="relative">
|
||||
<Poster src={c.result.posterUrl ?? c.result.thumb} title={c.result.title} />
|
||||
{it && (
|
||||
<span
|
||||
className="absolute end-1.5 top-1.5 grid size-6 place-items-center rounded-full bg-accent-fill text-on-accent"
|
||||
title={STATUS_BY_VALUE[it.status].label}
|
||||
aria-label={STATUS_BY_VALUE[it.status].label}
|
||||
>
|
||||
<Check size={14} strokeWidth={2.6} />
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<p className="mt-1.5 line-clamp-2 text-xs font-medium leading-snug">{c.result.title}</p>
|
||||
<p className="mt-0.5 line-clamp-2 text-[11px] leading-snug text-ink-3">{[c.year, c.role].filter(Boolean).join(' · ')}</p>
|
||||
</button>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
)}
|
||||
</section>
|
||||
)}
|
||||
|
||||
{person && (
|
||||
<p className="mt-10 text-center text-[11px] text-ink-3">{personId.startsWith('tmdbp:') ? t('person.sourceTmdb') : t('person.sourceAnilist')}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
function Bio({ text, open, onToggle }: { text: string; open: boolean; onToggle: () => void }) {
|
||||
const long = text.length > 320
|
||||
return (
|
||||
<div>
|
||||
<p className={cx('whitespace-pre-line text-sm leading-relaxed text-ink-2', !open && long && 'line-clamp-4')}>{text}</p>
|
||||
{long && (
|
||||
<button onClick={onToggle} className="mt-1.5 text-sm font-medium text-ink" aria-expanded={open}>
|
||||
{open ? t('person.bioLess') : t('person.bioMore')}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import Avatar from './Avatar'
|
||||
import { useSocial } from './SocialProvider'
|
||||
|
||||
/** Ligne « personne » : photo, nom, @pseudo, et bouton d'abonnement (ou actions personnalisées). */
|
||||
export default function PersonRow({ person, actions }: { person: ProfileCard; actions?: ReactNode }) {
|
||||
export default function PersonRow({ person, actions, onOpen }: { person: ProfileCard; actions?: ReactNode; /** Appelé juste avant d'ouvrir le profil */ onOpen?: () => void }) {
|
||||
const social = useSocial()
|
||||
const [relation, setRelation] = useState(person.relation)
|
||||
const [busy, setBusy] = useState(false)
|
||||
@@ -31,7 +31,13 @@ export default function PersonRow({ person, actions }: { person: ProfileCard; ac
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-3 py-2.5">
|
||||
<button onClick={() => social.openProfile(person.username)} className="flex min-w-0 flex-1 items-center gap-3 text-start">
|
||||
<button
|
||||
onClick={() => {
|
||||
onOpen?.()
|
||||
social.openProfile(person.username)
|
||||
}}
|
||||
className="flex min-w-0 flex-1 items-center gap-3 text-start"
|
||||
>
|
||||
<Avatar url={person.avatarUrl} name={person.displayName} size={44} />
|
||||
<span className="min-w-0">
|
||||
<span className="block truncate text-sm font-semibold">{person.displayName}</span>
|
||||
|
||||
@@ -1,40 +1,59 @@
|
||||
import { Check, Loader2, PenLine, Search, X } from 'lucide-react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
||||
import { t } from '../../i18n'
|
||||
import { useBackToClose } from '../../lib/backNav'
|
||||
import { useEscape } from '../../lib/escape'
|
||||
import { searchAll, type SearchResult } from '../../lib/catalogApi'
|
||||
import { searchProfiles, type ProfileCard } from '../../lib/cloud/social'
|
||||
import { useEscape } from '../../lib/escape'
|
||||
import { findFranchiseItem } from '../../lib/franchise'
|
||||
import { searchPeople, type PersonHit } from '../../lib/people'
|
||||
import { useScrollLock } from '../../lib/scrollLock'
|
||||
import { cx } from '../../lib/utils'
|
||||
import { useMedia } from '../../store'
|
||||
import type { MediaItem } from '../../types'
|
||||
import PersonRow from '../social/PersonRow'
|
||||
import { useSocial } from '../social/SocialProvider'
|
||||
|
||||
type Tab = 'all' | 'titles' | 'people' | 'members'
|
||||
|
||||
/** Une recherche (titres, personnes ou membres) : résultats, chargement, erreur. */
|
||||
interface Slot<T> {
|
||||
items: T[]
|
||||
loading: boolean
|
||||
error?: string
|
||||
}
|
||||
const empty = <T,>(): Slot<T> => ({ items: [], loading: false })
|
||||
|
||||
/**
|
||||
* « Ajouter » : on cherche le titre (films, séries et animes en une fois), puis on ouvre sa fiche pour le noter / l'ajouter.
|
||||
* Si le titre, ou une autre saison de la même série, est déjà dans la bibliothèque, on ouvre directement ma fiche.
|
||||
* Recherche : titres (films, séries, animes), personnes (acteurs, réalisateurs, doubleurs) et membres, en une fois.
|
||||
* Un titre déjà dans la bibliothèque (ou une autre saison de la même série) ouvre directement ma fiche.
|
||||
*/
|
||||
export default function AddTitle({
|
||||
onClose,
|
||||
onPick,
|
||||
onOpenItem,
|
||||
onOpenPerson,
|
||||
onManual,
|
||||
onGoToSettings,
|
||||
}: {
|
||||
onClose: () => void
|
||||
onPick: (r: SearchResult) => void
|
||||
onOpenItem: (item: MediaItem) => void
|
||||
onOpenPerson: (p: PersonHit) => void
|
||||
onManual: (title: string) => void
|
||||
onGoToSettings?: () => void
|
||||
}) {
|
||||
const { items, settings } = useMedia()
|
||||
const social = useSocial()
|
||||
useScrollLock()
|
||||
useEscape(onClose)
|
||||
useBackToClose(onClose)
|
||||
const hasKey = !!settings.tmdbKey?.trim()
|
||||
const [query, setQuery] = useState('')
|
||||
const [results, setResults] = useState<SearchResult[]>([])
|
||||
const [loading, setLoading] = useState(false)
|
||||
const [error, setError] = useState<string>()
|
||||
const [tab, setTab] = useState<Tab>('all')
|
||||
const [titles, setTitles] = useState<Slot<SearchResult>>(empty)
|
||||
const [people, setPeople] = useState<Slot<PersonHit>>(empty)
|
||||
const [members, setMembers] = useState<Slot<ProfileCard>>(empty)
|
||||
const request = useRef(0)
|
||||
const inLibrary = (r: SearchResult) =>
|
||||
items.find((i) => i.externalId === r.externalId) ?? findFranchiseItem(items, [r.title, r.originalTitle, ...(r.altTitles ?? [])], { type: r.typeGuess })
|
||||
@@ -43,40 +62,128 @@ export default function AddTitle({
|
||||
const q = query.trim()
|
||||
// Toute réponse d'une recherche précédente devient caduque
|
||||
const id = ++request.current
|
||||
setError(undefined)
|
||||
if (q.length < 2) {
|
||||
setResults([])
|
||||
setLoading(false)
|
||||
setTitles(empty)
|
||||
setPeople(empty)
|
||||
setMembers(empty)
|
||||
return
|
||||
}
|
||||
setLoading(true)
|
||||
const timer = setTimeout(async () => {
|
||||
try {
|
||||
const res = await searchAll(q, hasKey ? settings.tmdbKey : undefined)
|
||||
if (id === request.current) setResults(res)
|
||||
} catch (e) {
|
||||
if (id === request.current) {
|
||||
setResults([])
|
||||
setError(navigator.onLine ? (e as Error).message : t('search.offline'))
|
||||
}
|
||||
} finally {
|
||||
if (id === request.current) setLoading(false)
|
||||
}
|
||||
setTitles((s) => ({ ...s, loading: true, error: undefined }))
|
||||
setPeople((s) => ({ ...s, loading: true, error: undefined }))
|
||||
setMembers((s) => ({ ...s, loading: social.enabled, error: undefined }))
|
||||
const errorText = (e: unknown) => (navigator.onLine ? (e as Error).message : t('search.offline'))
|
||||
const run = <T,>(p: Promise<T[]>, set: (s: Slot<T>) => void) =>
|
||||
p.then(
|
||||
(list) => id === request.current && set({ items: list, loading: false }),
|
||||
(e) => id === request.current && set({ items: [], loading: false, error: errorText(e) }),
|
||||
)
|
||||
const timer = setTimeout(() => {
|
||||
void run(searchAll(q, hasKey ? settings.tmdbKey : undefined), setTitles)
|
||||
void run(searchPeople(q, hasKey ? settings.tmdbKey : undefined), setPeople)
|
||||
if (social.enabled) void run(searchProfiles(q), setMembers)
|
||||
}, 350)
|
||||
return () => clearTimeout(timer)
|
||||
}, [query, hasKey, settings.tmdbKey])
|
||||
}, [query, hasKey, settings.tmdbKey, social.enabled])
|
||||
|
||||
const searched = query.trim().length >= 2
|
||||
const loading = titles.loading || people.loading || members.loading
|
||||
const tabs: { id: Tab; label: string; n?: number }[] = [
|
||||
{ id: 'all', label: t('search.tabAll') },
|
||||
{ id: 'titles', label: t('search.tabTitles'), n: searched ? titles.items.length : undefined },
|
||||
{ id: 'people', label: t('search.tabPeople'), n: searched ? people.items.length : undefined },
|
||||
...(social.enabled ? [{ id: 'members' as const, label: t('search.tabMembers'), n: searched ? members.items.length : undefined }] : []),
|
||||
]
|
||||
|
||||
const titleList = (list: SearchResult[]) => (
|
||||
<ul className="divide-y divide-line lg:grid lg:grid-cols-2 lg:gap-x-10 lg:divide-y-0 xl:grid-cols-3">
|
||||
{list.map((r) => {
|
||||
const mine = inLibrary(r)
|
||||
return (
|
||||
<li key={r.externalId}>
|
||||
<button onClick={() => (mine ? onOpenItem(mine) : onPick(r))} className="flex w-full items-center gap-3 py-3 text-start active:bg-surface lg:border-b lg:border-line">
|
||||
{r.thumb ? (
|
||||
<img src={r.thumb} alt="" loading="lazy" className="h-[5.25rem] w-14 shrink-0 rounded-lg border border-line bg-surface-2 object-cover" />
|
||||
) : (
|
||||
<span className="grid h-[5.25rem] w-14 shrink-0 place-items-center rounded-lg border border-line bg-surface-2 font-semibold text-ink-3">{r.title.charAt(0)}</span>
|
||||
)}
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate font-semibold">{r.title}</span>
|
||||
{r.originalTitle && <span className="block truncate text-xs text-ink-3">{r.originalTitle}</span>}
|
||||
<span className="mt-1 block text-[11px] uppercase tracking-wide text-ink-3">{[r.year, r.kindLabel].filter(Boolean).join(' · ')}</span>
|
||||
{mine && (
|
||||
<span className="mt-1 inline-flex items-center gap-1 text-xs text-accent">
|
||||
<Check size={12} /> {t('title.inLibrary')}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span className="shrink-0 text-accent rtl:-scale-x-100">→</span>
|
||||
</button>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
)
|
||||
|
||||
const personList = (list: PersonHit[]) => (
|
||||
<ul className="divide-y divide-line lg:grid lg:grid-cols-2 lg:gap-x-10 lg:divide-y-0 xl:grid-cols-3">
|
||||
{list.map((p) => (
|
||||
<li key={p.id}>
|
||||
<button onClick={() => onOpenPerson(p)} className="flex w-full items-center gap-3 py-2.5 text-start active:bg-surface lg:border-b lg:border-line">
|
||||
{p.photo ? (
|
||||
<img src={p.photo} alt="" loading="lazy" className="size-14 shrink-0 rounded-full border border-line bg-surface-2 object-cover" />
|
||||
) : (
|
||||
<span className="grid size-14 shrink-0 place-items-center rounded-full border border-line bg-surface-2 text-lg font-semibold text-ink-3">{p.name.charAt(0)}</span>
|
||||
)}
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate font-semibold">{p.name}</span>
|
||||
{p.department && <span className="block text-[11px] uppercase tracking-wide text-ink-3">{p.department}</span>}
|
||||
{p.knownFor.length > 0 && <span className="mt-0.5 block truncate text-xs text-ink-2">{p.knownFor.join(' · ')}</span>}
|
||||
</span>
|
||||
<span className="shrink-0 text-accent rtl:-scale-x-100">→</span>
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)
|
||||
|
||||
const memberList = (list: ProfileCard[]) => (
|
||||
<div className="divide-y divide-line lg:grid lg:grid-cols-2 lg:gap-x-10 lg:divide-y-0 xl:grid-cols-3">
|
||||
{list.map((m) => (
|
||||
<div key={m.id} className="lg:border-b lg:border-line">
|
||||
{/* Les profils s'ouvrent sous les fenêtres de l'app : on referme la recherche pour que le profil soit visible */}
|
||||
<PersonRow person={m} onOpen={onClose} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)
|
||||
|
||||
const section = (label: string, body: ReactNode, more?: () => void) => (
|
||||
<section className="mt-6">
|
||||
<div className="mb-1 flex items-center justify-between">
|
||||
<h3 className="eyebrow text-ink-2">{label}</h3>
|
||||
{more && (
|
||||
<button onClick={more} className="text-xs font-medium text-ink-2">
|
||||
{t('search.seeAll')} <span className="text-accent rtl:-scale-x-100">→</span>
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
{body}
|
||||
</section>
|
||||
)
|
||||
|
||||
const errorLine = (e?: string) => e && <p className="mt-4 text-sm text-accent">{e}</p>
|
||||
const none = (text: string) => <p className="mt-6 text-center text-sm text-ink-3">{text}</p>
|
||||
const nothingAtAll = searched && !loading && !titles.items.length && !people.items.length && !members.items.length
|
||||
|
||||
return (
|
||||
<div className="sheet sheet-in" role="dialog" aria-modal="true" aria-label={t('title.addTitle')}>
|
||||
<div className="sheet sheet-in" role="dialog" aria-modal="true" aria-label={t('search.title')}>
|
||||
<header className="safe-top border-b border-line">
|
||||
<div className="mx-auto max-w-2xl px-3 pb-3 pt-2.5 lg:max-w-none lg:px-10">
|
||||
<div className="flex items-center gap-2">
|
||||
<button onClick={onClose} className="grid size-10 shrink-0 place-items-center rounded-full text-ink-2" aria-label={t('common.close')}>
|
||||
<X size={22} />
|
||||
</button>
|
||||
<h2 className="min-w-0 flex-1 truncate text-center text-base font-semibold">{t('title.addTitle')}</h2>
|
||||
<h2 className="min-w-0 flex-1 truncate text-center text-base font-semibold">{t('search.title')}</h2>
|
||||
<span className="size-10 shrink-0" />
|
||||
</div>
|
||||
<div className="relative mt-2">
|
||||
@@ -85,7 +192,8 @@ export default function AddTitle({
|
||||
type="search"
|
||||
value={query}
|
||||
onChange={(e) => setQuery(e.target.value)}
|
||||
placeholder={t('title.searchPh')}
|
||||
placeholder={social.enabled ? t('search.placeholder') : t('search.placeholderNoMembers')}
|
||||
aria-label={t('search.title')}
|
||||
className="field ps-10"
|
||||
enterKeyHint="search"
|
||||
autoComplete="off"
|
||||
@@ -93,12 +201,20 @@ export default function AddTitle({
|
||||
/>
|
||||
{loading && <Loader2 size={17} className="absolute end-3.5 top-1/2 -translate-y-1/2 animate-spin text-ink-3" />}
|
||||
</div>
|
||||
<div className="no-scrollbar -mx-1 mt-3 flex gap-2 overflow-x-auto px-1" role="tablist">
|
||||
{tabs.map((x) => (
|
||||
<button key={x.id} role="tab" aria-selected={tab === x.id} onClick={() => setTab(x.id)} className={cx('chip shrink-0', tab === x.id && 'chip-on')}>
|
||||
{x.label}
|
||||
{x.n !== undefined && x.n > 0 && <span className="opacity-60">{x.n}</span>}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className="sheet-scroll">
|
||||
<div className="mx-auto max-w-2xl px-4 pb-[calc(10rem+env(safe-area-inset-bottom))] pt-2 lg:max-w-none lg:px-10">
|
||||
{!hasKey && (
|
||||
{!hasKey && (tab === 'all' || tab === 'titles' || tab === 'people') && (
|
||||
<div className="mt-4 rounded-2xl border border-dashed border-line-strong p-4 text-sm text-ink-2">
|
||||
{t('search.animeOnly')}
|
||||
{onGoToSettings && (
|
||||
@@ -109,49 +225,48 @@ export default function AddTitle({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{error && <p className="mt-4 text-sm text-accent">{error}</p>}
|
||||
{!searched && <p className="mt-8 text-center text-sm text-ink-3">{social.enabled ? t('search.hint') : t('search.hintNoMembers')}</p>}
|
||||
|
||||
{results.length > 0 && (
|
||||
<ul className="divide-y divide-line lg:grid lg:grid-cols-2 lg:gap-x-10 lg:divide-y-0 xl:grid-cols-3">
|
||||
{results.map((r) => {
|
||||
const mine = inLibrary(r)
|
||||
return (
|
||||
<li key={r.externalId}>
|
||||
<button onClick={() => (mine ? onOpenItem(mine) : onPick(r))} className="flex w-full items-center gap-3 py-3 text-start active:bg-surface lg:border-b lg:border-line">
|
||||
{r.thumb ? (
|
||||
<img src={r.thumb} alt="" loading="lazy" className="h-[5.25rem] w-14 shrink-0 rounded-lg border border-line bg-surface-2 object-cover" />
|
||||
) : (
|
||||
<span className="grid h-[5.25rem] w-14 shrink-0 place-items-center rounded-lg border border-line bg-surface-2 font-semibold text-ink-3">{r.title.charAt(0)}</span>
|
||||
)}
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate font-semibold">{r.title}</span>
|
||||
{r.originalTitle && <span className="block truncate text-xs text-ink-3">{r.originalTitle}</span>}
|
||||
<span className="mt-1 block text-[11px] uppercase tracking-wide text-ink-3">{[r.year, r.kindLabel].filter(Boolean).join(' · ')}</span>
|
||||
{mine && (
|
||||
<span className="mt-1 inline-flex items-center gap-1 text-xs text-accent">
|
||||
<Check size={12} /> {t('title.inLibrary')}
|
||||
</span>
|
||||
)}
|
||||
</span>
|
||||
<span className="shrink-0 text-accent">→</span>
|
||||
</button>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
</ul>
|
||||
{searched && tab === 'all' && (
|
||||
<>
|
||||
{nothingAtAll && none(t('title.noResults'))}
|
||||
{people.items.length > 0 && section(t('search.tabPeople'), personList(people.items.slice(0, 3)), people.items.length > 3 ? () => setTab('people') : undefined)}
|
||||
{members.items.length > 0 && section(t('search.tabMembers'), memberList(members.items.slice(0, 3)), members.items.length > 3 ? () => setTab('members') : undefined)}
|
||||
{titles.items.length > 0 && section(t('search.tabTitles'), titleList(titles.items))}
|
||||
{errorLine(titles.error)}
|
||||
</>
|
||||
)}
|
||||
{searched && tab === 'titles' && (
|
||||
<>
|
||||
{errorLine(titles.error)}
|
||||
{titleList(titles.items)}
|
||||
{!titles.loading && !titles.error && titles.items.length === 0 && none(t('title.noResults'))}
|
||||
</>
|
||||
)}
|
||||
{searched && tab === 'people' && (
|
||||
<>
|
||||
{errorLine(people.error)}
|
||||
{personList(people.items)}
|
||||
{!people.loading && !people.error && people.items.length === 0 && none(t('search.noPeople'))}
|
||||
</>
|
||||
)}
|
||||
{searched && tab === 'members' && (
|
||||
<>
|
||||
{errorLine(members.error)}
|
||||
{memberList(members.items)}
|
||||
{!members.loading && !members.error && members.items.length === 0 && none(t('search.noMembers'))}
|
||||
</>
|
||||
)}
|
||||
|
||||
{!loading && !error && searched && results.length === 0 && <p className="mt-6 text-center text-sm text-ink-3">{t('title.noResults')}</p>}
|
||||
|
||||
{!searched && <p className="mt-8 text-center text-sm text-ink-3">{t('title.searchHint')}</p>}
|
||||
|
||||
<button onClick={() => onManual(query.trim())} className="mt-8 flex w-full items-center gap-3 rounded-2xl border border-dashed border-line-strong px-4 py-3.5 text-start">
|
||||
<PenLine size={18} className="shrink-0 text-accent" />
|
||||
<span>
|
||||
<span className="block text-sm font-medium">{t('title.manual')}</span>
|
||||
<span className="block text-xs text-ink-3">{t('title.manualHint')}</span>
|
||||
</span>
|
||||
</button>
|
||||
{(tab === 'all' || tab === 'titles') && (
|
||||
<button onClick={() => onManual(query.trim())} className="mt-8 flex w-full items-center gap-3 rounded-2xl border border-dashed border-line-strong px-4 py-3.5 text-start">
|
||||
<PenLine size={18} className="shrink-0 text-accent" />
|
||||
<span>
|
||||
<span className="block text-sm font-medium">{t('title.manual')}</span>
|
||||
<span className="block text-xs text-ink-3">{t('title.manualHint')}</span>
|
||||
</span>
|
||||
</button>
|
||||
)}
|
||||
|
||||
<p className="mt-6 text-center text-[11px] leading-relaxed text-ink-3">{t('search.privacy', { source: hasKey ? 'TMDB / AniList' : 'AniList' })}</p>
|
||||
</div>
|
||||
|
||||
@@ -42,13 +42,15 @@ interface Props {
|
||||
seed?: SearchResult
|
||||
onClose: () => void
|
||||
onGoToSettings?: () => void
|
||||
/** Ouvre la page d'un acteur / réalisateur (sa filmographie) */
|
||||
onOpenPerson?: (p: { id: string; name?: string; photo?: string }) => void
|
||||
}
|
||||
|
||||
/**
|
||||
* Fiche d'un titre, façon Letterboxd : tout se fait ici, et chaque geste est enregistré tout de suite.
|
||||
* Vu / En cours / À voir, note, coup de cœur, avis, épisodes, casting et note moyenne du public.
|
||||
*/
|
||||
export default function TitleSheet({ item: initial, seed, onClose, onGoToSettings }: Props) {
|
||||
export default function TitleSheet({ item: initial, seed, onClose, onGoToSettings, onOpenPerson }: Props) {
|
||||
const { items, settings, add, update, lists, patchMany } = useMedia()
|
||||
const actions = useLibraryActions()
|
||||
const social = useSocial()
|
||||
@@ -339,7 +341,22 @@ export default function TitleSheet({ item: initial, seed, onClose, onGoToSetting
|
||||
{metaLine.length > 0 && <p className="mt-2 text-xs uppercase tracking-wide text-ink-2 lg:text-sm">{metaLine.join(' · ')}</p>}
|
||||
{extras && extras.directors.length > 0 && (
|
||||
<p className="mt-2 text-sm text-ink-2 lg:text-base">
|
||||
{extras.directorKind === 'director' ? t('title.directedBy') : t('title.createdBy')} <span className="font-medium text-ink">{extras.directors.join(', ')}</span>
|
||||
{extras.directorKind === 'director' ? t('title.directedBy') : t('title.createdBy')}{' '}
|
||||
{(extras.directorPeople ?? extras.directors.map((name) => ({ name, personId: undefined }))).map((d, k) => (
|
||||
<span key={d.name}>
|
||||
{k > 0 && ', '}
|
||||
{d.personId && onOpenPerson ? (
|
||||
<button
|
||||
onClick={() => onOpenPerson({ id: d.personId!, name: d.name })}
|
||||
className="font-medium text-ink underline decoration-line-strong underline-offset-4 hover:decoration-accent"
|
||||
>
|
||||
{d.name}
|
||||
</button>
|
||||
) : (
|
||||
<span className="font-medium text-ink">{d.name}</span>
|
||||
)}
|
||||
</span>
|
||||
))}
|
||||
</p>
|
||||
)}
|
||||
{status && (
|
||||
@@ -523,17 +540,25 @@ export default function TitleSheet({ item: initial, seed, onClose, onGoToSetting
|
||||
<section className="mt-8">
|
||||
<h3 className="eyebrow mx-4 mb-3 text-ink-2">{t('title.cast')}</h3>
|
||||
<div className="no-scrollbar flex gap-3 overflow-x-auto px-4 pb-1">
|
||||
{extras.cast.map((c, k) => (
|
||||
<div key={c.name + k} className="w-[5.5rem] shrink-0 text-center">
|
||||
{extras.cast.map((c, k) => {
|
||||
const open = c.personId && onOpenPerson ? () => onOpenPerson({ id: c.personId!, name: c.voice ?? c.name, photo: c.voice ? undefined : c.photo }) : undefined
|
||||
const Tag = open ? 'button' : 'div'
|
||||
return (
|
||||
<Tag
|
||||
key={c.name + k}
|
||||
{...(open ? { onClick: open, type: 'button' as const } : {})}
|
||||
className="group w-[5.5rem] shrink-0 text-center"
|
||||
>
|
||||
{c.photo ? (
|
||||
<img src={c.photo} alt="" loading="lazy" className="mx-auto size-20 rounded-full border border-line bg-surface-2 object-cover" />
|
||||
<img src={c.photo} alt="" loading="lazy" className="mx-auto size-20 rounded-full border border-line bg-surface-2 object-cover transition-colors group-hover:border-accent" />
|
||||
) : (
|
||||
<span className="mx-auto grid size-20 place-items-center rounded-full border border-line bg-surface-2 text-lg font-semibold text-ink-3">{c.name.charAt(0)}</span>
|
||||
<span className="mx-auto grid size-20 place-items-center rounded-full border border-line bg-surface-2 text-lg font-semibold text-ink-3 transition-colors group-hover:border-accent">{c.name.charAt(0)}</span>
|
||||
)}
|
||||
<p className="mt-2 line-clamp-2 text-xs font-medium leading-snug">{c.name}</p>
|
||||
{(c.role || c.voice) && <p className="mt-0.5 line-clamp-2 text-[11px] leading-snug text-ink-3">{c.role ?? t('title.voice', { name: c.voice! })}</p>}
|
||||
</div>
|
||||
))}
|
||||
</Tag>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
|
||||
Reference in new issue
Block a user