From 355a2d11cd782ef7c4c9e9d7cc9e0618aabfd8dd Mon Sep 17 00:00:00 2001 From: Yaojia Wang Date: Sat, 11 Jul 2026 14:04:01 +0200 Subject: [PATCH] =?UTF-8?q?feat(ui):=20Checkbox/Radio=20=E5=8E=9F=E5=AD=90?= =?UTF-8?q?=E4=BB=B6=20+=203=20=E5=A4=84=E5=8E=9F=E7=94=9F=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6=E9=87=87=E7=94=A8=EF=BC=88P2-5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - checkboxClass/radioClass(accent-cinnabar + 统一焦点环)+ 同名测试 - Checkbox/Radio 原子件:无 label 只渲染受控原生 input 便于就地替换 - 采用:ChainStarter 链类型单选、GeneratorRunner 入库勾选、CharacterCardItem 角色勾选 --- apps/web/components/chain/ChainStarter.tsx | 4 ++-- .../generation/CharacterCardItem.tsx | 5 ++--- .../components/toolbox/GeneratorRunner.tsx | 4 ++-- apps/web/components/ui/Checkbox.tsx | 20 +++++++++++++++++++ apps/web/components/ui/Radio.tsx | 20 +++++++++++++++++++ apps/web/lib/ui/variants.test.ts | 10 ++++++++++ apps/web/lib/ui/variants.ts | 12 +++++++++++ 7 files changed, 68 insertions(+), 7 deletions(-) create mode 100644 apps/web/components/ui/Checkbox.tsx create mode 100644 apps/web/components/ui/Radio.tsx diff --git a/apps/web/components/chain/ChainStarter.tsx b/apps/web/components/chain/ChainStarter.tsx index 4e56fdd..78cfe65 100644 --- a/apps/web/components/chain/ChainStarter.tsx +++ b/apps/web/components/chain/ChainStarter.tsx @@ -5,6 +5,7 @@ import { Play } from "lucide-react"; import { Button } from "@/components/ui/Button"; import { Field } from "@/components/ui/Field"; +import { Radio } from "@/components/ui/Radio"; import { SectionHeader } from "@/components/ui/SectionHeader"; import { TextInput } from "@/components/ui/TextInput"; import { CHAIN_KINDS, type ChainKind } from "@/lib/chain/chain"; @@ -58,8 +59,7 @@ export function ChainStarter({ onStart, disabled }: ChainStarterProps) { key={kind.key} className="flex items-start gap-2 text-sm text-ink" > -
- {onEdit ? ( {selectable ? ( - onToggle(index)} className="mt-1" diff --git a/apps/web/components/ui/Checkbox.tsx b/apps/web/components/ui/Checkbox.tsx new file mode 100644 index 0000000..f6cf0b9 --- /dev/null +++ b/apps/web/components/ui/Checkbox.tsx @@ -0,0 +1,20 @@ +import type { InputHTMLAttributes, ReactNode } from "react"; + +import { checkboxClass } from "@/lib/ui/variants"; + +interface CheckboxProps extends Omit, "type"> { + label?: ReactNode; +} + +// 勾选框:无 label 时只渲染受控原生 input(供已有