@teamix-evo/ui 0.1.1
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/LICENSE +21 -0
- package/README.md +336 -0
- package/_data.json +12 -0
- package/manifest.json +1688 -0
- package/package.json +90 -0
- package/src/components/accordion/accordion.meta.md +87 -0
- package/src/components/accordion/accordion.stories.tsx +67 -0
- package/src/components/accordion/accordion.tsx +58 -0
- package/src/components/affix/affix.meta.md +80 -0
- package/src/components/affix/affix.stories.tsx +57 -0
- package/src/components/affix/affix.tsx +97 -0
- package/src/components/alert/alert.meta.md +101 -0
- package/src/components/alert/alert.stories.tsx +93 -0
- package/src/components/alert/alert.tsx +132 -0
- package/src/components/alert-dialog/alert-dialog.meta.md +107 -0
- package/src/components/alert-dialog/alert-dialog.stories.tsx +81 -0
- package/src/components/alert-dialog/alert-dialog.tsx +136 -0
- package/src/components/anchor/anchor.meta.md +87 -0
- package/src/components/anchor/anchor.stories.tsx +74 -0
- package/src/components/anchor/anchor.tsx +130 -0
- package/src/components/app/app.meta.md +86 -0
- package/src/components/app/app.stories.tsx +62 -0
- package/src/components/app/app.tsx +58 -0
- package/src/components/aspect-ratio/aspect-ratio.meta.md +81 -0
- package/src/components/aspect-ratio/aspect-ratio.stories.tsx +59 -0
- package/src/components/aspect-ratio/aspect-ratio.tsx +22 -0
- package/src/components/auto-complete/auto-complete.meta.md +102 -0
- package/src/components/auto-complete/auto-complete.stories.tsx +93 -0
- package/src/components/auto-complete/auto-complete.tsx +205 -0
- package/src/components/avatar/avatar.meta.md +94 -0
- package/src/components/avatar/avatar.stories.tsx +80 -0
- package/src/components/avatar/avatar.tsx +126 -0
- package/src/components/badge/badge.meta.md +119 -0
- package/src/components/badge/badge.stories.tsx +153 -0
- package/src/components/badge/badge.tsx +210 -0
- package/src/components/breadcrumb/breadcrumb.meta.md +107 -0
- package/src/components/breadcrumb/breadcrumb.stories.tsx +84 -0
- package/src/components/breadcrumb/breadcrumb.tsx +122 -0
- package/src/components/button/button.meta.md +98 -0
- package/src/components/button/button.stories.tsx +235 -0
- package/src/components/button/button.tsx +160 -0
- package/src/components/button-group/button-group.meta.md +92 -0
- package/src/components/button-group/button-group.stories.tsx +90 -0
- package/src/components/button-group/button-group.tsx +75 -0
- package/src/components/calendar/calendar.meta.md +118 -0
- package/src/components/calendar/calendar.stories.tsx +68 -0
- package/src/components/calendar/calendar.tsx +107 -0
- package/src/components/card/card.meta.md +117 -0
- package/src/components/card/card.stories.tsx +112 -0
- package/src/components/card/card.tsx +222 -0
- package/src/components/carousel/carousel.meta.md +117 -0
- package/src/components/carousel/carousel.stories.tsx +84 -0
- package/src/components/carousel/carousel.tsx +224 -0
- package/src/components/cascader/cascader.meta.md +110 -0
- package/src/components/cascader/cascader.stories.tsx +108 -0
- package/src/components/cascader/cascader.tsx +198 -0
- package/src/components/checkbox/checkbox.meta.md +99 -0
- package/src/components/checkbox/checkbox.stories.tsx +130 -0
- package/src/components/checkbox/checkbox.tsx +125 -0
- package/src/components/collapsible/collapsible.meta.md +80 -0
- package/src/components/collapsible/collapsible.stories.tsx +35 -0
- package/src/components/collapsible/collapsible.tsx +18 -0
- package/src/components/color-picker/color-picker.meta.md +84 -0
- package/src/components/color-picker/color-picker.stories.tsx +80 -0
- package/src/components/color-picker/color-picker.tsx +160 -0
- package/src/components/combobox/combobox.meta.md +93 -0
- package/src/components/combobox/combobox.stories.tsx +55 -0
- package/src/components/combobox/combobox.tsx +130 -0
- package/src/components/command/command.meta.md +104 -0
- package/src/components/command/command.stories.tsx +59 -0
- package/src/components/command/command.tsx +147 -0
- package/src/components/context-menu/context-menu.meta.md +90 -0
- package/src/components/context-menu/context-menu.stories.tsx +46 -0
- package/src/components/context-menu/context-menu.tsx +191 -0
- package/src/components/data-table/data-table.meta.md +149 -0
- package/src/components/data-table/data-table.stories.tsx +125 -0
- package/src/components/data-table/data-table.tsx +185 -0
- package/src/components/date-picker/date-picker.meta.md +106 -0
- package/src/components/date-picker/date-picker.stories.tsx +58 -0
- package/src/components/date-picker/date-picker.tsx +156 -0
- package/src/components/descriptions/descriptions.meta.md +78 -0
- package/src/components/descriptions/descriptions.stories.tsx +60 -0
- package/src/components/descriptions/descriptions.tsx +129 -0
- package/src/components/dialog/dialog.meta.md +105 -0
- package/src/components/dialog/dialog.stories.tsx +93 -0
- package/src/components/dialog/dialog.tsx +128 -0
- package/src/components/drawer/drawer.meta.md +96 -0
- package/src/components/drawer/drawer.stories.tsx +54 -0
- package/src/components/drawer/drawer.tsx +114 -0
- package/src/components/dropdown-menu/dropdown-menu.meta.md +103 -0
- package/src/components/dropdown-menu/dropdown-menu.stories.tsx +112 -0
- package/src/components/dropdown-menu/dropdown-menu.tsx +195 -0
- package/src/components/empty/empty.meta.md +81 -0
- package/src/components/empty/empty.stories.tsx +46 -0
- package/src/components/empty/empty.tsx +47 -0
- package/src/components/field/field.meta.md +116 -0
- package/src/components/field/field.stories.tsx +117 -0
- package/src/components/field/field.tsx +164 -0
- package/src/components/flex/flex.meta.md +94 -0
- package/src/components/flex/flex.stories.tsx +112 -0
- package/src/components/flex/flex.tsx +122 -0
- package/src/components/float-button/float-button.meta.md +87 -0
- package/src/components/float-button/float-button.stories.tsx +78 -0
- package/src/components/float-button/float-button.tsx +143 -0
- package/src/components/form/form.meta.md +131 -0
- package/src/components/form/form.stories.tsx +122 -0
- package/src/components/form/form.tsx +194 -0
- package/src/components/grid/grid.meta.md +87 -0
- package/src/components/grid/grid.stories.tsx +99 -0
- package/src/components/grid/grid.tsx +130 -0
- package/src/components/hover-card/hover-card.meta.md +92 -0
- package/src/components/hover-card/hover-card.stories.tsx +68 -0
- package/src/components/hover-card/hover-card.tsx +29 -0
- package/src/components/image/image.meta.md +94 -0
- package/src/components/image/image.stories.tsx +55 -0
- package/src/components/image/image.tsx +138 -0
- package/src/components/input/input.meta.md +109 -0
- package/src/components/input/input.stories.tsx +117 -0
- package/src/components/input/input.tsx +213 -0
- package/src/components/input-group/input-group.meta.md +92 -0
- package/src/components/input-group/input-group.stories.tsx +88 -0
- package/src/components/input-group/input-group.tsx +107 -0
- package/src/components/input-number/input-number.meta.md +91 -0
- package/src/components/input-number/input-number.stories.tsx +87 -0
- package/src/components/input-number/input-number.tsx +210 -0
- package/src/components/input-otp/input-otp.meta.md +105 -0
- package/src/components/input-otp/input-otp.stories.tsx +65 -0
- package/src/components/input-otp/input-otp.tsx +97 -0
- package/src/components/item/item.meta.md +116 -0
- package/src/components/item/item.stories.tsx +113 -0
- package/src/components/item/item.tsx +171 -0
- package/src/components/kbd/kbd.meta.md +85 -0
- package/src/components/kbd/kbd.stories.tsx +70 -0
- package/src/components/kbd/kbd.tsx +81 -0
- package/src/components/label/label.meta.md +91 -0
- package/src/components/label/label.stories.tsx +87 -0
- package/src/components/label/label.tsx +66 -0
- package/src/components/masonry/masonry.meta.md +85 -0
- package/src/components/masonry/masonry.stories.tsx +66 -0
- package/src/components/masonry/masonry.tsx +59 -0
- package/src/components/mentions/mentions.meta.md +89 -0
- package/src/components/mentions/mentions.stories.tsx +75 -0
- package/src/components/mentions/mentions.tsx +237 -0
- package/src/components/menubar/menubar.meta.md +100 -0
- package/src/components/menubar/menubar.stories.tsx +81 -0
- package/src/components/menubar/menubar.tsx +232 -0
- package/src/components/native-select/native-select.meta.md +88 -0
- package/src/components/native-select/native-select.stories.tsx +80 -0
- package/src/components/native-select/native-select.tsx +54 -0
- package/src/components/navigation-menu/navigation-menu.meta.md +108 -0
- package/src/components/navigation-menu/navigation-menu.stories.tsx +112 -0
- package/src/components/navigation-menu/navigation-menu.tsx +125 -0
- package/src/components/notification/notification.meta.md +91 -0
- package/src/components/notification/notification.stories.tsx +96 -0
- package/src/components/notification/notification.tsx +84 -0
- package/src/components/pagination/pagination.meta.md +127 -0
- package/src/components/pagination/pagination.stories.tsx +62 -0
- package/src/components/pagination/pagination.tsx +285 -0
- package/src/components/popconfirm/popconfirm.meta.md +109 -0
- package/src/components/popconfirm/popconfirm.stories.tsx +76 -0
- package/src/components/popconfirm/popconfirm.tsx +134 -0
- package/src/components/popover/popover.meta.md +97 -0
- package/src/components/popover/popover.stories.tsx +82 -0
- package/src/components/popover/popover.tsx +55 -0
- package/src/components/progress/progress.meta.md +86 -0
- package/src/components/progress/progress.stories.tsx +75 -0
- package/src/components/progress/progress.tsx +195 -0
- package/src/components/radio-group/radio-group.meta.md +103 -0
- package/src/components/radio-group/radio-group.stories.tsx +77 -0
- package/src/components/radio-group/radio-group.tsx +78 -0
- package/src/components/rate/rate.meta.md +87 -0
- package/src/components/rate/rate.stories.tsx +81 -0
- package/src/components/rate/rate.tsx +153 -0
- package/src/components/resizable/resizable.meta.md +92 -0
- package/src/components/resizable/resizable.stories.tsx +104 -0
- package/src/components/resizable/resizable.tsx +56 -0
- package/src/components/result/result.meta.md +90 -0
- package/src/components/result/result.stories.tsx +71 -0
- package/src/components/result/result.tsx +91 -0
- package/src/components/scroll-area/scroll-area.meta.md +84 -0
- package/src/components/scroll-area/scroll-area.stories.tsx +41 -0
- package/src/components/scroll-area/scroll-area.tsx +51 -0
- package/src/components/segmented/segmented.meta.md +103 -0
- package/src/components/segmented/segmented.stories.tsx +101 -0
- package/src/components/segmented/segmented.tsx +138 -0
- package/src/components/select/select.meta.md +110 -0
- package/src/components/select/select.stories.tsx +100 -0
- package/src/components/select/select.tsx +188 -0
- package/src/components/separator/separator.meta.md +74 -0
- package/src/components/separator/separator.stories.tsx +71 -0
- package/src/components/separator/separator.tsx +104 -0
- package/src/components/sheet/sheet.meta.md +97 -0
- package/src/components/sheet/sheet.stories.tsx +82 -0
- package/src/components/sheet/sheet.tsx +139 -0
- package/src/components/sidebar/sidebar.meta.md +131 -0
- package/src/components/sidebar/sidebar.stories.tsx +82 -0
- package/src/components/sidebar/sidebar.tsx +351 -0
- package/src/components/skeleton/skeleton.meta.md +95 -0
- package/src/components/skeleton/skeleton.stories.tsx +79 -0
- package/src/components/skeleton/skeleton.tsx +144 -0
- package/src/components/slider/slider.meta.md +94 -0
- package/src/components/slider/slider.stories.tsx +69 -0
- package/src/components/slider/slider.tsx +86 -0
- package/src/components/sonner/sonner.meta.md +96 -0
- package/src/components/sonner/sonner.stories.tsx +91 -0
- package/src/components/sonner/sonner.tsx +40 -0
- package/src/components/space/space.meta.md +94 -0
- package/src/components/space/space.stories.tsx +94 -0
- package/src/components/space/space.tsx +106 -0
- package/src/components/spinner/spinner.meta.md +76 -0
- package/src/components/spinner/spinner.stories.tsx +71 -0
- package/src/components/spinner/spinner.tsx +64 -0
- package/src/components/statistic/statistic.meta.md +99 -0
- package/src/components/statistic/statistic.stories.tsx +71 -0
- package/src/components/statistic/statistic.tsx +197 -0
- package/src/components/steps/steps.meta.md +102 -0
- package/src/components/steps/steps.stories.tsx +75 -0
- package/src/components/steps/steps.tsx +170 -0
- package/src/components/switch/switch.meta.md +92 -0
- package/src/components/switch/switch.stories.tsx +75 -0
- package/src/components/switch/switch.tsx +101 -0
- package/src/components/table/table.meta.md +95 -0
- package/src/components/table/table.stories.tsx +75 -0
- package/src/components/table/table.tsx +122 -0
- package/src/components/tabs/tabs.meta.md +98 -0
- package/src/components/tabs/tabs.stories.tsx +70 -0
- package/src/components/tabs/tabs.tsx +119 -0
- package/src/components/tag/tag.meta.md +94 -0
- package/src/components/tag/tag.stories.tsx +77 -0
- package/src/components/tag/tag.tsx +185 -0
- package/src/components/textarea/textarea.meta.md +83 -0
- package/src/components/textarea/textarea.stories.tsx +63 -0
- package/src/components/textarea/textarea.tsx +113 -0
- package/src/components/time-picker/time-picker.meta.md +83 -0
- package/src/components/time-picker/time-picker.stories.tsx +59 -0
- package/src/components/time-picker/time-picker.tsx +94 -0
- package/src/components/timeline/timeline.meta.md +102 -0
- package/src/components/timeline/timeline.stories.tsx +104 -0
- package/src/components/timeline/timeline.tsx +147 -0
- package/src/components/toggle/toggle.meta.md +88 -0
- package/src/components/toggle/toggle.stories.tsx +66 -0
- package/src/components/toggle/toggle.tsx +53 -0
- package/src/components/toggle-group/toggle-group.meta.md +90 -0
- package/src/components/toggle-group/toggle-group.stories.tsx +83 -0
- package/src/components/toggle-group/toggle-group.tsx +78 -0
- package/src/components/tooltip/tooltip.meta.md +99 -0
- package/src/components/tooltip/tooltip.stories.tsx +71 -0
- package/src/components/tooltip/tooltip.tsx +93 -0
- package/src/components/tour/tour.meta.md +116 -0
- package/src/components/tour/tour.stories.tsx +66 -0
- package/src/components/tour/tour.tsx +242 -0
- package/src/components/transfer/transfer.meta.md +90 -0
- package/src/components/transfer/transfer.stories.tsx +68 -0
- package/src/components/transfer/transfer.tsx +251 -0
- package/src/components/tree/tree.meta.md +111 -0
- package/src/components/tree/tree.stories.tsx +109 -0
- package/src/components/tree/tree.tsx +367 -0
- package/src/components/tree-select/tree-select.meta.md +100 -0
- package/src/components/tree-select/tree-select.stories.tsx +80 -0
- package/src/components/tree-select/tree-select.tsx +171 -0
- package/src/components/typography/typography.meta.md +102 -0
- package/src/components/typography/typography.stories.tsx +115 -0
- package/src/components/typography/typography.tsx +245 -0
- package/src/components/upload/upload.meta.md +111 -0
- package/src/components/upload/upload.stories.tsx +75 -0
- package/src/components/upload/upload.tsx +265 -0
- package/src/components/watermark/watermark.meta.md +95 -0
- package/src/components/watermark/watermark.stories.tsx +78 -0
- package/src/components/watermark/watermark.tsx +165 -0
- package/src/utils/cn.ts +6 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: badge
|
|
3
|
+
name: Badge
|
|
4
|
+
type: component
|
|
5
|
+
category: foundation
|
|
6
|
+
since: 0.1.0
|
|
7
|
+
package: "@teamix-evo/ui"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Badge
|
|
11
|
+
|
|
12
|
+
徽标 — shadcn 文本标签风格 + antd 数字徽标 / 红点 / 状态点的合集。
|
|
13
|
+
**单组件四种形态**,根据 props 自动切换:
|
|
14
|
+
|
|
15
|
+
| 形态 | 触发条件 | 示例 |
|
|
16
|
+
| --- | --- | --- |
|
|
17
|
+
| 文本徽标(shadcn) | 无 `count / dot / status`,仅 `children` | `<Badge>New</Badge>` |
|
|
18
|
+
| 包裹徽标(antd) | 有 `children` + `count` 或 `dot` | `<Badge count={5}><Avatar /></Badge>` |
|
|
19
|
+
| 独立数字气泡 | 仅 `count`,无 `children` | `<Badge count={3} />` |
|
|
20
|
+
| 状态点 + 文字 | 有 `status` | `<Badge status="success" text="运行中" />` |
|
|
21
|
+
|
|
22
|
+
## When to use
|
|
23
|
+
|
|
24
|
+
- **文本徽标**:版本号 / 标签 / 状态短文(`Beta` / `New` / `Pro`)
|
|
25
|
+
- **数字气泡**:消息未读数、购物车数量等数字提示(浮在 Avatar / 按钮右上角)
|
|
26
|
+
- **红点**:有未读但不需要数字时
|
|
27
|
+
- **状态点**:列表 / 详情页的资源状态(运行中 / 已停止 / 错误等)
|
|
28
|
+
|
|
29
|
+
## When NOT to use
|
|
30
|
+
|
|
31
|
+
- 需要可关闭、可定制颜色的标签 → 用 `Tag`(v0.7 提供)
|
|
32
|
+
- 角标(置于 Card 或图片右上角的丝带)→ 用 `Badge.Ribbon`(v0.x 提供)
|
|
33
|
+
- 大段说明文字 → 用 `Alert` 或 `Tooltip`
|
|
34
|
+
|
|
35
|
+
## Props
|
|
36
|
+
|
|
37
|
+
> 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成,数据源是 [`badge.tsx`](./badge.tsx) 的 `BadgeProps` interface JSDoc。**手工编辑 marker 之间的内容会在下次生成时被覆盖**。
|
|
38
|
+
|
|
39
|
+
<!-- auto:props:begin -->
|
|
40
|
+
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
41
|
+
| --- | --- | --- | --- | --- |
|
|
42
|
+
| `variant` | `'default' \| 'secondary' \| 'destructive' \| 'outline' \| 'success' \| 'warning'` | `"default"` | – | 视觉风格;`default / secondary / destructive / outline` 来自 shadcn, `success / warning` 来自 antd 状态色补足。 |
|
|
43
|
+
| `count` | `number` | – | – | 数字徽标内容。配合 `children` 时,数字气泡浮在右上角(包裹模式); 无 `children` 时,渲染为独立小气泡(standalone 模式)。 `0` 默认不显示,需配 `showZero`。 |
|
|
44
|
+
| `overflowCount` | `number` | `99` | – | 数字超过此值时显示 `${overflowCount}+`。仅在有 `count` 时生效。 |
|
|
45
|
+
| `showZero` | `boolean` | `false` | – | `true` 时即使 `count === 0` 也显示气泡。 |
|
|
46
|
+
| `dot` | `boolean` | `false` | – | `true` 时渲染为纯红点(无文字)。配合 `children` 时浮在右上角。 `dot` 与 `count` 同时存在,`dot` 优先。 |
|
|
47
|
+
| `status` | `BadgeStatus` | – | – | 状态点 + 文字(`<dot> <text>` 行内组合),用于"运行中 / 已停止"等状态描述。 必须与 `children` 互斥使用 — 这是 standalone 状态条形态。 |
|
|
48
|
+
| `text` | `React.ReactNode` | – | – | 配合 `status` 使用,渲染在状态点右侧。无 `status` 时忽略。 |
|
|
49
|
+
| `children` | `React.ReactNode` | – | – | 被包裹的元素(包裹模式)或徽标文本内容(standalone 文本模式)。 |
|
|
50
|
+
<!-- auto:props:end -->
|
|
51
|
+
|
|
52
|
+
## 依赖
|
|
53
|
+
|
|
54
|
+
> 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成,数据源是 [`manifest.json`](../../../manifest.json)。**手工编辑 marker 之间的内容会在下次生成时被覆盖**。
|
|
55
|
+
|
|
56
|
+
<!-- auto:deps:begin -->
|
|
57
|
+
### 同库依赖
|
|
58
|
+
|
|
59
|
+
> `teamix-evo ui add badge` 时,以下 entry 会被自动连带安装(无需手动 add)。
|
|
60
|
+
|
|
61
|
+
| Entry | 类型 | 描述 |
|
|
62
|
+
| --- | --- | --- |
|
|
63
|
+
| `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge) |
|
|
64
|
+
|
|
65
|
+
### npm 依赖
|
|
66
|
+
|
|
67
|
+
> 业务侧需要先 `pnpm add` / `npm install` 这些包。CLI 在 `ui add` 完成后会列出此提示。
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pnpm add class-variance-authority@^0.7.0
|
|
71
|
+
```
|
|
72
|
+
<!-- auto:deps:end -->
|
|
73
|
+
|
|
74
|
+
> 除上述 props 外,Badge 透传所有 `<span>` 原生属性(`onClick` / `aria-*` / `id` / ...)。
|
|
75
|
+
|
|
76
|
+
## AI 生成纪律
|
|
77
|
+
|
|
78
|
+
- **形态自动判断**:不要同时传 `count + dot`(`dot` 优先)、`status + children`(语义冲突),组件会按优先级降级,但人写代码时应明确单一形态。
|
|
79
|
+
- **status 颜色不要硬编码**:`success / warning / error` 等颜色已在 design `foundations/color/semantic.md` 锁定;**不要**绕过 `status` prop 直接写 `bg-green-500` 等。
|
|
80
|
+
- **count 必须为非负整数**:负数会渲染但语义错乱;0 默认不显示,需要显示 0 时显式传 `showZero`。
|
|
81
|
+
- **包裹模式的 ring**:气泡有 `ring-2 ring-background` 模拟"挖空"边框,**不要**改这里的 ring 颜色 — 切换 dark mode 时会自动适配。
|
|
82
|
+
- **状态条文案**:`text` 用现在分词或简短状态语(`运行中` / `已停止` / `异常`),不超过 6 个汉字。
|
|
83
|
+
- **不要堆叠**:同一容器内不要并排出现多种 Badge 形态(数字 + 状态条),信息过载;改用一张分组的状态卡片。
|
|
84
|
+
|
|
85
|
+
## Examples
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { Badge } from '@/components/ui/badge';
|
|
89
|
+
import { Bell } from 'lucide-react';
|
|
90
|
+
|
|
91
|
+
// 文本徽标(shadcn)
|
|
92
|
+
<Badge>New</Badge>
|
|
93
|
+
<Badge variant="secondary">Beta</Badge>
|
|
94
|
+
<Badge variant="destructive">Critical</Badge>
|
|
95
|
+
<Badge variant="success">Verified</Badge>
|
|
96
|
+
<Badge variant="warning">Pending</Badge>
|
|
97
|
+
|
|
98
|
+
// 数字徽标(antd 风格 — 包裹模式)
|
|
99
|
+
<Badge count={5}>
|
|
100
|
+
<Bell className="size-6" />
|
|
101
|
+
</Badge>
|
|
102
|
+
|
|
103
|
+
<Badge count={120} overflowCount={99}>
|
|
104
|
+
<Bell className="size-6" />
|
|
105
|
+
</Badge>
|
|
106
|
+
|
|
107
|
+
// 红点
|
|
108
|
+
<Badge dot>
|
|
109
|
+
<Bell className="size-6" />
|
|
110
|
+
</Badge>
|
|
111
|
+
|
|
112
|
+
// 独立数字气泡
|
|
113
|
+
<Badge count={3} />
|
|
114
|
+
|
|
115
|
+
// 状态点 + 文字
|
|
116
|
+
<Badge status="success" text="运行中" />
|
|
117
|
+
<Badge status="processing" text="部署中" />
|
|
118
|
+
<Badge status="error" text="异常" />
|
|
119
|
+
```
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Bell, MessageSquare, ShoppingCart } from 'lucide-react';
|
|
3
|
+
import { Badge } from './badge';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof Badge> = {
|
|
6
|
+
title: '基础原语 · Foundation/Badge',
|
|
7
|
+
component: Badge,
|
|
8
|
+
tags: ['autodocs'],
|
|
9
|
+
parameters: {
|
|
10
|
+
docs: {
|
|
11
|
+
description: {
|
|
12
|
+
component:
|
|
13
|
+
'徽标 — shadcn 文本徽标 + antd 数字 / 红点 / 状态点的合集,单组件四种形态。',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
argTypes: {
|
|
18
|
+
variant: {
|
|
19
|
+
description: '视觉风格(仅文本徽标形态生效)',
|
|
20
|
+
control: 'select',
|
|
21
|
+
options: [
|
|
22
|
+
'default',
|
|
23
|
+
'secondary',
|
|
24
|
+
'destructive',
|
|
25
|
+
'outline',
|
|
26
|
+
'success',
|
|
27
|
+
'warning',
|
|
28
|
+
],
|
|
29
|
+
},
|
|
30
|
+
count: {
|
|
31
|
+
description: '数字徽标(配 children 时浮在右上角,否则独立气泡)',
|
|
32
|
+
control: { type: 'number', min: 0 },
|
|
33
|
+
},
|
|
34
|
+
overflowCount: {
|
|
35
|
+
description: 'count 溢出阈值',
|
|
36
|
+
control: { type: 'number', min: 1 },
|
|
37
|
+
},
|
|
38
|
+
showZero: {
|
|
39
|
+
description: 'count 为 0 时是否显示',
|
|
40
|
+
control: 'boolean',
|
|
41
|
+
},
|
|
42
|
+
dot: {
|
|
43
|
+
description: '渲染为纯红点(配 children 时浮在右上角)',
|
|
44
|
+
control: 'boolean',
|
|
45
|
+
},
|
|
46
|
+
status: {
|
|
47
|
+
description: '状态点 + 文字(与 children 互斥)',
|
|
48
|
+
control: 'select',
|
|
49
|
+
options: [
|
|
50
|
+
undefined,
|
|
51
|
+
'default',
|
|
52
|
+
'success',
|
|
53
|
+
'processing',
|
|
54
|
+
'error',
|
|
55
|
+
'warning',
|
|
56
|
+
],
|
|
57
|
+
},
|
|
58
|
+
text: {
|
|
59
|
+
description: '配合 status 渲染的文字',
|
|
60
|
+
control: 'text',
|
|
61
|
+
},
|
|
62
|
+
children: {
|
|
63
|
+
description: '徽标内容(文本模式)或被包裹元素',
|
|
64
|
+
control: 'text',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
args: {
|
|
68
|
+
children: 'New',
|
|
69
|
+
variant: 'default',
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export default meta;
|
|
74
|
+
type Story = StoryObj<typeof Badge>;
|
|
75
|
+
|
|
76
|
+
/** 文本徽标(默认形态)。在 Controls 调 variant / 文字 / 切换形态。 */
|
|
77
|
+
export const Playground: Story = {};
|
|
78
|
+
|
|
79
|
+
/** 六种 variant 文本徽标对照。 */
|
|
80
|
+
export const VariantsMatrix: Story = {
|
|
81
|
+
parameters: { controls: { disable: true } },
|
|
82
|
+
render: () => (
|
|
83
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
84
|
+
<Badge>Default</Badge>
|
|
85
|
+
<Badge variant="secondary">Secondary</Badge>
|
|
86
|
+
<Badge variant="destructive">Destructive</Badge>
|
|
87
|
+
<Badge variant="outline">Outline</Badge>
|
|
88
|
+
<Badge variant="success">Success</Badge>
|
|
89
|
+
<Badge variant="warning">Warning</Badge>
|
|
90
|
+
</div>
|
|
91
|
+
),
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
/** 数字徽标 — 包裹模式(浮在 children 右上角)。 */
|
|
95
|
+
export const NumericWrapped: Story = {
|
|
96
|
+
parameters: { controls: { disable: true } },
|
|
97
|
+
render: () => (
|
|
98
|
+
<div className="flex items-center gap-8">
|
|
99
|
+
<Badge count={5}>
|
|
100
|
+
<Bell className="size-6 text-muted-foreground" />
|
|
101
|
+
</Badge>
|
|
102
|
+
<Badge count={32}>
|
|
103
|
+
<MessageSquare className="size-6 text-muted-foreground" />
|
|
104
|
+
</Badge>
|
|
105
|
+
<Badge count={120} overflowCount={99}>
|
|
106
|
+
<ShoppingCart className="size-6 text-muted-foreground" />
|
|
107
|
+
</Badge>
|
|
108
|
+
</div>
|
|
109
|
+
),
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
/** 红点 — 无文字提示有未读。 */
|
|
113
|
+
export const Dot: Story = {
|
|
114
|
+
parameters: { controls: { disable: true } },
|
|
115
|
+
render: () => (
|
|
116
|
+
<div className="flex items-center gap-8">
|
|
117
|
+
<Badge dot>
|
|
118
|
+
<Bell className="size-6 text-muted-foreground" />
|
|
119
|
+
</Badge>
|
|
120
|
+
<Badge dot>
|
|
121
|
+
<MessageSquare className="size-6 text-muted-foreground" />
|
|
122
|
+
</Badge>
|
|
123
|
+
</div>
|
|
124
|
+
),
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
/** 独立数字气泡(无 children)。常用于内联标记。 */
|
|
128
|
+
export const StandaloneCount: Story = {
|
|
129
|
+
parameters: { controls: { disable: true } },
|
|
130
|
+
render: () => (
|
|
131
|
+
<div className="flex items-center gap-3">
|
|
132
|
+
<Badge count={1} />
|
|
133
|
+
<Badge count={9} />
|
|
134
|
+
<Badge count={99} />
|
|
135
|
+
<Badge count={150} overflowCount={99} />
|
|
136
|
+
<Badge count={0} showZero />
|
|
137
|
+
</div>
|
|
138
|
+
),
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/** 状态点 + 文字(列表 / 详情页资源状态)。 */
|
|
142
|
+
export const StatusMatrix: Story = {
|
|
143
|
+
parameters: { controls: { disable: true } },
|
|
144
|
+
render: () => (
|
|
145
|
+
<div className="flex flex-col items-start gap-2">
|
|
146
|
+
<Badge status="success" text="运行中" />
|
|
147
|
+
<Badge status="processing" text="部署中" />
|
|
148
|
+
<Badge status="warning" text="降级运行" />
|
|
149
|
+
<Badge status="error" text="异常" />
|
|
150
|
+
<Badge status="default" text="已停止" />
|
|
151
|
+
</div>
|
|
152
|
+
),
|
|
153
|
+
};
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { cva, type VariantProps } from 'class-variance-authority';
|
|
3
|
+
|
|
4
|
+
import { cn } from '@/utils/cn';
|
|
5
|
+
|
|
6
|
+
const badgeVariants = cva(
|
|
7
|
+
'inline-flex items-center rounded-md border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2',
|
|
8
|
+
{
|
|
9
|
+
variants: {
|
|
10
|
+
variant: {
|
|
11
|
+
default:
|
|
12
|
+
'border-transparent bg-primary text-primary-foreground hover:bg-primary/80',
|
|
13
|
+
secondary:
|
|
14
|
+
'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
15
|
+
destructive:
|
|
16
|
+
'border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80',
|
|
17
|
+
outline: 'text-foreground',
|
|
18
|
+
success:
|
|
19
|
+
'border-transparent bg-emerald-500 text-white hover:bg-emerald-500/80',
|
|
20
|
+
warning:
|
|
21
|
+
'border-transparent bg-amber-500 text-white hover:bg-amber-500/80',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
defaultVariants: {
|
|
25
|
+
variant: 'default',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 状态点的语义色映射。来自 design `foundations/color/semantic.md`。
|
|
32
|
+
* 之所以这里硬编码 hex/tailwind class 而非 design token,
|
|
33
|
+
* 是因为 status 是数值化状态枚举(antd 体系),需要稳定一对一映射;
|
|
34
|
+
* 切换 design variant 时通过 token 层调整这些颜色,而非组件层。
|
|
35
|
+
*/
|
|
36
|
+
const statusDotClasses: Record<BadgeStatus, string> = {
|
|
37
|
+
default: 'bg-muted-foreground',
|
|
38
|
+
success: 'bg-emerald-500',
|
|
39
|
+
processing: 'bg-blue-500',
|
|
40
|
+
error: 'bg-destructive',
|
|
41
|
+
warning: 'bg-amber-500',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type BadgeStatus =
|
|
45
|
+
| 'default'
|
|
46
|
+
| 'success'
|
|
47
|
+
| 'processing'
|
|
48
|
+
| 'error'
|
|
49
|
+
| 'warning';
|
|
50
|
+
|
|
51
|
+
export interface BadgeProps
|
|
52
|
+
extends Omit<React.HTMLAttributes<HTMLSpanElement>, 'children'>,
|
|
53
|
+
VariantProps<typeof badgeVariants> {
|
|
54
|
+
/**
|
|
55
|
+
* 视觉风格;`default / secondary / destructive / outline` 来自 shadcn,
|
|
56
|
+
* `success / warning` 来自 antd 状态色补足。
|
|
57
|
+
* @default "default"
|
|
58
|
+
*/
|
|
59
|
+
variant?:
|
|
60
|
+
| 'default'
|
|
61
|
+
| 'secondary'
|
|
62
|
+
| 'destructive'
|
|
63
|
+
| 'outline'
|
|
64
|
+
| 'success'
|
|
65
|
+
| 'warning';
|
|
66
|
+
/**
|
|
67
|
+
* 数字徽标内容。配合 `children` 时,数字气泡浮在右上角(包裹模式);
|
|
68
|
+
* 无 `children` 时,渲染为独立小气泡(standalone 模式)。
|
|
69
|
+
* `0` 默认不显示,需配 `showZero`。
|
|
70
|
+
*/
|
|
71
|
+
count?: number;
|
|
72
|
+
/**
|
|
73
|
+
* 数字超过此值时显示 `${overflowCount}+`。仅在有 `count` 时生效。
|
|
74
|
+
* @default 99
|
|
75
|
+
*/
|
|
76
|
+
overflowCount?: number;
|
|
77
|
+
/**
|
|
78
|
+
* `true` 时即使 `count === 0` 也显示气泡。
|
|
79
|
+
* @default false
|
|
80
|
+
*/
|
|
81
|
+
showZero?: boolean;
|
|
82
|
+
/**
|
|
83
|
+
* `true` 时渲染为纯红点(无文字)。配合 `children` 时浮在右上角。
|
|
84
|
+
* `dot` 与 `count` 同时存在,`dot` 优先。
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
87
|
+
dot?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* 状态点 + 文字(`<dot> <text>` 行内组合),用于"运行中 / 已停止"等状态描述。
|
|
90
|
+
* 必须与 `children` 互斥使用 — 这是 standalone 状态条形态。
|
|
91
|
+
*/
|
|
92
|
+
status?: BadgeStatus;
|
|
93
|
+
/**
|
|
94
|
+
* 配合 `status` 使用,渲染在状态点右侧。无 `status` 时忽略。
|
|
95
|
+
*/
|
|
96
|
+
text?: React.ReactNode;
|
|
97
|
+
/** 被包裹的元素(包裹模式)或徽标文本内容(standalone 文本模式)。 */
|
|
98
|
+
children?: React.ReactNode;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
|
|
102
|
+
(
|
|
103
|
+
{
|
|
104
|
+
className,
|
|
105
|
+
variant,
|
|
106
|
+
count,
|
|
107
|
+
overflowCount = 99,
|
|
108
|
+
showZero = false,
|
|
109
|
+
dot = false,
|
|
110
|
+
status,
|
|
111
|
+
text,
|
|
112
|
+
children,
|
|
113
|
+
...props
|
|
114
|
+
},
|
|
115
|
+
ref,
|
|
116
|
+
) => {
|
|
117
|
+
// ── Standalone status mode: <dot> + <text> ────────────────────────────────
|
|
118
|
+
if (status) {
|
|
119
|
+
return (
|
|
120
|
+
<span
|
|
121
|
+
ref={ref}
|
|
122
|
+
className={cn('inline-flex items-center gap-2 text-sm', className)}
|
|
123
|
+
{...props}
|
|
124
|
+
>
|
|
125
|
+
<span
|
|
126
|
+
className={cn(
|
|
127
|
+
'inline-block size-2 rounded-full',
|
|
128
|
+
statusDotClasses[status],
|
|
129
|
+
)}
|
|
130
|
+
aria-hidden="true"
|
|
131
|
+
/>
|
|
132
|
+
{text != null ? <span>{text}</span> : null}
|
|
133
|
+
</span>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const hasNumeric = count !== undefined;
|
|
138
|
+
const shouldShowCount = hasNumeric && (count !== 0 || showZero);
|
|
139
|
+
const display =
|
|
140
|
+
hasNumeric && count! > overflowCount ? `${overflowCount}+` : count;
|
|
141
|
+
|
|
142
|
+
// ── Wrapped mode: badge floats on top-right of children ───────────────────
|
|
143
|
+
if (children !== undefined && (dot || shouldShowCount)) {
|
|
144
|
+
return (
|
|
145
|
+
<span
|
|
146
|
+
ref={ref}
|
|
147
|
+
className={cn('relative inline-flex shrink-0', className)}
|
|
148
|
+
{...props}
|
|
149
|
+
>
|
|
150
|
+
{children}
|
|
151
|
+
{dot ? (
|
|
152
|
+
<span
|
|
153
|
+
className="absolute right-0 top-0 size-2 -translate-y-1/2 translate-x-1/2 rounded-full bg-destructive ring-2 ring-background"
|
|
154
|
+
aria-hidden="true"
|
|
155
|
+
/>
|
|
156
|
+
) : (
|
|
157
|
+
<span className="absolute right-0 top-0 inline-flex min-w-[1.25rem] -translate-y-1/2 translate-x-1/2 items-center justify-center rounded-full bg-destructive px-1 text-[10px] font-semibold leading-none text-destructive-foreground ring-2 ring-background">
|
|
158
|
+
{display}
|
|
159
|
+
</span>
|
|
160
|
+
)}
|
|
161
|
+
</span>
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// ── Standalone dot ────────────────────────────────────────────────────────
|
|
166
|
+
if (dot) {
|
|
167
|
+
return (
|
|
168
|
+
<span
|
|
169
|
+
ref={ref}
|
|
170
|
+
className={cn(
|
|
171
|
+
'inline-block size-2 rounded-full bg-destructive',
|
|
172
|
+
className,
|
|
173
|
+
)}
|
|
174
|
+
aria-hidden="true"
|
|
175
|
+
{...props}
|
|
176
|
+
/>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// ── Standalone numeric badge ──────────────────────────────────────────────
|
|
181
|
+
if (shouldShowCount) {
|
|
182
|
+
return (
|
|
183
|
+
<span
|
|
184
|
+
ref={ref}
|
|
185
|
+
className={cn(
|
|
186
|
+
'inline-flex min-w-[1.25rem] items-center justify-center rounded-full bg-destructive px-1 text-[10px] font-semibold leading-none text-destructive-foreground',
|
|
187
|
+
className,
|
|
188
|
+
)}
|
|
189
|
+
{...props}
|
|
190
|
+
>
|
|
191
|
+
{display}
|
|
192
|
+
</span>
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ── shadcn-style text badge (default mode) ────────────────────────────────
|
|
197
|
+
return (
|
|
198
|
+
<span
|
|
199
|
+
ref={ref}
|
|
200
|
+
className={cn(badgeVariants({ variant }), className)}
|
|
201
|
+
{...props}
|
|
202
|
+
>
|
|
203
|
+
{children}
|
|
204
|
+
</span>
|
|
205
|
+
);
|
|
206
|
+
},
|
|
207
|
+
);
|
|
208
|
+
Badge.displayName = 'Badge';
|
|
209
|
+
|
|
210
|
+
export { Badge, badgeVariants };
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
---
|
|
2
|
+
id: breadcrumb
|
|
3
|
+
name: Breadcrumb
|
|
4
|
+
type: component
|
|
5
|
+
category: navigation
|
|
6
|
+
since: 0.1.0
|
|
7
|
+
package: "@teamix-evo/ui"
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Breadcrumb
|
|
11
|
+
|
|
12
|
+
面包屑 — 纯组合组件 + antd `separator` 自定义并集。
|
|
13
|
+
**与 antd Breadcrumb 的差异**:antd 用 `routes` 数组配置;本组件走 shadcn 的**组合式**(每项手写 `<BreadcrumbItem>`),配 React Router / Next.js Link 时更灵活。
|
|
14
|
+
|
|
15
|
+
## When to use
|
|
16
|
+
|
|
17
|
+
- 多层级页面的当前位置导航(项目 / 资源 / 详情)
|
|
18
|
+
- 文件系统 / 树形结构当前路径
|
|
19
|
+
- 表单分步流程的位置提示
|
|
20
|
+
|
|
21
|
+
## When NOT to use
|
|
22
|
+
|
|
23
|
+
- 平级 tab → `Tabs`
|
|
24
|
+
- 步骤流程 → `Steps`(v0.x)
|
|
25
|
+
- 仅一级 → 不需要 Breadcrumb
|
|
26
|
+
|
|
27
|
+
## Props
|
|
28
|
+
|
|
29
|
+
> 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成。
|
|
30
|
+
|
|
31
|
+
<!-- auto:props:begin -->
|
|
32
|
+
| 名称 | 类型 | 默认值 | 必填 | 说明 |
|
|
33
|
+
| --- | --- | --- | --- | --- |
|
|
34
|
+
| `separator` | `React.ReactNode` | – | – | 自定义分隔符(antd `separator` 并集)。每个 `<BreadcrumbSeparator />` 默认渲染 `<ChevronRight />`, 通过设置 children 可全局覆盖。 |
|
|
35
|
+
<!-- auto:props:end -->
|
|
36
|
+
|
|
37
|
+
## 依赖
|
|
38
|
+
|
|
39
|
+
> 以下表格由 `pnpm --filter @teamix-evo/ui gen:meta` 自动生成,数据源是 [`manifest.json`](../../../manifest.json)。**手工编辑 marker 之间的内容会在下次生成时被覆盖**。
|
|
40
|
+
|
|
41
|
+
<!-- auto:deps:begin -->
|
|
42
|
+
### 同库依赖
|
|
43
|
+
|
|
44
|
+
> `teamix-evo ui add breadcrumb` 时,以下 entry 会被自动连带安装(无需手动 add)。
|
|
45
|
+
|
|
46
|
+
| Entry | 类型 | 描述 |
|
|
47
|
+
| --- | --- | --- |
|
|
48
|
+
| `cn` | util | Tailwind className 合并工具(clsx + tailwind-merge) |
|
|
49
|
+
|
|
50
|
+
### npm 依赖
|
|
51
|
+
|
|
52
|
+
> 业务侧需要先 `pnpm add` / `npm install` 这些包。CLI 在 `ui add` 完成后会列出此提示。
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pnpm add @radix-ui/react-slot@^1.1.0 lucide-react@^0.460.0
|
|
56
|
+
```
|
|
57
|
+
<!-- auto:deps:end -->
|
|
58
|
+
|
|
59
|
+
> 子组件:`Breadcrumb`(nav)/ `BreadcrumbList`(ol)/ `BreadcrumbItem`(li)/ `BreadcrumbLink`(支持 asChild)/ `BreadcrumbPage`(当前页,不可点)/ `BreadcrumbSeparator`(默认 ChevronRight,可自定义)/ `BreadcrumbEllipsis`(省略,中间路径折叠用)。
|
|
60
|
+
|
|
61
|
+
## AI 生成纪律
|
|
62
|
+
|
|
63
|
+
- **当前页用 `BreadcrumbPage`**,不是 `BreadcrumbLink`(语义 + 视觉都不同)
|
|
64
|
+
- **配路由用 `asChild`**:`<BreadcrumbLink asChild><Link to="/x">...</Link></BreadcrumbLink>`
|
|
65
|
+
- **每两项之间必有 Separator**:不要手写 `>` 字符
|
|
66
|
+
- **过长路径用 Ellipsis**:超过 4 级时中间收成 `<BreadcrumbEllipsis />`(可配 DropdownMenu 展开完整列表)
|
|
67
|
+
- **路径文字简短**:每段 ≤ 6 字 / 12 字符,过长导致换行视觉破碎
|
|
68
|
+
|
|
69
|
+
## Examples
|
|
70
|
+
|
|
71
|
+
```tsx
|
|
72
|
+
import {
|
|
73
|
+
Breadcrumb, BreadcrumbList, BreadcrumbItem, BreadcrumbLink,
|
|
74
|
+
BreadcrumbPage, BreadcrumbSeparator, BreadcrumbEllipsis,
|
|
75
|
+
} from '@/components/ui/breadcrumb';
|
|
76
|
+
|
|
77
|
+
// 基本
|
|
78
|
+
<Breadcrumb>
|
|
79
|
+
<BreadcrumbList>
|
|
80
|
+
<BreadcrumbItem>
|
|
81
|
+
<BreadcrumbLink href="/">首页</BreadcrumbLink>
|
|
82
|
+
</BreadcrumbItem>
|
|
83
|
+
<BreadcrumbSeparator />
|
|
84
|
+
<BreadcrumbItem>
|
|
85
|
+
<BreadcrumbLink href="/projects">项目</BreadcrumbLink>
|
|
86
|
+
</BreadcrumbItem>
|
|
87
|
+
<BreadcrumbSeparator />
|
|
88
|
+
<BreadcrumbItem>
|
|
89
|
+
<BreadcrumbPage>运营后台</BreadcrumbPage>
|
|
90
|
+
</BreadcrumbItem>
|
|
91
|
+
</BreadcrumbList>
|
|
92
|
+
</Breadcrumb>
|
|
93
|
+
|
|
94
|
+
// 自定义 Separator
|
|
95
|
+
<BreadcrumbSeparator>/</BreadcrumbSeparator>
|
|
96
|
+
|
|
97
|
+
// 长路径折叠
|
|
98
|
+
<Breadcrumb>
|
|
99
|
+
<BreadcrumbList>
|
|
100
|
+
<BreadcrumbItem><BreadcrumbLink href="/">首页</BreadcrumbLink></BreadcrumbItem>
|
|
101
|
+
<BreadcrumbSeparator />
|
|
102
|
+
<BreadcrumbItem><BreadcrumbEllipsis /></BreadcrumbItem>
|
|
103
|
+
<BreadcrumbSeparator />
|
|
104
|
+
<BreadcrumbItem><BreadcrumbPage>当前页</BreadcrumbPage></BreadcrumbItem>
|
|
105
|
+
</BreadcrumbList>
|
|
106
|
+
</Breadcrumb>
|
|
107
|
+
```
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { Slash } from 'lucide-react';
|
|
3
|
+
import {
|
|
4
|
+
Breadcrumb,
|
|
5
|
+
BreadcrumbList,
|
|
6
|
+
BreadcrumbItem,
|
|
7
|
+
BreadcrumbLink,
|
|
8
|
+
BreadcrumbPage,
|
|
9
|
+
BreadcrumbSeparator,
|
|
10
|
+
BreadcrumbEllipsis,
|
|
11
|
+
} from './breadcrumb';
|
|
12
|
+
|
|
13
|
+
const meta: Meta<typeof Breadcrumb> = {
|
|
14
|
+
title: '导航 · Navigation/Breadcrumb',
|
|
15
|
+
component: Breadcrumb,
|
|
16
|
+
tags: ['autodocs'],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export default meta;
|
|
20
|
+
type Story = StoryObj<typeof Breadcrumb>;
|
|
21
|
+
|
|
22
|
+
export const Default: Story = {
|
|
23
|
+
render: () => (
|
|
24
|
+
<Breadcrumb>
|
|
25
|
+
<BreadcrumbList>
|
|
26
|
+
<BreadcrumbItem>
|
|
27
|
+
<BreadcrumbLink href="/">首页</BreadcrumbLink>
|
|
28
|
+
</BreadcrumbItem>
|
|
29
|
+
<BreadcrumbSeparator />
|
|
30
|
+
<BreadcrumbItem>
|
|
31
|
+
<BreadcrumbLink href="/projects">项目</BreadcrumbLink>
|
|
32
|
+
</BreadcrumbItem>
|
|
33
|
+
<BreadcrumbSeparator />
|
|
34
|
+
<BreadcrumbItem>
|
|
35
|
+
<BreadcrumbPage>运营后台</BreadcrumbPage>
|
|
36
|
+
</BreadcrumbItem>
|
|
37
|
+
</BreadcrumbList>
|
|
38
|
+
</Breadcrumb>
|
|
39
|
+
),
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const CustomSeparator: Story = {
|
|
43
|
+
parameters: { controls: { disable: true } },
|
|
44
|
+
render: () => (
|
|
45
|
+
<Breadcrumb>
|
|
46
|
+
<BreadcrumbList>
|
|
47
|
+
<BreadcrumbItem>
|
|
48
|
+
<BreadcrumbLink href="/">首页</BreadcrumbLink>
|
|
49
|
+
</BreadcrumbItem>
|
|
50
|
+
<BreadcrumbSeparator>
|
|
51
|
+
<Slash />
|
|
52
|
+
</BreadcrumbSeparator>
|
|
53
|
+
<BreadcrumbItem>
|
|
54
|
+
<BreadcrumbPage>当前页</BreadcrumbPage>
|
|
55
|
+
</BreadcrumbItem>
|
|
56
|
+
</BreadcrumbList>
|
|
57
|
+
</Breadcrumb>
|
|
58
|
+
),
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export const Ellipsis: Story = {
|
|
62
|
+
parameters: { controls: { disable: true } },
|
|
63
|
+
render: () => (
|
|
64
|
+
<Breadcrumb>
|
|
65
|
+
<BreadcrumbList>
|
|
66
|
+
<BreadcrumbItem>
|
|
67
|
+
<BreadcrumbLink href="/">首页</BreadcrumbLink>
|
|
68
|
+
</BreadcrumbItem>
|
|
69
|
+
<BreadcrumbSeparator />
|
|
70
|
+
<BreadcrumbItem>
|
|
71
|
+
<BreadcrumbEllipsis />
|
|
72
|
+
</BreadcrumbItem>
|
|
73
|
+
<BreadcrumbSeparator />
|
|
74
|
+
<BreadcrumbItem>
|
|
75
|
+
<BreadcrumbLink href="/services">服务</BreadcrumbLink>
|
|
76
|
+
</BreadcrumbItem>
|
|
77
|
+
<BreadcrumbSeparator />
|
|
78
|
+
<BreadcrumbItem>
|
|
79
|
+
<BreadcrumbPage>详情</BreadcrumbPage>
|
|
80
|
+
</BreadcrumbItem>
|
|
81
|
+
</BreadcrumbList>
|
|
82
|
+
</Breadcrumb>
|
|
83
|
+
),
|
|
84
|
+
};
|