diff --git a/docs/design-system.md b/docs/design-system.md index 2ce1eb3..815703d 100644 --- a/docs/design-system.md +++ b/docs/design-system.md @@ -218,7 +218,7 @@ eNotify 的视觉语言从它的核心语义直接长出来:**每一笔周期 **中性色阶(8 级,亮色 zinc 系微调,暗色独立调色非反色):** -亮色:`--n-0:#ffffff(bg)` `--n-50:#fafafa` `--n-100:#f4f4f5(muted bg)` `--n-200:#e4e4e7(border)` `--n-300:#d4d4d8(input border)` `--n-500:#71717a(muted fg,on 白 4.83:1 ✅)` `--n-700:#3f3f46(次级 fg)` `--n-900:#18181b(主 fg,on 白 17.72:1 ✅)` +亮色:`--n-0:#ffffff(bg)` `--n-50:#fafafa` `--n-100:#f4f4f5(muted bg)` `--n-200:#e4e4e7(border)` `--n-300:#d4d4d8(input border)` `--n-500:#666670(muted fg,on 白 6.10:1 ✅、on muted 5.16:1 ✅)` `--n-700:#3f3f46(次级 fg)` `--n-900:#18181b(主 fg,on 白 17.72:1 ✅)` 暗色:`--n-900:#0a0a0c(bg)` `--n-850:#111114(card bg)` `--n-800:#1a1a1f(muted bg)` `--n-700:#26262c(border)` `--n-600:#34343c(input border)` `--n-400:#a1a1aa(muted fg,on bg 7.76:1 ✅)` `--n-200:#d4d4d8(次级 fg)` `--n-50:#fafafa(主 fg,on bg 19.06:1 ✅)` @@ -231,7 +231,7 @@ eNotify 的视觉语言从它的核心语义直接长出来:**每一笔周期 | `--card` / `--popover` | `n-0 #ffffff` | `n-850 #111114` | | `--card-foreground` / `--popover-foreground` | `n-900 #18181b` | `n-50 #fafafa` | | `--muted` / `--accent` | `n-100 #f4f4f5` | `n-800 #1a1a1f` | -| `--muted-foreground` / `--accent-foreground` | `n-500 #71717a` / `n-900` | `n-400 #a1a1aa` / `n-50` | +| `--muted-foreground` / `--accent-foreground` | `n-500 #666670` / `n-900` | `n-400 #a1a1aa` / `n-50` | | `--secondary` | `n-100 #f4f4f5` | `n-800 #1a1a1f` | | `--secondary-foreground` | `n-900 #18181b` | `n-50 #fafafa` | | `--border` | `n-200 #e4e4e7` | `n-700 #26262c` | @@ -255,7 +255,7 @@ eNotify 的视觉语言从它的核心语义直接长出来:**每一笔周期 | token | 阈值 | 亮色 | 暗色 | |---|---|---|---| -| `--color-due-far` | >30 天 | neutral `#71717a` / `#a1a1aa` | `#a1a1aa` | +| `--color-due-far` | >30 天 | neutral `#666670` | `#a1a1aa` | | `--color-due-soon` | ≤30 天 | `#4f46e5` | `#818cf8` | | `--color-due-close` | ≤7 天 | `#b45309` | `#fbbf24` | | `--color-due-over` | 逾期 | `#b91c1c` | `#f87171` | @@ -297,6 +297,16 @@ eNotify 的视觉语言从它的核心语义直接长出来:**每一笔周期 --- +## 附录 A:契约修订记录 + +### A-1(ONE-70,2026-10-23,Mike 授权修订) + +- **问题**:冻结值 `muted-foreground on muted`(`n-500 #71717a` on `n-100 #f4f4f5`)实测对比度 4.39:1,低于父单 color 维度的 AA 正文指标(≥4.5:1),差 0.11。 +- **修订**:亮色 `n-500` 由 `240 3.8% 46.1%`(`#71717a`)调整为 `240 4.9% 42%`(`#666670`)。同步引用该值的 token:`--muted-foreground`(亮色)与 `--due-far`(亮色)。 +- **达标后对比度**:`n-500 on n-100` = **5.16:1** ✅;`n-500 on n-0`(白底)= **6.10:1** ✅。暗色组合(`n-400 on n-800` = 6.76:1)原本达标,未动。 + +--- + ## 6. 契约边界(与冻结条款对齐) - **唯一契约**:本文件是唯一冻结契约。历史文档 `web/docs/design-contract.md`(存在于旧分支 `agent/mary/a19f619bb981` / `ed2f1ad360d5`,未进 main)**已退役**,不再作为任何实现依据;若其所在分支后续合并,必须删除该文件或以醒目批注指向本文档。 diff --git a/web/src/components/AuthShell.tsx b/web/src/components/AuthShell.tsx new file mode 100644 index 0000000..50568cb --- /dev/null +++ b/web/src/components/AuthShell.tsx @@ -0,0 +1,48 @@ +import type { ReactNode } from "react"; +import { cn } from "@/lib/utils"; + +/** + * Centered auth card — shared by login/register/forgot/2fa/verify-email/setup + * (design contract §5: 400px width, shadow-2, display-level logo area). + */ +export function AuthShell({ + title, + subtitle, + children, + className, +}: { + title: ReactNode; + subtitle?: ReactNode; + children: ReactNode; + className?: string; +}) { + return ( +
+
+
+
+

{title}

+ {subtitle && ( +

+ {subtitle} +

+ )} +
+ {children} +
+
+
+ ); +} + +/** Inline form error that slides in (200ms, contract §5 auth). */ +export function FormError({ children }: { children: ReactNode }) { + return ( +

+ {children} +

+ ); +} diff --git a/web/src/components/ConfirmDialog.tsx b/web/src/components/ConfirmDialog.tsx index 11b7626..40427ff 100644 --- a/web/src/components/ConfirmDialog.tsx +++ b/web/src/components/ConfirmDialog.tsx @@ -1,4 +1,5 @@ import { AlertTriangle } from "lucide-react"; +import { useFocusTrap } from "@/hooks/useFocusTrap"; interface ConfirmDialogProps { open: boolean; @@ -21,6 +22,8 @@ export function ConfirmDialog({ onConfirm, onCancel, }: ConfirmDialogProps) { + const trapRef = useFocusTrap(open, onCancel); + if (!open) return null; return ( @@ -31,7 +34,10 @@ export function ConfirmDialog({ className="absolute inset-0 bg-black/40" onClick={onCancel} /> -
+
- {title &&

{title}

} -

{message}

+ {title &&

{title}

} +

{message}

@@ -56,7 +62,7 @@ export function ConfirmDialog({ type="button" onClick={onConfirm} className={cn( - "px-4 py-2 rounded-lg text-sm font-medium transition-colors", + "px-4 py-2 rounded-md text-body-sm font-medium transition-colors", variant === "danger" ? "bg-destructive text-destructive-foreground hover:bg-destructive/90" : "bg-primary text-primary-foreground hover:bg-primary/90", diff --git a/web/src/components/DueRing.tsx b/web/src/components/DueRing.tsx new file mode 100644 index 0000000..3749225 --- /dev/null +++ b/web/src/components/DueRing.tsx @@ -0,0 +1,129 @@ +import { useTranslation } from "react-i18next"; +import { cn } from "@/lib/utils"; + +/** + * Countdown urgency tiers — the single semantic color gradient of the + * design system (design contract §3.1 / §4.6). + */ +export type DueTier = "far" | "soon" | "close" | "over"; + +export function getDueTier(days: number): DueTier { + if (days < 0) return "over"; + if (days <= 7) return "close"; + if (days <= 30) return "soon"; + return "far"; +} + +const TIER_TEXT: Record = { + far: "text-due-far", + soon: "text-due-soon", + close: "text-due-close", + over: "text-due-over", +}; + +const TIER_BADGE: Record = { + far: "bg-due-far/10 text-due-far", + soon: "bg-due-soon/10 text-due-soon", + close: "bg-due-close/10 text-due-close", + over: "bg-due-over/10 text-due-over", +}; + +export function dueTierTextClass(days: number): string { + return TIER_TEXT[getDueTier(days)]; +} + +export function dueTierBadgeClass(days: number): string { + return TIER_BADGE[getDueTier(days)]; +} + +/** Circular remaining-progress ring (design contract §3.1 — countdown is first-class). */ +export function DueRing({ + days, + progress, + size = 28, + strokeWidth = 3, + className, +}: { + days: number; + /** 0..1 — fraction of the period still remaining */ + progress: number; + size?: number; + strokeWidth?: number; + className?: string; +}) { + const { t } = useTranslation(); + const tier = getDueTier(days); + const r = (size - strokeWidth) / 2; + const c = 2 * Math.PI * r; + const clamped = Math.max(0, Math.min(1, progress)); + const ariaLabel = + days < 0 + ? t("common.overdueBy", { count: -days }) + : t("common.daysLeftShort", { count: days }); + return ( + + + + + ); +} + +/** Ledger-style countdown: large tabular numeral + small unit (§3.1, Cron-style asymmetric type). */ +export function DueCount({ + days, + unit, + size = "md", + className, +}: { + days: number; + unit: string; + size?: "sm" | "md" | "lg"; + className?: string; +}) { + const tier = getDueTier(days); + const numCls = + size === "lg" + ? "text-display-lg" + : size === "md" + ? "text-display" + : "text-title"; + return ( + + + {days < 0 ? `-${Math.abs(days)}` : days} + + {unit} + + ); +} diff --git a/web/src/components/PasswordPromptDialog.tsx b/web/src/components/PasswordPromptDialog.tsx index 9d2aa0a..64ab621 100644 --- a/web/src/components/PasswordPromptDialog.tsx +++ b/web/src/components/PasswordPromptDialog.tsx @@ -1,5 +1,6 @@ import { useState } from "react"; import { useTranslation } from "react-i18next"; +import { useFocusTrap } from "@/hooks/useFocusTrap"; interface PasswordPromptDialogProps { open: boolean; @@ -17,13 +18,15 @@ export function PasswordPromptDialog({ const { t } = useTranslation(); const [password, setPassword] = useState(""); - if (!open) return null; + const trapRef = useFocusTrap(open, onCancel); const close = () => { setPassword(""); onCancel(); }; + if (!open) return null; + return (
+ )} +
+ ); +} diff --git a/web/src/components/ui/button.tsx b/web/src/components/ui/button.tsx index 4e8df2d..9f6b16b 100644 --- a/web/src/components/ui/button.tsx +++ b/web/src/components/ui/button.tsx @@ -8,7 +8,8 @@ const buttonVariants = cva( { variants: { variant: { - default: "bg-primary text-primary-foreground shadow-1 hover:bg-primary/90", + default: + "bg-primary text-primary-foreground shadow-1 hover:bg-primary/90", destructive: "bg-destructive text-destructive-foreground shadow-1 hover:bg-destructive/90", outline: diff --git a/web/src/components/ui/card.tsx b/web/src/components/ui/card.tsx index 046b8d5..e973a93 100644 --- a/web/src/components/ui/card.tsx +++ b/web/src/components/ui/card.tsx @@ -7,7 +7,10 @@ const Card = React.forwardRef< >(({ className, ...props }, ref) => (
)); @@ -49,7 +52,11 @@ const CardContent = React.forwardRef< HTMLDivElement, React.HTMLAttributes >(({ className, ...props }, ref) => ( -
+
)); CardContent.displayName = "CardContent"; diff --git a/web/src/hooks/useFocusTrap.ts b/web/src/hooks/useFocusTrap.ts new file mode 100644 index 0000000..a8c74bb --- /dev/null +++ b/web/src/hooks/useFocusTrap.ts @@ -0,0 +1,77 @@ +import { useEffect, useRef } from "react"; + +/** + * Focus trap for modal overlays (design contract / a11y): + * - moves initial focus into the container on mount + * - keeps Tab / Shift+Tab cycling inside + * - closes on Escape + * - returns focus to the previously focused element on unmount + */ +export function useFocusTrap( + active: boolean, + onEscape?: () => void, +) { + const ref = useRef(null); + const restoreRef = useRef(null); + const escapeRef = useRef(onEscape); + escapeRef.current = onEscape; + + useEffect(() => { + if (!active) return; + const node = ref.current; + if (!node) return; + + restoreRef.current = document.activeElement as HTMLElement | null; + + const focusables = () => + Array.from( + node.querySelectorAll( + 'a[href], button:not([disabled]), textarea, input, select, [tabindex]:not([tabindex="-1"])', + ), + ).filter( + (el) => el.offsetParent !== null || el === document.activeElement, + ); + + // initial focus: first focusable, else the container itself + const first = focusables()[0]; + if (first) first.focus(); + else { + node.setAttribute("tabindex", "-1"); + node.focus(); + } + + const onKeyDown = (e: KeyboardEvent) => { + if (e.key === "Escape") { + e.stopPropagation(); + escapeRef.current?.(); + return; + } + if (e.key !== "Tab") return; + const items = focusables(); + if (items.length === 0) { + e.preventDefault(); + return; + } + const firstItem = items[0]; + const lastItem = items[items.length - 1]; + const current = document.activeElement as HTMLElement | null; + if (e.shiftKey) { + if (!current || current === firstItem || !node.contains(current)) { + e.preventDefault(); + lastItem.focus(); + } + } else if (!current || current === lastItem || !node.contains(current)) { + e.preventDefault(); + firstItem.focus(); + } + }; + + document.addEventListener("keydown", onKeyDown, true); + return () => { + document.removeEventListener("keydown", onKeyDown, true); + restoreRef.current?.focus?.(); + }; + }, [active]); + + return ref; +} diff --git a/web/src/index.css b/web/src/index.css index af8387b..610ddb1 100644 --- a/web/src/index.css +++ b/web/src/index.css @@ -71,8 +71,9 @@ "Inter", ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif; - --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, - "Liberation Mono", monospace; + --font-mono: + ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", + monospace; --text-caption: 0.75rem; --text-caption--line-height: 1.5; @@ -136,7 +137,7 @@ --n-200: 240 5.9% 90%; --n-300: 240 4.9% 83.9%; --n-400: 240 5% 64.9%; - --n-500: 240 3.8% 46.1%; + --n-500: 240 4.9% 42%; --n-600: 240 7.1% 22%; --n-700: 240 5.3% 26.1%; --n-800: 240 8.8% 11.2%; @@ -157,7 +158,7 @@ --secondary: 240 4.8% 95.9%; --secondary-foreground: 240 5.9% 10%; --muted: 240 4.8% 95.9%; - --muted-foreground: 240 3.8% 46.1%; + --muted-foreground: 240 4.9% 42%; --accent: 240 4.8% 95.9%; --accent-foreground: 240 5.9% 10%; --destructive: 0 73.7% 41.8%; @@ -173,7 +174,7 @@ --ring: 243.4 75.4% 58.6%; /* Countdown urgency gradient (light) */ - --due-far: 240 3.8% 46.1%; + --due-far: 240 4.9% 42%; --due-soon: 243.4 75.4% 58.6%; --due-close: 26 90.5% 37.1%; --due-over: 0 73.7% 41.8%; @@ -264,6 +265,18 @@ body { font-variant-numeric: tabular-nums; } +/* Form error slide-in (design contract §5 auth) */ +@keyframes form-error-in { + from { + opacity: 0; + transform: translateY(-4px); + } + to { + opacity: 1; + transform: none; + } +} + /* Respect reduced motion — design contract §4.7. Unlayered rule beats Tailwind's layered utilities; avoids !important (biome noImportantStyles). */ @media (prefers-reduced-motion: reduce) { diff --git a/web/src/lib/utils.ts b/web/src/lib/utils.ts index ea2f9a1..5f5a1dd 100644 --- a/web/src/lib/utils.ts +++ b/web/src/lib/utils.ts @@ -5,6 +5,19 @@ export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } +/** Local YYYY-MM-DD today — shared by countdown/status calculations. */ +export function localToday(): string { + const d = new Date(); + return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, "0")}-${String(d.getDate()).padStart(2, "0")}`; +} + +/** Days from today until a YYYY-MM-DD date (negative = overdue). */ +export function daysUntil(date: string): number { + return Math.ceil( + (new Date(date).getTime() - new Date(localToday()).getTime()) / 86400000, + ); +} + function bufferToBase64url(buffer: ArrayBuffer): string { const bytes = new Uint8Array(buffer); let binary = ""; diff --git a/web/src/locales/en.json b/web/src/locales/en.json index df1e9f0..f6d5a1e 100644 --- a/web/src/locales/en.json +++ b/web/src/locales/en.json @@ -35,7 +35,11 @@ "period": "Period", "confirmDelete": "Delete \"{{name}}\"?", "confirmDeletePayment": "Delete this payment?", - "notificationSent": "Notification sent!" + "notificationSent": "Notification sent!", + "retry": "Retry", + "more": "More", + "daysLeftShort": "{{count}} days left", + "overdueBy": "Overdue by {{count}} days" }, "auth": { "login": "Login", @@ -71,7 +75,8 @@ "resendCode": "Resend code", "resendCodeCountdown": "Resend ({{seconds}}s)", "resetCodeCooldown": "Too many requests, please try again later", - "backToLogin": "Back to login" + "backToLogin": "Back to login", + "loading": "Please wait…" }, "nav": { "dashboard": "Dashboard", @@ -93,7 +98,7 @@ "yearlyExpense": "Yearly Expense", "monthlyAverage": "Monthly Avg", "activeCount": "Active Notifications", - "expiringSoon": "Expiring Soon", + "expiringSoon": "Due in 7 days", "upcomingRenewals": "Upcoming Renewals", "recentPayments": "Recent Payments", "categoryRanking": "By Category", @@ -105,7 +110,15 @@ "regularSection": "Regular Reminders", "activeRegularCount": "Active Reminders", "upcomingReminders": "Upcoming Reminders", - "regularCategoryRanking": "By Category (count)" + "regularCategoryRanking": "By Category (count)", + "overdue": "Overdue", + "expiring30": "Due in 30 days", + "daysUnit": "d", + "nextDue": "Next due", + "monthSpent": "This month", + "noUpcoming": "Nothing due soon", + "expiring7": "Due in 7 days", + "activeTotal": "Active items" }, "items": { "title": "Notifications", @@ -157,7 +170,7 @@ "expired": "Expired", "expiringSoon": "Expiring Soon" }, - "daysRemaining": "{{days}} days remaining", + "daysRemaining": "Days left", "expired": "Expired {{days}} days ago", "notFound": "Notification not found", "paymentType": { @@ -185,7 +198,13 @@ "filterAll": "All", "searchPlaceholder": "Search notifications...", "sortExpiry": "Expiry", - "statusAll": "All Status" + "statusAll": "All Status", + "daysShort": "{{count}}d", + "overdueShort": "{{count}}d overdue", + "emptyTitle": "No entries yet", + "emptyDesc": "Add your first subscription or reminder to start your ledger of time.", + "amountDue": "Amount", + "moreActions": "More actions" }, "settings": { "title": "Settings", @@ -275,7 +294,10 @@ "noData": "No notification records yet", "detail": "Notification Detail", "content": "Message Content", - "noContent": "No message content for this record" + "noContent": "No message content for this record", + "emptyTitle": "No history yet", + "emptyDesc": "Sent notifications will be recorded here.", + "loadError": "Failed to load history" }, "admin": { "title": "Admin Panel", @@ -395,6 +417,22 @@ "missingSecret": "Please enter the setup secret.", "wrongSecret": "Incorrect setup secret.", "rateLimited": "Too many requests, please try again later.", - "genericError": "Initialization failed, please try again later." + "genericError": "Initialization failed, please try again later.", + "stepInit": "Initialize", + "stepDone": "Done" + }, + "me": { + "dueThisMonth": "Due in 7 days", + "entries": "entries", + "due7": "Due in 7 days" + }, + "detail": { + "sectionBasic": "Basic info", + "sectionCycle": "Cycle & expiry", + "sectionReminder": "Reminder & channels", + "sectionNotes": "Notes", + "summary": "Due preview", + "daysLeft": "remaining", + "daysUnit": "d" } } diff --git a/web/src/locales/zh.json b/web/src/locales/zh.json index e7a14f2..e912595 100644 --- a/web/src/locales/zh.json +++ b/web/src/locales/zh.json @@ -35,7 +35,11 @@ "period": "周期", "confirmDelete": "确定删除 \"{{name}}\"?", "confirmDeletePayment": "确定删除该支付记录?", - "notificationSent": "通知已发送!" + "notificationSent": "通知已发送!", + "retry": "重试", + "more": "更多", + "daysLeftShort": "剩余 {{count}} 天", + "overdueBy": "已逾期 {{count}} 天" }, "auth": { "login": "登录", @@ -71,7 +75,8 @@ "resendCode": "重新发送验证码", "resendCodeCountdown": "重新发送 ({{seconds}}s)", "resetCodeCooldown": "请求过于频繁,请稍后再试", - "backToLogin": "返回登录" + "backToLogin": "返回登录", + "loading": "请稍候…" }, "nav": { "dashboard": "仪表盘", @@ -93,7 +98,7 @@ "yearlyExpense": "年度支出", "monthlyAverage": "月均", "activeCount": "活跃通知", - "expiringSoon": "即将到期", + "expiringSoon": "7 天内到期", "upcomingRenewals": "即将续费", "recentPayments": "近期支付", "categoryRanking": "分类排行", @@ -105,7 +110,15 @@ "regularSection": "普通提醒", "activeRegularCount": "活跃普通提醒", "upcomingReminders": "即将到期提醒", - "regularCategoryRanking": "分类排行(条数)" + "regularCategoryRanking": "分类排行(条数)", + "overdue": "已逾期", + "expiring30": "30 天内到期", + "daysUnit": "天", + "nextDue": "最近到期", + "monthSpent": "本月支出", + "noUpcoming": "暂无即将到期事项", + "expiring7": "7 天内到期", + "activeTotal": "活跃条目" }, "items": { "title": "通知管理", @@ -157,7 +170,7 @@ "expired": "已过期", "expiringSoon": "即将到期" }, - "daysRemaining": "剩余 {{days}} 天", + "daysRemaining": "剩余天数", "expired": "已过期 {{days}} 天", "notFound": "未找到该通知", "paymentType": { @@ -185,7 +198,13 @@ "filterAll": "全部", "searchPlaceholder": "搜索通知...", "sortExpiry": "到期日", - "statusAll": "全部状态" + "statusAll": "全部状态", + "daysShort": "{{count}} 天", + "overdueShort": "逾期 {{count}} 天", + "emptyTitle": "还没有任何账目", + "emptyDesc": "添加第一笔订阅或提醒,开始记录你的时间账本。", + "amountDue": "金额", + "moreActions": "更多操作" }, "settings": { "title": "设置", @@ -275,7 +294,10 @@ "noData": "暂无通知记录", "detail": "通知详情", "content": "消息内容", - "noContent": "该记录无消息内容" + "noContent": "该记录无消息内容", + "emptyTitle": "还没有发送记录", + "emptyDesc": "通知发出后会在这里留下账目。", + "loadError": "发送记录加载失败" }, "admin": { "title": "管理后台", @@ -395,6 +417,22 @@ "missingSecret": "请输入密钥。", "wrongSecret": "密钥错误,请检查后重试。", "rateLimited": "请求过于频繁,请稍后再试。", - "genericError": "初始化失败,请稍后再试。" + "genericError": "初始化失败,请稍后再试。", + "stepInit": "初始化", + "stepDone": "完成" + }, + "me": { + "dueThisMonth": "7 天内到期", + "entries": "笔", + "due7": "7 天内到期" + }, + "detail": { + "sectionBasic": "基本信息", + "sectionCycle": "周期与到期", + "sectionReminder": "提醒与渠道", + "sectionNotes": "备注", + "summary": "到期预览", + "daysLeft": "剩余", + "daysUnit": "天" } } diff --git a/web/src/pages/about/AboutPage.tsx b/web/src/pages/about/AboutPage.tsx index 038500f..9548e0b 100644 --- a/web/src/pages/about/AboutPage.tsx +++ b/web/src/pages/about/AboutPage.tsx @@ -13,32 +13,32 @@ export function AboutPage() { ]; return ( -
-

{t("about.title")}

+
+

{t("about.title")}

-
-
- +
+
+
{t("about.version")} - - +
+
{__APP_VERSION__} - -
+ +
-

+

{t("about.description")}

-
-

{t("about.builtWith")}

+
+

{t("about.builtWith")}

    {stack.map((item) => (
  • {item} @@ -47,26 +47,28 @@ export function AboutPage() {
-
-
- +
+
+
{t("about.sourceCode")} - - - GitHub - -
-
- + +
+ + GitHub + +
+ +
+
{t("about.license")} - - MIT -
+ +
MIT
+
); diff --git a/web/src/pages/admin/AdminAppPage.tsx b/web/src/pages/admin/AdminAppPage.tsx index c3b3e73..7af6206 100644 --- a/web/src/pages/admin/AdminAppPage.tsx +++ b/web/src/pages/admin/AdminAppPage.tsx @@ -5,12 +5,12 @@ import { api } from "@/lib/api"; import type { SystemSettings } from "@/types"; const INPUT = - "w-full rounded-lg border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary/50 transition-shadow"; + "w-full rounded-lg border bg-background px-3 py-2 text-body-sm focus:outline-none focus:ring-2 focus:ring-primary/50 transition-shadow"; function Field({ label, children }: { label: string; children: ReactNode }) { return (
- + {children}
); @@ -52,8 +52,11 @@ export function AdminAppPage() { if (loading) { return ( -
-
+
+
+
+
+
); } @@ -61,7 +64,7 @@ export function AdminAppPage() { return (
{error && ( -
+
{error}
@@ -89,7 +92,9 @@ export function AdminAppPage() { > {saving ? t("common.loading") : t("common.save")} - {saveMsg && {saveMsg}} + {saveMsg && ( + {saveMsg} + )}
diff --git a/web/src/pages/admin/AdminEmailPage.tsx b/web/src/pages/admin/AdminEmailPage.tsx index 866fdbc..f0d6990 100644 --- a/web/src/pages/admin/AdminEmailPage.tsx +++ b/web/src/pages/admin/AdminEmailPage.tsx @@ -23,12 +23,12 @@ interface ResendConfig { } const INPUT = - "w-full rounded-lg border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-primary/50 transition-shadow"; + "w-full rounded-lg border bg-background px-3 py-2 text-body-sm focus:outline-none focus:ring-2 focus:ring-primary/50 transition-shadow"; function Field({ label, children }: { label: string; children: ReactNode }) { return (
- + {children}
); @@ -162,7 +162,7 @@ export function AdminEmailPage() { if (loading) { return ( -
+
@@ -172,7 +172,7 @@ export function AdminEmailPage() { return (
{error && ( -
+
{error}
@@ -296,7 +296,9 @@ export function AdminEmailPage() { > {saving ? t("common.loading") : t("common.save")} - {saveMsg && {saveMsg}} + {saveMsg && ( + {saveMsg} + )}
{emailProvider !== "none" && ( @@ -320,7 +322,9 @@ export function AdminEmailPage() { {testEmailLoading ? t("common.loading") : t("admin.testEmail")} {testEmailMsg && ( - {testEmailMsg} + + {testEmailMsg} + )} {testEmailError && ( diff --git a/web/src/pages/admin/AdminPage.tsx b/web/src/pages/admin/AdminPage.tsx index 8371036..2add308 100644 --- a/web/src/pages/admin/AdminPage.tsx +++ b/web/src/pages/admin/AdminPage.tsx @@ -35,9 +35,7 @@ export function AdminPage() { if (isIndex && isMobile) { return (
-

- {t("admin.title")} -

+

{t("admin.title")}

{tabs.map(({ to, label, icon: Icon }) => ( - {saveMsg && {saveMsg}} + {saveMsg && ( + {saveMsg} + )}
@@ -201,7 +205,7 @@ export function AdminSecurityPage() {

{upgradeResult && ( -

{upgradeResult}

+

{upgradeResult}

)} {upgradeError && (

{upgradeError}

diff --git a/web/src/pages/admin/AdminUsersPage.tsx b/web/src/pages/admin/AdminUsersPage.tsx index 7743eee..a62153f 100644 --- a/web/src/pages/admin/AdminUsersPage.tsx +++ b/web/src/pages/admin/AdminUsersPage.tsx @@ -16,6 +16,7 @@ import { import { ConfirmDialog } from "@/components/ConfirmDialog"; import { api } from "@/lib/api"; import { cn } from "@/lib/utils"; +import { useFocusTrap } from "@/hooks/useFocusTrap"; import { useAuth } from "@/hooks/useAuth"; interface AdminUser { @@ -28,13 +29,12 @@ interface AdminUser { } const ROLE_STYLE: Record = { - admin: - "bg-purple-100 text-purple-700 dark:bg-purple-900/30 dark:text-purple-400", - user: "bg-gray-100 text-gray-600 dark:bg-gray-800 dark:text-gray-400", + admin: "bg-info/10 text-info", + user: "bg-muted text-muted-foreground", }; const INPUT = - "w-full px-3 py-2 rounded-md border border-input bg-background text-foreground text-sm focus:outline-none focus:ring-2 focus:ring-ring"; + "w-full px-3 py-2 rounded-md border border-input bg-background text-foreground text-body-sm focus:outline-none focus:ring-2 focus:ring-ring"; const SELECT = cn(INPUT, "cursor-pointer"); export function AdminUsersPage() { @@ -57,6 +57,9 @@ export function AdminUsersPage() { const [editEmail, setEditEmail] = useState(""); const [editPassword, setEditPassword] = useState(""); const [editing, setEditing] = useState(false); + const editTrapRef = useFocusTrap(!!editUser, () => + setEditUser(null), + ); const [pendingAction, setPendingAction] = useState<{ message: string; danger?: boolean; @@ -208,13 +211,15 @@ export function AdminUsersPage() {
-

+

{t("admin.userCount")}

{loading ? ( -
+
) : ( -

{users.length}

+

+ {users.length} +

)}
@@ -232,7 +237,7 @@ export function AdminUsersPage() {
{error && ( -
+
{error}
@@ -245,7 +250,9 @@ export function AdminUsersPage() {
- +
-
- +
-
+ ); } diff --git a/web/src/pages/auth/LoginPage.tsx b/web/src/pages/auth/LoginPage.tsx index b6d099f..a4ab214 100644 --- a/web/src/pages/auth/LoginPage.tsx +++ b/web/src/pages/auth/LoginPage.tsx @@ -5,6 +5,7 @@ import { Globe, Sun, Moon, Monitor } from "lucide-react"; import { useAuth } from "@/hooks/useAuth"; import { useTheme } from "@/components/ThemeProvider"; import { api } from "@/lib/api"; +import { AuthShell, FormError } from "@/components/AuthShell"; export function LoginPage() { const { t, i18n } = useTranslation(); @@ -68,9 +69,9 @@ export function LoginPage() { const ThemeIcon = theme === "light" ? Sun : theme === "dark" ? Moon : Monitor; return ( -
+ {/* Top-right controls */} -
+
-
-
-
-

- {t("app.name")} -

-

- {t("app.tagline")} -

-
- +
+
-
-
- {error && ( -

- {error} -

- )} + {error && {error}} {registrationEnabled && ( -

+

{t("auth.noAccount")}{" "}

-
+ ); } diff --git a/web/src/pages/auth/RegisterPage.tsx b/web/src/pages/auth/RegisterPage.tsx index df81b48..20ca5f8 100644 --- a/web/src/pages/auth/RegisterPage.tsx +++ b/web/src/pages/auth/RegisterPage.tsx @@ -4,6 +4,7 @@ import { useTranslation } from "react-i18next"; import { Globe, Sun, Moon, Monitor } from "lucide-react"; import { useAuth } from "@/hooks/useAuth"; import { useTheme } from "@/components/ThemeProvider"; +import { AuthShell, FormError } from "@/components/AuthShell"; export function RegisterPage() { const { t, i18n } = useTranslation(); @@ -56,9 +57,9 @@ export function RegisterPage() { const ThemeIcon = theme === "light" ? Sun : theme === "dark" ? Moon : Monitor; return ( -
+ {/* Top-right controls */} -
+
-
-
-
-

- {t("app.name")} -

-

- {t("app.tagline")} -

-
- +
+
{message ? (
-
+
{message}
{t("auth.login")} @@ -103,7 +95,7 @@ export function RegisterPage() { ) : (
-
-
-
- {error && ( -

- {error} -

- )} + {error && {error}}
)} {!message && ( -

+

{t("auth.hasAccount")}{" "}

-
+ ); } diff --git a/web/src/pages/auth/TwoFactorPage.tsx b/web/src/pages/auth/TwoFactorPage.tsx index 50f66be..8903be2 100644 --- a/web/src/pages/auth/TwoFactorPage.tsx +++ b/web/src/pages/auth/TwoFactorPage.tsx @@ -9,6 +9,7 @@ import { serializeAuthenticationCredential, prepareAuthenticationOptions, } from "@/lib/utils"; +import { AuthShell, FormError } from "@/components/AuthShell"; type Method = "totp" | "email_otp" | "passkey"; @@ -125,16 +126,9 @@ export function TwoFactorPage() { }; return ( -
-
-
-

- {t("auth.twoFactor")} -

-

- {t("auth.enterCode")} -

- + +
+
{/* Method selector */} {availableMethods.length > 1 && (
@@ -161,9 +155,9 @@ export function TwoFactorPage() { )} {error && ( -

- {error} -

+
+ {error} +
)} {activeMethod === "passkey" ? ( @@ -174,7 +168,7 @@ export function TwoFactorPage() { className="w-full py-2 px-4 bg-primary hover:bg-primary/90 disabled:opacity-50 text-primary-foreground text-sm font-medium rounded-md transition-colors flex items-center justify-center gap-2" > - {loading ? t("common.loading") : t("auth.passkey")} + {loading ? t("auth.loading") : t("auth.passkey")} ) : (
@@ -185,11 +179,11 @@ export function TwoFactorPage() { disabled={loading} className="w-full py-2 px-4 bg-secondary hover:bg-secondary/80 disabled:opacity-50 text-secondary-foreground text-sm font-medium rounded-md transition-colors" > - {loading ? t("common.loading") : t("auth.sendCode")} + {loading ? t("auth.loading") : t("auth.sendCode")} )} {activeMethod === "email_otp" && codeSent && ( -

+

{t("auth.verifyEmailSent")}

)} @@ -218,7 +212,7 @@ export function TwoFactorPage() { disabled={loading || code.length < 6} className="w-full py-2 px-4 bg-primary hover:bg-primary/90 disabled:opacity-50 text-primary-foreground text-sm font-medium rounded-md transition-colors" > - {loading ? t("common.loading") : t("common.confirm")} + {loading ? t("auth.loading") : t("common.confirm")} )} @@ -228,13 +222,13 @@ export function TwoFactorPage() {
← {t("common.back")}
-
+
); } diff --git a/web/src/pages/auth/VerifyEmailPage.tsx b/web/src/pages/auth/VerifyEmailPage.tsx index 7cc0ddd..d47cfca 100644 --- a/web/src/pages/auth/VerifyEmailPage.tsx +++ b/web/src/pages/auth/VerifyEmailPage.tsx @@ -3,6 +3,7 @@ import { Link, useSearchParams } from "react-router"; import { useTranslation } from "react-i18next"; import { CheckCircle, XCircle, Loader2 } from "lucide-react"; import { api } from "@/lib/api"; +import { AuthShell } from "@/components/AuthShell"; export function VerifyEmailPage() { const { t } = useTranslation(); @@ -38,27 +39,23 @@ export function VerifyEmailPage() { }, [token, t]); return ( -
-
-
-

- {t("auth.verifyEmail")} -

- + +
+
{status === "loading" && (
-

{t("common.loading")}

+

{t("auth.loading")}

)} {status === "success" && (
- -

{message}

+ +

{message}

{t("auth.login")} @@ -68,10 +65,10 @@ export function VerifyEmailPage() { {status === "error" && (
-

{message}

+

{message}

{t("auth.login")} @@ -79,6 +76,6 @@ export function VerifyEmailPage() { )}
-
+ ); } diff --git a/web/src/pages/channels/ChannelPage.tsx b/web/src/pages/channels/ChannelPage.tsx index e6d8d68..9424b4f 100644 --- a/web/src/pages/channels/ChannelPage.tsx +++ b/web/src/pages/channels/ChannelPage.tsx @@ -357,7 +357,7 @@ function ChannelCard({ }; return ( -
+
{/* Toggle switch */} @@ -366,7 +366,7 @@ function ChannelCard({ onClick={toggleEnabled} className={cn( "relative shrink-0 w-10 h-6 cursor-pointer rounded-full transition-colors", - isEnabled ? "bg-primary" : "bg-gray-300 dark:bg-gray-600", + isEnabled ? "bg-primary" : "bg-input", )} role="switch" aria-checked={isEnabled} @@ -378,8 +378,16 @@ function ChannelCard({ )} /> - - {channel.label} + {channel.label} + + {isEnabled ? t("common.enabled") : t("common.disabled")}
+ + + ))} + + ))} + + +
+ + {/* Mobile card list */} +
+ {groupedByDay.map(([day, rows]) => ( +
+

+ {day} +

+ {rows.map((g) => ( + - - - ))} - - -
- - {/* Mobile card list */} -
- {grouped.map((g) => ( - +
+
+ {g.channels.some((c) => c.error) && ( +

+ {g.channels + .filter((c) => c.error) + .map((c) => `${c.channel}: ${c.error}`) + .join("; ")}

)} -
- {g.allSuccess ? ( - - - {t("history.success")} - - ) : ( - - - {t("history.failed")} - - )} -
-
-
- {g.channels.map((c) => ( - - {c.channel} - - ))} -
-
- - {new Date(g.created_at).toLocaleString()} - - -
-
- {g.channels.some((c) => c.error) && ( -

- {g.channels - .filter((c) => c.error) - .map((c) => `${c.channel}: ${c.error}`) - .join("; ")} -

- )} - + + ))} +
))}
@@ -301,9 +356,15 @@ export function HistoryPage() { className="absolute inset-0 bg-black/40" onClick={() => setSelected(null)} /> -
+
-

{t("history.detail")}

+

{t("history.detail")}

-

{item.name}

+

{item.name}

- {error && ( -
- - {error} -
- )} - - {/* Edit form */} -
-

{t("common.edit")}

- - {/* Kind (read-only) */} -
- - {t("items.kind")}: - - - {item.item_kind === "subscription" - ? t("items.kindSubscription") - : t("items.kindRegular")} - -
- -
- - setField("name", e.target.value)} - required - /> - + {error && } - - - - - - setField("category", v)} - options={tags} - /> - - - +
+
+ {/* Edit form */} +
+

{t("common.edit")}

+ + {/* Kind (read-only) */}
- - setField("start_date", e.target.value || null) - } - /> - {item.calendar_mode !== "solar" && item.start_date && ( - - {formatLunarDate(item.start_date)} - - )} + + {t("items.kind")}: + + + {item.item_kind === "subscription" + ? t("items.kindSubscription") + : t("items.kindRegular")} +
- - - -
- - setField("period_value", Number(e.target.value)) - } - /> - setField("name", e.target.value)} + required + /> + + + - {item.calendar_mode === "solar" && ( - - )} - {item.calendar_mode === "solar" && ( - - )} - - - -
-
+ + + + + setField("category", v)} + options={tags} + /> + -
- - {item.calendar_mode === "both" ? ( -
-
- - {t("items.calendarSolar")} - - - setField("expiry_date", e.target.value) - } - required - /> - - {formatLunarDate(item.expiry_date)} - -
-
- - {t("items.calendarLunar")} - - - setField("lunar_expiry_date", e.target.value || null) - } - /> - {item.lunar_expiry_date && ( - - {formatLunarDate(item.lunar_expiry_date)} - - )} -
-
- ) : ( +
setField("expiry_date", e.target.value)} - required + value={item.start_date ?? ""} + onChange={(e) => + setField("start_date", e.target.value || null) + } /> - {item.calendar_mode !== "solar" && item.expiry_date && ( + {item.calendar_mode !== "solar" && item.start_date && ( - {formatLunarDate(item.expiry_date)} + {formatLunarDate(item.start_date)} )}
- )} -
-
+ - -
- - setField("reminder_value", Number(e.target.value)) - } - /> - + setField("period_value", Number(e.target.value)) + } + /> + +
+
+ +
- - - -
- -
+ + {item.calendar_mode === "both" ? ( +
+
+ + {t("items.calendarSolar")} + + + setField("expiry_date", e.target.value) + } + required + /> + + {formatLunarDate(item.expiry_date)} + +
+
+ + {t("items.calendarLunar")} + + + setField( + "lunar_expiry_date", + e.target.value || null, + ) + } + /> + {item.lunar_expiry_date && ( + + {formatLunarDate(item.lunar_expiry_date)} + + )} +
+
+ ) : ( +
+ + setField("expiry_date", e.target.value) + } + required + /> + {item.calendar_mode !== "solar" && item.expiry_date && ( + + {formatLunarDate(item.expiry_date)} + + )} +
+ )} +
+
- {item.item_kind === "subscription" && ( -
- - - setField( - "amount", - e.target.value ? Number(e.target.value) : null, - ) - } - /> - + +
+ + setField("reminder_value", Number(e.target.value)) + } + /> + +
+
+
- - - -
- )} + {item.item_kind === "subscription" && ( +
+

+ {t("detail.sectionCycle")} +

+ + + setField( + "amount", + e.target.value ? Number(e.target.value) : null, + ) + } + /> + + + + + +
+ )} -
- setField("is_active", v ? 1 : 0)} - label={t("items.enableItem")} - /> - setField("auto_renew", v ? 1 : 0)} - label={t("items.autoRenew")} - /> -
+
+ setField("is_active", v ? 1 : 0)} + label={t("items.enableItem")} + /> + setField("auto_renew", v ? 1 : 0)} + label={t("items.autoRenew")} + /> +
- {/* Calendar mode selector + action buttons */} -
- -
- {(["solar", "lunar", "both"] as const).map((mode) => ( + {/* Calendar mode selector + action buttons */} +
+ +
+ {(["solar", "lunar", "both"] as const).map((mode) => ( + + ))} +
+
+
- ))} -
- -
- - - {notifyMsg && ( - + + {t("items.recalcExpiry")} + + {notifyMsg && ( + + {notifyMsg} + )} +
+
+ +
+

+ {t("detail.sectionReminder")} +

+ +