From cc35400f67d71e62f7e2dc8da4a6bacb0a761d86 Mon Sep 17 00:00:00 2001 From: CNWei Date: Sun, 1 Nov 2026 21:59:13 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E6=96=B0=E5=A2=9E=20TextButton=20/?= =?UTF-8?q?=20ToggleRow=EF=BC=8CTable=20=E6=94=AF=E6=8C=81=E7=B4=A7?= =?UTF-8?q?=E5=87=91=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - TextButton:文字按钮(tone 主色/危险、可选图标、disabled), 用于表格行内操作,hover 只加下划线 - ToggleRow:左标签 + 右开关的开关行,支持 hint 与 switchLabel - Table:新增 size='md' | 'sm',sm 把行内边距收到 space-2 - 展示页:按钮补「文字按钮」、开关补「开关行」、表格补「紧凑档」; COMPONENTS.md 契约 3.46 / 3.47 与 README 清单同步 --- README.md | 4 +- docs/COMPONENTS.md | 27 ++++++++++++-- site/sections/Buttons.tsx | 33 ++++++++++++++++- site/sections/Switches.tsx | 31 +++++++++++++++- site/sections/Tables.tsx | 10 +++++ src/components/Table.module.css | 6 +++ src/components/Table.tsx | 5 ++- src/components/TextButton.module.css | 47 ++++++++++++++++++++++++ src/components/TextButton.tsx | 54 +++++++++++++++++++++++++++ src/components/ToggleRow.module.css | 14 +++++++ src/components/ToggleRow.tsx | 55 ++++++++++++++++++++++++++++ src/index.ts | 6 +++ 12 files changed, 285 insertions(+), 7 deletions(-) create mode 100644 src/components/TextButton.module.css create mode 100644 src/components/TextButton.tsx create mode 100644 src/components/ToggleRow.module.css create mode 100644 src/components/ToggleRow.tsx diff --git a/README.md b/README.md index 8009b47..4610889 100644 --- a/README.md +++ b/README.md @@ -95,6 +95,7 @@ stash-ui/ | --- | --- | --- | | `Button` | 操作按钮(圆角 / 胶囊,支持描边) | `variant` `size` `shape` `block` `loading` `icon` | | `IconButton` | 圆形图标按钮(28/36/44) | `label`(必填) `icon` `variant` `size` `spinning` | +| `TextButton` | 文字按钮(行内操作,无外框) | `icon` `tone` `disabled` `title` `label` | | `Card` | 白色容器(极浅描边) | `as` `padding` `hoverable` | | `Cover` | 比例封面卡(2:3 / 4:3 / 16:9) | `ratio` `src` `caption` `lift` `onClick` | | `Image` | 带比例 / 圆角 / 失败降级的图片 | `ratio` `fit` `radius` `fallback` | @@ -103,6 +104,7 @@ stash-ui/ | `Skeleton` | 骨架屏占位 | `variant` `lines` `width` `height` | | `Spinner` | 加载指示 | `size` `label` | | `Switch` | 即时开关 | `checked` `onChange` `size` `label` | +| `ToggleRow` | 开关行(左标签 + 右开关) | `label` `checked` `onChange` `hint` `switchLabel` | | `Checkbox` | 复选框 | `checked` `onChange` `label` | | `RadioGroup` | 互斥单选组 | `options` `value` `onChange` `direction` | | `Select` | 受控下拉选择 | `options` `value` `onChange` `placeholder` | @@ -110,7 +112,7 @@ stash-ui/ | `Tabs` | 页内分区切换 | `items` `activeKey` `onChange` `variant` | | `Menu` | 侧栏两级菜单 | `items` `activeKey` `onSelect` | | `Breadcrumb` | 路径导航 | `items` `separator` | -| `Table` | 只读数据表格 | `columns` `rows` `rowKey` `emptyText` | +| `Table` | 只读数据表格 | `columns` `rows` `rowKey` `size` `emptyText` | | `Tag` | 分类 / 标签 / 状态(浅底 / 实底) | `tone` `variant` `shape` `icon` `dot` | | `ItemBadge` | 状态角标:置顶 / 付费 / HOT | `tone` | | `Badge` | 数字角标 | `count` `tone` `max` | diff --git a/docs/COMPONENTS.md b/docs/COMPONENTS.md index f571060..ee0f1d3 100644 --- a/docs/COMPONENTS.md +++ b/docs/COMPONENTS.md @@ -19,10 +19,12 @@ | `Typography` | L1 | ✅ | 标题 / 文字 / 段落(Title / Text / Paragraph) | `level` `tone` `size` `lines` | | `Button` | L2 | ✅ | 操作按钮(圆角 / 胶囊) | `variant` `size` `shape` `block` `loading` `icon` | | `IconButton` | L2 | ✅ | 圆形图标按钮(28 / 36 / 44) | `label`(必填) `icon` `variant` `size` `spinning` | +| `TextButton` | L2 | ✅ | 文字按钮(行内操作,无外框) | `icon` `tone` `disabled` `title` `label` | | `Input` | L2 | ✅ | 组合式输入框 | `icon` `clearable` `onClear` `shortcut` `inputRef` | | `Textarea` | L2 | ✅ | 多行文本(Markdown / 简介) | `rows` `resize` `invalid` | | `PasswordInput` | L2 | ✅ | 密码输入(锁图标 + 显隐切换) | `icon` `size` `toggle` | | `Switch` | L2 | ✅ | 即时生效的开关 | `checked` `onChange` `size` `label` | +| `ToggleRow` | L2 | ✅ | 开关行:左标签 + 右开关 | `label` `checked` `onChange` `hint` `switchLabel` | | `Checkbox` | L2 | ✅ | 复选框(多选 / 确认) | `checked` `onChange` `label` | | `RadioGroup` | L2 | ✅ | 互斥单选组 | `options` `value` `onChange` `direction` | | `Select` | L2 | ✅ | 受控下拉选择 | `options` `value` `onChange` `placeholder` | @@ -42,7 +44,7 @@ | `FormField` | L3 | ✅ | 表单字段排版(标签 + 控件 + 提示/错误) | `label` `hint` `error` `required` | | `Grid` | L3 | ✅ | 卡片列表网格 | `columns` `tabletColumns` `mobileColumns` `gap` `as` | | `Space` | L3 | ✅ | 一维间距容器 | `direction` `gap` `wrap` `align` `justify` | -| `Table` | L3 | ✅ | 只读数据表格 | `columns` `rows` `rowKey` `emptyText` | +| `Table` | L3 | ✅ | 只读数据表格 | `columns` `rows` `rowKey` `size` `emptyText` | | `Notice` | L4 | ✅ | 说明 / 错误提示条 | `tone` `title` `action` | | `Empty` | L4 | ✅ | 空态 | `text` `action` | | `Result` | L4 | ✅ | 整块结果反馈 | `status` `title` `description` `actions` | @@ -448,8 +450,8 @@ ### 3.30 Table ✅ - **用途**:数据表格(只读)。 -- **Props**:`columns: { key, title, width?, align? }[]`、`rows: Record[]`、`rowKey`(默认 `id`)、`emptyText`。 -- **规则**:排序 / 筛选 / 分页由页面组合,组件不内置交互;空数据渲染 `emptyText`。 +- **Props**:`columns: { key, title, width?, align? }[]`、`rows: Record[]`、`rowKey`(默认 `id`)、`size: 'md' | 'sm'`(行高密度,默认 `md`)、`emptyText`。 +- **规则**:排序 / 筛选 / 分页由页面组合,组件不内置交互;空数据渲染 `emptyText`;单元格是任意 `ReactNode`,行内操作直接用 `TextButton` / `IconButton`。 - **展示页**:`#table` ### 3.31 Result ✅ @@ -666,6 +668,24 @@ - **规则**:`onChange` 给字符串而不是事件——这是它和 `Input` 唯一的语义差别,别在组件里做过滤/请求。 - **展示页**:`#site-chrome` +### 3.46 TextButton ✅ + +- **用途**:文字按钮——看起来像链接、行为像按钮,用于表格行内操作(编辑 / 删除 / 新建子项)。 +- **不该用在哪**:需要底色、尺寸或独立成行的地方(用 `Button`);只有图标的地方(用 `IconButton`)。 +- **解剖**:`