@tfdesign/b-end 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AI_READ_FIRST.md +131 -0
- package/LICENSE +21 -0
- package/README.md +353 -0
- package/package.json +67 -0
- package/scripts/check-tfds-contract.mjs +334 -0
- package/scripts/check-tfds-integration.mjs +263 -0
- package/scripts/postinstall-cursor-skill.mjs +382 -0
- package/scripts/setup.mjs +520 -0
- package/skills/tfds/CHECKLIST.md +205 -0
- package/skills/tfds/COMMON_FAILURES.md +238 -0
- package/skills/tfds/DESIGN_PRINCIPLES.md +477 -0
- package/skills/tfds/GLOBAL_DESIGN_RULES.md +636 -0
- package/skills/tfds/LAYOUT_RECIPES.md +140 -0
- package/skills/tfds/LAYOUT_RULES.md +1355 -0
- package/skills/tfds/PAGE_ARCHETYPES.md +201 -0
- package/skills/tfds/SKILL.md +188 -0
- package/skills/tfds/components.index.json +7305 -0
- package/skills/tfds/components.summary.json +1809 -0
- package/src/_b_end_runtime/components/AiSuggestionShared.jsx +166 -0
- package/src/_b_end_runtime/components/Avatar.jsx +325 -0
- package/src/_b_end_runtime/components/Avatar.tokens.js +76 -0
- package/src/_b_end_runtime/components/AvatarGridPreview.jsx +56 -0
- package/src/_b_end_runtime/components/AvatarGroup.jsx +80 -0
- package/src/_b_end_runtime/components/AvatarGroup.tokens.js +28 -0
- package/src/_b_end_runtime/components/Button.jsx +144 -0
- package/src/_b_end_runtime/components/Button.tokens.js +90 -0
- package/src/_b_end_runtime/components/Card.jsx +460 -0
- package/src/_b_end_runtime/components/Card.tokens.js +124 -0
- package/src/_b_end_runtime/components/CardPreview.jsx +51 -0
- package/src/_b_end_runtime/components/ChatBubble.jsx +384 -0
- package/src/_b_end_runtime/components/ChatBubble.tokens.js +60 -0
- package/src/_b_end_runtime/components/ChatBubblePreview.jsx +129 -0
- package/src/_b_end_runtime/components/ChatInput.jsx +1399 -0
- package/src/_b_end_runtime/components/ChatInput.tokens.js +75 -0
- package/src/_b_end_runtime/components/ChatMessage.jsx +2215 -0
- package/src/_b_end_runtime/components/ChatMessage.tokens.js +257 -0
- package/src/_b_end_runtime/components/ChatMessagePreview.jsx +388 -0
- package/src/_b_end_runtime/components/Checkbox.jsx +317 -0
- package/src/_b_end_runtime/components/Checkbox.tokens.js +59 -0
- package/src/_b_end_runtime/components/ConversationList.jsx +1264 -0
- package/src/_b_end_runtime/components/ConversationList.tokens.js +135 -0
- package/src/_b_end_runtime/components/ConversationListPreview.jsx +108 -0
- package/src/_b_end_runtime/components/CustomerServiceWorkspaceFrame.jsx +324 -0
- package/src/_b_end_runtime/components/CustomerServiceWorkspaceFrame.tokens.js +69 -0
- package/src/_b_end_runtime/components/DatePicker.jsx +739 -0
- package/src/_b_end_runtime/components/DatePicker.tokens.js +99 -0
- package/src/_b_end_runtime/components/Empty.jsx +141 -0
- package/src/_b_end_runtime/components/Empty.tokens.js +40 -0
- package/src/_b_end_runtime/components/Form.jsx +609 -0
- package/src/_b_end_runtime/components/Form.tokens.js +77 -0
- package/src/_b_end_runtime/components/FormFieldStack.jsx +123 -0
- package/src/_b_end_runtime/components/FormFieldStack.tokens.js +12 -0
- package/src/_b_end_runtime/components/FormTitle.jsx +119 -0
- package/src/_b_end_runtime/components/FormTitle.tokens.js +87 -0
- package/src/_b_end_runtime/components/FullScreenPage.jsx +97 -0
- package/src/_b_end_runtime/components/FullScreenPage.tokens.js +19 -0
- package/src/_b_end_runtime/components/Icon.jsx +172 -0
- package/src/_b_end_runtime/components/Icon.tokens.js +26 -0
- package/src/_b_end_runtime/components/IconGridPreview.jsx +277 -0
- package/src/_b_end_runtime/components/InfoDisplayPanel.jsx +620 -0
- package/src/_b_end_runtime/components/InfoDisplayPanel.tokens.js +71 -0
- package/src/_b_end_runtime/components/InfoDisplayPanelPreview.jsx +133 -0
- package/src/_b_end_runtime/components/Input.jsx +258 -0
- package/src/_b_end_runtime/components/Input.tokens.js +68 -0
- package/src/_b_end_runtime/components/InputNumber.jsx +242 -0
- package/src/_b_end_runtime/components/InputNumber.tokens.js +55 -0
- package/src/_b_end_runtime/components/Modal.jsx +155 -0
- package/src/_b_end_runtime/components/Modal.tokens.js +73 -0
- package/src/_b_end_runtime/components/NavBar.jsx +842 -0
- package/src/_b_end_runtime/components/NavBar.tokens.js +97 -0
- package/src/_b_end_runtime/components/NavBarPreview.jsx +11 -0
- package/src/_b_end_runtime/components/Radio.jsx +227 -0
- package/src/_b_end_runtime/components/Radio.tokens.js +59 -0
- package/src/_b_end_runtime/components/Select.jsx +766 -0
- package/src/_b_end_runtime/components/Select.tokens.js +99 -0
- package/src/_b_end_runtime/components/Sheet.jsx +132 -0
- package/src/_b_end_runtime/components/Sheet.tokens.js +61 -0
- package/src/_b_end_runtime/components/Slider.jsx +346 -0
- package/src/_b_end_runtime/components/Slider.tokens.js +47 -0
- package/src/_b_end_runtime/components/Switch.jsx +124 -0
- package/src/_b_end_runtime/components/Switch.tokens.js +38 -0
- package/src/_b_end_runtime/components/Table.jsx +1338 -0
- package/src/_b_end_runtime/components/Table.tokens.js +147 -0
- package/src/_b_end_runtime/components/TablePreview.jsx +599 -0
- package/src/_b_end_runtime/components/Tabs.jsx +149 -0
- package/src/_b_end_runtime/components/Tabs.tokens.js +102 -0
- package/src/_b_end_runtime/components/Tag.jsx +199 -0
- package/src/_b_end_runtime/components/Tag.tokens.js +171 -0
- package/src/_b_end_runtime/components/TagBar.jsx +1134 -0
- package/src/_b_end_runtime/components/TagBar.tokens.js +75 -0
- package/src/_b_end_runtime/components/TagGridPreview.jsx +23 -0
- package/src/_b_end_runtime/components/TagInput.jsx +382 -0
- package/src/_b_end_runtime/components/TagInput.tokens.js +52 -0
- package/src/_b_end_runtime/components/TextArea.jsx +363 -0
- package/src/_b_end_runtime/components/TextArea.tokens.js +65 -0
- package/src/_b_end_runtime/components/TimePicker.jsx +444 -0
- package/src/_b_end_runtime/components/TimePicker.tokens.js +77 -0
- package/src/_b_end_runtime/components/Toast.jsx +120 -0
- package/src/_b_end_runtime/components/Toast.tokens.js +146 -0
- package/src/_b_end_runtime/components/Tooltip.jsx +282 -0
- package/src/_b_end_runtime/components/Tooltip.tokens.js +48 -0
- package/src/_b_end_runtime/components/TooltipPreview.jsx +50 -0
- package/src/_b_end_runtime/components/Upload.jsx +455 -0
- package/src/_b_end_runtime/components/Upload.tokens.js +47 -0
- package/src/_b_end_runtime/components/avatar-assets/avatar-default.png +0 -0
- package/src/_b_end_runtime/components/avatar-group-assets/avatar-group-1.png +0 -0
- package/src/_b_end_runtime/components/avatar-group-assets/avatar-group-2.png +0 -0
- package/src/_b_end_runtime/components/avatar-group-assets/avatar-group-3.png +0 -0
- package/src/_b_end_runtime/components/avatar-group-assets/avatar-group-4.png +0 -0
- package/src/_b_end_runtime/components/avatar-group-assets/avatar-group-5.png +0 -0
- package/src/_b_end_runtime/components/empty-assets/administrator-1.svg +40 -0
- package/src/_b_end_runtime/components/empty-assets/administrator-2.svg +33 -0
- package/src/_b_end_runtime/components/empty-assets/construction.svg +33 -0
- package/src/_b_end_runtime/components/empty-assets/failure.svg +49 -0
- package/src/_b_end_runtime/components/empty-assets/idle.svg +34 -0
- package/src/_b_end_runtime/components/empty-assets/no-access.svg +36 -0
- package/src/_b_end_runtime/components/empty-assets/no-content.svg +77 -0
- package/src/_b_end_runtime/components/empty-assets/no-result.svg +61 -0
- package/src/_b_end_runtime/components/empty-assets/not-found.svg +46 -0
- package/src/_b_end_runtime/components/empty-assets/success.svg +38 -0
- package/src/_b_end_runtime/components/file-type-assets/batch-report.png +0 -0
- package/src/_b_end_runtime/components/file-type-assets/catcat.svg +21 -0
- package/src/_b_end_runtime/components/file-type-assets/code.png +0 -0
- package/src/_b_end_runtime/components/file-type-assets/conversation.png +0 -0
- package/src/_b_end_runtime/components/file-type-assets/document.png +0 -0
- package/src/_b_end_runtime/components/file-type-assets/feishu-card.png +0 -0
- package/src/_b_end_runtime/components/file-type-assets/feishu-sheet.png +0 -0
- package/src/_b_end_runtime/components/file-type-assets/feishu.png +0 -0
- package/src/_b_end_runtime/components/file-type-assets/image.png +0 -0
- package/src/_b_end_runtime/components/file-type-assets/index.js +105 -0
- package/src/_b_end_runtime/components/file-type-assets/knowledge.png +0 -0
- package/src/_b_end_runtime/components/file-type-assets/pdf.png +0 -0
- package/src/_b_end_runtime/components/file-type-assets/pe.png +0 -0
- package/src/_b_end_runtime/components/file-type-assets/strategy.png +0 -0
- package/src/_b_end_runtime/components/file-type-assets/table.png +0 -0
- package/src/_b_end_runtime/components/file-type-assets/webpage.png +0 -0
- package/src/_b_end_runtime/components/file-type-assets/xmind.png +0 -0
- package/src/_b_end_runtime/components/icons/icon-data.js +12496 -0
- package/src/_b_end_runtime/components/nav-bar-assets/bytehi-logo-mark.svg +21 -0
- package/src/_b_end_runtime/components/table-assets/avatar.png +0 -0
- package/src/_b_end_runtime/components/table-assets/button.png +0 -0
- package/src/_b_end_runtime/components/table-assets/icon-chevron-down.png +0 -0
- package/src/_b_end_runtime/components/table-cell-assets/avatar.png +0 -0
- package/src/_b_end_runtime/components/table-cell-assets/button.png +0 -0
- package/src/_b_end_runtime/components/table-cell-assets/checkbox.png +0 -0
- package/src/_b_end_runtime/components/table-cell-assets/icon-chevron-right.png +0 -0
- package/src/_b_end_runtime/components/table-cell-assets/icon.png +0 -0
- package/src/_b_end_runtime/components/table-cell-assets/semi-icons-handle.png +0 -0
- package/src/_b_end_runtime/components/table-cell-assets/semi-icons-tree-triangle-right.png +0 -0
- package/src/_b_end_runtime/components/table-cell-assets/switch.png +0 -0
- package/src/_b_end_runtime/components/tagShared.js +3 -0
- package/src/_b_end_runtime/components/team-avatar-assets/chengcheng-murphy.png +0 -0
- package/src/_b_end_runtime/components/team-avatar-assets/duan-ran.png +0 -0
- package/src/_b_end_runtime/components/team-avatar-assets/guo-zhezhi.png +0 -0
- package/src/_b_end_runtime/components/team-avatar-assets/li-siru.png +0 -0
- package/src/_b_end_runtime/components/team-avatar-assets/liu-delin.png +0 -0
- package/src/_b_end_runtime/components.js +3499 -0
- package/src/_b_end_runtime/index.js +9 -0
- package/src/_b_end_runtime/page-patterns/BasePageFramePattern.jsx +395 -0
- package/src/_b_end_runtime/page-patterns/ChatConversationPattern.jsx +989 -0
- package/src/_b_end_runtime/page-patterns/ChatHomePagePattern.jsx +281 -0
- package/src/_b_end_runtime/page-patterns/CopilotPagePattern.jsx +380 -0
- package/src/_b_end_runtime/page-patterns/CustomerServiceWorkspaceFramePattern.jsx +392 -0
- package/src/_b_end_runtime/page-patterns/IMConversationPattern.jsx +590 -0
- package/src/_b_end_runtime/page-patterns/McpManagementPage.jsx +237 -0
- package/src/_b_end_runtime/page-patterns/StrategyListPage.jsx +189 -0
- package/src/_b_end_runtime/page-patterns/TabTopBarListPage.jsx +594 -0
- package/src/_b_end_runtime/page-patterns/VariableManagementPage.jsx +87 -0
- package/src/_b_end_runtime/page-patterns/pageListShared.jsx +177 -0
- package/src/_b_end_runtime/patterns.js +428 -0
- package/src/_b_end_runtime/preview-registry.jsx +4719 -0
- package/src/_b_end_runtime/teamMembers.js +56 -0
- package/src/_b_end_runtime/tokens.js +500 -0
- package/src/index.d.ts +1073 -0
- package/src/index.js +52 -0
- package/theme.css +350 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import Avatar from './Avatar';
|
|
2
|
+
import { getTeamMemberByName } from '../teamMembers';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* AvatarGroup — B端头像组组件(Tailwind 内联)
|
|
6
|
+
*
|
|
7
|
+
* 对齐 Figma AvatarGroup 组件集,展示 5 个头像按固定 10px 重叠的多人场景。
|
|
8
|
+
* 头像单项直接复用 Avatar 组件,仅通过宿主处理重叠层级和图片微调覆盖。
|
|
9
|
+
*
|
|
10
|
+
* **何时用**:强调「多人参与、协作氛围」的装饰性缩略(人数与顺序不可配)。
|
|
11
|
+
* **不用**:要展示真实成员列表、可点姓名、或人数 ≠5 → 用 `Avatar` 列表/表格列,勿强行用本组件。
|
|
12
|
+
*
|
|
13
|
+
* @prop {'s'|'default'|'m'} [size='s'] — 头像组尺寸,对应单项 32 / 40 / 48px
|
|
14
|
+
* @prop {string} [className=''] — 自定义类名
|
|
15
|
+
* @prop {React.CSSProperties|undefined} [style=undefined] — 自定义内联样式
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/* ── 容器 → 头像组排列 ── */
|
|
19
|
+
const GROUP = 'relative flex isolate items-start pr-avatar-group-overlap';
|
|
20
|
+
|
|
21
|
+
/* ── 单项 → 复用 Avatar 并关闭默认人像缩放 ── */
|
|
22
|
+
const ITEM_CLASS = [
|
|
23
|
+
'-mr-avatar-group-overlap',
|
|
24
|
+
'after:pointer-events-none',
|
|
25
|
+
'after:absolute',
|
|
26
|
+
'after:inset-0',
|
|
27
|
+
'after:rounded-full',
|
|
28
|
+
"after:content-['']",
|
|
29
|
+
'after:shadow-[inset_0_0_0_1px_var(--color-fill)]',
|
|
30
|
+
'[&_img]:scale-100',
|
|
31
|
+
'[&_img]:translate-y-0',
|
|
32
|
+
].join(' ');
|
|
33
|
+
|
|
34
|
+
/* ── 尺寸 → 单项边长 ── */
|
|
35
|
+
const SIZE_CLASS = {
|
|
36
|
+
s: 'size-8',
|
|
37
|
+
default: 'size-10',
|
|
38
|
+
m: 'size-12',
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
/* ── 头像组资源 ── */
|
|
42
|
+
const GROUP_IMAGES = [
|
|
43
|
+
getTeamMemberByName('李思儒')?.avatarSrc,
|
|
44
|
+
getTeamMemberByName('程程murphy')?.avatarSrc,
|
|
45
|
+
getTeamMemberByName('刘德琳')?.avatarSrc,
|
|
46
|
+
getTeamMemberByName('段然')?.avatarSrc,
|
|
47
|
+
getTeamMemberByName('郭泽智')?.avatarSrc,
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
export default function AvatarGroup({
|
|
51
|
+
size = 's',
|
|
52
|
+
className = '',
|
|
53
|
+
style,
|
|
54
|
+
...rest
|
|
55
|
+
}) {
|
|
56
|
+
const resolvedSize = SIZE_CLASS[size] ? size : 's';
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<div
|
|
60
|
+
className={[`tfds-avatar-group`, [GROUP, className].filter(Boolean).join(' ')].filter(Boolean).join(' ')}
|
|
61
|
+
style={style}
|
|
62
|
+
{...rest}
|
|
63
|
+
data-tfds-component="AvatarGroup">
|
|
64
|
+
{GROUP_IMAGES.filter(Boolean).map((src, index) => (
|
|
65
|
+
<Avatar
|
|
66
|
+
key={src}
|
|
67
|
+
size={resolvedSize}
|
|
68
|
+
type="image"
|
|
69
|
+
src={src}
|
|
70
|
+
alt=""
|
|
71
|
+
aria-hidden="true"
|
|
72
|
+
className={ITEM_CLASS}
|
|
73
|
+
style={{
|
|
74
|
+
zIndex: GROUP_IMAGES.length - index,
|
|
75
|
+
}}
|
|
76
|
+
/>
|
|
77
|
+
))}
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AvatarGroup — TOKEN_MAP(供平台属性面板展示)
|
|
3
|
+
*
|
|
4
|
+
* 分组顺序:容器 → 头像项 → 尺寸
|
|
5
|
+
*/
|
|
6
|
+
export const AVATAR_GROUP_TOKEN_MAP = {
|
|
7
|
+
base: [
|
|
8
|
+
{ label: '排列', cssProp: 'display', value: 'flex' },
|
|
9
|
+
{ label: '隔离', cssProp: 'isolation', value: 'isolate' },
|
|
10
|
+
{ label: '右侧补偿', cssProp: 'padding-right', token: '--spacing-avatar-group-overlap', value: '10px' },
|
|
11
|
+
],
|
|
12
|
+
头像项: [
|
|
13
|
+
{ label: '重叠间距', cssProp: 'margin-right', token: '--spacing-avatar-group-overlap', value: '-10px' },
|
|
14
|
+
{ label: '裁切', cssProp: 'overflow', value: 'hidden' },
|
|
15
|
+
{ label: '圆角', cssProp: 'border-radius', token: '--radius-full', value: '9999px' },
|
|
16
|
+
],
|
|
17
|
+
sizes: {
|
|
18
|
+
s: [
|
|
19
|
+
{ label: '单项边长', cssProp: 'width / height', token: '--spacing-8', value: '32px' },
|
|
20
|
+
],
|
|
21
|
+
default: [
|
|
22
|
+
{ label: '单项边长', cssProp: 'width / height', token: '--spacing-10', value: '40px' },
|
|
23
|
+
],
|
|
24
|
+
m: [
|
|
25
|
+
{ label: '单项边长', cssProp: 'width / height', token: '--spacing-12', value: '48px' },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button — 触发离散动作(提交、取消、打开弹窗、行内操作)
|
|
3
|
+
*
|
|
4
|
+
* **何时用**:改变业务状态、导航至任务、打开抽屉/对话框;与 `Tabs`(切换同容器内面板)区分。
|
|
5
|
+
* **组合**:仅图标时用 `icon` + `iconOnly`,必须传 `tooltip` 说明真实操作。
|
|
6
|
+
*
|
|
7
|
+
* @prop {'button'|'a'|import('react').ElementType} [as='button'] — 根元素类型(链接式操作可用 `as="a"`)
|
|
8
|
+
* @prop {'primary'|'outline-brand'|'outline-black'|'ghost-brand'|'ghost-black'|'text-brand'|'text-black'} [variant='primary'] — 变体(primary = 每视图唯一主操作)
|
|
9
|
+
* @prop {'sm'|'md'} [size='md'] — 高度档位,md 与 Input md 对齐
|
|
10
|
+
* @prop {'rounded'|'full'} [radius='rounded'] — 圆角
|
|
11
|
+
* @prop {import('react').ReactNode} [icon=null] — 图标插槽(通常传 `<Icon />`)
|
|
12
|
+
* @prop {boolean} [iconOnly=false] — 是否仅图标
|
|
13
|
+
* @prop {import('react').ReactNode} [tooltip=null] — 仅图标按钮的操作说明,hover/focus 时通过 Tooltip 展示
|
|
14
|
+
* @prop {boolean} [disabled=false]
|
|
15
|
+
* @prop {boolean} [loading=false]
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import Tooltip from './Tooltip';
|
|
19
|
+
|
|
20
|
+
/* ── 基础样式(所有变体 / 尺寸共用) ── */
|
|
21
|
+
const BASE = [
|
|
22
|
+
'tfds-button',
|
|
23
|
+
'inline-flex items-center justify-center',
|
|
24
|
+
'[font-family:inherit] [font-weight:var(--font-semibold)]',
|
|
25
|
+
'border cursor-pointer select-none',
|
|
26
|
+
'transition-all duration-150 leading-none',
|
|
27
|
+
'[outline:2px_solid_transparent] outline-offset-2',
|
|
28
|
+
'disabled:opacity-50 disabled:cursor-not-allowed disabled:pointer-events-none',
|
|
29
|
+
].join(' ');
|
|
30
|
+
|
|
31
|
+
/* ── 变体 → Tailwind 类名 ── */
|
|
32
|
+
const VARIANT_CLASS = {
|
|
33
|
+
primary: [
|
|
34
|
+
'bg-grey-950 text-white border-transparent',
|
|
35
|
+
'hover:bg-grey-900',
|
|
36
|
+
'active:bg-grey-800 active:scale-[0.97]',
|
|
37
|
+
'focus-visible:outline-grey-400',
|
|
38
|
+
].join(' '),
|
|
39
|
+
'outline-brand': [
|
|
40
|
+
'bg-white text-brand-700 border-border-brand',
|
|
41
|
+
'hover:bg-brand-50',
|
|
42
|
+
'active:bg-brand-100',
|
|
43
|
+
'focus-visible:outline-brand-200',
|
|
44
|
+
].join(' '),
|
|
45
|
+
'outline-black': [
|
|
46
|
+
'bg-white text-foreground border-border-default',
|
|
47
|
+
'hover:bg-blueGrey-50 hover:border-border-strong',
|
|
48
|
+
'active:bg-blueGrey-100',
|
|
49
|
+
'focus-visible:outline-blueGrey-400',
|
|
50
|
+
].join(' '),
|
|
51
|
+
'ghost-brand': [
|
|
52
|
+
'bg-transparent text-brand-700 border-transparent',
|
|
53
|
+
'hover:bg-brand-50',
|
|
54
|
+
'active:bg-brand-100',
|
|
55
|
+
'focus-visible:outline-brand-200',
|
|
56
|
+
].join(' '),
|
|
57
|
+
'ghost-black': [
|
|
58
|
+
'bg-transparent text-foreground border-transparent',
|
|
59
|
+
'hover:bg-blueGrey-100',
|
|
60
|
+
'active:bg-blueGrey-200',
|
|
61
|
+
'focus-visible:outline-blueGrey-400',
|
|
62
|
+
].join(' '),
|
|
63
|
+
'text-brand': [
|
|
64
|
+
'bg-transparent text-brand-700 border-transparent',
|
|
65
|
+
'hover:text-brand-800',
|
|
66
|
+
'active:text-brand-900',
|
|
67
|
+
'focus-visible:outline-brand-200',
|
|
68
|
+
].join(' '),
|
|
69
|
+
'text-black': [
|
|
70
|
+
'bg-transparent text-foreground border-transparent',
|
|
71
|
+
'hover:text-blueGrey-700',
|
|
72
|
+
'active:text-blueGrey-600',
|
|
73
|
+
'focus-visible:outline-blueGrey-400',
|
|
74
|
+
].join(' '),
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/* ── 尺寸 → Tailwind 类名 ── */
|
|
78
|
+
const SIZE_CLASS = {
|
|
79
|
+
sm: 'h-[24px] py-1 px-2 text-xs gap-1',
|
|
80
|
+
md: 'h-[36px] py-2 px-3 text-sm gap-2',
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
/* ── 圆角 → Tailwind 类名 ── */
|
|
84
|
+
const RADIUS_CLASS = {
|
|
85
|
+
rounded: 'rounded-md',
|
|
86
|
+
full: 'rounded-full',
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default function Button({
|
|
90
|
+
as = 'button',
|
|
91
|
+
variant = 'primary',
|
|
92
|
+
size = 'md',
|
|
93
|
+
radius = 'rounded',
|
|
94
|
+
icon,
|
|
95
|
+
iconOnly = false,
|
|
96
|
+
tooltip = null,
|
|
97
|
+
disabled = false,
|
|
98
|
+
loading = false,
|
|
99
|
+
className = '',
|
|
100
|
+
children,
|
|
101
|
+
...rest
|
|
102
|
+
}) {
|
|
103
|
+
const cls = [
|
|
104
|
+
BASE,
|
|
105
|
+
VARIANT_CLASS[variant],
|
|
106
|
+
SIZE_CLASS[size],
|
|
107
|
+
RADIUS_CLASS[radius],
|
|
108
|
+
iconOnly && '!p-0 !gap-0 aspect-square',
|
|
109
|
+
loading && 'cursor-wait pointer-events-none',
|
|
110
|
+
className,
|
|
111
|
+
].filter(Boolean).join(' ');
|
|
112
|
+
|
|
113
|
+
const iconSlot = loading
|
|
114
|
+
? <span className="inline-block w-[1em] h-[1em] border-2 border-current border-t-transparent rounded-full animate-spin shrink-0" />
|
|
115
|
+
: icon;
|
|
116
|
+
|
|
117
|
+
const Component = as;
|
|
118
|
+
const hasIconOnlyTooltip = iconOnly && tooltip !== null && tooltip !== undefined && tooltip !== '';
|
|
119
|
+
const ariaLabel = rest['aria-label'] ?? (hasIconOnlyTooltip && typeof tooltip === 'string' ? tooltip : undefined);
|
|
120
|
+
|
|
121
|
+
const buttonNode = (
|
|
122
|
+
<Component
|
|
123
|
+
className={cls}
|
|
124
|
+
data-tfds-component="Button"
|
|
125
|
+
disabled={Component === 'button' ? disabled : undefined}
|
|
126
|
+
aria-busy={loading || undefined}
|
|
127
|
+
{...rest}
|
|
128
|
+
aria-label={ariaLabel}
|
|
129
|
+
>
|
|
130
|
+
{iconSlot}
|
|
131
|
+
{!iconOnly && children}
|
|
132
|
+
</Component>
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
if (!hasIconOnlyTooltip) {
|
|
136
|
+
return buttonNode;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
<Tooltip content={tooltip} placement="top">
|
|
141
|
+
{buttonNode}
|
|
142
|
+
</Tooltip>
|
|
143
|
+
);
|
|
144
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Button — TOKEN_MAP(供平台属性面板展示)
|
|
3
|
+
* 组件实现代码见 Button.jsx
|
|
4
|
+
*/
|
|
5
|
+
export const BUTTON_TOKEN_MAP = {
|
|
6
|
+
base: [
|
|
7
|
+
{ label: '字重', cssProp: 'font-weight', token: '--font-semibold', value: '600(运行时使用 [font-weight:var(--font-semibold)])' },
|
|
8
|
+
{ label: '边框宽度', cssProp: 'border-width', value: '1px' },
|
|
9
|
+
],
|
|
10
|
+
variants: {
|
|
11
|
+
primary: [
|
|
12
|
+
{ label: '背景色', cssProp: 'background', token: '--color-grey-950', value: '#111116' },
|
|
13
|
+
{ label: '悬浮背景', cssProp: 'background', token: '--color-grey-900', value: '#1C1C23', state: 'hover' },
|
|
14
|
+
{ label: '按下背景', cssProp: 'background', token: '--color-grey-800', value: '#2E2F38', state: 'active' },
|
|
15
|
+
{ label: '文字颜色', cssProp: 'color', token: '--color-white', value: '#FFFFFF', semanticRef: 'text-inverse' },
|
|
16
|
+
{ label: '聚焦环', cssProp: 'outline-color', token: '--color-grey-400', value: '#878892', state: 'focus' },
|
|
17
|
+
],
|
|
18
|
+
'outline-brand': [
|
|
19
|
+
{ label: '背景色', cssProp: 'background', token: '--color-white', value: '#FFFFFF', semanticRef: 'bg-surface' },
|
|
20
|
+
{ label: '悬浮背景', cssProp: 'background', token: '--color-brand-50', value: '#EAFAF6', state: 'hover', semanticRef: 'status-primary.bg' },
|
|
21
|
+
{ label: '按下背景', cssProp: 'background', token: '--color-brand-100', value: '#CFF3EA', state: 'active' },
|
|
22
|
+
{ label: '文字颜色', cssProp: 'color', token: '--color-brand-700', value: '#18B49D', semanticRef: 'text-link' },
|
|
23
|
+
{ label: '边框色', cssProp: 'border-color', token: '--color-border-brand', value: '#56D3BC', semanticRef: 'border-brand' },
|
|
24
|
+
{ label: '聚焦环', cssProp: 'outline-color', token: '--color-brand-200', value: '#A8E8D7', state: 'focus' },
|
|
25
|
+
],
|
|
26
|
+
'outline-black': [
|
|
27
|
+
{ label: '背景色', cssProp: 'background', token: '--color-white', value: '#FFFFFF', semanticRef: 'bg-surface' },
|
|
28
|
+
{ label: '悬浮背景', cssProp: 'background', token: '--color-blueGrey-50', value: '#FCFCFD', state: 'hover' },
|
|
29
|
+
{ label: '按下背景', cssProp: 'background', token: '--color-blueGrey-100', value: '#F9FAFB', state: 'active' },
|
|
30
|
+
{ label: '文字颜色', cssProp: 'color', token: '--color-foreground', value: '#182230', semanticRef: 'text-primary' },
|
|
31
|
+
{ label: '边框色', cssProp: 'border-color', token: '--color-border-default', value: '#E4E7EC', semanticRef: 'border-default' },
|
|
32
|
+
{ label: '悬浮边框', cssProp: 'border-color', token: '--color-border-strong', value: '#D0D5DD', state: 'hover', semanticRef: 'border-strong' },
|
|
33
|
+
{ label: '聚焦环', cssProp: 'outline-color', token: '--color-blueGrey-400', value: '#D0D5DD', state: 'focus' },
|
|
34
|
+
],
|
|
35
|
+
'ghost-brand': [
|
|
36
|
+
{ label: '背景色', cssProp: 'background', value: 'transparent' },
|
|
37
|
+
{ label: '悬浮背景', cssProp: 'background', token: '--color-brand-50', value: '#EAFAF6', state: 'hover', semanticRef: 'status-primary.bg' },
|
|
38
|
+
{ label: '按下背景', cssProp: 'background', token: '--color-brand-100', value: '#CFF3EA', state: 'active' },
|
|
39
|
+
{ label: '文字颜色', cssProp: 'color', token: '--color-brand-700', value: '#18B49D', semanticRef: 'text-link' },
|
|
40
|
+
{ label: '聚焦环', cssProp: 'outline-color', token: '--color-brand-200', value: '#A8E8D7', state: 'focus' },
|
|
41
|
+
],
|
|
42
|
+
'ghost-black': [
|
|
43
|
+
{ label: '背景色', cssProp: 'background', value: 'transparent' },
|
|
44
|
+
{ label: '悬浮背景', cssProp: 'background', token: '--color-blueGrey-100', value: '#F9FAFB', state: 'hover' },
|
|
45
|
+
{ label: '按下背景', cssProp: 'background', token: '--color-blueGrey-200', value: '#F2F4F7', state: 'active' },
|
|
46
|
+
{ label: '文字颜色', cssProp: 'color', token: '--color-foreground', value: '#182230', semanticRef: 'text-primary' },
|
|
47
|
+
{ label: '聚焦环', cssProp: 'outline-color', token: '--color-blueGrey-400', value: '#D0D5DD', state: 'focus' },
|
|
48
|
+
],
|
|
49
|
+
'text-brand': [
|
|
50
|
+
{ label: '背景色', cssProp: 'background', value: 'transparent' },
|
|
51
|
+
{ label: '文字颜色', cssProp: 'color', token: '--color-brand-700', value: '#18B49D', semanticRef: 'text-link' },
|
|
52
|
+
{ label: '悬浮文字', cssProp: 'color', token: '--color-brand-800', value: '#129683', state: 'hover', semanticRef: 'text-link.hover' },
|
|
53
|
+
{ label: '按下文字', cssProp: 'color', token: '--color-brand-900', value: '#0D786A', state: 'active', semanticRef: 'text-link.active' },
|
|
54
|
+
{ label: '聚焦环', cssProp: 'outline-color', token: '--color-brand-200', value: '#A8E8D7', state: 'focus' },
|
|
55
|
+
],
|
|
56
|
+
'text-black': [
|
|
57
|
+
{ label: '背景色', cssProp: 'background', value: 'transparent' },
|
|
58
|
+
{ label: '文字颜色', cssProp: 'color', token: '--color-foreground', value: '#182230', semanticRef: 'text-primary' },
|
|
59
|
+
{ label: '悬浮文字', cssProp: 'color', token: '--color-blueGrey-700', value: '#475467', state: 'hover', semanticRef: 'text-secondary' },
|
|
60
|
+
{ label: '按下文字', cssProp: 'color', token: '--color-blueGrey-600', value: '#667085', state: 'active', semanticRef: 'text-tertiary' },
|
|
61
|
+
{ label: '聚焦环', cssProp: 'outline-color', token: '--color-blueGrey-400', value: '#D0D5DD', state: 'focus' },
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
sizes: {
|
|
65
|
+
sm: [
|
|
66
|
+
{ label: '高度', cssProp: 'height', value: '24px' },
|
|
67
|
+
{ label: '水平内距', cssProp: 'padding-inline', token: '--spacing-2', value: '8px' },
|
|
68
|
+
{ label: '垂直内距', cssProp: 'padding-block', token: '--spacing-1', value: '4px' },
|
|
69
|
+
{ label: '字号', cssProp: 'font-size', token: '--text-xs', value: '12px' },
|
|
70
|
+
{ label: '间距', cssProp: 'gap', token: '--spacing-1', value: '4px' },
|
|
71
|
+
],
|
|
72
|
+
md: [
|
|
73
|
+
{ label: '高度', cssProp: 'height', value: '36px' },
|
|
74
|
+
{ label: '水平内距', cssProp: 'padding-inline', token: '--spacing-4', value: '16px' },
|
|
75
|
+
{ label: '垂直内距', cssProp: 'padding-block', token: '--spacing-2', value: '8px' },
|
|
76
|
+
{ label: '字号', cssProp: 'font-size', token: '--text-sm', value: '14px' },
|
|
77
|
+
{ label: '间距', cssProp: 'gap', token: '--spacing-2', value: '8px' },
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
iconOnly: [
|
|
81
|
+
{ label: '宽高比', cssProp: 'aspect-ratio', value: '1:1' },
|
|
82
|
+
{ label: '内距', cssProp: 'padding', value: '0' },
|
|
83
|
+
{ label: '间距', cssProp: 'gap', value: '0' },
|
|
84
|
+
{ label: '操作说明', cssProp: 'interaction', value: '所有 iconOnly 纯图标按钮必须传 tooltip;hover/focus 通过 Tooltip 展示真实操作文案' },
|
|
85
|
+
],
|
|
86
|
+
radii: {
|
|
87
|
+
rounded: [{ label: '圆角', cssProp: 'border-radius', token: '--radius-md', value: '8px' }],
|
|
88
|
+
full: [{ label: '圆角', cssProp: 'border-radius', token: '--radius-full', value: '9999px' }],
|
|
89
|
+
},
|
|
90
|
+
};
|