Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions docs/design-system.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 ✅)`

Expand All @@ -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` |
Expand All @@ -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` |
Expand Down Expand Up @@ -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)**已退役**,不再作为任何实现依据;若其所在分支后续合并,必须删除该文件或以醒目批注指向本文档。
Expand Down
48 changes: 48 additions & 0 deletions web/src/components/AuthShell.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<div className="flex min-h-screen items-center justify-center bg-muted/40 p-4">
<div className={cn("w-full max-w-[400px]", className)}>
<div className="rounded-lg border bg-card p-8 shadow-2">
<div className="mb-8 text-center">
<h1 className="text-display">{title}</h1>
{subtitle && (
<p className="mt-2 text-body-sm text-muted-foreground">
{subtitle}
</p>
)}
</div>
{children}
</div>
</div>
</div>
);
}

/** Inline form error that slides in (200ms, contract §5 auth). */
export function FormError({ children }: { children: ReactNode }) {
return (
<p
role="alert"
className="rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-body-sm text-destructive motion-safe:animate-[form-error-in_200ms_var(--ease-out)]"
>
{children}
</p>
);
}
16 changes: 11 additions & 5 deletions web/src/components/ConfirmDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AlertTriangle } from "lucide-react";
import { useFocusTrap } from "@/hooks/useFocusTrap";

interface ConfirmDialogProps {
open: boolean;
Expand All @@ -21,6 +22,8 @@ export function ConfirmDialog({
onConfirm,
onCancel,
}: ConfirmDialogProps) {
const trapRef = useFocusTrap<HTMLDivElement>(open, onCancel);

if (!open) return null;

return (
Expand All @@ -31,7 +34,10 @@ export function ConfirmDialog({
className="absolute inset-0 bg-black/40"
onClick={onCancel}
/>
<div className="relative bg-card border rounded-xl p-6 w-full max-w-sm mx-4 space-y-4 shadow-lg">
<div
ref={trapRef}
className="relative bg-card border rounded-xl p-6 w-full max-w-sm mx-4 space-y-4 shadow-lg"
>
<div className="flex items-start gap-3">
<AlertTriangle
className={cn(
Expand All @@ -40,23 +46,23 @@ export function ConfirmDialog({
)}
/>
<div className="space-y-1">
{title && <h3 className="font-semibold text-sm">{title}</h3>}
<p className="text-sm text-muted-foreground">{message}</p>
{title && <h3 className="text-title">{title}</h3>}
<p className="text-body-sm text-muted-foreground">{message}</p>
</div>
</div>
<div className="flex justify-end gap-2">
<button
type="button"
onClick={onCancel}
className="px-4 py-2 rounded-lg text-sm font-medium border hover:bg-accent transition-colors"
className="px-4 py-2 rounded-md text-body-sm font-medium border hover:bg-accent transition-colors"
>
{cancelLabel || "Cancel"}
</button>
<button
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",
Expand Down
129 changes: 129 additions & 0 deletions web/src/components/DueRing.tsx
Original file line number Diff line number Diff line change
@@ -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<DueTier, string> = {
far: "text-due-far",
soon: "text-due-soon",
close: "text-due-close",
over: "text-due-over",
};

const TIER_BADGE: Record<DueTier, string> = {
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 (
<svg
width={size}
height={size}
viewBox={`0 0 ${size} ${size}`}
className={cn("shrink-0 -rotate-90", TIER_TEXT[tier], className)}
role="img"
aria-label={ariaLabel}
>
<circle
cx={size / 2}
cy={size / 2}
r={r}
fill="none"
stroke="currentColor"
strokeOpacity={0.15}
strokeWidth={strokeWidth}
/>
<circle
cx={size / 2}
cy={size / 2}
r={r}
fill="none"
stroke="currentColor"
strokeWidth={strokeWidth}
strokeLinecap="round"
strokeDasharray={c}
strokeDashoffset={c * (1 - clamped)}
/>
</svg>
);
}

/** 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 (
<span
className={cn(
"inline-flex items-baseline gap-1",
TIER_TEXT[tier],
className,
)}
>
<span className={cn(numCls, "tabular-nums leading-none")}>
{days < 0 ? `-${Math.abs(days)}` : days}
</span>
<span className="text-caption">{unit}</span>
</span>
);
}
7 changes: 5 additions & 2 deletions web/src/components/PasswordPromptDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState } from "react";
import { useTranslation } from "react-i18next";
import { useFocusTrap } from "@/hooks/useFocusTrap";

interface PasswordPromptDialogProps {
open: boolean;
Expand All @@ -17,13 +18,15 @@ export function PasswordPromptDialog({
const { t } = useTranslation();
const [password, setPassword] = useState("");

if (!open) return null;
const trapRef = useFocusTrap<HTMLFormElement>(open, onCancel);

const close = () => {
setPassword("");
onCancel();
};

if (!open) return null;

return (
<div className="fixed inset-0 z-50 flex items-center justify-center">
<button
Expand All @@ -33,6 +36,7 @@ export function PasswordPromptDialog({
onClick={close}
/>
<form
ref={trapRef}
className="relative bg-card border rounded-xl p-6 w-full max-w-sm mx-4 space-y-4 shadow-lg"
onSubmit={async (e) => {
e.preventDefault();
Expand All @@ -50,7 +54,6 @@ export function PasswordPromptDialog({
<input
type="password"
autoComplete="current-password"
// biome-ignore lint/a11y/noAutofocus: dialog opens on explicit user action
autoFocus
value={password}
onChange={(e) => setPassword(e.target.value)}
Expand Down
9 changes: 8 additions & 1 deletion web/src/components/ThemeProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import {

type Theme = "light" | "dark" | "system";

// Values mirror the --background token channels in index.css (light n-0, dark n-900);
// DOM meta API requires a concrete color string, not a CSS var reference.
const META_THEME_COLOR = {
light: "hsl(0 0% 100%)",
dark: "hsl(240 9.1% 4.3%)",
} as const;

interface ThemeContextType {
theme: Theme;
setTheme: (theme: Theme) => void;
Expand Down Expand Up @@ -58,7 +65,7 @@ export function ThemeProvider({ children }: { children: ReactNode }) {
: theme === "dark";
metaThemeColor.setAttribute(
"content",
isDark ? "hsl(240 9.1% 4.3%)" : "hsl(0 0% 100%)",
isDark ? META_THEME_COLOR.dark : META_THEME_COLOR.light,
);
}

Expand Down
10 changes: 8 additions & 2 deletions web/src/components/layout/AppLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,10 @@ export function AppLayout() {
<div className="h-14 flex items-center px-4 border-b">
<h1 className="text-title text-primary">
{appName}
<span aria-hidden="true" className="ml-0.5 inline-block h-1 w-1 rounded-full bg-primary align-baseline" />
<span
aria-hidden="true"
className="ml-0.5 inline-block h-1 w-1 rounded-full bg-primary align-baseline"
/>
</h1>
</div>
<nav className="flex-1 p-2 space-y-1">
Expand Down Expand Up @@ -343,7 +346,10 @@ export function AppLayout() {
>
<span className="text-title text-primary">
{appName}
<span aria-hidden="true" className="ml-0.5 inline-block h-1 w-1 rounded-full bg-primary align-baseline" />
<span
aria-hidden="true"
className="ml-0.5 inline-block h-1 w-1 rounded-full bg-primary align-baseline"
/>
</span>
</header>

Expand Down
Loading
Loading