From 45025c36bfaf50088325003ed19c75fe2f4497a8 Mon Sep 17 00:00:00 2001 From: Yaojia Wang Date: Sat, 11 Jul 2026 08:12:36 +0200 Subject: [PATCH] =?UTF-8?q?feat(ui):=20P4=20=E6=97=A0=E9=9A=9C=E7=A2=8D?= =?UTF-8?q?=E4=B8=8E=E6=89=93=E7=A3=A8=E6=94=B6=E5=B0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - P4-1 对比度:muted-soft 提到 WCAG AA 小字(≥4.5:1)于两主题各面 - P4-3 ConflictCard 原文/建议加 Minus/Plus 图标 + sr-only 标签(不靠颜色) - P4-4 动效:3 处 chevron transition-transform 加 motion-safe 门控 - P4-5 命令面板 ⌘K 键帽提示 + 键盘操作读数 + 空态引导 + mono 快捷键 - P2-8 SegmentedControl 升级 radiogroup(role=radio/aria-checked + 方向键 roving) --- apps/web/app/globals.css | 6 +- .../web/components/command/CommandPalette.tsx | 73 +++++++++++++++---- apps/web/components/review/ConflictCard.tsx | 14 +++- apps/web/components/review/ReviewReport.tsx | 2 +- .../components/review/ReviewSectionPanel.tsx | 2 +- apps/web/components/ui/SegmentedControl.tsx | 50 ++++++++++++- apps/web/components/workbench/AiToolbar.tsx | 2 +- 7 files changed, 123 insertions(+), 26 deletions(-) diff --git a/apps/web/app/globals.css b/apps/web/app/globals.css index aef43f7..1b52c18 100644 --- a/apps/web/app/globals.css +++ b/apps/web/app/globals.css @@ -16,7 +16,8 @@ --color-body-strong: #3a342b; --color-body: #4a4234; --color-ink-soft: #6b6356; - --color-muted-soft: #8a8073; + /* muted-soft 达 WCAG AA 小字(≥4.5:1)于 bg/card/panel/soft 各面(P4-1)。 */ + --color-muted-soft: #6f6556; /* 边框:主边框 + 同带内更弱分隔 */ --color-line: #e5ddcd; --color-line-soft: #ece4d5; @@ -54,7 +55,8 @@ --color-body-strong: #ddd2c0; --color-body: #cdc0ab; --color-ink-soft: #b9ab96; - --color-muted-soft: #8f8474; + /* muted-soft 达 AA 小字(≥4.5:1)于夜读 bg/card/soft 各面(P4-1)。 */ + --color-muted-soft: #9a8e7c; /* 边框 */ --color-line: #3c352c; --color-line-soft: #2f2a23; diff --git a/apps/web/components/command/CommandPalette.tsx b/apps/web/components/command/CommandPalette.tsx index 028b148..2d3f5af 100644 --- a/apps/web/components/command/CommandPalette.tsx +++ b/apps/web/components/command/CommandPalette.tsx @@ -66,6 +66,15 @@ export function useCommandPaletteOpen(): boolean { const LIST_ID = "command-list"; const optionId = (cmd: Command): string => `command-option-${cmd.id}`; +// 统一的键帽(kbd)样式:暖纸感描边 + 等宽小字,与 NavDrawer 的 ⌘K 提示一致。 +function KeyCap({ children }: { children: React.ReactNode }) { + return ( + + {children} + + ); +} + // 从 pathname 抽取当前 projectId(/projects//...)。 function projectIdFromPath(pathname: string): string | null { const m = pathname.match(/^\/projects\/([^/]+)/); @@ -208,20 +217,26 @@ export function CommandPalette({ pathname }: CommandPaletteProps) { if (dialogRef.current) handleTabTrap(dialogRef.current, e); }} > - setQuery(e.target.value)} - onKeyDown={onInputKey} - placeholder="搜索命令或页面…(写本章 / 审稿 / 生成角色 / 跳转伏笔 / 搜设定)" - role="combobox" - aria-label="命令搜索" - aria-expanded={true} - aria-controls={LIST_ID} - aria-activedescendant={activeCmd ? optionId(activeCmd) : undefined} - aria-autocomplete="list" - className={`w-full border-b border-line bg-bg px-4 py-3 text-sm text-ink ${focusRing}`} - /> +
+ setQuery(e.target.value)} + onKeyDown={onInputKey} + placeholder="搜索命令或页面…(写本章 / 审稿 / 生成角色 / 跳转伏笔 / 搜设定)" + role="combobox" + aria-label="命令搜索" + aria-expanded={true} + aria-controls={LIST_ID} + aria-activedescendant={activeCmd ? optionId(activeCmd) : undefined} + aria-autocomplete="list" + className={`w-full bg-bg py-3 pl-4 pr-12 text-sm text-ink ${focusRing}`} + /> + {/* 触发快捷键读数:随面板常驻,强化 ⌘K 的可发现性(纯装饰,不入 Tab 序)。 */} + + ⌘K + +
+ {/* 键盘操作读数:↑↓ 选择 · ↵ 打开 · esc 关闭(常驻引导,纯装饰)。 */} + ); diff --git a/apps/web/components/review/ConflictCard.tsx b/apps/web/components/review/ConflictCard.tsx index 4ede673..193e2d5 100644 --- a/apps/web/components/review/ConflictCard.tsx +++ b/apps/web/components/review/ConflictCard.tsx @@ -1,6 +1,6 @@ "use client"; -import { AlertTriangle, CheckCircle2, LocateFixed, Sparkles } from "lucide-react"; +import { AlertTriangle, CheckCircle2, LocateFixed, Minus, Plus, Sparkles } from "lucide-react"; import { Badge } from "@/components/ui/Badge"; import { TextInput } from "@/components/ui/TextInput"; @@ -80,10 +80,22 @@ export function ConflictCard({ {conflict.original && conflict.replacement ? (
改法: + {/* 非颜色线索:Minus/「原文」标签,色盲也可辨(不单靠红色 + 删除线) */} +
diff --git a/apps/web/components/review/ReviewReport.tsx b/apps/web/components/review/ReviewReport.tsx index 33e66c0..5d240a4 100644 --- a/apps/web/components/review/ReviewReport.tsx +++ b/apps/web/components/review/ReviewReport.tsx @@ -604,7 +604,7 @@ export function ReviewReport({ : "已处理"}