correctoipn
deploy / deploy (push) Successful in 32s

This commit is contained in:
Romain committed 2026-10-04 12:44:46 +02:00
1 parent b15207aa88
commit eaad6f1e77
3 files changed
+107 -30

No files matched your search

+1 -2
View File
@@ -88,7 +88,7 @@ export default function EpisodeList({ form, onChange }: Props) {
))} ))}
</select> </select>
) : ( ) : (
<span className="eyebrow">{t('form.episodes')}</span> <span />
)} )}
<span className="flex items-center gap-2 text-xs text-ink-3"> <span className="flex items-center gap-2 text-xs text-ink-3">
{loading && <Loader2 size={13} className="animate-spin" />} {loading && <Loader2 size={13} className="animate-spin" />}
@@ -115,7 +115,6 @@ export default function EpisodeList({ form, onChange }: Props) {
) : ( ) : (
<span className="grid size-full place-items-center text-sm font-semibold text-ink-3">{e.number}</span> <span className="grid size-full place-items-center text-sm font-semibold text-ink-3">{e.number}</span>
)} )}
{seen && <span className="absolute inset-x-0 bottom-0 h-[3px] bg-accent" />}
</span> </span>
<span className="min-w-0 flex-1"> <span className="min-w-0 flex-1">
<span className="block text-[11px] font-medium uppercase tracking-wide text-ink-3"> <span className="block text-[11px] font-medium uppercase tracking-wide text-ink-3">
+83 -7
View File
@@ -1,8 +1,10 @@
import { Check, Info, Plus } from 'lucide-react' import { Check, Info, Plus } from 'lucide-react'
import { useEffect, useRef, useState } from 'react'
import { t } from '../i18n' import { t } from '../i18n'
import { TYPE_BY_VALUE } from '../lib/constants' import { TYPE_BY_VALUE } from '../lib/constants'
import { episodeCap, seasonPosition } from '../lib/franchise' import { episodeCap, seasonPosition } from '../lib/franchise'
import { genreLabel } from '../lib/genres' import { genreLabel } from '../lib/genres'
import { cx } from '../lib/utils'
import { useMedia } from '../store' import { useMedia } from '../store'
import type { MediaItem } from '../types' import type { MediaItem } from '../types'
@@ -16,27 +18,88 @@ export function nextEpisodeLabel(item: MediaItem): string | undefined {
return pos ? `S${pos.season} · ${ep}` : ep return pos ? `S${pos.season} · ${ep}` : ep
} }
/** Grande bannière de l'accueil : le titre que je regarde en ce moment (ou le prochain à voir). */ /** Grande bannière de l'accueil : défile entre les titres que je regarde en ce moment (ou le prochain à voir). */
export default function HomeHero({ item, onOpen }: { item: MediaItem; onOpen: (item: MediaItem) => void }) { export default function HomeHero({ items, onOpen }: { items: MediaItem[]; onOpen: (item: MediaItem) => void }) {
const { incrementEpisode } = useMedia() const { incrementEpisode } = useMedia()
const image = item.backdrop ?? item.poster // On retient le titre affiché (et pas sa position) : la liste se réordonne quand on avance un épisode
const [currentId, setCurrentId] = useState<string>()
const [pausedAt, setPausedAt] = useState(0)
const touchX = useRef<number | null>(null)
const count = items.length
const current = Math.max(0, items.findIndex((i) => i.id === currentId))
const item = items[current]
const latest = useRef(items)
latest.current = items
// Défilement automatique (toutes les 7 s), relancé après chaque action manuelle
useEffect(() => {
if (count < 2) return
const timer = setInterval(() => {
if (document.visibilityState !== 'visible') return
setCurrentId((id) => {
const list = latest.current
const k = Math.max(0, list.findIndex((i) => i.id === id))
return list[(k + 1) % list.length]?.id
})
}, 7000)
return () => clearInterval(timer)
}, [count, pausedAt])
const go = (k: number) => {
setCurrentId(items[((k % count) + count) % count]?.id)
setPausedAt(Date.now())
}
if (!item) return null
const next = nextEpisodeLabel(item) const next = nextEpisodeLabel(item)
const episodic = TYPE_BY_VALUE[item.type].episodic const episodic = TYPE_BY_VALUE[item.type].episodic
const meta = [TYPE_BY_VALUE[item.type].label, item.year, ...item.genres.slice(0, 2).map(genreLabel)].filter(Boolean).join(' · ') const meta = [TYPE_BY_VALUE[item.type].label, item.year, ...item.genres.slice(0, 2).map(genreLabel)].filter(Boolean).join(' · ')
return ( return (
<section className="relative -mx-4 overflow-hidden sm:mx-0 sm:rounded-3xl"> <section
className="relative -mx-4 overflow-hidden sm:mx-0 sm:rounded-3xl"
aria-roledescription="carousel"
onTouchStart={(e) => (touchX.current = e.touches[0].clientX)}
onTouchEnd={(e) => {
const start = touchX.current
touchX.current = null
if (start == null || count < 2) return
const dx = e.changedTouches[0].clientX - start
if (Math.abs(dx) > 45) go(current + (dx < 0 ? 1 : -1))
}}
>
<button onClick={() => onOpen(item)} className="relative block aspect-[4/3] w-full bg-surface-2 sm:aspect-video" aria-label={t('card.open', { title: item.title })}> <button onClick={() => onOpen(item)} className="relative block aspect-[4/3] w-full bg-surface-2 sm:aspect-video" aria-label={t('card.open', { title: item.title })}>
{image && <img src={image} alt="" className={item.backdrop ? 'size-full object-cover' : 'size-full scale-110 object-cover blur-md'} />} {items.map((it, k) => {
const image = it.backdrop ?? it.poster
return image ? (
<img
key={it.id}
src={image}
alt=""
loading={k === 0 ? 'eager' : 'lazy'}
className={cx(
'absolute inset-0 size-full object-cover transition-opacity duration-700',
!it.backdrop && 'scale-110 blur-md',
k === current ? 'opacity-100' : 'opacity-0',
)}
/>
) : null
})}
<span className="absolute inset-0 bg-bg/50" /> <span className="absolute inset-0 bg-bg/50" />
</button> </button>
<div className="pointer-events-none absolute inset-x-0 bottom-0 p-5"> <div className="pointer-events-none absolute inset-x-0 bottom-0 p-5">
<p className="eyebrow text-ink-2">{item.status === 'en_cours' ? t('homeHero.continue') : t('homeHero.next')}</p> <p className="eyebrow text-ink-2">{item.status === 'en_cours' ? t('homeHero.continue') : t('homeHero.next')}</p>
<h2 className="mt-1.5 line-clamp-2 text-[1.9rem] font-bold leading-[1.1]">{item.title}</h2> <h2 className="mt-1.5 line-clamp-2 text-[1.9rem] font-bold leading-[1.1]">{item.title}</h2>
{meta && <p className="mt-1.5 text-xs text-ink-2">{meta}</p>} {meta && <p className="mt-1.5 text-xs text-ink-2">{meta}</p>}
<div className="pointer-events-auto mt-4 flex gap-2"> <div className="pointer-events-auto mt-4 flex items-center gap-2">
{episodic && next ? ( {episodic && next ? (
<button onClick={() => incrementEpisode(item.id)} className="btn btn-primary px-5"> <button
onClick={() => {
setPausedAt(Date.now())
void incrementEpisode(item.id)
}}
className="btn btn-primary px-5"
>
<Plus size={17} strokeWidth={2.5} /> {t('hero.seenEp', { ep: next })} <Plus size={17} strokeWidth={2.5} /> {t('hero.seenEp', { ep: next })}
</button> </button>
) : episodic ? ( ) : episodic ? (
@@ -47,6 +110,19 @@ export default function HomeHero({ item, onOpen }: { item: MediaItem; onOpen: (i
<button onClick={() => onOpen(item)} className="btn btn-ghost bg-bg/60 px-4"> <button onClick={() => onOpen(item)} className="btn btn-ghost bg-bg/60 px-4">
<Info size={17} /> {t('homeHero.details')} <Info size={17} /> {t('homeHero.details')}
</button> </button>
{count > 1 && (
<span className="ml-auto flex items-center gap-1.5">
{items.map((it, k) => (
<button
key={it.id}
onClick={() => go(k)}
className={cx('h-1.5 rounded-full transition-all', k === current ? 'w-5 bg-ink' : 'w-1.5 bg-ink/40')}
aria-label={it.title}
aria-current={k === current}
/>
))}
</span>
)}
</div> </div>
</div> </div>
</section> </section>
+23 -21
View File
@@ -86,7 +86,9 @@ export default function HomePage({ onOpen, onAdd, onNavigate, onRoulette, onCale
const inProgress = items.filter((i) => i.status === 'en_cours') const inProgress = items.filter((i) => i.status === 'en_cours')
// Bannière : ce que je regarde en ce moment (le plus récemment touché), sinon le prochain « à voir » // Bannière : ce que je regarde en ce moment (le plus récemment touché), sinon le prochain « à voir »
const featured = [...inProgress].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))[0] ?? items.find((i) => i.status === 'a_voir') const byRecent = [...inProgress].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt))
const firstToWatch = items.find((i) => i.status === 'a_voir')
const featured = (byRecent.length ? byRecent.slice(0, 8) : firstToWatch ? [firstToWatch] : [])
const toWatch = items.filter((i) => i.status === 'a_voir').slice(0, 12) const toWatch = items.filter((i) => i.status === 'a_voir').slice(0, 12)
const recent = items const recent = items
.filter((i) => i.status === 'termine') .filter((i) => i.status === 'termine')
@@ -140,7 +142,26 @@ export default function HomePage({ onOpen, onAdd, onNavigate, onRoulette, onCale
</> </>
) : ( ) : (
<> <>
{featured && <HomeHero item={featured} onOpen={onOpen} />} {featured.length > 0 && <HomeHero items={featured} onOpen={onOpen} />}
<FriendsFeed />
{/* Roulette : pour les soirs sans idée */}
<button onClick={onRoulette} className="card mt-8 flex w-full items-center gap-4 p-4 text-left transition-colors active:bg-surface-2">
<span className="grid size-12 shrink-0 place-items-center rounded-full bg-accent-fill text-on-accent">
<Dices size={24} />
</span>
<span className="min-w-0 flex-1">
<span className="block font-semibold">
{t('home.noIdea')} <span className="text-accent">{t('roulette.name')}</span>
</span>
<span className="mt-0.5 block text-xs text-ink-3">
{stats.toWatch ? t('home.rouletteHint', { count: stats.toWatch }) : t('home.rouletteHintAll')}
</span>
</span>
<span className="text-accent">→</span>
</button>
{inProgress.length > 0 && ( {inProgress.length > 0 && (
<> <>
@@ -162,25 +183,6 @@ export default function HomePage({ onOpen, onAdd, onNavigate, onRoulette, onCale
</> </>
)} )}
<FriendsFeed />
{/* Roulette : pour les soirs sans idée */}
<button onClick={onRoulette} className="card mt-8 flex w-full items-center gap-4 p-4 text-left transition-colors active:bg-surface-2">
<span className="grid size-12 shrink-0 place-items-center rounded-full bg-accent-fill text-on-accent">
<Dices size={24} />
</span>
<span className="min-w-0 flex-1">
<span className="block font-semibold">
{t('home.noIdea')} <span className="text-accent">{t('roulette.name')}</span>
</span>
<span className="mt-0.5 block text-xs text-ink-3">
{stats.toWatch ? t('home.rouletteHint', { count: stats.toWatch }) : t('home.rouletteHintAll')}
</span>
</span>
<span className="text-accent">→</span>
</button>
<TopFive onOpen={onOpen} /> <TopFive onOpen={onOpen} />
<Recommendations /> <Recommendations />