diff --git a/CLAUDE.md b/CLAUDE.md index b8a902c..4571d5c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -94,3 +94,4 @@ npm run build # build de prod - **Installation iPhone (2 déc. 2026)** : guide « Installer Bobinoo » (`components/InstallGuide.tsx`) : carte masquable sur l'accueil (`azuucine:install-hint`) et section des Réglages, sur les appareils Apple seulement (`lib/install.ts`, `installPlatform()`) : iPhone/iPad (Partager → Sur l'écran d'accueil), Mac + Safari 17+ (Fichier → Ajouter au Dock), Mac + Chrome/Edge (icône d'installation de la barre d'adresse) ; rien sur Firefox, Windows, Android, ni si l'app est déjà installée. Pas de connexion Apple (elle exige un compte Apple Developer payant) : à ajouter seulement si l'app passe sur l'App Store. - **Langue automatique (2 déc. 2026)** : `detectLang()` (`src/i18n/index.ts`) suit la langue du téléphone si Bobinoo la parle (parmi plusieurs, celle du pays du fuseau horaire), sinon l'anglais. Le pays ne s'impose plus (un anglophone à Paris lit en anglais). Le pays sert toujours aux plateformes de streaming et aux sorties (`detectRegion`). Un choix fait à la main dans Réglages → Langue reste prioritaire. - **Recadrage photo de profil / bannière (2 déc. 2026)** : `components/social/ImageCropper.tsx` (glisser, pincer, molette, curseur, flèches du clavier ; l'image couvre toujours le cadre), sortie JPEG sans métadonnées via `cropToJpeg` (`lib/image.ts`) : 400 × 400 pour la photo, 1500 × 500 pour la bannière. Ouvert par `EditProfile` après le choix d'une photo. +- **Bilan de l'année (2 déc. 2026)** : calcul dans `lib/recap.ts` (`yearRecap`, tout sur l'appareil, mêmes chiffres que la page Stats pour l'année), pages type story dans `components/YearRecap.tsx`, entrées dans `components/RecapEntry.tsx` : bouton « Mon année » sur la page Stats (année filtrée, sinon l'année en cours) et carte sur l'accueil en décembre (année en cours) et janvier (année passée) dès 3 titres terminés, masquable (clé `azuucine:recap-hint-`). Image à partager : `renderRecapCard` dans `lib/shareCard.ts`. diff --git a/src/components/RecapEntry.tsx b/src/components/RecapEntry.tsx new file mode 100644 index 0000000..3d961c7 --- /dev/null +++ b/src/components/RecapEntry.tsx @@ -0,0 +1,92 @@ +import { Sparkles, X } from 'lucide-react' +import { lazy, Suspense, useMemo, useState } from 'react' +import { t } from '../i18n' +import { recapSeasonYear, yearRecap } from '../lib/recap' +import type { MediaItem } from '../types' + +// Les pages du bilan ne sont chargées qu'à l'ouverture +const YearRecap = lazy(() => import('./YearRecap')) + +/** Ouvre le bilan d'une année (chargé à la demande). */ +function RecapViewer({ items, year, onClose, onSeeStats }: { items: MediaItem[]; year: string; onClose: () => void; onSeeStats?: () => void }) { + const recap = useMemo(() => yearRecap(items, year), [items, year]) + return ( + + + + ) +} + +/** Bouton « Mon année 2026 » de la page Stats (si l'année a au moins un titre terminé). */ +export function RecapButton({ items, year }: { items: MediaItem[]; year: string }) { + const [open, setOpen] = useState(false) + const finished = useMemo(() => yearRecap(items, year).finished, [items, year]) + if (!finished) return null + return ( + <> + + {open && setOpen(false)} />} + + ) +} + +const hiddenKey = (year: string) => `azuucine:recap-hint-${year}` + +/** + * Carte de l'accueil en décembre (année en cours) et en janvier (année passée), masquable, + * dès que l'année compte au moins 3 titres terminés. + */ +export function RecapHint({ items, onSeeStats }: { items: MediaItem[]; onSeeStats: () => void }) { + const year = recapSeasonYear() + const finished = useMemo(() => (year ? yearRecap(items, year).finished : 0), [items, year]) + const [hidden, setHidden] = useState(() => { + try { + return !!year && localStorage.getItem(hiddenKey(year)) === '1' + } catch { + return false + } + }) + const [open, setOpen] = useState(false) + if (!year || finished < 3 || hidden) return null + + const hide = () => { + setHidden(true) + try { + localStorage.setItem(hiddenKey(year), '1') + } catch { + /* stockage bloqué : la carte reviendra à la prochaine visite */ + } + } + + return ( +
+
+ +
+

{t('recap.homeTitle', { year })}

+

{t('recap.homeText')}

+ +
+ +
+ {open && ( + setOpen(false)} + onSeeStats={() => { + setOpen(false) + onSeeStats() + }} + /> + )} +
+ ) +} diff --git a/src/components/YearRecap.tsx b/src/components/YearRecap.tsx new file mode 100644 index 0000000..f245a60 --- /dev/null +++ b/src/components/YearRecap.tsx @@ -0,0 +1,257 @@ +import { BarChart3, Heart, Share2, X } from 'lucide-react' +import { useEffect, useMemo, useRef, useState, type ReactNode } from 'react' +import { dateFormat, fmtNumber, t } from '../i18n' +import { useBackToClose } from '../lib/backNav' +import { useEscape } from '../lib/escape' +import { genreLabel } from '../lib/genres' +import type { RecapFamily, YearRecap as Recap } from '../lib/recap' +import { useScrollLock } from '../lib/scrollLock' +import { cx, formatRating } from '../lib/utils' +import Poster from './Poster' +import SharePreview from './SharePreview' + +const familyLabel = (f: RecapFamily) => (f === 'autre' ? t('stats.tabOther') : t(`typePlural.${f}`)) + +/** Grand chiffre d'une page (couleur d'accent). */ +function Big({ children }: { children: ReactNode }) { + return

{children}

+} + +/** + * Bilan de l'année, page par page comme une story : toucher à droite pour avancer, à gauche pour revenir, + * glisser, ou les flèches du clavier. La dernière page propose de partager le bilan en image. + */ +export default function YearRecap({ recap, onClose, onSeeStats }: { recap: Recap; onClose: () => void; onSeeStats?: () => void }) { + useScrollLock() + useEscape(onClose) + useBackToClose(onClose) + const [page, setPage] = useState(0) + const [share, setShare] = useState() + const [busy, setBusy] = useState(false) + const down = useRef(null) + + const days = Math.floor(recap.minutes / 1440) + const maxFamily = Math.max(1, ...recap.families.map((f) => f.count)) + const monthName = recap.busiest ? dateFormat({ month: 'long' }).format(new Date(`${recap.busiest.key}-15T12:00:00`)) : '' + + // Pages : seulement celles qui ont quelque chose à montrer + const pages = useMemo(() => { + const list: { key: string; title: string; body: ReactNode }[] = [ + { + key: 'intro', + title: t('recap.introTitle', { year: recap.year }), + body: ( + <> + {fmtNumber(recap.finished)} +

{t('recap.finished', { count: recap.finished })}

+ + ), + }, + ] + if (recap.minutes > 0) + list.push({ + key: 'time', + title: t('recap.timeTitle'), + body: ( + <> + {t('common.hours', { h: fmtNumber(Math.round(recap.minutes / 60)) })} + {days > 0 &&

{`${t('stats.nonStopPre')}${t('stats.days', { count: days })}${t('stats.nonStopPost')}`}

} + {recap.episodes > 0 &&

{t('stats.episodesN', { count: recap.episodes })}

} + + ), + }) + if (recap.families.length) + list.push({ + key: 'types', + title: t('recap.typesTitle'), + body: ( +
    + {recap.families.map((f) => ( +
  • +
    + {familyLabel(f.family)} + {fmtNumber(f.count)} +
    +
    +
    +
    +
  • + ))} +
+ ), + }) + if (recap.genres.length) + list.push({ + key: 'genres', + title: t('recap.genresTitle'), + body: ( + <> +
    + {recap.genres.map((g, k) => ( +
  1. + {genreLabel(g.label)} +
  2. + ))} +
+ {recap.country && ( +

+ {t('recap.topCountry')} · {recap.country.name} +

+ )} + + ), + }) + if (recap.best.length) + list.push({ + key: 'best', + title: t('recap.bestTitle'), + body: ( + <> +
+ {recap.best.map((i) => ( +
+ +
{i.title}
+

{formatRating(i.rating)} ★

+
+ ))} +
+ {recap.favorites > 0 && ( +

+ {t('recap.favorites', { count: recap.favorites })} +

+ )} + + ), + }) + if (recap.busiest || recap.first) + list.push({ + key: 'month', + title: recap.busiest ? t('recap.monthTitle') : t('recap.firstTitle'), + body: ( + <> + {recap.busiest && ( + <> + {monthName.charAt(0).toUpperCase() + monthName.slice(1)} +

{t('stats.monthFinished', { count: recap.busiest.count })}

+ + )} + {recap.first && ( +
+
+ +
+
+ {recap.busiest &&

{t('recap.firstTitle')}

} +

{recap.first.title}

+
+
+ )} + + ), + }) + list.push({ + key: 'end', + title: t('recap.introTitle', { year: recap.year }), + body: ( +
+ + {onSeeStats && ( + + )} +
+ ), + }) + return list + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [recap, busy]) + + const last = pages.length - 1 + const go = (d: number) => setPage((p) => Math.min(last, Math.max(0, p + d))) + + useEffect(() => { + const onKey = (e: KeyboardEvent) => { + if (e.key === 'ArrowRight') go(document.dir === 'rtl' ? -1 : 1) + else if (e.key === 'ArrowLeft') go(document.dir === 'rtl' ? 1 : -1) + } + window.addEventListener('keydown', onKey) + return () => window.removeEventListener('keydown', onKey) + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [last]) + + async function makeShare() { + setBusy(true) + try { + const { renderRecapCard } = await import('../lib/shareCard') + setShare(await renderRecapCard(recap)) + } finally { + setBusy(false) + } + } + + // Toucher : moitié de fin = suivant, début = précédent ; glisser = changer de page + const onPointerDown = (e: React.PointerEvent) => { + down.current = e.clientX + } + const onPointerUp = (e: React.PointerEvent) => { + if (down.current == null) return + const dx = e.clientX - down.current + down.current = null + const rtl = document.dir === 'rtl' + if (Math.abs(dx) > 50) return go((dx < 0) !== rtl ? 1 : -1) + const r = e.currentTarget.getBoundingClientRect() + const atStart = rtl ? e.clientX > r.left + r.width * 0.7 : e.clientX < r.left + r.width * 0.3 + go(atStart ? -1 : 1) + } + + const current = pages[page] + return ( +
+
+
+ {pages.map((p, k) => ( + + ))} +
+
+ + Bobinoo · {recap.year} + + +
+
+ +
+

+ {current.title} +

+
+ {current.body} +
+
+ + {/* Boutons pour le clavier et les lecteurs d'écran (le toucher passe par la zone au-dessus) */} +
+ + +
+ + {share && setShare(undefined)} />} +
+ ) +} diff --git a/src/i18n/locales/ar.ts b/src/i18n/locales/ar.ts index dbeb0f7..7bf2ead 100644 --- a/src/i18n/locales/ar.ts +++ b/src/i18n/locales/ar.ts @@ -1198,6 +1198,34 @@ const dict: Translations = { "crop.hint": "اسحب لتحريك الصورة. استخدم إصبعين أو شريط التمرير للتكبير.", "crop.zoom": "تكبير", "crop.apply": "تم", + "recap.cta": "سنتي {year}", + "recap.homeTitle": "ملخص سنتك {year} جاهز", + "recap.homeText": "أفلامك ومسلسلاتك وأنميك لهذا العام، في بضع شاشات للمشاركة.", + "recap.open": "عرض الملخص", + "recap.introTitle": "سنتك {year}", + "recap.finished_one": "عمل واحد مكتمل", + "recap.finished_two": "عملان مكتملان", + "recap.finished_few": "{count} أعمال مكتملة", + "recap.finished_many": "{count} عملًا مكتملًا", + "recap.finished_other": "{count} عمل مكتمل", + "recap.timeTitle": "أمام الشاشة", + "recap.typesTitle": "ما شاهدته", + "recap.genresTitle": "أنواعك المفضلة", + "recap.topCountry": "البلد الأكثر مشاهدة", + "recap.bestTitle": "الأعلى تقييمًا لديك", + "recap.favorites_one": "عمل مفضل واحد هذا العام", + "recap.favorites_two": "عملان مفضلان هذا العام", + "recap.favorites_few": "{count} أعمال مفضلة هذا العام", + "recap.favorites_many": "{count} عملًا مفضلًا هذا العام", + "recap.favorites_other": "{count} عمل مفضل هذا العام", + "recap.monthTitle": "أكثر شهر مشاهدة", + "recap.firstTitle": "أول عمل أكملته هذا العام", + "recap.share": "شارك ملخصي", + "recap.seeStats": "عرض كل الإحصائيات", + "recap.next": "التالي", + "recap.prev": "السابق", + "recap.cardTitle": "سنتي", + "recap.shareTitle": "سنتي {year} على Bobinoo", } export default dict diff --git a/src/i18n/locales/de.ts b/src/i18n/locales/de.ts index bf69ea8..00449f8 100644 --- a/src/i18n/locales/de.ts +++ b/src/i18n/locales/de.ts @@ -1049,6 +1049,28 @@ const dict: Translations = { "crop.hint": "Zieh das Bild, um es zu verschieben. Zum Zoomen die Finger spreizen oder den Regler nutzen.", "crop.zoom": "Zoom", "crop.apply": "Fertig", + "recap.cta": "Mein Jahr {year}", + "recap.homeTitle": "Dein Jahresrückblick {year} ist da", + "recap.homeText": "Deine Filme, Serien und Animes des Jahres, in ein paar Bildern zum Teilen.", + "recap.open": "Rückblick ansehen", + "recap.introTitle": "Dein Jahr {year}", + "recap.finished_one": "{count} Titel beendet", + "recap.finished_other": "{count} Titel beendet", + "recap.timeTitle": "Vor dem Bildschirm", + "recap.typesTitle": "Was du geschaut hast", + "recap.genresTitle": "Deine Lieblingsgenres", + "recap.topCountry": "Meistgeschautes Land", + "recap.bestTitle": "Deine bestbewerteten", + "recap.favorites_one": "{count} Favorit in diesem Jahr", + "recap.favorites_other": "{count} Favoriten in diesem Jahr", + "recap.monthTitle": "Dein aktivster Monat", + "recap.firstTitle": "Dein erster beendeter Titel des Jahres", + "recap.share": "Rückblick teilen", + "recap.seeStats": "Alle Statistiken ansehen", + "recap.next": "Weiter", + "recap.prev": "Zurück", + "recap.cardTitle": "Mein Jahr", + "recap.shareTitle": "Mein Jahr {year} auf Bobinoo", } export default dict diff --git a/src/i18n/locales/en.ts b/src/i18n/locales/en.ts index 7cc0afb..af5fd1a 100644 --- a/src/i18n/locales/en.ts +++ b/src/i18n/locales/en.ts @@ -1049,6 +1049,28 @@ const dict: Translations = { "crop.hint": "Drag to move the image. Pinch or use the slider to zoom.", "crop.zoom": "Zoom", "crop.apply": "Done", + "recap.cta": "My {year} in review", + "recap.homeTitle": "Your {year} in review is ready", + "recap.homeText": "Your films, series and anime of the year, in a few screens to share.", + "recap.open": "See my year", + "recap.introTitle": "Your {year}", + "recap.finished_one": "{count} title finished", + "recap.finished_other": "{count} titles finished", + "recap.timeTitle": "Screen time", + "recap.typesTitle": "What you watched", + "recap.genresTitle": "Your favorite genres", + "recap.topCountry": "Most watched country", + "recap.bestTitle": "Your top rated", + "recap.favorites_one": "{count} favorite this year", + "recap.favorites_other": "{count} favorites this year", + "recap.monthTitle": "Your busiest month", + "recap.firstTitle": "Your first title finished this year", + "recap.share": "Share my year", + "recap.seeStats": "See all my stats", + "recap.next": "Next", + "recap.prev": "Previous", + "recap.cardTitle": "My year", + "recap.shareTitle": "My {year} on Bobinoo", } export default dict diff --git a/src/i18n/locales/es.ts b/src/i18n/locales/es.ts index d158434..def76c5 100644 --- a/src/i18n/locales/es.ts +++ b/src/i18n/locales/es.ts @@ -1049,6 +1049,28 @@ const dict: Translations = { "crop.hint": "Arrastra para mover la imagen. Pellizca o usa el control deslizante para hacer zoom.", "crop.zoom": "Zoom", "crop.apply": "Listo", + "recap.cta": "Mi año {year}", + "recap.homeTitle": "Tu resumen de {year} está listo", + "recap.homeText": "Tus películas, series y animes del año, en unas pantallas para compartir.", + "recap.open": "Ver mi resumen", + "recap.introTitle": "Tu año {year}", + "recap.finished_one": "{count} título terminado", + "recap.finished_other": "{count} títulos terminados", + "recap.timeTitle": "Frente a la pantalla", + "recap.typesTitle": "Lo que viste", + "recap.genresTitle": "Tus géneros favoritos", + "recap.topCountry": "País que más viste", + "recap.bestTitle": "Tus mejor valorados", + "recap.favorites_one": "{count} favorito este año", + "recap.favorites_other": "{count} favoritos este año", + "recap.monthTitle": "Tu mes más activo", + "recap.firstTitle": "Tu primer título terminado del año", + "recap.share": "Compartir mi resumen", + "recap.seeStats": "Ver todas mis estadísticas", + "recap.next": "Siguiente", + "recap.prev": "Anterior", + "recap.cardTitle": "Mi año", + "recap.shareTitle": "Mi {year} en Bobinoo", } export default dict diff --git a/src/i18n/locales/fr.ts b/src/i18n/locales/fr.ts index 632282c..f947343 100644 --- a/src/i18n/locales/fr.ts +++ b/src/i18n/locales/fr.ts @@ -1051,6 +1051,28 @@ const dict = { "crop.hint": "Fais glisser pour déplacer l'image. Pince ou utilise le curseur pour zoomer.", "crop.zoom": "Zoom", "crop.apply": "Valider", + "recap.cta": "Mon année {year}", + "recap.homeTitle": "Ton bilan {year} est prêt", + "recap.homeText": "Tes films, séries et animes de l'année, en quelques écrans à partager.", + "recap.open": "Voir mon bilan", + "recap.introTitle": "Ton année {year}", + "recap.finished_one": "{count} titre terminé", + "recap.finished_other": "{count} titres terminés", + "recap.timeTitle": "Devant l'écran", + "recap.typesTitle": "Ce que tu as regardé", + "recap.genresTitle": "Tes genres préférés", + "recap.topCountry": "Pays le plus regardé", + "recap.bestTitle": "Tes mieux notés", + "recap.favorites_one": "{count} coup de cœur cette année", + "recap.favorites_other": "{count} coups de cœur cette année", + "recap.monthTitle": "Ton mois le plus chargé", + "recap.firstTitle": "Ton premier titre terminé de l'année", + "recap.share": "Partager mon bilan", + "recap.seeStats": "Voir toutes mes stats", + "recap.next": "Suivant", + "recap.prev": "Précédent", + "recap.cardTitle": "Mon année", + "recap.shareTitle": "Mon année {year} sur Bobinoo", } export default dict diff --git a/src/i18n/locales/hi.ts b/src/i18n/locales/hi.ts index 2d85361..94f73c4 100644 --- a/src/i18n/locales/hi.ts +++ b/src/i18n/locales/hi.ts @@ -1049,6 +1049,28 @@ const dict: Translations = { "crop.hint": "इमेज खिसकाने के लिए खींचें। ज़ूम के लिए पिंच करें या स्लाइडर का इस्तेमाल करें।", "crop.zoom": "ज़ूम", "crop.apply": "हो गया", + "recap.cta": "मेरा {year}", + "recap.homeTitle": "आपका {year} का सारांश तैयार है", + "recap.homeText": "इस साल की आपकी फ़िल्में, सीरीज़ और ऐनिमे, शेयर करने लायक कुछ स्क्रीन में।", + "recap.open": "सारांश देखें", + "recap.introTitle": "आपका {year}", + "recap.finished_one": "{count} टाइटल पूरा किया", + "recap.finished_other": "{count} टाइटल पूरे किए", + "recap.timeTitle": "स्क्रीन के सामने", + "recap.typesTitle": "आपने क्या देखा", + "recap.genresTitle": "आपकी पसंदीदा शैलियाँ", + "recap.topCountry": "सबसे ज़्यादा देखा गया देश", + "recap.bestTitle": "आपकी सबसे ऊँची रेटिंग वाले", + "recap.favorites_one": "इस साल {count} पसंदीदा", + "recap.favorites_other": "इस साल {count} पसंदीदा", + "recap.monthTitle": "सबसे व्यस्त महीना", + "recap.firstTitle": "इस साल पूरा किया पहला टाइटल", + "recap.share": "सारांश शेयर करें", + "recap.seeStats": "सारे आँकड़े देखें", + "recap.next": "आगे", + "recap.prev": "पीछे", + "recap.cardTitle": "मेरा साल", + "recap.shareTitle": "Bobinoo पर मेरा {year}", } export default dict diff --git a/src/i18n/locales/id.ts b/src/i18n/locales/id.ts index 2cd9acf..2ea9859 100644 --- a/src/i18n/locales/id.ts +++ b/src/i18n/locales/id.ts @@ -1049,6 +1049,28 @@ const dict: Translations = { "crop.hint": "Seret untuk menggeser gambar. Cubit atau gunakan penggeser untuk zoom.", "crop.zoom": "Zoom", "crop.apply": "Selesai", + "recap.cta": "Tahun {year}-ku", + "recap.homeTitle": "Rangkuman {year}-mu sudah siap", + "recap.homeText": "Film, serial, dan anime tahun ini, dalam beberapa layar untuk dibagikan.", + "recap.open": "Lihat rangkumanku", + "recap.introTitle": "Tahun {year}-mu", + "recap.finished_one": "{count} judul selesai", + "recap.finished_other": "{count} judul selesai", + "recap.timeTitle": "Di depan layar", + "recap.typesTitle": "Yang kamu tonton", + "recap.genresTitle": "Genre favoritmu", + "recap.topCountry": "Negara paling sering ditonton", + "recap.bestTitle": "Nilai tertinggimu", + "recap.favorites_one": "{count} favorit tahun ini", + "recap.favorites_other": "{count} favorit tahun ini", + "recap.monthTitle": "Bulan tersibukmu", + "recap.firstTitle": "Judul pertama yang kamu selesaikan tahun ini", + "recap.share": "Bagikan rangkumanku", + "recap.seeStats": "Lihat semua statistik", + "recap.next": "Berikutnya", + "recap.prev": "Sebelumnya", + "recap.cardTitle": "Tahunku", + "recap.shareTitle": "Tahun {year}-ku di Bobinoo", } export default dict diff --git a/src/i18n/locales/it.ts b/src/i18n/locales/it.ts index 5e938a4..c057417 100644 --- a/src/i18n/locales/it.ts +++ b/src/i18n/locales/it.ts @@ -1049,6 +1049,28 @@ const dict: Translations = { "crop.hint": "Trascina per spostare l’immagine. Pizzica o usa il cursore per lo zoom.", "crop.zoom": "Zoom", "crop.apply": "Fatto", + "recap.cta": "Il mio {year}", + "recap.homeTitle": "Il tuo riepilogo {year} è pronto", + "recap.homeText": "I tuoi film, serie e anime dell’anno, in poche schermate da condividere.", + "recap.open": "Guarda il riepilogo", + "recap.introTitle": "Il tuo {year}", + "recap.finished_one": "{count} titolo finito", + "recap.finished_other": "{count} titoli finiti", + "recap.timeTitle": "Davanti allo schermo", + "recap.typesTitle": "Cosa hai guardato", + "recap.genresTitle": "I tuoi generi preferiti", + "recap.topCountry": "Paese più visto", + "recap.bestTitle": "I tuoi più votati", + "recap.favorites_one": "{count} preferito quest’anno", + "recap.favorites_other": "{count} preferiti quest’anno", + "recap.monthTitle": "Il tuo mese più intenso", + "recap.firstTitle": "Il primo titolo finito dell’anno", + "recap.share": "Condividi il riepilogo", + "recap.seeStats": "Vedi tutte le statistiche", + "recap.next": "Avanti", + "recap.prev": "Indietro", + "recap.cardTitle": "Il mio anno", + "recap.shareTitle": "Il mio {year} su Bobinoo", } export default dict diff --git a/src/i18n/locales/ja.ts b/src/i18n/locales/ja.ts index 3beb101..95f88cd 100644 --- a/src/i18n/locales/ja.ts +++ b/src/i18n/locales/ja.ts @@ -1049,6 +1049,28 @@ const dict: Translations = { "crop.hint": "ドラッグで画像を移動、ピンチまたはスライダーで拡大・縮小できます。", "crop.zoom": "ズーム", "crop.apply": "完了", + "recap.cta": "わたしの{year}年", + "recap.homeTitle": "{year}年のまとめができました", + "recap.homeText": "今年見た映画・ドラマ・アニメを、シェアできる数枚の画面でふり返ります。", + "recap.open": "まとめを見る", + "recap.introTitle": "あなたの{year}年", + "recap.finished_one": "{count}作品を見終わりました", + "recap.finished_other": "{count}作品を見終わりました", + "recap.timeTitle": "視聴時間", + "recap.typesTitle": "見たもの", + "recap.genresTitle": "好きなジャンル", + "recap.topCountry": "いちばん見た国", + "recap.bestTitle": "高評価の作品", + "recap.favorites_one": "今年のお気に入り {count}作品", + "recap.favorites_other": "今年のお気に入り {count}作品", + "recap.monthTitle": "いちばん見た月", + "recap.firstTitle": "今年最初に見終わった作品", + "recap.share": "まとめをシェア", + "recap.seeStats": "統計をすべて見る", + "recap.next": "次へ", + "recap.prev": "前へ", + "recap.cardTitle": "わたしの1年", + "recap.shareTitle": "Bobinoo でふり返る{year}年", } export default dict diff --git a/src/i18n/locales/ko.ts b/src/i18n/locales/ko.ts index 525116f..47aeac5 100644 --- a/src/i18n/locales/ko.ts +++ b/src/i18n/locales/ko.ts @@ -1049,6 +1049,28 @@ const dict: Translations = { "crop.hint": "드래그해서 이미지를 옮기고, 핀치하거나 슬라이더로 확대해요.", "crop.zoom": "확대", "crop.apply": "완료", + "recap.cta": "나의 {year}년", + "recap.homeTitle": "{year}년 결산이 준비됐어요", + "recap.homeText": "올해 본 영화, 시리즈, 애니를 공유할 수 있는 몇 장의 화면으로 돌아봐요.", + "recap.open": "결산 보기", + "recap.introTitle": "당신의 {year}년", + "recap.finished_one": "{count}개 작품 완료", + "recap.finished_other": "{count}개 작품 완료", + "recap.timeTitle": "시청 시간", + "recap.typesTitle": "올해 본 것", + "recap.genresTitle": "좋아하는 장르", + "recap.topCountry": "가장 많이 본 나라", + "recap.bestTitle": "가장 높게 평가한 작품", + "recap.favorites_one": "올해의 최애 {count}개", + "recap.favorites_other": "올해의 최애 {count}개", + "recap.monthTitle": "가장 많이 본 달", + "recap.firstTitle": "올해 처음으로 다 본 작품", + "recap.share": "결산 공유하기", + "recap.seeStats": "통계 모두 보기", + "recap.next": "다음", + "recap.prev": "이전", + "recap.cardTitle": "나의 한 해", + "recap.shareTitle": "Bobinoo로 돌아본 나의 {year}년", } export default dict diff --git a/src/i18n/locales/nl.ts b/src/i18n/locales/nl.ts index 2ebd5a0..6a84aa7 100644 --- a/src/i18n/locales/nl.ts +++ b/src/i18n/locales/nl.ts @@ -1049,6 +1049,28 @@ const dict: Translations = { "crop.hint": "Sleep om de afbeelding te verplaatsen. Knijp of gebruik de schuifregelaar om te zoomen.", "crop.zoom": "Zoom", "crop.apply": "Klaar", + "recap.cta": "Mijn {year}", + "recap.homeTitle": "Je jaaroverzicht {year} staat klaar", + "recap.homeText": "Je films, series en anime van het jaar, in een paar schermen om te delen.", + "recap.open": "Bekijk mijn overzicht", + "recap.introTitle": "Jouw {year}", + "recap.finished_one": "{count} titel uitgekeken", + "recap.finished_other": "{count} titels uitgekeken", + "recap.timeTitle": "Voor het scherm", + "recap.typesTitle": "Wat je keek", + "recap.genresTitle": "Je favoriete genres", + "recap.topCountry": "Meest bekeken land", + "recap.bestTitle": "Je best beoordeelde", + "recap.favorites_one": "{count} favoriet dit jaar", + "recap.favorites_other": "{count} favorieten dit jaar", + "recap.monthTitle": "Je drukste maand", + "recap.firstTitle": "Je eerste uitgekeken titel van het jaar", + "recap.share": "Deel mijn overzicht", + "recap.seeStats": "Bekijk al mijn statistieken", + "recap.next": "Volgende", + "recap.prev": "Vorige", + "recap.cardTitle": "Mijn jaar", + "recap.shareTitle": "Mijn {year} op Bobinoo", } export default dict diff --git a/src/i18n/locales/pl.ts b/src/i18n/locales/pl.ts index 89675da..b8db767 100644 --- a/src/i18n/locales/pl.ts +++ b/src/i18n/locales/pl.ts @@ -1147,6 +1147,32 @@ const dict: Translations = { "crop.hint": "Przeciągnij, aby przesunąć obraz. Uszczypnij lub użyj suwaka, aby powiększyć.", "crop.zoom": "Powiększenie", "crop.apply": "Gotowe", + "recap.cta": "Mój rok {year}", + "recap.homeTitle": "Twoje podsumowanie {year} jest gotowe", + "recap.homeText": "Twoje filmy, seriale i anime z tego roku, na kilku ekranach do udostępnienia.", + "recap.open": "Zobacz podsumowanie", + "recap.introTitle": "Twój rok {year}", + "recap.finished_one": "{count} ukończony tytuł", + "recap.finished_few": "{count} ukończone tytuły", + "recap.finished_many": "{count} ukończonych tytułów", + "recap.finished_other": "{count} ukończonego tytułu", + "recap.timeTitle": "Przed ekranem", + "recap.typesTitle": "Twoje seanse", + "recap.genresTitle": "Twoje ulubione gatunki", + "recap.topCountry": "Najczęściej oglądany kraj", + "recap.bestTitle": "Najwyżej ocenione", + "recap.favorites_one": "{count} ulubiony w tym roku", + "recap.favorites_few": "{count} ulubione w tym roku", + "recap.favorites_many": "{count} ulubionych w tym roku", + "recap.favorites_other": "{count} ulubionego w tym roku", + "recap.monthTitle": "Twój najaktywniejszy miesiąc", + "recap.firstTitle": "Pierwszy ukończony tytuł roku", + "recap.share": "Udostępnij podsumowanie", + "recap.seeStats": "Zobacz wszystkie statystyki", + "recap.next": "Dalej", + "recap.prev": "Wstecz", + "recap.cardTitle": "Mój rok", + "recap.shareTitle": "Mój rok {year} w Bobinoo", } export default dict diff --git a/src/i18n/locales/pt.ts b/src/i18n/locales/pt.ts index f482d75..68aeb11 100644 --- a/src/i18n/locales/pt.ts +++ b/src/i18n/locales/pt.ts @@ -1049,6 +1049,28 @@ const dict: Translations = { "crop.hint": "Arraste para mover a imagem. Use o gesto de pinça ou o controle deslizante para dar zoom.", "crop.zoom": "Zoom", "crop.apply": "Concluir", + "recap.cta": "Meu {year}", + "recap.homeTitle": "Sua retrospectiva {year} está pronta", + "recap.homeText": "Seus filmes, séries e animes do ano, em poucas telas para compartilhar.", + "recap.open": "Ver minha retrospectiva", + "recap.introTitle": "Seu {year}", + "recap.finished_one": "{count} título concluído", + "recap.finished_other": "{count} títulos concluídos", + "recap.timeTitle": "Na frente da tela", + "recap.typesTitle": "O que você assistiu", + "recap.genresTitle": "Seus gêneros favoritos", + "recap.topCountry": "País mais assistido", + "recap.bestTitle": "Seus mais bem avaliados", + "recap.favorites_one": "{count} favorito este ano", + "recap.favorites_other": "{count} favoritos este ano", + "recap.monthTitle": "Seu mês mais movimentado", + "recap.firstTitle": "Seu primeiro título concluído do ano", + "recap.share": "Compartilhar retrospectiva", + "recap.seeStats": "Ver todas as estatísticas", + "recap.next": "Próximo", + "recap.prev": "Anterior", + "recap.cardTitle": "Meu ano", + "recap.shareTitle": "Meu {year} no Bobinoo", } export default dict diff --git a/src/i18n/locales/ru.ts b/src/i18n/locales/ru.ts index 42af1b8..c84cdbe 100644 --- a/src/i18n/locales/ru.ts +++ b/src/i18n/locales/ru.ts @@ -1147,6 +1147,32 @@ const dict: Translations = { "crop.hint": "Перетаскивай, чтобы сдвинуть изображение. Сведи или разведи пальцы либо используй ползунок для масштаба.", "crop.zoom": "Масштаб", "crop.apply": "Готово", + "recap.cta": "Мой {year} год", + "recap.homeTitle": "Твои итоги {year} готовы", + "recap.homeText": "Твои фильмы, сериалы и аниме за год на нескольких экранах, которыми можно поделиться.", + "recap.open": "Смотреть итоги", + "recap.introTitle": "Твой {year} год", + "recap.finished_one": "{count} тайтл просмотрен", + "recap.finished_few": "{count} тайтла просмотрено", + "recap.finished_many": "{count} тайтлов просмотрено", + "recap.finished_other": "{count} тайтла просмотрено", + "recap.timeTitle": "Перед экраном", + "recap.typesTitle": "Твои просмотры", + "recap.genresTitle": "Любимые жанры", + "recap.topCountry": "Самая просматриваемая страна", + "recap.bestTitle": "Лучшие по твоим оценкам", + "recap.favorites_one": "{count} любимый тайтл за год", + "recap.favorites_few": "{count} любимых тайтла за год", + "recap.favorites_many": "{count} любимых тайтлов за год", + "recap.favorites_other": "{count} любимого тайтла за год", + "recap.monthTitle": "Самый насыщенный месяц", + "recap.firstTitle": "Первый просмотренный тайтл года", + "recap.share": "Поделиться итогами", + "recap.seeStats": "Вся статистика", + "recap.next": "Далее", + "recap.prev": "Назад", + "recap.cardTitle": "Мой год", + "recap.shareTitle": "Мой {year} год в Bobinoo", } export default dict diff --git a/src/i18n/locales/th.ts b/src/i18n/locales/th.ts index d5cd3d1..61cc00d 100644 --- a/src/i18n/locales/th.ts +++ b/src/i18n/locales/th.ts @@ -1049,6 +1049,28 @@ const dict: Translations = { "crop.hint": "ลากเพื่อเลื่อนภาพ ใช้สองนิ้วหรือแถบเลื่อนเพื่อซูม", "crop.zoom": "ซูม", "crop.apply": "เสร็จ", + "recap.cta": "ปี {year} ของฉัน", + "recap.homeTitle": "สรุปปี {year} ของคุณพร้อมแล้ว", + "recap.homeText": "หนัง ซีรีส์ และอนิเมะของคุณในปีนี้ ในไม่กี่หน้าที่แชร์ได้", + "recap.open": "ดูสรุปของฉัน", + "recap.introTitle": "ปี {year} ของคุณ", + "recap.finished_one": "ดูจบ {count} เรื่อง", + "recap.finished_other": "ดูจบ {count} เรื่อง", + "recap.timeTitle": "เวลาหน้าจอ", + "recap.typesTitle": "สิ่งที่คุณดู", + "recap.genresTitle": "แนวที่คุณชอบ", + "recap.topCountry": "ประเทศที่ดูมากที่สุด", + "recap.bestTitle": "เรื่องที่คุณให้คะแนนสูงสุด", + "recap.favorites_one": "เรื่องโปรด {count} เรื่องในปีนี้", + "recap.favorites_other": "เรื่องโปรด {count} เรื่องในปีนี้", + "recap.monthTitle": "เดือนที่ดูมากที่สุด", + "recap.firstTitle": "เรื่องแรกที่ดูจบในปีนี้", + "recap.share": "แชร์สรุปของฉัน", + "recap.seeStats": "ดูสถิติทั้งหมด", + "recap.next": "ถัดไป", + "recap.prev": "ก่อนหน้า", + "recap.cardTitle": "ปีของฉัน", + "recap.shareTitle": "ปี {year} ของฉันบน Bobinoo", } export default dict diff --git a/src/i18n/locales/tr.ts b/src/i18n/locales/tr.ts index 0600860..a198422 100644 --- a/src/i18n/locales/tr.ts +++ b/src/i18n/locales/tr.ts @@ -1049,6 +1049,28 @@ const dict: Translations = { "crop.hint": "Görseli taşımak için sürükle. Yakınlaştırmak için iki parmağını kullan ya da kaydırıcıyı sürükle.", "crop.zoom": "Yakınlaştırma", "crop.apply": "Tamam", + "recap.cta": "{year} yılım", + "recap.homeTitle": "{year} özetin hazır", + "recap.homeText": "Yılın filmleri, dizileri ve animeleri, paylaşabileceğin birkaç ekranda.", + "recap.open": "Özetimi gör", + "recap.introTitle": "{year} yılın", + "recap.finished_one": "{count} yapım bitti", + "recap.finished_other": "{count} yapım bitti", + "recap.timeTitle": "Ekran başında", + "recap.typesTitle": "Neler izledin", + "recap.genresTitle": "En sevdiğin türler", + "recap.topCountry": "En çok izlediğin ülke", + "recap.bestTitle": "En yüksek puan verdiklerin", + "recap.favorites_one": "Bu yıl {count} favori", + "recap.favorites_other": "Bu yıl {count} favori", + "recap.monthTitle": "En yoğun ayın", + "recap.firstTitle": "Yılın ilk bitirdiğin yapımı", + "recap.share": "Özetimi paylaş", + "recap.seeStats": "Tüm istatistiklerim", + "recap.next": "İleri", + "recap.prev": "Geri", + "recap.cardTitle": "Yılım", + "recap.shareTitle": "Bobinoo’da {year} yılım", } export default dict diff --git a/src/i18n/locales/vi.ts b/src/i18n/locales/vi.ts index 8367377..a7e861a 100644 --- a/src/i18n/locales/vi.ts +++ b/src/i18n/locales/vi.ts @@ -1049,6 +1049,28 @@ const dict: Translations = { "crop.hint": "Kéo để di chuyển ảnh. Chụm hai ngón tay hoặc dùng thanh trượt để thu phóng.", "crop.zoom": "Thu phóng", "crop.apply": "Xong", + "recap.cta": "Năm {year} của tôi", + "recap.homeTitle": "Tổng kết năm {year} của bạn đã sẵn sàng", + "recap.homeText": "Phim lẻ, phim bộ và anime của bạn trong năm, gói gọn trong vài màn hình để chia sẻ.", + "recap.open": "Xem tổng kết", + "recap.introTitle": "Năm {year} của bạn", + "recap.finished_one": "Đã xem xong {count} tựa", + "recap.finished_other": "Đã xem xong {count} tựa", + "recap.timeTitle": "Trước màn hình", + "recap.typesTitle": "Bạn đã xem gì", + "recap.genresTitle": "Thể loại yêu thích", + "recap.topCountry": "Quốc gia xem nhiều nhất", + "recap.bestTitle": "Được bạn chấm cao nhất", + "recap.favorites_one": "{count} tựa yêu thích năm nay", + "recap.favorites_other": "{count} tựa yêu thích năm nay", + "recap.monthTitle": "Tháng xem nhiều nhất", + "recap.firstTitle": "Tựa đầu tiên bạn xem xong trong năm", + "recap.share": "Chia sẻ tổng kết", + "recap.seeStats": "Xem toàn bộ thống kê", + "recap.next": "Tiếp", + "recap.prev": "Trước", + "recap.cardTitle": "Năm của tôi", + "recap.shareTitle": "Năm {year} của tôi trên Bobinoo", } export default dict diff --git a/src/i18n/locales/zh.ts b/src/i18n/locales/zh.ts index 0fd26f6..c4e0611 100644 --- a/src/i18n/locales/zh.ts +++ b/src/i18n/locales/zh.ts @@ -1049,6 +1049,28 @@ const dict: Translations = { "crop.hint": "拖动以移动图片,双指或滑块可以缩放。", "crop.zoom": "缩放", "crop.apply": "完成", + "recap.cta": "我的 {year} 年", + "recap.homeTitle": "你的 {year} 年度回顾已生成", + "recap.homeText": "用几页可分享的画面,回顾你今年看过的电影、剧集和动画。", + "recap.open": "查看年度回顾", + "recap.introTitle": "你的 {year} 年", + "recap.finished_one": "看完 {count} 部作品", + "recap.finished_other": "看完 {count} 部作品", + "recap.timeTitle": "观看时长", + "recap.typesTitle": "你看了什么", + "recap.genresTitle": "最爱的类型", + "recap.topCountry": "看得最多的国家/地区", + "recap.bestTitle": "你评分最高的作品", + "recap.favorites_one": "今年 {count} 部最爱", + "recap.favorites_other": "今年 {count} 部最爱", + "recap.monthTitle": "看得最多的月份", + "recap.firstTitle": "今年看完的第一部作品", + "recap.share": "分享年度回顾", + "recap.seeStats": "查看全部统计", + "recap.next": "下一页", + "recap.prev": "上一页", + "recap.cardTitle": "我的一年", + "recap.shareTitle": "我在 Bobinoo 的 {year} 年", } export default dict diff --git a/src/lib/recap.ts b/src/lib/recap.ts new file mode 100644 index 0000000..b10ec56 --- /dev/null +++ b/src/lib/recap.ts @@ -0,0 +1,72 @@ +import type { MediaItem, MediaType } from '../types' +import { computeStats, countries, itemsForPeriod, monthly, watchDate, type CountryCount, type MonthBucket } from './stats' + +/** Grandes familles du bilan (les dramas coréens et chinois comptent avec les séries, comme dans les stats). */ +export type RecapFamily = 'film' | 'serie' | 'anime' | 'autre' +const FAMILY: Record = { film: 'film', serie: 'serie', kdrama: 'serie', cdrama: 'serie', anime: 'anime', autre: 'autre' } + +export interface YearRecap { + year: string + /** Titres terminés dans l'année */ + finished: number + /** Temps passé, en minutes (même calcul que la page Stats pour l'année) */ + minutes: number + episodes: number + avgRating?: number + /** Titres terminés par famille, dans l'ordre film, série, anime, autre (familles vides retirées) */ + families: { family: RecapFamily; count: number }[] + /** Genres les plus vus (3 au plus) */ + genres: { label: string; value: number }[] + country?: CountryCount + /** Mieux notés de l'année (3 au plus), du meilleur au moins bon */ + best: MediaItem[] + favorites: number + /** Mois avec le plus de titres terminés (seulement s'il sort du lot) */ + busiest?: MonthBucket + /** Premier titre terminé de l'année */ + first?: MediaItem +} + +/** Bilan d'une année à partir de la bibliothèque (rien n'est envoyé : tout est calculé sur l'appareil). */ +export function yearRecap(items: MediaItem[], year: string): YearRecap { + const list = itemsForPeriod(items, year) + const done = list.filter((i) => i.status === 'termine') + const stats = computeStats(list) + + const families: Record = { film: 0, serie: 0, anime: 0, autre: 0 } + for (const i of done) families[FAMILY[i.type]]++ + + const byDate = (i: MediaItem) => watchDate(i) ?? '' + const best = done + .filter((i) => (i.rating ?? 0) > 0) + .sort((a, b) => (b.rating ?? 0) - (a.rating ?? 0) || byDate(b).localeCompare(byDate(a))) + .slice(0, 3) + + const months = monthly(list, year).sort((a, b) => b.count - a.count) + const busiest = months[0] && months[0].count > (months[1]?.count ?? 0) ? months[0] : undefined + + return { + year, + finished: done.length, + minutes: stats.totalMinutes, + episodes: stats.episodesWatched, + avgRating: stats.avgRating, + families: (Object.keys(families) as RecapFamily[]).filter((f) => families[f] > 0).map((family) => ({ family, count: families[family] })), + genres: stats.topGenres.slice(0, 3), + country: countries(list).list[0], + best, + favorites: list.filter((i) => i.favorite && i.status !== 'a_voir').length, + busiest, + first: [...done].sort((a, b) => byDate(a).localeCompare(byDate(b)))[0], + } +} + +/** + * Année dont le bilan est mis en avant sur l'accueil : l'année en cours en décembre, l'année passée en janvier. + * Le reste du temps, aucun (le bilan reste accessible depuis les stats). + */ +export function recapSeasonYear(now = new Date()): string | undefined { + if (now.getMonth() === 11) return String(now.getFullYear()) + if (now.getMonth() === 0) return String(now.getFullYear() - 1) + return undefined +} diff --git a/src/lib/shareCard.ts b/src/lib/shareCard.ts index 3bb3fca..872ed83 100644 --- a/src/lib/shareCard.ts +++ b/src/lib/shareCard.ts @@ -1,9 +1,11 @@ import { genreLabel } from './genres' -import { t } from '../i18n' +import { fmtNumber, t } from '../i18n' import type { MediaItem } from '../types' import { TYPE_BY_VALUE } from './constants' import { episodeCap } from './franchise' import { safePosterUrl } from './security' +import type { YearRecap } from './recap' +import { formatRating } from './utils' /** * Génère des images à partager (story / message) directement dans le navigateur, @@ -423,6 +425,86 @@ export async function renderTopCard(title: string, entries: (MediaItem | undefin return toBlob(canvas) } +/** + * Bilan de l'année : grande année en couleur, quatre chiffres clés, les trois titres les mieux notés + * (affiches) et les genres préférés. + */ +export async function renderRecapCard(recap: YearRecap): Promise { + const { canvas, ctx } = await newCanvas() + const c = colors() + const imgs = await Promise.all(recap.best.map((i) => loadImage(i.poster))) + const x0 = 90 + const width = W - x0 * 2 + + // « MON ANNÉE » puis l'année en grand + ctx.textAlign = 'left' + ctx.textBaseline = 'alphabetic' + ctx.font = `600 30px ${FONT}` + setTracking(ctx, 3) + ctx.fillStyle = c.ink3 + ctx.fillText(t('recap.cardTitle').toUpperCase(), x0, 150) + setTracking(ctx, -6) + ctx.font = `800 210px ${FONT}` + ctx.fillStyle = c.accent + ctx.fillText(recap.year, x0 - 8, 335) + setTracking(ctx, 0) + + // Quatre chiffres clés, en grille 2 × 2 + const cells: [string, string][] = [ + [fmtNumber(recap.finished), t('stats.finished')], + [t('common.hours', { h: fmtNumber(Math.round(recap.minutes / 60)) }), t('stats.timeSpent')], + [fmtNumber(recap.episodes), t('stats.episodesSeen')], + [recap.avgRating ? `${formatRating(Math.round(recap.avgRating * 10) / 10)} ★` : '—', t('stats.avgRating')], + ] + cells.forEach(([value, label], k) => { + const x = x0 + (k % 2) * (width / 2) + const y = 470 + Math.floor(k / 2) * 150 + ctx.fillStyle = c.ink + ctx.font = `800 ${fitSize(ctx, value, 800, 76, 40, width / 2 - 30) ?? 40}px ${FONT}` + ctx.fillText(value, x, y) + ctx.font = `600 24px ${FONT}` + setTracking(ctx, 1.5) + ctx.fillStyle = c.ink3 + ctx.fillText(wrap(ctx, label.toUpperCase(), width / 2 - 30, 1)[0] ?? '', x, y + 44) + setTracking(ctx, 0) + }) + + // Les mieux notés : trois affiches côte à côte + const label = (text: string, ly: number) => { + ctx.font = `600 24px ${FONT}` + setTracking(ctx, 1.5) + ctx.fillStyle = c.ink3 + ctx.fillText(text.toUpperCase(), x0, ly) + setTracking(ctx, 0) + } + let y = 730 + if (recap.best.length) { + label(t('recap.bestTitle'), y) + const gap = 30 + const pw = (width - gap * 2) / 3 + const ph = 320 + recap.best.forEach((item, k) => { + const px = x0 + k * (pw + gap) + drawPoster(ctx, imgs[k], item.title, px, y + 26, pw, ph, 18) + ctx.fillStyle = c.ink2 + ctx.font = `600 24px ${FONT}` + ctx.fillText(wrap(ctx, item.title, pw, 1)[0] ?? '', px, y + 26 + ph + 36) + }) + y += 26 + ph + 36 + 60 + } + + // Genres préférés, sur une ligne + if (recap.genres.length) { + label(t('stats.favGenres'), y) + ctx.font = `700 34px ${FONT}` + ctx.fillStyle = c.ink + ctx.fillText(wrap(ctx, recap.genres.map((g) => genreLabel(g.label)).join(' · '), width, 1)[0] ?? '', x0, y + 46) + } + + drawBrand(ctx, H - 60) + return toBlob(canvas) +} + export const slug = (s: string) => s .normalize('NFD') diff --git a/src/pages/HomePage.tsx b/src/pages/HomePage.tsx index cbeeaec..20532fb 100644 --- a/src/pages/HomePage.tsx +++ b/src/pages/HomePage.tsx @@ -11,6 +11,7 @@ import { progressView } from '../lib/rewatch' import type { Tab } from '../components/BottomNav' import { EmptyState, LinkArrow, PageHeader, SectionTitle } from '../components/ui' import { InstallHint } from '../components/InstallGuide' +import { RecapHint } from '../components/RecapEntry' import LatestReleases from '../components/LatestReleases' import type { SearchResult } from '../lib/catalogApi' import { CACHE_EVENT, isCaughtUp, loadAiring, needsCheck, refreshAiring, saveAiring, trackable } from '../lib/airing' @@ -218,6 +219,7 @@ export default memo(function HomePage({ onOpen, onAdd, onNavigate, onRoulette, o /> + onNavigate('stats')} /> {loading && items.length === 0 ? ( // Bibliothèque pas encore lue : la place de la bannière est réservée (rien ne saute ensuite) diff --git a/src/pages/StatsPage.tsx b/src/pages/StatsPage.tsx index 3f8644c..e771037 100644 --- a/src/pages/StatsPage.tsx +++ b/src/pages/StatsPage.tsx @@ -3,6 +3,7 @@ import { useMemo, useState } from 'react' import { fmtNumber, t } from '../i18n' import { BarList, Columns, Panel, StatTile } from '../components/stats/Charts' import StatsSettings from '../components/stats/StatsSettings' +import { RecapButton } from '../components/RecapEntry' import { EmptyState, PageHeader } from '../components/ui' import { STATUSES, TYPE_BY_VALUE } from '../lib/constants' import { genreLabel } from '../lib/genres' @@ -32,6 +33,7 @@ export default function StatsPage() { const scoped = useMemo(() => (scope === 'all' ? items : items.filter((i) => SCOPE_TYPES[scope].includes(i.type))), [items, scope]) const years = useMemo(() => availableYears(scoped), [scoped]) const period = year && years.includes(year) ? year : '' + const thisYear = String(new Date().getFullYear()) const list = useMemo(() => itemsForPeriod(scoped, period), [scoped, period]) // Onglets : « Général », « Films », « Séries » toujours ; les autres seulement s'ils ont des titres @@ -65,6 +67,9 @@ export default function StatsPage() { + {/* Bilan de l'année choisie, sinon de l'année en cours (ou de la dernière année avec des titres) */} + + {list.length === 0 ? ( ) : (