Pc / tel
deploy / deploy (push) Successful in 35s

This commit is contained in:
Romain committed 2026-10-04 17:10:56 +02:00
1 parent c82b7894a5
commit 1eed66e1c4
31 files changed
+556 -72

No files matched your search

+4 -2
View File
@@ -1,6 +1,7 @@
import { SocialProvider } from './components/social/SocialProvider'
import { useEffect, useState } from 'react'
import BottomNav, { type Tab } from './components/BottomNav'
import SideNav from './components/SideNav'
import MediaForm from './components/MediaForm'
import Roulette from './components/Roulette'
import CalendarView from './components/CalendarView'
@@ -44,8 +45,9 @@ export default function App() {
return (
<SocialProvider onOpenOwnItem={openItem}>
<div className="mx-auto min-h-dvh max-w-2xl">
<main className="safe-top px-4 pb-32">
<SideNav current={tab} onChange={go} onAdd={openNew} />
<div className="mx-auto min-h-dvh max-w-2xl lg:max-w-5xl lg:ps-60">
<main className="safe-top px-4 pb-32 lg:pb-10">
{error && <p className="mt-4 rounded-xl border border-accent p-3 text-sm text-ink">{error}</p>}
{tab === 'home' && <HomePage onOpen={openItem} onAdd={openNew} onNavigate={go} onRoulette={() => setRoulette(true)} onCalendar={() => setCalendar(true)} />}
{tab === 'catalog' && <CatalogPage onOpen={openItem} onAdd={openNew} />}
+4 -43
View File
@@ -1,48 +1,22 @@
import Avatar from './social/Avatar'
import { useSocial } from './social/SocialProvider'
import { locale, t } from '../i18n'
import { CloudOff, KeyRound, Loader2, LogOut, RefreshCw, UserRound } from 'lucide-react'
import { useEffect, useState, type FormEvent } from 'react'
import { t } from '../i18n'
import { KeyRound, Loader2, LogOut, UserRound } from 'lucide-react'
import { useState, type FormEvent } from 'react'
import { PASSWORD_MIN, updatePassword } from '../lib/cloud/auth'
import { cx } from '../lib/utils'
import type { AccountApi } from '../store'
import ConfirmDialog from './ConfirmDialog'
import { SectionTitle } from './ui'
function ago(iso?: string): string {
if (!iso) return t('time.never')
const s = Math.max(0, (Date.now() - new Date(iso).getTime()) / 1000)
if (s < 60) return t('time.justNow')
if (s < 3600) return t('time.minutesAgo', { n: Math.floor(s / 60) })
if (s < 86400) return t('time.hoursAgo', { n: Math.floor(s / 3600) })
return t('time.onDate', { date: new Date(iso).toLocaleDateString(locale(), { day: 'numeric', month: 'short' }) })
}
/** Réglages → Mon compte : état de la synchro, mot de passe, déconnexion. */
/** Réglages → Mon compte : mot de passe, déconnexion. La synchro tourne en arrière-plan. */
export default function AccountSection({ account, onMessage }: { account: AccountApi; onMessage: (kind: 'ok' | 'error', text: string) => void }) {
const { sync } = account
const social = useSocial()
const [, tick] = useState(0)
const [pwOpen, setPwOpen] = useState(false)
const [pw, setPw] = useState('')
const [busy, setBusy] = useState<'pw' | 'logout' | 'import' | null>(null)
const [confirmLogout, setConfirmLogout] = useState(false)
// Rafraîchit « il y a x min »
useEffect(() => {
const timer = setInterval(() => tick((n) => n + 1), 30_000)
return () => clearInterval(timer)
}, [])
const statusText =
sync.state === 'syncing'
? t('account.syncing')
: sync.state === 'offline'
? t('account.offline')
: sync.state === 'error'
? t('account.syncError')
: t('account.synced', { when: ago(sync.lastSyncAt) })
const changePassword = async (e: FormEvent) => {
e.preventDefault()
setBusy('pw')
@@ -90,20 +64,7 @@ export default function AccountSection({ account, onMessage }: { account: Accoun
</span>
<span className="min-w-0 flex-1">
<span className="block truncate font-medium">{account.email}</span>
<span className={cx('mt-0.5 flex items-center gap-1.5 text-xs', sync.state === 'error' ? 'text-accent' : 'text-ink-3')}>
{sync.state === 'offline' && <CloudOff size={12} />}
{statusText}
{sync.pending > 0 && sync.state !== 'syncing' && ` · ${t('account.pending', { count: sync.pending })}`}
</span>
</span>
<button
onClick={() => account.syncNow()}
disabled={sync.state === 'syncing'}
className="grid size-10 shrink-0 place-items-center rounded-full border border-line text-ink-2"
aria-label={t('account.syncNow')}
>
{sync.state === 'syncing' ? <Loader2 size={17} className="animate-spin" /> : <RefreshCw size={17} />}
</button>
</div>
<button
+1 -1
View File
@@ -38,7 +38,7 @@ export default function BottomNav({ current, onChange, onAdd }: Props) {
}
return (
<nav className="safe-bottom fixed inset-x-0 bottom-0 z-30 border-t border-line bg-bg/95 backdrop-blur-md">
<nav className="safe-bottom fixed inset-x-0 bottom-0 z-30 border-t border-line bg-bg/95 backdrop-blur-md lg:hidden">
<div className="mx-auto flex max-w-2xl items-center px-2">
{ITEMS.slice(0, 2).map(button)}
<div className="flex flex-1 justify-center">
+55
View File
@@ -0,0 +1,55 @@
import { type Tab } from './BottomNav'
import { t } from '../i18n'
import { BarChart3, Home, LibraryBig, Plus, Settings } from 'lucide-react'
import { cx } from '../lib/utils'
const ITEMS: { tab: Tab; readonly label: string; Icon: typeof Home }[] = [
{ tab: 'home', get label() { return t('nav.home') }, Icon: Home },
{ tab: 'catalog', get label() { return t('nav.catalog') }, Icon: LibraryBig },
{ tab: 'stats', get label() { return t('nav.stats') }, Icon: BarChart3 },
{ tab: 'settings', get label() { return t('nav.settings') }, Icon: Settings },
]
interface Props {
current: Tab
onChange: (tab: Tab) => void
onAdd: () => void
}
export default function SideNav({ current, onChange, onAdd }: Props) {
return (
<nav className="fixed inset-y-0 start-0 z-30 hidden w-60 flex-col border-e border-line bg-bg px-4 py-6 lg:flex">
<h1 className="px-2 text-2xl font-bold">
Azuu<span className="text-accent">Cine</span>
</h1>
<button
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')}
</button>
<div className="mt-6 flex flex-col gap-1">
{ITEMS.map(({ tab, label, Icon }) => {
const active = current === tab
return (
<button
key={tab}
onClick={() => onChange(tab)}
aria-current={active ? 'page' : undefined}
className={cx(
'flex w-full items-center gap-3 rounded-xl px-3 py-2.5 text-sm font-medium transition-colors',
active ? 'bg-surface-2 text-ink' : 'text-ink-3 hover:text-ink',
)}
>
<Icon size={20} strokeWidth={active ? 2.2 : 1.6} />
{label}
</button>
)
})}
</div>
</nav>
)
}
+11
View File
@@ -223,6 +223,17 @@ const dict: Translations = {
'settings.scale10': 'من 10',
'settings.ratingHint': 'أنصاف نجوم من 5، أو خطوات 0.5 من 10. تُحوَّل التقييمات الحالية تلقائيًا.',
'settings.theme': 'السمة',
'settings.appearance': 'المظهر',
'settings.appearanceHint': '«تلقائي» يتبع متصفحك (فاتح أو داكن).',
'theme.modeAuto': 'تلقائي',
'theme.modeLight': 'فاتح',
'theme.modeDark': 'داكن',
'theme.modeNight': 'ليلي',
'theme.modeStarfield': 'نجوم',
'settings.accentColor': 'لون التمييز',
'settings.installApp': 'تثبيت التطبيق',
'settings.installHint': 'أضِف AzuuCine إلى شاشتك الرئيسية أو سطح المكتب.',
'settings.installed': 'تم تثبيت التطبيق',
'settings.themeX': 'سمة {name}',
'settings.pickColor': 'اختيار لون مخصص',
'settings.freeColor': 'لون مخصص',
+11
View File
@@ -217,6 +217,17 @@ const dict: Translations = {
'settings.scale10': 'Von 10',
'settings.ratingHint': 'Halbe Sterne bei 5, oder 0,5er-Schritte bei 10. Bestehende Bewertungen werden automatisch umgerechnet.',
'settings.theme': 'Design',
'settings.appearance': 'Darstellung',
'settings.appearanceHint': '„Auto“ folgt deinem Browser (hell oder dunkel).',
'theme.modeAuto': 'Auto',
'theme.modeLight': 'Hell',
'theme.modeDark': 'Dunkel',
'theme.modeNight': 'Nacht',
'theme.modeStarfield': 'Sternenhimmel',
'settings.accentColor': 'Akzentfarbe',
'settings.installApp': 'App installieren',
'settings.installHint': 'Füge AzuuCine zum Startbildschirm oder Desktop hinzu.',
'settings.installed': 'App installiert',
'settings.themeX': 'Design {name}',
'settings.pickColor': 'Eigene Farbe wählen',
'settings.freeColor': 'Eigene Farbe',
+11
View File
@@ -217,6 +217,17 @@ const dict: Translations = {
'settings.scale10': 'Out of 10',
'settings.ratingHint': 'Half stars out of 5, or 0.5 steps out of 10. Existing ratings are converted automatically.',
'settings.theme': 'Theme',
'settings.appearance': 'Appearance',
'settings.appearanceHint': '“Auto” follows your browser (light or dark).',
'theme.modeAuto': 'Auto',
'theme.modeLight': 'Light',
'theme.modeDark': 'Dark',
'theme.modeNight': 'Night',
'theme.modeStarfield': 'Starry',
'settings.accentColor': 'Accent color',
'settings.installApp': 'Install the app',
'settings.installHint': 'Add AzuuCine to your home screen or desktop.',
'settings.installed': 'App installed',
'settings.themeX': '{name} theme',
'settings.pickColor': 'Pick a custom color',
'settings.freeColor': 'Custom color',
+11
View File
@@ -217,6 +217,17 @@ const dict: Translations = {
'settings.scale10': 'Sobre 10',
'settings.ratingHint': 'Medias estrellas sobre 5, o pasos de 0,5 sobre 10. Las notas existentes se convierten automáticamente.',
'settings.theme': 'Tema',
'settings.appearance': 'Apariencia',
'settings.appearanceHint': '«Auto» sigue tu navegador (claro u oscuro).',
'theme.modeAuto': 'Auto',
'theme.modeLight': 'Claro',
'theme.modeDark': 'Oscuro',
'theme.modeNight': 'Noche',
'theme.modeStarfield': 'Estrellado',
'settings.accentColor': 'Color de acento',
'settings.installApp': 'Instalar la aplicación',
'settings.installHint': 'Añade AzuuCine a tu pantalla de inicio o escritorio.',
'settings.installed': 'Aplicación instalada',
'settings.themeX': 'Tema {name}',
'settings.pickColor': 'Elegir un color libre',
'settings.freeColor': 'Color libre',
+11
View File
@@ -219,6 +219,17 @@ const dict = {
'settings.scale10': 'Sur 10',
'settings.ratingHint': 'Demi-étoiles sur 5, ou pas de 0,5 sur 10. Les notes existantes sont converties automatiquement.',
'settings.theme': 'Thème',
'settings.appearance': 'Apparence',
'settings.appearanceHint': '« Auto » suit ton navigateur (clair ou sombre).',
'theme.modeAuto': 'Auto',
'theme.modeLight': 'Clair',
'theme.modeDark': 'Sombre',
'theme.modeNight': 'Nuit',
'theme.modeStarfield': 'Étoilé',
'settings.accentColor': 'Couleur d\'accent',
'settings.installApp': 'Installer l\'application',
'settings.installHint': 'Ajoute AzuuCine à ton écran d\'accueil ou ton bureau.',
'settings.installed': 'Application installée',
'settings.themeX': 'Thème {name}',
'settings.pickColor': 'Choisir une couleur libre',
'settings.freeColor': 'Couleur libre',
+11
View File
@@ -217,6 +217,17 @@ const dict: Translations = {
'settings.scale10': '10 में से',
'settings.ratingHint': '5 में से आधे स्टार, या 10 में से 0.5 के स्टेप। मौजूदा रेटिंग अपने-आप बदल जाती हैं।',
'settings.theme': 'थीम',
'settings.appearance': 'दिखावट',
'settings.appearanceHint': '“ऑटो” आपके ब्राउज़र का अनुसरण करता है (हल्का या गहरा)।',
'theme.modeAuto': 'ऑटो',
'theme.modeLight': 'हल्का',
'theme.modeDark': 'गहरा',
'theme.modeNight': 'रात',
'theme.modeStarfield': 'तारों भरा',
'settings.accentColor': 'एक्सेंट रंग',
'settings.installApp': 'ऐप इंस्टॉल करें',
'settings.installHint': 'AzuuCine को अपनी होम स्क्रीन या डेस्कटॉप पर जोड़ें।',
'settings.installed': 'ऐप इंस्टॉल हो गया',
'settings.themeX': '{name} थीम',
'settings.pickColor': 'अपना रंग चुनें',
'settings.freeColor': 'कस्टम रंग',
+11
View File
@@ -217,6 +217,17 @@ const dict: Translations = {
'settings.scale10': 'Dari 10',
'settings.ratingHint': 'Setengah bintang dari 5, atau kelipatan 0,5 dari 10. Nilai yang sudah ada dikonversi otomatis.',
'settings.theme': 'Tema',
'settings.appearance': 'Tampilan',
'settings.appearanceHint': '“Otomatis” mengikuti browser kamu (terang atau gelap).',
'theme.modeAuto': 'Otomatis',
'theme.modeLight': 'Terang',
'theme.modeDark': 'Gelap',
'theme.modeNight': 'Malam',
'theme.modeStarfield': 'Berbintang',
'settings.accentColor': 'Warna aksen',
'settings.installApp': 'Pasang aplikasi',
'settings.installHint': 'Tambahkan AzuuCine ke layar utama atau desktop kamu.',
'settings.installed': 'Aplikasi terpasang',
'settings.themeX': 'Tema {name}',
'settings.pickColor': 'Pilih warna bebas',
'settings.freeColor': 'Warna bebas',
+11
View File
@@ -217,6 +217,17 @@ const dict: Translations = {
'settings.scale10': 'Su 10',
'settings.ratingHint': 'Mezze stelle su 5, o passi di 0,5 su 10. I voti esistenti vengono convertiti automaticamente.',
'settings.theme': 'Tema',
'settings.appearance': 'Aspetto',
'settings.appearanceHint': '«Auto» segue il browser (chiaro o scuro).',
'theme.modeAuto': 'Auto',
'theme.modeLight': 'Chiaro',
'theme.modeDark': 'Scuro',
'theme.modeNight': 'Notte',
'theme.modeStarfield': 'Stellato',
'settings.accentColor': 'Colore accento',
'settings.installApp': 'Installa l\'app',
'settings.installHint': 'Aggiungi AzuuCine alla schermata home o al desktop.',
'settings.installed': 'App installata',
'settings.themeX': 'Tema {name}',
'settings.pickColor': 'Scegli un colore libero',
'settings.freeColor': 'Colore libero',
+11
View File
@@ -217,6 +217,17 @@ const dict: Translations = {
'settings.scale10': '10点満点',
'settings.ratingHint': '5段階は星半分刻み、10点満点は0.5刻みです。既存の評価は自動で変換されます。',
'settings.theme': 'テーマ',
'settings.appearance': '外観',
'settings.appearanceHint': '「自動」はブラウザに合わせます(ライトまたはダーク)。',
'theme.modeAuto': '自動',
'theme.modeLight': 'ライト',
'theme.modeDark': 'ダーク',
'theme.modeNight': 'ナイト',
'theme.modeStarfield': '星空',
'settings.accentColor': 'アクセントカラー',
'settings.installApp': 'アプリをインストール',
'settings.installHint': 'AzuuCine をホーム画面やデスクトップに追加します。',
'settings.installed': 'アプリをインストール済み',
'settings.themeX': '{name}テーマ',
'settings.pickColor': '好きな色を選ぶ',
'settings.freeColor': 'カスタムカラー',
+11
View File
@@ -217,6 +217,17 @@ const dict: Translations = {
'settings.scale10': '10점 만점',
'settings.ratingHint': '5점 만점은 별 반 개 단위, 10점 만점은 0.5점 단위예요. 기존 평점은 자동으로 변환돼요.',
'settings.theme': '테마',
'settings.appearance': '화면',
'settings.appearanceHint': '‘자동’은 브라우저를 따릅니다(밝게 또는 어둡게).',
'theme.modeAuto': '자동',
'theme.modeLight': '밝게',
'theme.modeDark': '어둡게',
'theme.modeNight': '야간',
'theme.modeStarfield': '별',
'settings.accentColor': '강조 색상',
'settings.installApp': '앱 설치',
'settings.installHint': 'AzuuCine을 홈 화면이나 바탕화면에 추가하세요.',
'settings.installed': '앱 설치됨',
'settings.themeX': '{name} 테마',
'settings.pickColor': '원하는 색 고르기',
'settings.freeColor': '사용자 지정 색',
+11
View File
@@ -217,6 +217,17 @@ const dict: Translations = {
'settings.scale10': 'Op 10',
'settings.ratingHint': 'Halve sterren op 5, of stappen van 0,5 op 10. Bestaande scores worden automatisch omgerekend.',
'settings.theme': 'Thema',
'settings.appearance': 'Weergave',
'settings.appearanceHint': '“Auto” volgt je browser (licht of donker).',
'theme.modeAuto': 'Auto',
'theme.modeLight': 'Licht',
'theme.modeDark': 'Donker',
'theme.modeNight': 'Nacht',
'theme.modeStarfield': 'Sterren',
'settings.accentColor': 'Accentkleur',
'settings.installApp': 'App installeren',
'settings.installHint': 'Voeg AzuuCine toe aan je startscherm of bureaublad.',
'settings.installed': 'App geïnstalleerd',
'settings.themeX': 'Thema {name}',
'settings.pickColor': 'Kies een eigen kleur',
'settings.freeColor': 'Eigen kleur',
+11
View File
@@ -221,6 +221,17 @@ const dict: Translations = {
'settings.scale10': 'W skali do 10',
'settings.ratingHint': 'Połówki gwiazdek w skali do 5 lub co 0,5 w skali do 10. Istniejące oceny zostaną przeliczone automatycznie.',
'settings.theme': 'Motyw',
'settings.appearance': 'Wygląd',
'settings.appearanceHint': '„Auto” podąża za przeglądarką (jasny lub ciemny).',
'theme.modeAuto': 'Auto',
'theme.modeLight': 'Jasny',
'theme.modeDark': 'Ciemny',
'theme.modeNight': 'Noc',
'theme.modeStarfield': 'Gwiazdy',
'settings.accentColor': 'Kolor akcentu',
'settings.installApp': 'Zainstaluj aplikację',
'settings.installHint': 'Dodaj AzuuCine do ekranu głównego lub pulpitu.',
'settings.installed': 'Aplikacja zainstalowana',
'settings.themeX': 'Motyw {name}',
'settings.pickColor': 'Wybierz własny kolor',
'settings.freeColor': 'Własny kolor',
+11
View File
@@ -217,6 +217,17 @@ const dict: Translations = {
'settings.scale10': 'De 0 a 10',
'settings.ratingHint': 'Meias estrelas de 0 a 5, ou passos de 0,5 de 0 a 10. As notas existentes são convertidas automaticamente.',
'settings.theme': 'Tema',
'settings.appearance': 'Aparência',
'settings.appearanceHint': '“Auto” segue o seu navegador (claro ou escuro).',
'theme.modeAuto': 'Auto',
'theme.modeLight': 'Claro',
'theme.modeDark': 'Escuro',
'theme.modeNight': 'Noite',
'theme.modeStarfield': 'Estrelado',
'settings.accentColor': 'Cor de destaque',
'settings.installApp': 'Instalar o app',
'settings.installHint': 'Adicione o AzuuCine à tela inicial ou à área de trabalho.',
'settings.installed': 'App instalado',
'settings.themeX': 'Tema {name}',
'settings.pickColor': 'Escolher uma cor livre',
'settings.freeColor': 'Cor livre',
+11
View File
@@ -221,6 +221,17 @@ const dict: Translations = {
'settings.scale10': 'Из 10',
'settings.ratingHint': 'Половинки звёзд из 5 или шаг 0,5 из 10. Существующие оценки пересчитаются автоматически.',
'settings.theme': 'Тема',
'settings.appearance': 'Оформление',
'settings.appearanceHint': '«Авто» следует за браузером (светлая или тёмная).',
'theme.modeAuto': 'Авто',
'theme.modeLight': 'Светлая',
'theme.modeDark': 'Тёмная',
'theme.modeNight': 'Ночь',
'theme.modeStarfield': 'Звёзды',
'settings.accentColor': 'Цвет акцента',
'settings.installApp': 'Установить приложение',
'settings.installHint': 'Добавь AzuuCine на главный экран или рабочий стол.',
'settings.installed': 'Приложение установлено',
'settings.themeX': 'Тема «{name}»',
'settings.pickColor': 'Выбрать свой цвет',
'settings.freeColor': 'Свой цвет',
+11
View File
@@ -217,6 +217,17 @@ const dict: Translations = {
'settings.scale10': 'เต็ม 10',
'settings.ratingHint': 'ครึ่งดาวเมื่อคะแนนเต็ม 5 หรือทีละ 0.5 เมื่อคะแนนเต็ม 10 คะแนนเดิมจะแปลงให้อัตโนมัติ',
'settings.theme': 'ธีม',
'settings.appearance': 'ลักษณะที่ปรากฏ',
'settings.appearanceHint': '“อัตโนมัติ” จะตามเบราว์เซอร์ของคุณ (สว่างหรือมืด)',
'theme.modeAuto': 'อัตโนมัติ',
'theme.modeLight': 'สว่าง',
'theme.modeDark': 'มืด',
'theme.modeNight': 'กลางคืน',
'theme.modeStarfield': 'ดาว',
'settings.accentColor': 'สีเน้น',
'settings.installApp': 'ติดตั้งแอป',
'settings.installHint': 'เพิ่ม AzuuCine ไปที่หน้าจอหลักหรือเดสก์ท็อปของคุณ',
'settings.installed': 'ติดตั้งแอปแล้ว',
'settings.themeX': 'ธีม {name}',
'settings.pickColor': 'เลือกสีเอง',
'settings.freeColor': 'สีที่เลือกเอง',
+11
View File
@@ -217,6 +217,17 @@ const dict: Translations = {
'settings.scale10': '10 üzerinden',
'settings.ratingHint': '5 üzerinden yarım yıldız ya da 10 üzerinden 0,5 adım. Mevcut puanlar otomatik dönüştürülür.',
'settings.theme': 'Tema',
'settings.appearance': 'Görünüm',
'settings.appearanceHint': '“Otomatik” tarayıcını izler (açık veya koyu).',
'theme.modeAuto': 'Otomatik',
'theme.modeLight': 'Açık',
'theme.modeDark': 'Koyu',
'theme.modeNight': 'Gece',
'theme.modeStarfield': 'Yıldızlı',
'settings.accentColor': 'Vurgu rengi',
'settings.installApp': 'Uygulamayı yükle',
'settings.installHint': 'AzuuCine’i ana ekranına veya masaüstüne ekle.',
'settings.installed': 'Uygulama yüklendi',
'settings.themeX': '{name} tema',
'settings.pickColor': 'Özel renk seç',
'settings.freeColor': 'Özel renk',
+11
View File
@@ -217,6 +217,17 @@ const dict: Translations = {
'settings.scale10': 'Trên 10',
'settings.ratingHint': 'Nửa sao trên thang 5, hoặc bước 0,5 trên thang 10. Điểm hiện có sẽ được tự động quy đổi.',
'settings.theme': 'Giao diện',
'settings.appearance': 'Giao diện',
'settings.appearanceHint': '“Tự động” theo trình duyệt của bạn (sáng hoặc tối).',
'theme.modeAuto': 'Tự động',
'theme.modeLight': 'Sáng',
'theme.modeDark': 'Tối',
'theme.modeNight': 'Đêm',
'theme.modeStarfield': 'Sao',
'settings.accentColor': 'Màu nhấn',
'settings.installApp': 'Cài đặt ứng dụng',
'settings.installHint': 'Thêm AzuuCine vào màn hình chính hoặc màn hình nền của bạn.',
'settings.installed': 'Đã cài ứng dụng',
'settings.themeX': 'Giao diện {name}',
'settings.pickColor': 'Chọn màu tùy chỉnh',
'settings.freeColor': 'Màu tùy chỉnh',
+11
View File
@@ -217,6 +217,17 @@ const dict: Translations = {
'settings.scale10': '10分制',
'settings.ratingHint': '5分制可打半星,10分制以0.5分为单位。已有评分会自动换算。',
'settings.theme': '主题',
'settings.appearance': '外观',
'settings.appearanceHint': '“自动”跟随你的浏览器(浅色或深色)。',
'theme.modeAuto': '自动',
'theme.modeLight': '浅色',
'theme.modeDark': '深色',
'theme.modeNight': '夜间',
'theme.modeStarfield': '星空',
'settings.accentColor': '强调色',
'settings.installApp': '安装应用',
'settings.installHint': '将 AzuuCine 添加到主屏幕或桌面。',
'settings.installed': '应用已安装',
'settings.themeX': '{name}主题',
'settings.pickColor': '自选颜色',
'settings.freeColor': '自定义颜色',
+112
View File
@@ -60,6 +60,118 @@
}
}
/*
* Apparences (thèmes de fond). Le bloc @theme ci-dessus reste la palette SOMBRE
* par défaut (utilitaires Tailwind bg-bg/text-ink/border-line), et « dark » est
* donc l'apparence par défaut. On redéfinit ici UNIQUEMENT les jetons de palette
* pour chaque apparence — les jetons d'accent (--color-accent*) sont posés par JS.
*/
:root[data-theme='light'] {
--color-bg: #fafaf9;
--color-surface: #ffffff;
--color-surface-2: #f1f0ee;
--color-line: #e5e3df;
--color-line-strong: #d2cfc9;
--color-ink: #1c1b1a;
--color-ink-2: #57544e;
--color-ink-3: #86837c;
color-scheme: light;
}
:root[data-theme='dark'] {
--color-bg: #0a0a0a;
--color-surface: #111110;
--color-surface-2: #181817;
--color-line: #262624;
--color-line-strong: #3a3936;
--color-ink: #f4f2ee;
--color-ink-2: #b3b0a8;
--color-ink-3: #8a8781;
color-scheme: dark;
}
:root[data-theme='night'] {
--color-bg: #000000;
--color-surface: #0a0a0a;
--color-surface-2: #141414;
--color-line: #222222;
--color-line-strong: #333333;
--color-ink: #f4f2ee;
--color-ink-2: #b3b0a8;
--color-ink-3: #8a8781;
color-scheme: dark;
}
:root[data-theme='starfield'] {
--color-bg: #070b1c;
--color-surface: #0c1226;
--color-surface-2: #141c38;
--color-line: #1f2a4d;
--color-line-strong: #2d3a63;
--color-ink: #eef1fb;
--color-ink-2: #b4bbd6;
--color-ink-3: #8089ab;
color-scheme: dark;
}
/* Anti-flash : avant que le JS ne pose data-theme, un utilisateur en préférence
claire ne doit pas voir la palette sombre le temps d'une frame. */
@media (prefers-color-scheme: light) {
:root:not([data-theme]) {
--color-bg: #fafaf9;
--color-surface: #ffffff;
--color-surface-2: #f1f0ee;
--color-line: #e5e3df;
--color-line-strong: #d2cfc9;
--color-ink: #1c1b1a;
--color-ink-2: #57544e;
--color-ink-3: #86837c;
color-scheme: light;
}
}
/* Fond étoilé (apparence « bleu nuit »), 100% CSS, sans image ni réseau.
Une couche fixe derrière le contenu : nébuleuse bleue + étoiles en tuiles. */
:root[data-theme='starfield'] #root {
background: transparent;
}
:root[data-theme='starfield'] body::before {
content: '';
position: fixed;
inset: 0;
z-index: -1;
pointer-events: none;
background-color: #070b1c;
background-image:
radial-gradient(1.5px 1.5px at 40px 60px, #ffffff, transparent),
radial-gradient(1px 1px at 120px 20px, rgba(255, 255, 255, 0.8), transparent),
radial-gradient(1px 1px at 200px 140px, #cbd5ff, transparent),
radial-gradient(1.5px 1.5px at 260px 90px, rgba(255, 255, 255, 0.6), transparent),
radial-gradient(1px 1px at 80px 190px, rgba(255, 255, 255, 0.7), transparent),
radial-gradient(1px 1px at 300px 250px, #ffffff, transparent),
radial-gradient(1.5px 1.5px at 340px 160px, rgba(203, 213, 255, 0.9), transparent),
radial-gradient(1200px 600px at 70% -10%, rgba(45, 58, 99, 0.55), transparent 60%),
radial-gradient(900px 500px at 15% 5%, rgba(31, 42, 77, 0.45), transparent 55%);
background-repeat: repeat, repeat, repeat, repeat, repeat, repeat, repeat, no-repeat, no-repeat;
background-size: 360px 360px, 360px 360px, 360px 360px, 360px 360px, 360px 360px, 360px 360px, 360px 360px,
100% 100%, 100% 100%;
animation: starfield-twinkle 9s ease-in-out infinite;
}
@keyframes starfield-twinkle {
0%,
100% {
opacity: 0.85;
}
50% {
opacity: 1;
}
}
@media (prefers-reduced-motion: reduce) {
:root[data-theme='starfield'] body::before {
animation: none;
}
}
/* Petite étiquette en capitales (titres de section, libellés de champs) */
@utility eyebrow {
font-size: 11px;
+1
View File
@@ -129,6 +129,7 @@ export function normalizeSettings(raw: unknown): Partial<Settings> | undefined {
if (raw.ratingScale === '5' || raw.ratingScale === '10') out.ratingScale = raw.ratingScale
if (Array.isArray(raw.topCategories)) out.topCategories = ALL_TOP_CATEGORIES.filter((c) => (raw.topCategories as unknown[]).includes(c))
if (isHexColor(raw.accentColor)) out.accentColor = raw.accentColor.toLowerCase()
if (raw.themeMode === 'auto' || raw.themeMode === 'light' || raw.themeMode === 'dark' || raw.themeMode === 'night' || raw.themeMode === 'starfield') out.themeMode = raw.themeMode
return out
}
+1 -1
View File
@@ -15,7 +15,7 @@ import { cloudFetch } from './api'
* En cas de conflit, la modification la plus récente gagne (vérifié aussi par la base).
*/
export type SyncedSettings = Pick<Settings, 'ratingScale' | 'topCategories' | 'accentColor'>
export type SyncedSettings = Pick<Settings, 'ratingScale' | 'topCategories' | 'accentColor' | 'themeMode'>
export interface SyncHooks {
getLists: () => CustomList[]
+63
View File
@@ -0,0 +1,63 @@
import { useEffect, useState } from 'react'
/** Événement non standard déclenché par le navigateur avant l'invite d'installation. */
interface BeforeInstallPromptEvent extends Event {
prompt: () => Promise<void>
userChoice: Promise<{ outcome: 'accepted' | 'dismissed'; platform: string }>
}
let deferredPrompt: BeforeInstallPromptEvent | null = null
const listeners = new Set<() => void>()
function notify() {
listeners.forEach((fn) => fn())
}
if (typeof window !== 'undefined') {
window.addEventListener('beforeinstallprompt', (e) => {
e.preventDefault()
deferredPrompt = e as BeforeInstallPromptEvent
notify()
})
window.addEventListener('appinstalled', () => {
deferredPrompt = null
notify()
})
}
function isStandalone(): boolean {
if (typeof window === 'undefined') return false
return window.matchMedia?.('(display-mode: standalone)').matches || (navigator as { standalone?: boolean }).standalone === true
}
export function useInstallPrompt(): { canInstall: boolean; installed: boolean; install: () => Promise<boolean> } {
const [canInstall, setCanInstall] = useState(() => deferredPrompt !== null)
const [installed, setInstalled] = useState(isStandalone)
useEffect(() => {
const update = () => {
setCanInstall(deferredPrompt !== null)
setInstalled(isStandalone())
}
listeners.add(update)
const mql = window.matchMedia?.('(display-mode: standalone)')
mql?.addEventListener?.('change', update)
update()
return () => {
listeners.delete(update)
mql?.removeEventListener?.('change', update)
}
}, [])
const install = async (): Promise<boolean> => {
if (!deferredPrompt) return false
const prompt = deferredPrompt
deferredPrompt = null
notify()
await prompt.prompt()
const { outcome } = await prompt.userChoice
return outcome === 'accepted'
}
return { canInstall, installed, install }
}
+53 -16
View File
@@ -1,7 +1,8 @@
import { t } from '../i18n'
import type { ThemeMode } from '../types'
/**
* Thèmes de couleur : à partir d'une seule couleur, on calcule
* - accent : version lisible sur fond noir (texte, icônes, filets)
* - accent : version lisible comme TEXTE sur le fond du thème résolu
* - accentFill : la couleur choisie, pour les boutons pleins
* - onAccent : texte blanc ou noir sur ces boutons, selon ce qui se lit le mieux
*/
@@ -23,7 +24,13 @@ export const THEME_PRESETS: { readonly name: string; color: string; accent?: str
{ get name() { return t('theme.white') }, color: '#e7e5e4' },
]
const BG = '#0a0a0a'
/** Couleur de fond (canvas) de chaque thème résolu, pour calculer un accent lisible. */
const CANVAS: Record<Exclude<ThemeMode, 'auto'>, string> = {
light: '#ffffff',
dark: '#0a0a0a',
night: '#000000',
starfield: '#0a1230',
}
export const isHexColor = (v: unknown): v is string => typeof v === 'string' && /^#[0-9a-f]{6}$/i.test(v)
@@ -49,12 +56,17 @@ export function contrast(a: string, b: string): number {
return (x + 0.05) / (y + 0.05)
}
/** Éclaircit la couleur vers le blanc jusqu'à être lisible sur le fond noir. */
function readableOnBlack(color: string): string {
/**
* Rend la couleur lisible comme texte sur le canvas donné :
* - canvas clair → on assombrit vers le noir jusqu'à un contraste suffisant
* - canvas sombre → on éclaircit vers le blanc (comme avant)
*/
function readableOn(color: string, canvas: string): string {
const target = luminance(canvas) > 0.5 ? 0 : 255 // vers noir ou vers blanc
let c = color
const base = rgb(color)
for (let t = 0; t <= 1 && contrast(c, BG) < 4.8; t += 0.05) {
c = hex(base.map((v) => v + (255 - v) * t) as [number, number, number])
for (let m = 0; m <= 1 && contrast(c, canvas) < 4.8; m += 0.05) {
c = hex(base.map((v) => v + (target - v) * m) as [number, number, number])
}
return c
}
@@ -65,21 +77,46 @@ export interface ThemeColors {
onAccent: string
}
export function themeFromColor(color: string): ThemeColors {
function themeColors(color: string, resolved: Exclude<ThemeMode, 'auto'>): ThemeColors {
const fill = isHexColor(color) ? color.toLowerCase() : DEFAULT_ACCENT
const canvas = CANVAS[resolved]
const darkCanvas = '#0a0a0a'
const preset = THEME_PRESETS.find((p) => p.color === fill)
// Les overrides d'accent des presets sont pensés pour un fond sombre :
// sur fond clair on recalcule un accent assombri.
const accent = resolved === 'light' ? readableOn(fill, canvas) : (preset?.accent ?? readableOn(fill, canvas))
return {
accent: preset?.accent ?? readableOnBlack(fill),
accent,
accentFill: fill,
onAccent: contrast('#ffffff', fill) >= contrast(BG, fill) ? '#ffffff' : BG,
onAccent: contrast('#ffffff', fill) >= contrast(darkCanvas, fill) ? '#ffffff' : darkCanvas,
}
}
/** Applique le thème à toute l'app (les classes Tailwind lisent ces variables). */
export function applyTheme(color: string) {
const t = themeFromColor(color)
const root = document.documentElement.style
root.setProperty('--color-accent', t.accent)
root.setProperty('--color-accent-fill', t.accentFill)
root.setProperty('--color-on-accent', t.onAccent)
/** Compat : thème calculé pour le rendu sombre par défaut. */
export function themeFromColor(color: string): ThemeColors {
return themeColors(color, 'dark')
}
/** Applique le thème à toute l'app (les classes Tailwind lisent ces variables). */
export function applyTheme(accentColor: string, mode: ThemeMode) {
const resolved: Exclude<ThemeMode, 'auto'> =
mode === 'auto'
? window.matchMedia?.('(prefers-color-scheme: light)').matches
? 'light'
: 'dark'
: mode
document.documentElement.dataset.theme = resolved
const c = themeColors(accentColor, resolved)
const root = document.documentElement.style
root.setProperty('--color-accent', c.accent)
root.setProperty('--color-accent-fill', c.accentFill)
root.setProperty('--color-on-accent', c.onAccent)
}
export const THEME_MODES: { value: ThemeMode; readonly label: string }[] = [
{ value: 'auto', get label() { return t('theme.modeAuto') } },
{ value: 'light', get label() { return t('theme.modeLight') } },
{ value: 'dark', get label() { return t('theme.modeDark') } },
{ value: 'night', get label() { return t('theme.modeNight') } },
{ value: 'starfield', get label() { return t('theme.modeStarfield') } },
]
+45 -3
View File
@@ -1,6 +1,6 @@
import { t } from '../i18n'
import { LanguageSelect } from '../i18n/react'
import { Check, Download, Eye, EyeOff, HardDrive, Trash2, Upload, UserX } from 'lucide-react'
import { Check, Download, Eye, EyeOff, HardDrive, Smartphone, Trash2, Upload, UserX } from 'lucide-react'
import { useEffect, useRef, useState, type ReactNode } from 'react'
import AccountSection from '../components/AccountSection'
import ConfirmDialog from '../components/ConfirmDialog'
@@ -9,7 +9,8 @@ import { exportBackup, parseBackupFile, type ParsedBackup } from '../lib/backup'
import { testTmdbKey } from '../lib/catalogApi'
import { checkTmdbProxy, type ProxyState } from '../lib/cloud/api'
import { ALL_TOP_CATEGORIES, TOP_CATEGORIES } from '../lib/constants'
import { isHexColor, THEME_PRESETS } from '../lib/theme'
import { isHexColor, THEME_MODES, THEME_PRESETS } from '../lib/theme'
import { useInstallPrompt } from '../lib/pwa'
import { cx } from '../lib/utils'
import { useMedia } from '../store'
@@ -30,6 +31,7 @@ function Row({ icon, title, hint, onClick, danger }: { icon: ReactNode; title: s
export default function SettingsPage() {
const { items, settings, updateSettings, importItems, clearAll, lists, mergeLists, account } = useMedia()
const { canInstall, installed, install } = useInstallPrompt()
const fileRef = useRef<HTMLInputElement>(null)
const [pending, setPending] = useState<ParsedBackup>()
const [message, setMessage] = useState<Message>()
@@ -131,6 +133,15 @@ export default function SettingsPage() {
setMessage({ kind: 'ok', text: t('settings.cleared') })
}
const onInstall = async () => {
if (canInstall) {
const ok = await install()
if (ok) setMessage({ kind: 'ok', text: t('settings.installed') })
} else {
setMessage({ kind: 'ok', text: t('settings.installHint') })
}
}
return (
<>
<PageHeader title={t('settings.pageTitle')} accent={t('settings.pageAccent')} />
@@ -167,7 +178,21 @@ export default function SettingsPage() {
</div>
<p className="mt-2.5 text-xs text-ink-3">{t('settings.ratingHint')}</p>
<SectionTitle>{t('settings.theme')}</SectionTitle>
<SectionTitle>{t('settings.appearance')}</SectionTitle>
<div className="flex flex-wrap gap-2">
{THEME_MODES.map(({ value, label }) => {
const on = settings.themeMode === value
return (
<button key={value} onClick={() => updateSettings({ themeMode: value })} className={cx('chip', on && 'chip-on')} aria-pressed={on}>
{on && <Check size={14} />}
{label}
</button>
)
})}
</div>
<p className="mt-2.5 text-xs text-ink-3">{t('settings.appearanceHint')}</p>
<SectionTitle>{t('settings.accentColor')}</SectionTitle>
<div className="grid grid-cols-6 gap-3">
{THEME_PRESETS.map((p) => {
const on = settings.accentColor.toLowerCase() === p.color
@@ -207,6 +232,23 @@ export default function SettingsPage() {
<span className="text-xs uppercase text-ink-3">{settings.accentColor}</span>
</label>
<SectionTitle>{t('settings.installApp')}</SectionTitle>
<div className="card overflow-hidden">
{installed ? (
<div className="flex w-full items-center gap-3.5 px-4 py-4 text-start">
<span className="text-ink-2"><Check size={19} /></span>
<span className="flex-1 font-medium text-ink-3">{t('settings.installed')}</span>
</div>
) : (
<button onClick={onInstall} className="flex w-full items-center gap-3.5 px-4 py-4 text-start transition-colors active:bg-surface-2">
<span className="text-ink-2"><Smartphone size={19} /></span>
<span className="flex-1 font-medium">{t('settings.installApp')}</span>
<span className="text-ink-3">→</span>
</button>
)}
</div>
<p className="mt-2.5 text-xs text-ink-3">{t('settings.installHint')}</p>
<SectionTitle>{t('settings.databases')}</SectionTitle>
<div className="card space-y-4 p-4">
<div>
+13 -5
View File
@@ -31,7 +31,7 @@ function persistLists(lists: CustomList[]) {
/* ignore */
}
}
const DEFAULT_SETTINGS: Settings = { ratingScale: '5', topCategories: ALL_TOP_CATEGORIES, accentColor: DEFAULT_ACCENT }
const DEFAULT_SETTINGS: Settings = { ratingScale: '5', topCategories: ALL_TOP_CATEGORIES, accentColor: DEFAULT_ACCENT, themeMode: 'auto' }
/** Relit les réglages en ne gardant que des valeurs valides (le localStorage peut avoir été modifié). */
function loadSettings(): Settings {
@@ -168,8 +168,8 @@ export function MediaProvider({ children, cloudUser }: { children: ReactNode; cl
getLists: () => listsRef.current,
applyLists: (next) => setLists(() => next, true),
getSettings: () => {
const { ratingScale, topCategories, accentColor } = settingsRef.current
return { ratingScale, topCategories, accentColor }
const { ratingScale, topCategories, accentColor, themeMode } = settingsRef.current
return { ratingScale, topCategories, accentColor, themeMode }
},
applySettings: (patch) => updateSettingsRef.current(patch, true),
itemsChanged: () => void reloadItems(),
@@ -199,10 +199,18 @@ export function MediaProvider({ children, cloudUser }: { children: ReactNode; cl
}, [cloudUser?.id])
// Thème de couleur appliqué avant l'affichage (pas de flash de rouge)
useLayoutEffect(() => applyTheme(settings.accentColor), [settings.accentColor])
useLayoutEffect(() => applyTheme(settings.accentColor, settings.themeMode), [settings.accentColor, settings.themeMode])
// En mode « auto », suit le clair/sombre du navigateur en direct
useEffect(() => {
if (settings.themeMode !== 'auto' || !window.matchMedia) return
const mq = window.matchMedia('(prefers-color-scheme: light)')
const onChange = () => applyTheme(settingsRef.current.accentColor, 'auto')
mq.addEventListener('change', onChange)
return () => mq.removeEventListener('change', onChange)
}, [settings.themeMode])
const updateSettings = useCallback((patch: Partial<Settings>, silent = false) => {
if (!silent && syncRef.current && ('ratingScale' in patch || 'topCategories' in patch || 'accentColor' in patch)) syncRef.current.markSettings()
if (!silent && syncRef.current && ('ratingScale' in patch || 'topCategories' in patch || 'accentColor' in patch || 'themeMode' in patch)) syncRef.current.markSettings()
setSettings((prev) => {
const next = { ...prev, ...patch }
try {
+5
View File
@@ -64,6 +64,9 @@ export type MediaInput = Omit<MediaItem, 'id' | 'createdAt' | 'updatedAt'>
export type RatingScale = '5' | '10'
/** Apparence : auto suit le navigateur (clair/sombre), les autres sont forcés. */
export type ThemeMode = 'auto' | 'light' | 'dark' | 'night' | 'starfield'
/** Catégories de Top 5 */
export type TopCategory = 'film' | 'serie' | 'anime' | 'kdrama' | 'cdrama'
@@ -81,6 +84,8 @@ export interface Settings {
topCategories: TopCategory[]
/** Couleur du thème (hex), rouge par défaut. */
accentColor: string
/** Apparence (clair, sombre, nuit, bleu nuit étoilé). « auto » suit le navigateur. */
themeMode: ThemeMode
}
export interface CustomList {