feat(ui): 新增 TextButton / ToggleRow,Table 支持紧凑档
- TextButton:文字按钮(tone 主色/危险、可选图标、disabled), 用于表格行内操作,hover 只加下划线 - ToggleRow:左标签 + 右开关的开关行,支持 hint 与 switchLabel - Table:新增 size='md' | 'sm',sm 把行内边距收到 space-2 - 展示页:按钮补「文字按钮」、开关补「开关行」、表格补「紧凑档」; COMPONENTS.md 契约 3.46 / 3.47 与 README 清单同步
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { useState } from 'react'
|
||||
import { Button, Icon, IconButton, Space } from '../../src'
|
||||
import { Button, Icon, IconButton, Space, TextButton } from '../../src'
|
||||
import { Demo } from '../components/Demo'
|
||||
import { PropsTable } from '../components/PropsTable'
|
||||
import { Section } from '../components/Section'
|
||||
@@ -126,6 +126,27 @@ export function Buttons() {
|
||||
</Space>
|
||||
</Demo>
|
||||
|
||||
<Demo
|
||||
title="文字按钮"
|
||||
desc="看起来像链接、行为像按钮,用在表格行内操作这类不需要外框的地方;需要底色或独立操作时仍用 Button。"
|
||||
layout="column"
|
||||
code={`<TextButton icon={<Icon name="add_line" />}>新建子分组</TextButton>
|
||||
<TextButton icon={<Icon name="edit_4_line" />}>编辑</TextButton>
|
||||
<TextButton tone="danger" icon={<Icon name="delete_2_line" />}>删除</TextButton>
|
||||
<TextButton disabled>禁用</TextButton>`}
|
||||
>
|
||||
<Space gap="lg" wrap>
|
||||
<TextButton icon={<Icon name="add_line" />}>新建子分组</TextButton>
|
||||
<TextButton icon={<Icon name="edit_4_line" />}>编辑</TextButton>
|
||||
<TextButton tone="danger" icon={<Icon name="delete_2_line" />}>
|
||||
删除
|
||||
</TextButton>
|
||||
<TextButton disabled icon={<Icon name="edit_4_line" />}>
|
||||
禁用
|
||||
</TextButton>
|
||||
</Space>
|
||||
</Demo>
|
||||
|
||||
<PropsTable
|
||||
rows={[
|
||||
{ name: 'variant', type: "'primary' | 'secondary' | 'outline' | 'ghost' | 'danger'", defaultValue: "'primary'", desc: '语义变体' },
|
||||
@@ -148,6 +169,16 @@ export function Buttons() {
|
||||
{ name: 'spinning', type: 'boolean', defaultValue: 'false', desc: '图标旋转' },
|
||||
]}
|
||||
/>
|
||||
|
||||
<PropsTable
|
||||
rows={[
|
||||
{ name: 'icon', type: 'ReactNode', desc: '前置图标' },
|
||||
{ name: 'tone', type: "'primary' | 'danger'", defaultValue: "'primary'", desc: '颜色语义' },
|
||||
{ name: 'disabled', type: 'boolean', defaultValue: 'false', desc: '禁用态' },
|
||||
{ name: 'onClick', type: '() => void', desc: '点击回调' },
|
||||
{ name: 'title / label', type: 'string', desc: '悬停提示 / 无障碍名称' },
|
||||
]}
|
||||
/>
|
||||
</Section>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useState } from 'react'
|
||||
import { Space, Switch, Text } from '../../src'
|
||||
import { Space, Switch, Text, ToggleRow } from '../../src'
|
||||
import { Demo } from '../components/Demo'
|
||||
import { PropsTable } from '../components/PropsTable'
|
||||
import { Section } from '../components/Section'
|
||||
@@ -58,6 +58,24 @@ export function Switches() {
|
||||
</Space>
|
||||
</Demo>
|
||||
|
||||
<Demo
|
||||
title="开关行"
|
||||
desc="设置面板里每行一个开关时用 ToggleRow:左边标签(可带一行说明),右边开关,两端对齐,不用自己拼 Space。"
|
||||
layout="column"
|
||||
code={`<ToggleRow label="明暗切换" checked={on} onChange={setOn} />
|
||||
<ToggleRow label="显示封面图" hint="列表里用封面代替首字" checked={showCover} onChange={setShowCover} />`}
|
||||
>
|
||||
<div style={{ width: 360 }}>
|
||||
<ToggleRow label="明暗切换" checked={autoSync} onChange={setAutoSync} />
|
||||
<ToggleRow
|
||||
label="显示封面图"
|
||||
hint="列表里用封面代替首字"
|
||||
checked={showCover}
|
||||
onChange={setShowCover}
|
||||
/>
|
||||
</div>
|
||||
</Demo>
|
||||
|
||||
<PropsTable
|
||||
rows={[
|
||||
{ name: 'checked', type: 'boolean', required: true, desc: '受控状态' },
|
||||
@@ -67,6 +85,17 @@ export function Switches() {
|
||||
{ name: 'label', type: 'string', desc: '无障碍名称:旁边没有文字时必填' },
|
||||
]}
|
||||
/>
|
||||
|
||||
<PropsTable
|
||||
rows={[
|
||||
{ name: 'label', type: 'ReactNode', required: true, desc: '左侧标签' },
|
||||
{ name: 'checked', type: 'boolean', required: true, desc: '受控状态' },
|
||||
{ name: 'onChange', type: '(checked: boolean) => void', required: true, desc: '切换回调' },
|
||||
{ name: 'switchLabel', type: 'string', desc: '读屏用的开关名称,默认取 label' },
|
||||
{ name: 'hint', type: 'ReactNode', desc: '标签下方的一行说明' },
|
||||
{ name: 'disabled', type: 'boolean', defaultValue: 'false', desc: '禁用' },
|
||||
]}
|
||||
/>
|
||||
</Section>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -56,6 +56,15 @@ export function Tables() {
|
||||
<Table columns={COLUMNS} rows={ROWS} rowKey="id" />
|
||||
</Demo>
|
||||
|
||||
<Demo
|
||||
title="紧凑档"
|
||||
desc="size='sm' 把行高收一档,配置面板那种列多、面板窄的场景用它。"
|
||||
layout="column"
|
||||
code={`<Table columns={COLUMNS} rows={ROWS} size="sm" />`}
|
||||
>
|
||||
<Table columns={COLUMNS} rows={ROWS} size="sm" />
|
||||
</Demo>
|
||||
|
||||
<Demo
|
||||
title="空态"
|
||||
desc="空数据时渲染默认文案;也可以传 emptyText 换一句更具体的说明。"
|
||||
@@ -70,6 +79,7 @@ export function Tables() {
|
||||
{ name: 'columns', type: 'TableColumn[]', required: true, desc: '{ key, title, width?, align? }' },
|
||||
{ name: 'rows', type: 'Record<string, ReactNode>[]', required: true, desc: '行数据,键对应列的 key' },
|
||||
{ name: 'rowKey', type: 'string', defaultValue: "'id'", desc: '行的唯一键字段' },
|
||||
{ name: 'size', type: "'md' | 'sm'", defaultValue: "'md'", desc: '行高密度' },
|
||||
{ name: 'emptyText', type: 'ReactNode', defaultValue: "'暂无数据'", desc: '空态文案' },
|
||||
]}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user