@teamix-evo/ui 0.1.1 → 0.3.0
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/README.md +184 -184
- package/manifest.json +680 -492
- package/package.json +20 -10
- package/src/components/accordion/accordion.meta.md +5 -4
- package/src/components/accordion/accordion.stories.tsx +14 -9
- package/src/components/accordion/accordion.tsx +104 -8
- package/src/components/affix/affix.meta.md +20 -2
- package/src/components/affix/affix.stories.tsx +102 -25
- package/src/components/affix/affix.tsx +79 -9
- package/src/components/alert/alert.meta.md +44 -13
- package/src/components/alert/alert.stories.tsx +66 -21
- package/src/components/alert/alert.tsx +81 -34
- package/src/components/alert-dialog/alert-dialog.meta.md +61 -16
- package/src/components/alert-dialog/alert-dialog.stories.tsx +145 -3
- package/src/components/alert-dialog/alert-dialog.tsx +60 -13
- package/src/components/anchor/anchor.meta.md +8 -3
- package/src/components/anchor/anchor.stories.tsx +3 -3
- package/src/components/anchor/anchor.tsx +2 -2
- package/src/components/app/app.meta.md +9 -4
- package/src/components/app/app.stories.tsx +9 -7
- package/src/components/aspect-ratio/aspect-ratio.meta.md +4 -3
- package/src/components/aspect-ratio/aspect-ratio.stories.tsx +3 -3
- package/src/components/auto-complete/auto-complete.meta.md +14 -6
- package/src/components/auto-complete/auto-complete.stories.tsx +47 -4
- package/src/components/auto-complete/auto-complete.tsx +119 -71
- package/src/components/avatar/avatar.meta.md +6 -7
- package/src/components/avatar/avatar.stories.tsx +21 -3
- package/src/components/avatar/avatar.tsx +24 -23
- package/src/components/badge/badge.meta.md +10 -9
- package/src/components/badge/badge.stories.tsx +2 -2
- package/src/components/badge/badge.tsx +9 -15
- package/src/components/breadcrumb/breadcrumb.meta.md +27 -7
- package/src/components/breadcrumb/breadcrumb.stories.tsx +127 -4
- package/src/components/breadcrumb/breadcrumb.tsx +22 -8
- package/src/components/button/button.meta.md +258 -21
- package/src/components/button/button.stories.tsx +549 -41
- package/src/components/button/button.tsx +335 -33
- package/src/components/button/demo/as-child.tsx +24 -0
- package/src/components/button/demo/basic.tsx +8 -0
- package/src/components/button/demo/block.tsx +16 -0
- package/src/components/button/demo/loading.tsx +19 -0
- package/src/components/button/demo/shapes.tsx +18 -0
- package/src/components/button/demo/sizes.tsx +19 -0
- package/src/components/button/demo/variants.tsx +19 -0
- package/src/components/button/demo/with-icon.tsx +20 -0
- package/src/components/calendar/calendar.meta.md +13 -3
- package/src/components/calendar/calendar.stories.tsx +6 -6
- package/src/components/calendar/calendar.tsx +73 -8
- package/src/components/card/card.meta.md +27 -5
- package/src/components/card/card.stories.tsx +42 -3
- package/src/components/card/card.tsx +146 -63
- package/src/components/carousel/carousel.meta.md +4 -3
- package/src/components/carousel/carousel.stories.tsx +11 -6
- package/src/components/cascader/cascader.meta.md +47 -17
- package/src/components/cascader/cascader.stories.tsx +22 -10
- package/src/components/cascader/cascader.tsx +428 -85
- package/src/components/checkbox/checkbox.meta.md +75 -7
- package/src/components/checkbox/checkbox.stories.tsx +161 -3
- package/src/components/checkbox/checkbox.tsx +77 -9
- package/src/components/collapsible/collapsible.meta.md +14 -6
- package/src/components/collapsible/collapsible.stories.tsx +10 -2
- package/src/components/collapsible/collapsible.tsx +93 -6
- package/src/components/color-picker/color-picker.meta.md +12 -7
- package/src/components/color-picker/color-picker.stories.tsx +86 -7
- package/src/components/color-picker/color-picker.tsx +20 -9
- package/src/components/command/command.meta.md +29 -13
- package/src/components/command/command.stories.tsx +4 -4
- package/src/components/command/command.tsx +19 -8
- package/src/components/context-menu/context-menu.meta.md +11 -8
- package/src/components/context-menu/context-menu.stories.tsx +11 -3
- package/src/components/context-menu/context-menu.tsx +21 -8
- package/src/components/data-table/data-table.meta.md +6 -5
- package/src/components/data-table/data-table.stories.tsx +13 -6
- package/src/components/data-table/data-table.tsx +2 -2
- package/src/components/date-picker/date-picker.meta.md +88 -19
- package/src/components/date-picker/date-picker.stories.tsx +55 -5
- package/src/components/date-picker/date-picker.tsx +1489 -91
- package/src/components/descriptions/descriptions.meta.md +10 -5
- package/src/components/descriptions/descriptions.stories.tsx +3 -3
- package/src/components/descriptions/descriptions.tsx +22 -14
- package/src/components/dialog/dialog.meta.md +76 -13
- package/src/components/dialog/dialog.stories.tsx +182 -20
- package/src/components/dialog/dialog.tsx +67 -15
- package/src/components/dialog/imperative.tsx +252 -0
- package/src/components/drawer/drawer.meta.md +33 -34
- package/src/components/drawer/drawer.stories.tsx +29 -12
- package/src/components/drawer/drawer.tsx +22 -113
- package/src/components/dropdown-menu/dropdown-menu.meta.md +78 -10
- package/src/components/dropdown-menu/dropdown-menu.stories.tsx +88 -2
- package/src/components/dropdown-menu/dropdown-menu.tsx +24 -10
- package/src/components/ellipsis/ellipsis.meta.md +87 -0
- package/src/components/ellipsis/ellipsis.stories.tsx +72 -0
- package/src/components/ellipsis/ellipsis.tsx +153 -0
- package/src/components/empty/empty.meta.md +9 -4
- package/src/components/empty/empty.stories.tsx +4 -4
- package/src/components/empty/empty.tsx +10 -3
- package/src/components/field/field.meta.md +47 -9
- package/src/components/field/field.stories.tsx +385 -5
- package/src/components/field/field.tsx +263 -35
- package/src/components/filter-bar/filter-bar.meta.md +92 -0
- package/src/components/filter-bar/filter-bar.stories.tsx +1083 -0
- package/src/components/filter-bar/filter-bar.tsx +568 -0
- package/src/components/flex/flex.meta.md +54 -6
- package/src/components/flex/flex.stories.tsx +107 -20
- package/src/components/flex/flex.tsx +27 -4
- package/src/components/float-button/float-button.meta.md +8 -3
- package/src/components/float-button/float-button.stories.tsx +9 -7
- package/src/components/float-button/float-button.tsx +1 -1
- package/src/components/form/form.meta.md +39 -17
- package/src/components/form/form.stories.tsx +350 -3
- package/src/components/form/form.tsx +101 -35
- package/src/components/grid/grid.meta.md +7 -2
- package/src/components/grid/grid.stories.tsx +6 -4
- package/src/components/hover-card/hover-card.meta.md +20 -9
- package/src/components/hover-card/hover-card.stories.tsx +34 -5
- package/src/components/hover-card/hover-card.tsx +51 -13
- package/src/components/icon/DEVELOPMENT.md +809 -0
- package/src/components/icon/icon.meta.md +170 -0
- package/src/components/icon/icon.stories.tsx +344 -0
- package/src/components/icon/icon.tsx +248 -0
- package/src/components/image/image.meta.md +9 -4
- package/src/components/image/image.stories.tsx +3 -3
- package/src/components/image/image.tsx +6 -4
- package/src/components/input/demo/basic.tsx +12 -0
- package/src/components/input/demo/clearable.tsx +21 -0
- package/src/components/input/demo/show-count.tsx +18 -0
- package/src/components/input/demo/sizes.tsx +15 -0
- package/src/components/input/input.meta.md +39 -33
- package/src/components/input/input.stories.tsx +62 -35
- package/src/components/input/input.tsx +97 -98
- package/src/components/input-group/input-group.meta.md +54 -22
- package/src/components/input-group/input-group.stories.tsx +49 -16
- package/src/components/input-group/input-group.tsx +44 -8
- package/src/components/input-number/input-number.meta.md +64 -7
- package/src/components/input-number/input-number.stories.tsx +46 -8
- package/src/components/input-number/input-number.tsx +99 -26
- package/src/components/input-otp/input-otp.meta.md +4 -3
- package/src/components/input-otp/input-otp.stories.tsx +3 -3
- package/src/components/input-otp/input-otp.tsx +1 -1
- package/src/components/item/item.meta.md +8 -3
- package/src/components/item/item.stories.tsx +8 -5
- package/src/components/item/item.tsx +7 -6
- package/src/components/kbd/kbd.meta.md +13 -4
- package/src/components/kbd/kbd.stories.tsx +4 -4
- package/src/components/kbd/kbd.tsx +10 -5
- package/src/components/label/label.meta.md +18 -10
- package/src/components/label/label.stories.tsx +64 -6
- package/src/components/label/label.tsx +91 -19
- package/src/components/masonry/masonry.meta.md +8 -3
- package/src/components/masonry/masonry.stories.tsx +7 -5
- package/src/components/masonry/masonry.tsx +1 -0
- package/src/components/mentions/mentions.meta.md +36 -6
- package/src/components/mentions/mentions.stories.tsx +120 -6
- package/src/components/mentions/mentions.tsx +11 -5
- package/src/components/menubar/menubar.meta.md +30 -12
- package/src/components/menubar/menubar.stories.tsx +62 -2
- package/src/components/menubar/menubar.tsx +9 -9
- package/src/components/native-select/native-select.meta.md +8 -3
- package/src/components/native-select/native-select.stories.tsx +8 -5
- package/src/components/native-select/native-select.tsx +1 -1
- package/src/components/navigation-menu/navigation-menu.meta.md +19 -9
- package/src/components/navigation-menu/navigation-menu.stories.tsx +112 -9
- package/src/components/navigation-menu/navigation-menu.tsx +8 -4
- package/src/components/notification/notification.meta.md +52 -10
- package/src/components/notification/notification.stories.tsx +11 -9
- package/src/components/notification/notification.tsx +36 -21
- package/src/components/page-header/DEVELOPMENT.md +842 -0
- package/src/components/page-header/page-header.meta.md +208 -0
- package/src/components/page-header/page-header.stories.tsx +421 -0
- package/src/components/page-header/page-header.tsx +281 -0
- package/src/components/pagination/pagination.meta.md +140 -37
- package/src/components/pagination/pagination.stories.tsx +232 -10
- package/src/components/pagination/pagination.tsx +355 -63
- package/src/components/popconfirm/popconfirm.meta.md +9 -4
- package/src/components/popconfirm/popconfirm.stories.tsx +3 -4
- package/src/components/popconfirm/popconfirm.tsx +2 -2
- package/src/components/popover/popover.meta.md +62 -5
- package/src/components/popover/popover.stories.tsx +83 -7
- package/src/components/popover/popover.tsx +77 -28
- package/src/components/progress/progress.meta.md +38 -6
- package/src/components/progress/progress.stories.tsx +3 -3
- package/src/components/progress/progress.tsx +24 -16
- package/src/components/radio-group/radio-group.meta.md +79 -7
- package/src/components/radio-group/radio-group.stories.tsx +39 -3
- package/src/components/radio-group/radio-group.tsx +149 -18
- package/src/components/rate/rate.meta.md +35 -4
- package/src/components/rate/rate.stories.tsx +13 -5
- package/src/components/rate/rate.tsx +37 -10
- package/src/components/resizable/resizable.meta.md +7 -4
- package/src/components/resizable/resizable.stories.tsx +6 -6
- package/src/components/resizable/resizable.tsx +1 -1
- package/src/components/result/result.meta.md +7 -2
- package/src/components/result/result.stories.tsx +4 -8
- package/src/components/result/result.tsx +24 -15
- package/src/components/scroll-area/scroll-area.meta.md +4 -3
- package/src/components/scroll-area/scroll-area.stories.tsx +12 -4
- package/src/components/scroll-area/scroll-area.tsx +3 -3
- package/src/components/segmented/segmented.meta.md +7 -4
- package/src/components/segmented/segmented.stories.tsx +37 -8
- package/src/components/segmented/segmented.tsx +15 -7
- package/src/components/select/select.meta.md +197 -52
- package/src/components/select/select.stories.tsx +238 -63
- package/src/components/select/select.tsx +718 -171
- package/src/components/separator/separator.meta.md +4 -3
- package/src/components/separator/separator.stories.tsx +3 -3
- package/src/components/separator/separator.tsx +3 -7
- package/src/components/sheet/sheet.meta.md +32 -16
- package/src/components/sheet/sheet.stories.tsx +116 -10
- package/src/components/sheet/sheet.tsx +116 -29
- package/src/components/sidebar/sidebar.meta.md +37 -18
- package/src/components/sidebar/sidebar.stories.tsx +701 -29
- package/src/components/sidebar/sidebar.tsx +615 -142
- package/src/components/skeleton/skeleton.meta.md +4 -5
- package/src/components/skeleton/skeleton.stories.tsx +4 -4
- package/src/components/skeleton/skeleton.tsx +7 -7
- package/src/components/slider/slider.meta.md +57 -5
- package/src/components/slider/slider.stories.tsx +58 -6
- package/src/components/slider/slider.tsx +154 -13
- package/src/components/sonner/sonner.meta.md +58 -7
- package/src/components/sonner/sonner.stories.tsx +78 -5
- package/src/components/sonner/sonner.tsx +137 -8
- package/src/components/spinner/spinner.meta.md +62 -13
- package/src/components/spinner/spinner.stories.tsx +66 -14
- package/src/components/spinner/spinner.tsx +111 -9
- package/src/components/statistic/statistic.meta.md +7 -2
- package/src/components/statistic/statistic.stories.tsx +3 -7
- package/src/components/statistic/statistic.tsx +5 -6
- package/src/components/steps/steps.meta.md +18 -4
- package/src/components/steps/steps.stories.tsx +43 -3
- package/src/components/steps/steps.tsx +15 -12
- package/src/components/switch/switch.meta.md +51 -5
- package/src/components/switch/switch.stories.tsx +6 -6
- package/src/components/switch/switch.tsx +109 -41
- package/src/components/table/table.meta.md +17 -6
- package/src/components/table/table.stories.tsx +10 -5
- package/src/components/table/table.tsx +4 -4
- package/src/components/tabs/tabs.meta.md +38 -25
- package/src/components/tabs/tabs.stories.tsx +111 -25
- package/src/components/tabs/tabs.tsx +125 -54
- package/src/components/tag/tag.meta.md +105 -40
- package/src/components/tag/tag.stories.tsx +189 -16
- package/src/components/tag/tag.tsx +222 -21
- package/src/components/textarea/textarea.meta.md +35 -19
- package/src/components/textarea/textarea.stories.tsx +32 -6
- package/src/components/textarea/textarea.tsx +33 -9
- package/src/components/time-picker/time-picker.meta.md +124 -32
- package/src/components/time-picker/time-picker.stories.tsx +85 -15
- package/src/components/time-picker/time-picker.tsx +913 -61
- package/src/components/timeline/timeline.meta.md +14 -6
- package/src/components/timeline/timeline.stories.tsx +37 -7
- package/src/components/timeline/timeline.tsx +35 -14
- package/src/components/toggle/toggle.meta.md +5 -4
- package/src/components/toggle/toggle.stories.tsx +4 -4
- package/src/components/toggle/toggle.tsx +4 -3
- package/src/components/toggle-group/toggle-group.meta.md +5 -4
- package/src/components/toggle-group/toggle-group.stories.tsx +3 -3
- package/src/components/toggle-group/toggle-group.tsx +2 -2
- package/src/components/tooltip/tooltip.meta.md +55 -5
- package/src/components/tooltip/tooltip.stories.tsx +42 -5
- package/src/components/tooltip/tooltip.tsx +81 -21
- package/src/components/tour/tour.meta.md +9 -4
- package/src/components/tour/tour.stories.tsx +3 -3
- package/src/components/tour/tour.tsx +4 -4
- package/src/components/transfer/transfer.meta.md +11 -6
- package/src/components/transfer/transfer.stories.tsx +4 -8
- package/src/components/transfer/transfer.tsx +28 -21
- package/src/components/tree/tree.meta.md +63 -5
- package/src/components/tree/tree.stories.tsx +31 -12
- package/src/components/tree/tree.tsx +9 -8
- package/src/components/tree-select/tree-select.meta.md +59 -8
- package/src/components/tree-select/tree-select.stories.tsx +3 -3
- package/src/components/tree-select/tree-select.tsx +42 -7
- package/src/components/typography/typography.meta.md +61 -14
- package/src/components/typography/typography.stories.tsx +12 -11
- package/src/components/typography/typography.tsx +43 -28
- package/src/components/upload/upload.meta.md +49 -4
- package/src/components/upload/upload.stories.tsx +72 -12
- package/src/components/upload/upload.tsx +170 -37
- package/src/components/watermark/watermark.meta.md +7 -2
- package/src/components/watermark/watermark.stories.tsx +101 -9
- package/src/components/watermark/watermark.tsx +1 -0
- package/src/hooks/use-breakpoint.ts +117 -0
- package/src/hooks/use-debounce-callback.ts +52 -0
- package/src/hooks/use-mobile.ts +23 -0
- package/src/stories/theme-tokens.stories.tsx +747 -0
- package/src/utils/trigger-input.ts +53 -0
- package/src/components/button-group/button-group.meta.md +0 -92
- package/src/components/button-group/button-group.stories.tsx +0 -90
- package/src/components/button-group/button-group.tsx +0 -75
- package/src/components/combobox/combobox.meta.md +0 -93
- package/src/components/combobox/combobox.stories.tsx +0 -55
- package/src/components/combobox/combobox.tsx +0 -130
- package/src/components/space/space.meta.md +0 -94
- package/src/components/space/space.stories.tsx +0 -94
- package/src/components/space/space.tsx +0 -106
|
@@ -4,50 +4,184 @@ import { cva, type VariantProps } from 'class-variance-authority';
|
|
|
4
4
|
import { Loader2 } from 'lucide-react';
|
|
5
5
|
|
|
6
6
|
import { cn } from '@/utils/cn';
|
|
7
|
+
import { Tooltip } from '@/components/tooltip/tooltip';
|
|
7
8
|
|
|
9
|
+
// ─── Button cva ──────────────────────────────────────────────────────────────
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Button cva 配置 — 视觉与交互的全部档位均落在 OpenTrek tokens 上:
|
|
13
|
+
* - 圆角 `rounded-md` 直接消费 Tailwind v4 标准 namespace token `--radius-md`,
|
|
14
|
+
* uni-manager 主题下 = 2px(对齐 cd corner.1 锐利风格);
|
|
15
|
+
* opentrek 主题下 = Tailwind v4 默认 0.375rem = 6px。
|
|
16
|
+
* 注:不使用自定义 `--radius-button` 组件级别名,因 Tailwind v4 在多包 @import
|
|
17
|
+
* 场景下不会为非标准 namespace token 自动派生 utility(实测 .rounded-button
|
|
18
|
+
* 不生成);用标准档对齐主题语义即可,避免无谓的 @utility 注册。
|
|
19
|
+
* - 高度 `h-6 / h-8 / h-9` 对应 24/32/36px(与 Input / Select 同档)
|
|
20
|
+
* - 字重 `font-normal`(400)— cd hybridcloud Button 字重
|
|
21
|
+
* - 颜色 `bg-primary / bg-destructive / ...` 全部走 design semantic tokens
|
|
22
|
+
* - ghost / link 仅收紧左右 padding(ghost px-1 / link px-0),高度跟随主 size 档(h-6/h-8/h-9)
|
|
23
|
+
* 与 cd hybridcloud text 按钮实际表现一致(高度不追加独立紧凑档,只去背景/边框)
|
|
24
|
+
*/
|
|
8
25
|
const buttonVariants = cva(
|
|
9
|
-
'inline-flex items-center justify-center gap-
|
|
26
|
+
'inline-flex cursor-pointer items-center justify-center gap-1 whitespace-nowrap font-normal rounded-md transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
|
|
10
27
|
{
|
|
11
28
|
variants: {
|
|
12
29
|
variant: {
|
|
13
30
|
default:
|
|
14
|
-
'bg-primary text-primary-foreground shadow hover:bg-primary/90',
|
|
31
|
+
'bg-primary text-primary-foreground shadow hover:bg-primary/90 hover:shadow-md',
|
|
15
32
|
secondary:
|
|
16
33
|
'bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80',
|
|
17
34
|
destructive:
|
|
18
35
|
'bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90',
|
|
19
36
|
outline:
|
|
20
|
-
'border border-input bg-background shadow-sm hover:bg-
|
|
37
|
+
'border border-input bg-background shadow-sm hover:bg-muted hover:text-foreground hover:shadow-md',
|
|
21
38
|
dashed:
|
|
22
|
-
'border border-dashed border-input bg-background shadow-sm hover:bg-
|
|
39
|
+
'border border-dashed border-input bg-background shadow-sm hover:bg-muted hover:text-foreground hover:shadow-md',
|
|
23
40
|
ghost: 'hover:bg-accent hover:text-accent-foreground',
|
|
24
|
-
link: 'text-primary underline-offset-4
|
|
41
|
+
link: 'text-primary underline-offset-4',
|
|
42
|
+
},
|
|
43
|
+
// ADR 0021 语义色 — 与 `variant` 双 prop 组合,覆盖语义而非视觉骨架。
|
|
44
|
+
// 典型组合: `variant="outline" color="destructive"` ⇒ 旧库 warning + outline 形态。
|
|
45
|
+
color: {
|
|
46
|
+
default: '',
|
|
47
|
+
primary: '',
|
|
48
|
+
destructive: '',
|
|
25
49
|
},
|
|
26
50
|
size: {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
51
|
+
// 24px — 紧凑场景(表格行内、密集工具条),对齐 cd small
|
|
52
|
+
sm: 'h-6 px-3 text-xs',
|
|
53
|
+
// 32px — 默认 / 表单基线;`md` 与 `default` 等价(向后兼容旧 API)
|
|
54
|
+
// 字号对齐 cd hybridcloud --form-element-medium-font-size: 12px (ADR 0027)
|
|
55
|
+
md: 'h-8 px-3 text-xs',
|
|
56
|
+
default: 'h-8 px-3 text-xs',
|
|
57
|
+
// 36px — 强调主操作 / 落地页
|
|
58
|
+
lg: 'h-9 px-3 text-sm',
|
|
59
|
+
// 32px 正方形 — 纯图标按钮(配合 shape="circle" / "square")
|
|
60
|
+
icon: 'h-8 w-8',
|
|
31
61
|
},
|
|
32
62
|
shape: {
|
|
33
|
-
default: '
|
|
63
|
+
default: '',
|
|
64
|
+
// antd 兼容:`round` = 全圆角矩形
|
|
34
65
|
round: 'rounded-full',
|
|
66
|
+
// 等宽等高圆形 — 独立使用时常配 size="icon";SplitButton trigger 可省略 size 继承 group
|
|
35
67
|
circle: 'rounded-full aspect-square p-0',
|
|
68
|
+
// 等宽等高方形 — 独立使用时常配 size="icon";SplitButton trigger 可省略 size 继承 group
|
|
69
|
+
square: 'aspect-square p-0',
|
|
36
70
|
},
|
|
37
71
|
block: {
|
|
38
72
|
true: 'w-full',
|
|
39
73
|
false: '',
|
|
40
74
|
},
|
|
75
|
+
// 仅 icon、无 children 时收紧水平 padding,避免视觉过宽
|
|
76
|
+
iconOnly: {
|
|
77
|
+
true: 'px-0',
|
|
78
|
+
false: '',
|
|
79
|
+
},
|
|
41
80
|
},
|
|
81
|
+
compoundVariants: [
|
|
82
|
+
// size=icon 时强制方形,无需手动 px
|
|
83
|
+
{ size: 'icon', className: 'p-0' },
|
|
84
|
+
|
|
85
|
+
// ─── color × variant 语义覆盖(ADR 0021) ────────────────────────────
|
|
86
|
+
// outline + destructive ⇒ 旧库 warning+outline:边线 / 文字红,背景透明
|
|
87
|
+
{
|
|
88
|
+
variant: 'outline',
|
|
89
|
+
color: 'destructive',
|
|
90
|
+
className:
|
|
91
|
+
'border-destructive text-destructive hover:bg-destructive/10 hover:text-destructive',
|
|
92
|
+
},
|
|
93
|
+
// ghost + destructive ⇒ 删除类危险操作的轻量按钮(hover 背景走中性灰,对齐 cd hybridcloud)
|
|
94
|
+
{
|
|
95
|
+
variant: 'ghost',
|
|
96
|
+
color: 'destructive',
|
|
97
|
+
className: 'text-destructive hover:bg-muted',
|
|
98
|
+
},
|
|
99
|
+
// link + destructive ⇒ 链接式危险操作
|
|
100
|
+
{
|
|
101
|
+
variant: 'link',
|
|
102
|
+
color: 'destructive',
|
|
103
|
+
className: 'text-destructive',
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
// text 形态(ghost / link) 水平 padding 收紧;高度跟随主 size 档(h-6/h-8/h-9),
|
|
107
|
+
// 与 cd hybridcloud text 按钮实际表现一致(早期版本曾加独立 18/20px 紧凑档,D1 决策删除)
|
|
108
|
+
{
|
|
109
|
+
variant: 'ghost',
|
|
110
|
+
size: 'sm',
|
|
111
|
+
className: 'px-1',
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
variant: 'ghost',
|
|
115
|
+
size: 'md',
|
|
116
|
+
className: 'px-1',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
variant: 'ghost',
|
|
120
|
+
size: 'default',
|
|
121
|
+
className: 'px-1',
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
variant: 'ghost',
|
|
125
|
+
size: 'lg',
|
|
126
|
+
className: 'px-1',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
variant: 'link',
|
|
130
|
+
size: 'sm',
|
|
131
|
+
className: 'px-0',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
variant: 'link',
|
|
135
|
+
size: 'md',
|
|
136
|
+
className: 'px-0',
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
variant: 'link',
|
|
140
|
+
size: 'default',
|
|
141
|
+
className: 'px-0',
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
variant: 'link',
|
|
145
|
+
size: 'lg',
|
|
146
|
+
className: 'px-0',
|
|
147
|
+
},
|
|
148
|
+
],
|
|
42
149
|
defaultVariants: {
|
|
43
150
|
variant: 'default',
|
|
151
|
+
color: 'default',
|
|
44
152
|
size: 'default',
|
|
45
153
|
shape: 'default',
|
|
46
154
|
block: false,
|
|
155
|
+
iconOnly: false,
|
|
47
156
|
},
|
|
48
157
|
},
|
|
49
158
|
);
|
|
50
159
|
|
|
160
|
+
export type ButtonVariant =
|
|
161
|
+
| 'default'
|
|
162
|
+
| 'secondary'
|
|
163
|
+
| 'destructive'
|
|
164
|
+
| 'outline'
|
|
165
|
+
| 'dashed'
|
|
166
|
+
| 'ghost'
|
|
167
|
+
| 'link';
|
|
168
|
+
export type ButtonColor = 'default' | 'primary' | 'destructive';
|
|
169
|
+
export type ButtonSize = 'sm' | 'md' | 'default' | 'lg' | 'icon';
|
|
170
|
+
export type ButtonShape = 'default' | 'round' | 'circle' | 'square';
|
|
171
|
+
|
|
172
|
+
// ─── ButtonGroup Context — 把 size 自顶向下注入子 Button ─────────────────────
|
|
173
|
+
|
|
174
|
+
interface ButtonGroupContextValue {
|
|
175
|
+
/** 由 `<ButtonGroup size>` 注入,子 Button 未显式传 size 时回退到此值。 */
|
|
176
|
+
size?: ButtonSize;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const ButtonGroupContext = React.createContext<ButtonGroupContextValue | null>(
|
|
180
|
+
null,
|
|
181
|
+
);
|
|
182
|
+
|
|
183
|
+
// ─── Button ──────────────────────────────────────────────────────────────────
|
|
184
|
+
|
|
51
185
|
export interface ButtonProps
|
|
52
186
|
extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, 'children'>,
|
|
53
187
|
VariantProps<typeof buttonVariants> {
|
|
@@ -55,48 +189,60 @@ export interface ButtonProps
|
|
|
55
189
|
* 视觉风格,语义按 design token 走。
|
|
56
190
|
* @default "default"
|
|
57
191
|
*/
|
|
58
|
-
variant?:
|
|
59
|
-
| 'default'
|
|
60
|
-
| 'secondary'
|
|
61
|
-
| 'destructive'
|
|
62
|
-
| 'outline'
|
|
63
|
-
| 'dashed'
|
|
64
|
-
| 'ghost'
|
|
65
|
-
| 'link';
|
|
192
|
+
variant?: ButtonVariant;
|
|
66
193
|
/**
|
|
67
|
-
*
|
|
194
|
+
* 语义色(ADR 0021)。与 `variant` 双 prop 组合表达"语义 × 视觉"两个维度,
|
|
195
|
+
* 例:`variant="outline" color="destructive"` 实现旧库 warning+outline 形态;
|
|
196
|
+
* `variant="ghost" color="destructive"` 实现轻量危险删除按钮。
|
|
68
197
|
* @default "default"
|
|
69
198
|
*/
|
|
70
|
-
|
|
199
|
+
color?: ButtonColor;
|
|
71
200
|
/**
|
|
72
|
-
*
|
|
201
|
+
* 尺寸。`md` 与 `default` 等价,`icon` 为正方形纯图标按钮。
|
|
202
|
+
* 若包在 `<ButtonGroup size="..">` 中且本地未显式传值,自动继承 group 的 size。
|
|
73
203
|
* @default "default"
|
|
74
204
|
*/
|
|
75
|
-
|
|
205
|
+
size?: ButtonSize;
|
|
206
|
+
/**
|
|
207
|
+
* 形状。`circle` / `square` 必须配 `size="icon"`。
|
|
208
|
+
* @default "default"
|
|
209
|
+
*/
|
|
210
|
+
shape?: ButtonShape;
|
|
76
211
|
/**
|
|
77
212
|
* `true` 时撑满父容器宽度。
|
|
78
213
|
* @default false
|
|
79
214
|
*/
|
|
80
215
|
block?: boolean;
|
|
81
216
|
/**
|
|
82
|
-
* 用 Radix Slot 模式渲染为子元素;此时 `loading` / `icon` 被忽略。
|
|
217
|
+
* 用 Radix Slot 模式渲染为子元素;此时 `loading` / `icon` / `iconRight` 被忽略。
|
|
83
218
|
* @default false
|
|
84
219
|
*/
|
|
85
220
|
asChild?: boolean;
|
|
86
221
|
/**
|
|
87
|
-
* 显示自旋 spinner,自动 disabled
|
|
222
|
+
* 显示自旋 spinner,自动 `disabled` + `aria-busy=true`,保留视觉宽度。
|
|
88
223
|
* @default false
|
|
89
224
|
*/
|
|
90
225
|
loading?: boolean;
|
|
91
226
|
/**
|
|
92
|
-
*
|
|
227
|
+
* 文本左侧图标。推荐 `lucide-react`。loading 时被 spinner 替换。
|
|
93
228
|
*/
|
|
94
229
|
icon?: React.ReactNode;
|
|
95
230
|
/**
|
|
96
|
-
*
|
|
231
|
+
* 文本右侧图标。推荐 `lucide-react`。
|
|
232
|
+
*/
|
|
233
|
+
iconRight?: React.ReactNode;
|
|
234
|
+
/**
|
|
235
|
+
* 兼容旧 API:`icon` 相对文本的位置;新代码请直接使用 `icon` / `iconRight` 双 slot。
|
|
97
236
|
* @default "start"
|
|
237
|
+
* @deprecated 使用 `icon` 与 `iconRight` 双 slot。
|
|
98
238
|
*/
|
|
99
239
|
iconPosition?: 'start' | 'end';
|
|
240
|
+
/**
|
|
241
|
+
* `disabled=true` 时的禁用解释文本。仅在 `disabled` 同时存在时生效:
|
|
242
|
+
* 内部包一层 `cursor-not-allowed` wrapper + Tooltip,把 button pointer-events 关闭后由 wrapper 拾取 hover。
|
|
243
|
+
* 不传则保持原生 disabled 行为。
|
|
244
|
+
*/
|
|
245
|
+
disabledTooltip?: React.ReactNode;
|
|
100
246
|
/** 按钮文本 / 内容。 */
|
|
101
247
|
children?: React.ReactNode;
|
|
102
248
|
}
|
|
@@ -106,21 +252,47 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
106
252
|
{
|
|
107
253
|
className,
|
|
108
254
|
variant,
|
|
255
|
+
color,
|
|
109
256
|
size,
|
|
110
257
|
shape,
|
|
111
258
|
block,
|
|
112
259
|
asChild = false,
|
|
113
260
|
loading = false,
|
|
114
261
|
icon,
|
|
262
|
+
iconRight,
|
|
115
263
|
iconPosition = 'start',
|
|
116
264
|
disabled,
|
|
265
|
+
disabledTooltip,
|
|
117
266
|
children,
|
|
118
267
|
...props
|
|
119
268
|
},
|
|
120
269
|
ref,
|
|
121
270
|
) => {
|
|
271
|
+
// ButtonGroup 注入的 size 在本地未显式传值时生效
|
|
272
|
+
const groupCtx = React.useContext(ButtonGroupContext);
|
|
273
|
+
const resolvedSize = size ?? groupCtx?.size;
|
|
274
|
+
|
|
275
|
+
// 兼容旧 API:iconPosition="end" 时把 icon 视作 iconRight(若 iconRight 未显式传)
|
|
276
|
+
const resolvedIcon =
|
|
277
|
+
iconPosition === 'end' && !iconRight ? undefined : icon;
|
|
278
|
+
const resolvedIconRight =
|
|
279
|
+
iconPosition === 'end' && !iconRight ? icon : iconRight;
|
|
280
|
+
|
|
281
|
+
// icon-only 检测:无 children + 至少一个 icon slot,适合收紧 padding
|
|
282
|
+
const isIconOnly =
|
|
283
|
+
(children == null || children === false || children === '') &&
|
|
284
|
+
(resolvedIcon != null || resolvedIconRight != null || loading);
|
|
285
|
+
|
|
122
286
|
const composedClassName = cn(
|
|
123
|
-
buttonVariants({
|
|
287
|
+
buttonVariants({
|
|
288
|
+
variant,
|
|
289
|
+
color,
|
|
290
|
+
size: resolvedSize,
|
|
291
|
+
shape,
|
|
292
|
+
block,
|
|
293
|
+
iconOnly: isIconOnly,
|
|
294
|
+
className,
|
|
295
|
+
}),
|
|
124
296
|
);
|
|
125
297
|
|
|
126
298
|
if (asChild) {
|
|
@@ -131,16 +303,16 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
131
303
|
);
|
|
132
304
|
}
|
|
133
305
|
|
|
134
|
-
const
|
|
306
|
+
const leadingNode = loading ? (
|
|
135
307
|
<Loader2
|
|
136
308
|
className="animate-spin motion-reduce:animate-none"
|
|
137
309
|
aria-hidden="true"
|
|
138
310
|
/>
|
|
139
311
|
) : (
|
|
140
|
-
|
|
312
|
+
resolvedIcon
|
|
141
313
|
);
|
|
142
314
|
|
|
143
|
-
|
|
315
|
+
const buttonEl = (
|
|
144
316
|
<button
|
|
145
317
|
ref={ref}
|
|
146
318
|
className={composedClassName}
|
|
@@ -148,13 +320,143 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
|
148
320
|
aria-busy={loading || undefined}
|
|
149
321
|
{...props}
|
|
150
322
|
>
|
|
151
|
-
{
|
|
323
|
+
{leadingNode}
|
|
152
324
|
{children}
|
|
153
|
-
{
|
|
325
|
+
{resolvedIconRight}
|
|
154
326
|
</button>
|
|
155
327
|
);
|
|
328
|
+
|
|
329
|
+
// 禁用 + 提示文案 ⇒ 用 cursor-not-allowed wrapper 拾取 hover,关闭 button pointer-events
|
|
330
|
+
if (disabled && disabledTooltip != null) {
|
|
331
|
+
return (
|
|
332
|
+
<Tooltip title={disabledTooltip} withProvider>
|
|
333
|
+
<span className="inline-block cursor-not-allowed">
|
|
334
|
+
{React.cloneElement(buttonEl, {
|
|
335
|
+
className: cn(composedClassName, 'pointer-events-none'),
|
|
336
|
+
})}
|
|
337
|
+
</span>
|
|
338
|
+
</Tooltip>
|
|
339
|
+
);
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
return buttonEl;
|
|
156
343
|
},
|
|
157
344
|
);
|
|
158
345
|
Button.displayName = 'Button';
|
|
159
346
|
|
|
160
|
-
|
|
347
|
+
// ─── ButtonGroup ─────────────────────────────────────────────────────────────
|
|
348
|
+
|
|
349
|
+
const buttonGroupVariants = cva('inline-flex isolate', {
|
|
350
|
+
variants: {
|
|
351
|
+
orientation: {
|
|
352
|
+
horizontal:
|
|
353
|
+
'flex-row [&>*:not(:first-child)]:rounded-l-none [&>*:not(:last-child)]:rounded-r-none [&>*:not(:first-child)]:-ml-px hover:[&>*]:z-10 focus-visible:[&>*]:z-10',
|
|
354
|
+
vertical:
|
|
355
|
+
'flex-col [&>*:not(:first-child)]:rounded-t-none [&>*:not(:last-child)]:rounded-b-none [&>*:not(:first-child)]:-mt-px hover:[&>*]:z-10 focus-visible:[&>*]:z-10',
|
|
356
|
+
},
|
|
357
|
+
attached: {
|
|
358
|
+
true: '',
|
|
359
|
+
false: 'gap-2',
|
|
360
|
+
},
|
|
361
|
+
},
|
|
362
|
+
defaultVariants: { orientation: 'horizontal', attached: true },
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
export interface ButtonGroupProps
|
|
366
|
+
extends React.HTMLAttributes<HTMLDivElement>,
|
|
367
|
+
VariantProps<typeof buttonGroupVariants> {
|
|
368
|
+
/**
|
|
369
|
+
* 排列方向。
|
|
370
|
+
* @default "horizontal"
|
|
371
|
+
*/
|
|
372
|
+
orientation?: 'horizontal' | 'vertical';
|
|
373
|
+
/**
|
|
374
|
+
* 是否把按钮"粘"在一起去除边距(antd `Space.Compact` 等价行为)— `false` 时按钮间留 8px gap。
|
|
375
|
+
* @default true
|
|
376
|
+
*/
|
|
377
|
+
attached?: boolean;
|
|
378
|
+
/**
|
|
379
|
+
* 统一下发给子 Button 的尺寸;子 Button 若显式传了 `size` 则以子值优先。
|
|
380
|
+
* 通过 React.Context 注入,跨 Slot 透传无效(asChild 自定义渲染不会拿到)。
|
|
381
|
+
*/
|
|
382
|
+
size?: ButtonSize;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* 按钮组容器 — 语义类似 antd `Space.Compact`(v6 替代旧 `Button.Group`):
|
|
387
|
+
* 把多个 `Button` / `Input` 包在一起共享边线,典型场景:
|
|
388
|
+
* - Split button(左主操作 + 右下拉箭头)
|
|
389
|
+
* - Toolbar(同语义按钮集合)
|
|
390
|
+
* - Input + 按钮拼装(`<Input/><Button>搜索</Button>`)
|
|
391
|
+
*
|
|
392
|
+
* 通过 `size` prop + React.Context 把尺寸自顶向下注入未显式传 size 的子 Button。
|
|
393
|
+
*/
|
|
394
|
+
const ButtonGroup = React.forwardRef<HTMLDivElement, ButtonGroupProps>(
|
|
395
|
+
({ orientation, attached, size, className, children, ...props }, ref) => {
|
|
396
|
+
const ctxValue = React.useMemo<ButtonGroupContextValue>(
|
|
397
|
+
() => ({ size }),
|
|
398
|
+
[size],
|
|
399
|
+
);
|
|
400
|
+
|
|
401
|
+
return (
|
|
402
|
+
<ButtonGroupContext.Provider value={ctxValue}>
|
|
403
|
+
<div
|
|
404
|
+
ref={ref}
|
|
405
|
+
role="group"
|
|
406
|
+
className={cn(
|
|
407
|
+
buttonGroupVariants({ orientation, attached }),
|
|
408
|
+
className,
|
|
409
|
+
)}
|
|
410
|
+
{...props}
|
|
411
|
+
>
|
|
412
|
+
{children}
|
|
413
|
+
</div>
|
|
414
|
+
</ButtonGroupContext.Provider>
|
|
415
|
+
);
|
|
416
|
+
},
|
|
417
|
+
);
|
|
418
|
+
ButtonGroup.displayName = 'ButtonGroup';
|
|
419
|
+
|
|
420
|
+
// ─── ButtonGroupText(antd-style addon text)─────────────────────────────────
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* ButtonGroupText 的高度走与 Button 一致的 size 档,通过 ButtonGroupContext 读取;
|
|
424
|
+
* 不在 Group 内时回退到 default(32px),不再写死 `h-9`(36px),修复跟 Button 默认尺寸不齐的 bug。
|
|
425
|
+
*/
|
|
426
|
+
const buttonGroupTextSizeClassMap: Record<ButtonSize, string> = {
|
|
427
|
+
sm: 'h-6 text-xs',
|
|
428
|
+
md: 'h-8 text-xs',
|
|
429
|
+
default: 'h-8 text-xs',
|
|
430
|
+
lg: 'h-9 text-sm',
|
|
431
|
+
// icon 在 addon 文本场景无意义,回退到 default
|
|
432
|
+
icon: 'h-8 text-xs',
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
const ButtonGroupText = React.forwardRef<
|
|
436
|
+
HTMLSpanElement,
|
|
437
|
+
React.HTMLAttributes<HTMLSpanElement>
|
|
438
|
+
>(({ className, ...props }, ref) => {
|
|
439
|
+
const groupCtx = React.useContext(ButtonGroupContext);
|
|
440
|
+
const sizeCls = buttonGroupTextSizeClassMap[groupCtx?.size ?? 'default'];
|
|
441
|
+
return (
|
|
442
|
+
<span
|
|
443
|
+
ref={ref}
|
|
444
|
+
className={cn(
|
|
445
|
+
'inline-flex select-none items-center border border-input bg-muted px-3 text-muted-foreground',
|
|
446
|
+
sizeCls,
|
|
447
|
+
className,
|
|
448
|
+
)}
|
|
449
|
+
{...props}
|
|
450
|
+
/>
|
|
451
|
+
);
|
|
452
|
+
});
|
|
453
|
+
ButtonGroupText.displayName = 'ButtonGroupText';
|
|
454
|
+
|
|
455
|
+
export {
|
|
456
|
+
Button,
|
|
457
|
+
ButtonGroup,
|
|
458
|
+
ButtonGroupText,
|
|
459
|
+
ButtonGroupContext,
|
|
460
|
+
buttonVariants,
|
|
461
|
+
buttonGroupVariants,
|
|
462
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Button } from '@/components/ui/button';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* asChild:用 Radix Slot 渲染为子元素(如 `<a>` / 路由 Link)。
|
|
5
|
+
* 此时 `loading` / `icon` prop 会被忽略,因为底层不再是 `<button>`。
|
|
6
|
+
*/
|
|
7
|
+
export default function Demo() {
|
|
8
|
+
return (
|
|
9
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
10
|
+
<Button asChild variant="link">
|
|
11
|
+
<a href="/ui/components/button">查看文档</a>
|
|
12
|
+
</Button>
|
|
13
|
+
<Button asChild>
|
|
14
|
+
<a
|
|
15
|
+
href="https://github.com/teamix-evo/teamix-evo"
|
|
16
|
+
target="_blank"
|
|
17
|
+
rel="noreferrer"
|
|
18
|
+
>
|
|
19
|
+
GitHub 仓库
|
|
20
|
+
</a>
|
|
21
|
+
</Button>
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Button } from '@/components/ui/button';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 块级按钮:撑满父容器宽度。
|
|
5
|
+
* 不要再额外加 `className="w-full"` 重复声明。
|
|
6
|
+
*/
|
|
7
|
+
export default function Demo() {
|
|
8
|
+
return (
|
|
9
|
+
<div className="flex w-80 flex-col gap-3">
|
|
10
|
+
<Button block>登录</Button>
|
|
11
|
+
<Button block variant="outline">
|
|
12
|
+
注册
|
|
13
|
+
</Button>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Button } from '@/components/ui/button';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Loading 状态:自动 disabled,spinner 替换 icon 占位,按钮宽度保持。
|
|
5
|
+
* 写 `loading` 即可,不要额外加 `disabled`。
|
|
6
|
+
*/
|
|
7
|
+
export default function Demo() {
|
|
8
|
+
return (
|
|
9
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
10
|
+
<Button loading>提交中</Button>
|
|
11
|
+
<Button variant="secondary" loading>
|
|
12
|
+
加载
|
|
13
|
+
</Button>
|
|
14
|
+
<Button variant="destructive" loading>
|
|
15
|
+
删除中
|
|
16
|
+
</Button>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { X } from 'lucide-react';
|
|
2
|
+
import { Button } from '@/components/ui/button';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 三种形状:default / round / circle。
|
|
6
|
+
* circle 必须配 `size="icon"`,否则视觉会扁圆变形。
|
|
7
|
+
*/
|
|
8
|
+
export default function Demo() {
|
|
9
|
+
return (
|
|
10
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
11
|
+
<Button>Default</Button>
|
|
12
|
+
<Button shape="round">Round</Button>
|
|
13
|
+
<Button shape="circle" size="icon" variant="ghost" aria-label="关闭">
|
|
14
|
+
<X />
|
|
15
|
+
</Button>
|
|
16
|
+
</div>
|
|
17
|
+
);
|
|
18
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Plus } from 'lucide-react';
|
|
2
|
+
import { Button } from '@/components/ui/button';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 四种尺寸:sm / default / lg / icon。
|
|
6
|
+
* icon 为正方形纯图标按钮,配合 `size="icon"` 使用。
|
|
7
|
+
*/
|
|
8
|
+
export default function Demo() {
|
|
9
|
+
return (
|
|
10
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
11
|
+
<Button size="sm">Small</Button>
|
|
12
|
+
<Button size="default">Default</Button>
|
|
13
|
+
<Button size="lg">Large</Button>
|
|
14
|
+
<Button size="icon" aria-label="Add">
|
|
15
|
+
<Plus />
|
|
16
|
+
</Button>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Button } from '@/components/ui/button';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 七种 variant:default / secondary / destructive / outline / dashed / ghost / link。
|
|
5
|
+
* 视觉差异由 OpenTrek semantic tokens 决定,无任何 mock 值。
|
|
6
|
+
*/
|
|
7
|
+
export default function Demo() {
|
|
8
|
+
return (
|
|
9
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
10
|
+
<Button>Default</Button>
|
|
11
|
+
<Button variant="secondary">Secondary</Button>
|
|
12
|
+
<Button variant="destructive">Destructive</Button>
|
|
13
|
+
<Button variant="outline">Outline</Button>
|
|
14
|
+
<Button variant="dashed">Dashed</Button>
|
|
15
|
+
<Button variant="ghost">Ghost</Button>
|
|
16
|
+
<Button variant="link">Link</Button>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ChevronRight, Download } from 'lucide-react';
|
|
2
|
+
import { Button } from '@/components/ui/button';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* 带图标按钮:通过 `icon` prop 传入 lucide-react 节点;
|
|
6
|
+
* 用 `iconPosition` 切换图标位置(默认 start)。
|
|
7
|
+
*/
|
|
8
|
+
export default function Demo() {
|
|
9
|
+
return (
|
|
10
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
11
|
+
<Button icon={<Download />}>下载</Button>
|
|
12
|
+
<Button icon={<ChevronRight />} iconPosition="end">
|
|
13
|
+
下一步
|
|
14
|
+
</Button>
|
|
15
|
+
<Button variant="outline" icon={<Download />}>
|
|
16
|
+
Outline + Icon
|
|
17
|
+
</Button>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|