agentic-ds-kit 0.1.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/AGENTS.md +10 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +21 -0
- package/README.md +38 -0
- package/contracts/accordion.json +38 -0
- package/contracts/alert.json +57 -0
- package/contracts/alertdialog.json +89 -0
- package/contracts/appheader.json +140 -0
- package/contracts/appnav.json +72 -0
- package/contracts/avatar.json +63 -0
- package/contracts/avatargroup.json +83 -0
- package/contracts/badge.json +92 -0
- package/contracts/barchart.json +55 -0
- package/contracts/breadcrumb.json +76 -0
- package/contracts/button.json +120 -0
- package/contracts/buttongroup.json +48 -0
- package/contracts/calendar.json +93 -0
- package/contracts/card.json +123 -0
- package/contracts/carousel.json +98 -0
- package/contracts/cell.json +203 -0
- package/contracts/chat.json +131 -0
- package/contracts/checkbox.json +101 -0
- package/contracts/collapsible.json +66 -0
- package/contracts/command.json +84 -0
- package/contracts/datatable.json +126 -0
- package/contracts/datepicker.json +102 -0
- package/contracts/drawer.json +93 -0
- package/contracts/dropdownmenu.json +190 -0
- package/contracts/empty.json +79 -0
- package/contracts/field.json +49 -0
- package/contracts/fieldset.json +29 -0
- package/contracts/headercell.json +107 -0
- package/contracts/index.json +478 -0
- package/contracts/input.json +119 -0
- package/contracts/inputotp.json +119 -0
- package/contracts/insightcard.json +130 -0
- package/contracts/linechart.json +51 -0
- package/contracts/loadinganimation.json +33 -0
- package/contracts/modal.json +100 -0
- package/contracts/modalcard.json +88 -0
- package/contracts/navigationmenu.json +65 -0
- package/contracts/numbertransition.json +33 -0
- package/contracts/pageheader.json +101 -0
- package/contracts/pagination.json +85 -0
- package/contracts/patterns/activity.json +30 -0
- package/contracts/patterns/assistant-workspace.json +16 -0
- package/contracts/patterns/dashboard.json +12 -0
- package/contracts/patterns/empty-first-run.json +15 -0
- package/contracts/patterns/inbox.json +32 -0
- package/contracts/patterns/invite-members.json +14 -0
- package/contracts/patterns/list-detail.json +13 -0
- package/contracts/patterns/settings-form.json +13 -0
- package/contracts/piechart.json +68 -0
- package/contracts/progress.json +124 -0
- package/contracts/progresssteps.json +91 -0
- package/contracts/radiogroup.json +132 -0
- package/contracts/scoreboard.json +46 -0
- package/contracts/scorecard.json +124 -0
- package/contracts/section.json +97 -0
- package/contracts/select.json +130 -0
- package/contracts/shimmertext.json +33 -0
- package/contracts/sidenav.json +133 -0
- package/contracts/slider.json +81 -0
- package/contracts/spinner.json +52 -0
- package/contracts/switch.json +94 -0
- package/contracts/table.json +92 -0
- package/contracts/tabs.json +90 -0
- package/contracts/textarea.json +54 -0
- package/contracts/thinkinganimation.json +32 -0
- package/contracts/timeline.json +49 -0
- package/contracts/toast.json +104 -0
- package/contracts/tooltip.json +66 -0
- package/lib/tokens.css +637 -0
- package/package.json +60 -0
- package/skills/prototype-from-kit/SKILL.md +29 -0
- package/src/index.ts +71 -0
- package/tokens/tokens.json +725 -0
- package/ui/Accordion/Accordion.module.css +68 -0
- package/ui/Accordion/Accordion.tsx +51 -0
- package/ui/Accordion/Accordion.types.ts +10 -0
- package/ui/Accordion/index.ts +2 -0
- package/ui/Alert/Alert.module.css +62 -0
- package/ui/Alert/Alert.tsx +27 -0
- package/ui/Alert/Alert.types.ts +7 -0
- package/ui/Alert/index.ts +2 -0
- package/ui/AlertDialog/AlertDialog.module.css +71 -0
- package/ui/AlertDialog/AlertDialog.tsx +109 -0
- package/ui/AlertDialog/AlertDialog.types.ts +14 -0
- package/ui/AlertDialog/index.ts +6 -0
- package/ui/AppHeader/AppHeader.module.css +120 -0
- package/ui/AppHeader/AppHeader.tsx +70 -0
- package/ui/AppHeader/AppHeader.types.ts +28 -0
- package/ui/AppHeader/index.ts +2 -0
- package/ui/AppNav/AppNav.module.css +168 -0
- package/ui/AppNav/AppNav.tsx +137 -0
- package/ui/AppNav/AppNav.types.ts +24 -0
- package/ui/AppNav/index.ts +2 -0
- package/ui/Avatar/Avatar.module.css +52 -0
- package/ui/Avatar/Avatar.tsx +62 -0
- package/ui/Avatar/Avatar.types.ts +8 -0
- package/ui/Avatar/index.ts +2 -0
- package/ui/AvatarGroup/AvatarGroup.module.css +49 -0
- package/ui/AvatarGroup/AvatarGroup.tsx +29 -0
- package/ui/AvatarGroup/AvatarGroup.types.ts +16 -0
- package/ui/AvatarGroup/index.ts +2 -0
- package/ui/Badge/Badge.module.css +92 -0
- package/ui/Badge/Badge.tsx +43 -0
- package/ui/Badge/Badge.types.ts +11 -0
- package/ui/Badge/index.ts +2 -0
- package/ui/BarChart/BarChart.module.css +56 -0
- package/ui/BarChart/BarChart.tsx +380 -0
- package/ui/BarChart/BarChart.types.ts +18 -0
- package/ui/BarChart/index.ts +2 -0
- package/ui/Breadcrumb/Breadcrumb.module.css +64 -0
- package/ui/Breadcrumb/Breadcrumb.tsx +89 -0
- package/ui/Breadcrumb/Breadcrumb.types.ts +14 -0
- package/ui/Breadcrumb/index.ts +2 -0
- package/ui/Button/Button.module.css +101 -0
- package/ui/Button/Button.tsx +49 -0
- package/ui/Button/Button.types.ts +18 -0
- package/ui/Button/index.ts +2 -0
- package/ui/Button/lucideName.tsx +188 -0
- package/ui/ButtonGroup/ButtonGroup.module.css +31 -0
- package/ui/ButtonGroup/ButtonGroup.tsx +12 -0
- package/ui/ButtonGroup/ButtonGroup.types.ts +6 -0
- package/ui/ButtonGroup/index.ts +2 -0
- package/ui/Calendar/Calendar.module.css +146 -0
- package/ui/Calendar/Calendar.tsx +296 -0
- package/ui/Calendar/Calendar.types.ts +11 -0
- package/ui/Calendar/index.ts +2 -0
- package/ui/Card/Card.module.css +95 -0
- package/ui/Card/Card.tsx +69 -0
- package/ui/Card/Card.types.ts +23 -0
- package/ui/Card/index.ts +2 -0
- package/ui/Carousel/Carousel.module.css +114 -0
- package/ui/Carousel/Carousel.tsx +152 -0
- package/ui/Carousel/Carousel.types.ts +17 -0
- package/ui/Carousel/index.ts +7 -0
- package/ui/Cell/Cell.module.css +133 -0
- package/ui/Cell/Cell.tsx +300 -0
- package/ui/Cell/Cell.types.ts +69 -0
- package/ui/Cell/index.ts +11 -0
- package/ui/Chat/Chat.module.css +149 -0
- package/ui/Chat/Chat.tsx +175 -0
- package/ui/Chat/Chat.types.ts +39 -0
- package/ui/Chat/index.ts +2 -0
- package/ui/Checkbox/Checkbox.module.css +135 -0
- package/ui/Checkbox/Checkbox.tsx +70 -0
- package/ui/Checkbox/Checkbox.types.ts +15 -0
- package/ui/Checkbox/index.ts +2 -0
- package/ui/Collapsible/Collapsible.module.css +68 -0
- package/ui/Collapsible/Collapsible.tsx +59 -0
- package/ui/Collapsible/Collapsible.types.ts +9 -0
- package/ui/Collapsible/index.ts +2 -0
- package/ui/Command/Command.module.css +138 -0
- package/ui/Command/Command.tsx +152 -0
- package/ui/Command/Command.types.ts +20 -0
- package/ui/Command/index.ts +2 -0
- package/ui/DataTable/DataTable.module.css +211 -0
- package/ui/DataTable/DataTable.tsx +429 -0
- package/ui/DataTable/DataTable.types.ts +35 -0
- package/ui/DataTable/index.ts +8 -0
- package/ui/DatePicker/DatePicker.module.css +44 -0
- package/ui/DatePicker/DatePicker.tsx +123 -0
- package/ui/DatePicker/DatePicker.types.ts +15 -0
- package/ui/DatePicker/index.ts +2 -0
- package/ui/Drawer/Drawer.module.css +204 -0
- package/ui/Drawer/Drawer.tsx +112 -0
- package/ui/Drawer/Drawer.types.ts +14 -0
- package/ui/Drawer/index.ts +2 -0
- package/ui/DropdownMenu/DropdownMenu.module.css +319 -0
- package/ui/DropdownMenu/DropdownMenu.tsx +580 -0
- package/ui/DropdownMenu/DropdownMenu.types.ts +48 -0
- package/ui/DropdownMenu/index.ts +8 -0
- package/ui/Empty/Empty.module.css +68 -0
- package/ui/Empty/Empty.tsx +35 -0
- package/ui/Empty/Empty.types.ts +10 -0
- package/ui/Empty/index.ts +2 -0
- package/ui/Field/Field.module.css +66 -0
- package/ui/Field/Field.tsx +46 -0
- package/ui/Field/Field.types.ts +12 -0
- package/ui/Field/index.ts +2 -0
- package/ui/FieldSet/FieldSet.module.css +30 -0
- package/ui/FieldSet/FieldSet.tsx +14 -0
- package/ui/FieldSet/FieldSet.types.ts +7 -0
- package/ui/FieldSet/index.ts +2 -0
- package/ui/HeaderCell/HeaderCell.module.css +85 -0
- package/ui/HeaderCell/HeaderCell.tsx +71 -0
- package/ui/HeaderCell/HeaderCell.types.ts +18 -0
- package/ui/HeaderCell/index.ts +2 -0
- package/ui/Input/Input.module.css +59 -0
- package/ui/Input/Input.tsx +65 -0
- package/ui/Input/Input.types.ts +22 -0
- package/ui/Input/index.ts +2 -0
- package/ui/InputOTP/InputOTP.module.css +139 -0
- package/ui/InputOTP/InputOTP.tsx +136 -0
- package/ui/InputOTP/InputOTP.types.ts +19 -0
- package/ui/InputOTP/index.ts +2 -0
- package/ui/InsightCard/InsightCard.module.css +166 -0
- package/ui/InsightCard/InsightCard.tsx +90 -0
- package/ui/InsightCard/InsightCard.types.ts +20 -0
- package/ui/InsightCard/index.ts +7 -0
- package/ui/LineChart/LineChart.module.css +93 -0
- package/ui/LineChart/LineChart.tsx +424 -0
- package/ui/LineChart/LineChart.types.ts +19 -0
- package/ui/LineChart/index.ts +2 -0
- package/ui/LoadingAnimation/LoadingAnimation.module.css +66 -0
- package/ui/LoadingAnimation/LoadingAnimation.tsx +41 -0
- package/ui/LoadingAnimation/LoadingAnimation.types.ts +9 -0
- package/ui/LoadingAnimation/index.ts +6 -0
- package/ui/Modal/Modal.module.css +48 -0
- package/ui/Modal/Modal.tsx +114 -0
- package/ui/Modal/Modal.types.ts +15 -0
- package/ui/Modal/index.ts +2 -0
- package/ui/ModalCard/ModalCard.module.css +137 -0
- package/ui/ModalCard/ModalCard.tsx +58 -0
- package/ui/ModalCard/ModalCard.types.ts +15 -0
- package/ui/ModalCard/index.ts +2 -0
- package/ui/NavigationMenu/NavigationMenu.module.css +31 -0
- package/ui/NavigationMenu/NavigationMenu.tsx +57 -0
- package/ui/NavigationMenu/NavigationMenu.types.ts +22 -0
- package/ui/NavigationMenu/index.ts +7 -0
- package/ui/NumberTransition/NumberTransition.module.css +110 -0
- package/ui/NumberTransition/NumberTransition.tsx +78 -0
- package/ui/NumberTransition/NumberTransition.types.ts +9 -0
- package/ui/NumberTransition/index.ts +2 -0
- package/ui/PageHeader/PageHeader.module.css +57 -0
- package/ui/PageHeader/PageHeader.tsx +39 -0
- package/ui/PageHeader/PageHeader.types.ts +12 -0
- package/ui/PageHeader/index.ts +2 -0
- package/ui/Pagination/Pagination.module.css +19 -0
- package/ui/Pagination/Pagination.tsx +147 -0
- package/ui/Pagination/Pagination.types.ts +12 -0
- package/ui/Pagination/index.ts +2 -0
- package/ui/PieChart/PieChart.module.css +116 -0
- package/ui/PieChart/PieChart.tsx +293 -0
- package/ui/PieChart/PieChart.types.ts +22 -0
- package/ui/PieChart/index.ts +2 -0
- package/ui/Progress/Progress.module.css +226 -0
- package/ui/Progress/Progress.tsx +167 -0
- package/ui/Progress/Progress.types.ts +15 -0
- package/ui/Progress/index.ts +8 -0
- package/ui/ProgressSteps/ProgressSteps.module.css +210 -0
- package/ui/ProgressSteps/ProgressSteps.tsx +105 -0
- package/ui/ProgressSteps/ProgressSteps.types.ts +19 -0
- package/ui/ProgressSteps/index.ts +8 -0
- package/ui/RadioGroup/RadioGroup.module.css +284 -0
- package/ui/RadioGroup/RadioGroup.tsx +116 -0
- package/ui/RadioGroup/RadioGroup.types.ts +30 -0
- package/ui/RadioGroup/index.ts +8 -0
- package/ui/Scoreboard/Scoreboard.module.css +53 -0
- package/ui/Scoreboard/Scoreboard.tsx +41 -0
- package/ui/Scoreboard/Scoreboard.types.ts +7 -0
- package/ui/Scoreboard/index.ts +2 -0
- package/ui/Scorecard/Scorecard.module.css +150 -0
- package/ui/Scorecard/Scorecard.tsx +92 -0
- package/ui/Scorecard/Scorecard.types.ts +18 -0
- package/ui/Scorecard/index.ts +2 -0
- package/ui/Section/Section.module.css +104 -0
- package/ui/Section/Section.tsx +75 -0
- package/ui/Section/Section.types.ts +15 -0
- package/ui/Section/index.ts +2 -0
- package/ui/Select/Select.module.css +7 -0
- package/ui/Select/Select.tsx +113 -0
- package/ui/Select/Select.types.ts +26 -0
- package/ui/Select/index.ts +2 -0
- package/ui/ShimmerText/ShimmerText.module.css +46 -0
- package/ui/ShimmerText/ShimmerText.tsx +48 -0
- package/ui/ShimmerText/ShimmerText.types.ts +12 -0
- package/ui/ShimmerText/index.ts +2 -0
- package/ui/SideNav/SideNav.module.css +347 -0
- package/ui/SideNav/SideNav.tsx +222 -0
- package/ui/SideNav/SideNav.types.ts +42 -0
- package/ui/SideNav/index.ts +8 -0
- package/ui/Slider/Slider.module.css +105 -0
- package/ui/Slider/Slider.tsx +187 -0
- package/ui/Slider/Slider.types.ts +11 -0
- package/ui/Slider/index.ts +2 -0
- package/ui/Spinner/Spinner.module.css +58 -0
- package/ui/Spinner/Spinner.tsx +19 -0
- package/ui/Spinner/Spinner.types.ts +6 -0
- package/ui/Spinner/index.ts +2 -0
- package/ui/Switch/Switch.module.css +189 -0
- package/ui/Switch/Switch.tsx +65 -0
- package/ui/Switch/Switch.types.ts +12 -0
- package/ui/Switch/index.ts +2 -0
- package/ui/Table/Table.module.css +132 -0
- package/ui/Table/Table.tsx +108 -0
- package/ui/Table/Table.types.ts +26 -0
- package/ui/Table/index.ts +8 -0
- package/ui/Tabs/Tabs.module.css +162 -0
- package/ui/Tabs/Tabs.tsx +150 -0
- package/ui/Tabs/Tabs.types.ts +21 -0
- package/ui/Tabs/index.ts +2 -0
- package/ui/Textarea/Textarea.module.css +74 -0
- package/ui/Textarea/Textarea.tsx +38 -0
- package/ui/Textarea/Textarea.types.ts +14 -0
- package/ui/Textarea/index.ts +2 -0
- package/ui/ThinkingAnimation/ThinkingAnimation.module.css +75 -0
- package/ui/ThinkingAnimation/ThinkingAnimation.tsx +31 -0
- package/ui/ThinkingAnimation/ThinkingAnimation.types.ts +8 -0
- package/ui/ThinkingAnimation/index.ts +2 -0
- package/ui/Timeline/Timeline.module.css +99 -0
- package/ui/Timeline/Timeline.tsx +47 -0
- package/ui/Timeline/Timeline.types.ts +16 -0
- package/ui/Timeline/index.ts +2 -0
- package/ui/Toast/Toast.module.css +133 -0
- package/ui/Toast/Toast.tsx +89 -0
- package/ui/Toast/Toast.types.ts +17 -0
- package/ui/Toast/index.ts +2 -0
- package/ui/Tooltip/Tooltip.module.css +111 -0
- package/ui/Tooltip/Tooltip.tsx +101 -0
- package/ui/Tooltip/index.ts +2 -0
- package/ui/patterns/ActivityPattern/ActivityFeed.tsx +77 -0
- package/ui/patterns/ActivityPattern/ActivityPattern.tsx +120 -0
- package/ui/patterns/ActivityPattern/ActivityTasks.tsx +86 -0
- package/ui/patterns/ActivityPattern/TaskDrawer.module.css +39 -0
- package/ui/patterns/ActivityPattern/TaskDrawer.tsx +186 -0
- package/ui/patterns/ActivityPattern/index.ts +2 -0
- package/ui/patterns/AssistantWorkspacePattern/AssistantWorkspacePattern.module.css +16 -0
- package/ui/patterns/AssistantWorkspacePattern/AssistantWorkspacePattern.tsx +159 -0
- package/ui/patterns/AssistantWorkspacePattern/index.ts +2 -0
- package/ui/patterns/DashboardPattern/DashboardPattern.tsx +102 -0
- package/ui/patterns/DashboardPattern/index.ts +1 -0
- package/ui/patterns/DashboardPattern/patterns.module.css +6 -0
- package/ui/patterns/EmptyFirstRunPattern/EmptyFirstRunPattern.tsx +125 -0
- package/ui/patterns/EmptyFirstRunPattern/index.ts +2 -0
- package/ui/patterns/InboxPattern/InboxPattern.module.css +40 -0
- package/ui/patterns/InboxPattern/InboxPattern.tsx +192 -0
- package/ui/patterns/InboxPattern/InboxReplyDrawer.tsx +97 -0
- package/ui/patterns/InboxPattern/inbox-data.ts +101 -0
- package/ui/patterns/InboxPattern/index.ts +2 -0
- package/ui/patterns/InviteMembersPattern/InviteMembersPattern.tsx +148 -0
- package/ui/patterns/InviteMembersPattern/index.ts +2 -0
- package/ui/patterns/ListDetailPattern/ListDetailPattern.module.css +34 -0
- package/ui/patterns/ListDetailPattern/ListDetailPattern.tsx +145 -0
- package/ui/patterns/ListDetailPattern/index.ts +2 -0
- package/ui/patterns/SettingsFormPattern/SettingsFormPattern.module.css +12 -0
- package/ui/patterns/SettingsFormPattern/SettingsFormPattern.tsx +89 -0
- package/ui/patterns/SettingsFormPattern/index.ts +3 -0
- package/ui/shared/ChartFrame.module.css +295 -0
- package/ui/shared/ChartFrame.tsx +87 -0
- package/ui/shared/chartMath.ts +228 -0
- package/ui/shared/controls.module.css +48 -0
- package/ui/shared/useChartSize.ts +22 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
.nav {
|
|
2
|
+
width: 15rem;
|
|
3
|
+
flex-shrink: 0;
|
|
4
|
+
padding: var(--space-4);
|
|
5
|
+
background-color: var(--surface-card);
|
|
6
|
+
border: var(--border-width-thin) solid var(--border-faint);
|
|
7
|
+
border-radius: var(--radius-surface-md);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.title {
|
|
11
|
+
margin: 0 0 var(--space-4);
|
|
12
|
+
padding: 0 var(--space-2);
|
|
13
|
+
font-family: var(--font-sans);
|
|
14
|
+
font-size: var(--type-size-body-sm);
|
|
15
|
+
font-weight: var(--type-weight-heading);
|
|
16
|
+
color: var(--text-primary);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.groupList {
|
|
20
|
+
margin: 0;
|
|
21
|
+
padding: 0;
|
|
22
|
+
list-style: none;
|
|
23
|
+
display: flex;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
gap: var(--space-1);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.group {
|
|
29
|
+
display: flex;
|
|
30
|
+
flex-direction: column;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.groupToggle {
|
|
34
|
+
display: flex;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: space-between;
|
|
37
|
+
gap: var(--space-2);
|
|
38
|
+
width: 100%;
|
|
39
|
+
margin: 0;
|
|
40
|
+
padding: var(--space-2) var(--space-3);
|
|
41
|
+
border: 0;
|
|
42
|
+
border-radius: var(--radius-control-sm);
|
|
43
|
+
background: transparent;
|
|
44
|
+
color: var(--text-muted);
|
|
45
|
+
cursor: pointer;
|
|
46
|
+
text-align: left;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.groupToggle:hover,
|
|
50
|
+
.groupToggleOpen,
|
|
51
|
+
.groupToggleActive {
|
|
52
|
+
color: var(--text-primary);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.groupToggle:hover {
|
|
56
|
+
background: var(--surface-muted);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.groupToggle:focus-visible {
|
|
60
|
+
outline: var(--border-focus-width) solid var(--focus-ring);
|
|
61
|
+
outline-offset: var(--space-inset-2xs);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.groupLabel {
|
|
65
|
+
font-family: var(--font-sans);
|
|
66
|
+
font-size: var(--type-size-overline);
|
|
67
|
+
font-weight: var(--type-weight-overline);
|
|
68
|
+
letter-spacing: var(--type-tracking-overline);
|
|
69
|
+
text-transform: uppercase;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.chevron {
|
|
73
|
+
flex-shrink: 0;
|
|
74
|
+
color: var(--icon-muted);
|
|
75
|
+
transition: transform var(--motion-expand-duration) var(--motion-ease-out);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.chevronOpen {
|
|
79
|
+
transform: rotate(90deg);
|
|
80
|
+
color: var(--icon-default);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.accordion {
|
|
84
|
+
display: grid;
|
|
85
|
+
grid-template-rows: 0fr;
|
|
86
|
+
transition: grid-template-rows var(--motion-expand-duration) var(--motion-expand-easing);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.isOpen .accordion {
|
|
90
|
+
grid-template-rows: 1fr;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.accordionInner {
|
|
94
|
+
overflow: hidden;
|
|
95
|
+
min-height: 0;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@media (prefers-reduced-motion: reduce) {
|
|
99
|
+
.accordion,
|
|
100
|
+
.chevron {
|
|
101
|
+
transition: none;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.list {
|
|
106
|
+
margin: 0;
|
|
107
|
+
padding: 0;
|
|
108
|
+
list-style: none;
|
|
109
|
+
display: flex;
|
|
110
|
+
flex-direction: column;
|
|
111
|
+
gap: var(--space-1);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.item {
|
|
115
|
+
display: flex;
|
|
116
|
+
flex-direction: column;
|
|
117
|
+
gap: var(--space-1);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.subgroupLabel {
|
|
121
|
+
padding: var(--space-2) var(--space-3);
|
|
122
|
+
font-family: var(--font-sans);
|
|
123
|
+
font-size: var(--type-size-body-sm);
|
|
124
|
+
font-weight: var(--type-weight-body);
|
|
125
|
+
line-height: var(--type-line-body);
|
|
126
|
+
color: var(--text-primary);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.subList {
|
|
130
|
+
margin: 0;
|
|
131
|
+
padding: 0 0 0 var(--space-2);
|
|
132
|
+
list-style: none;
|
|
133
|
+
display: flex;
|
|
134
|
+
flex-direction: column;
|
|
135
|
+
gap: var(--space-1);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.link {
|
|
139
|
+
display: block;
|
|
140
|
+
padding: var(--space-2) var(--space-3);
|
|
141
|
+
font-family: var(--font-sans);
|
|
142
|
+
font-size: var(--type-size-body-sm);
|
|
143
|
+
font-weight: var(--type-weight-body);
|
|
144
|
+
line-height: var(--type-line-body);
|
|
145
|
+
color: var(--text-primary);
|
|
146
|
+
text-decoration: none;
|
|
147
|
+
border-radius: var(--radius-control-md);
|
|
148
|
+
transition: background-color var(--motion-fast) ease, color var(--motion-fast) ease;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
.linkNested {
|
|
152
|
+
padding-left: var(--space-4);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.link:hover {
|
|
156
|
+
background-color: var(--surface-muted);
|
|
157
|
+
color: var(--text-primary);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
.link:focus-visible {
|
|
161
|
+
outline: var(--border-focus-width) solid var(--focus-ring);
|
|
162
|
+
outline-offset: var(--space-inset-2xs);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
.active {
|
|
166
|
+
background-color: color-mix(in srgb, var(--action-primary) 10%, var(--surface-card));
|
|
167
|
+
color: var(--action-primary);
|
|
168
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import Link from "next/link";
|
|
5
|
+
import { ChevronRight } from "lucide-react";
|
|
6
|
+
import type { AppNavGroup, AppNavItem, AppNavLeaf, AppNavProps } from "./AppNav.types";
|
|
7
|
+
import styles from "./AppNav.module.css";
|
|
8
|
+
|
|
9
|
+
export type { AppNavProps, AppNavItem, AppNavLeaf, AppNavGroup } from "./AppNav.types";
|
|
10
|
+
|
|
11
|
+
function navKey(item: AppNavLeaf, index: number): string {
|
|
12
|
+
return `${item.href}::${item.label}::${index}`;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function groupHasActive(group: AppNavGroup): boolean {
|
|
16
|
+
return group.items.some((item) => item.active || item.items?.some((child) => child.active));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function NavLink({ href, label, active, nested }: AppNavLeaf & { nested?: boolean }) {
|
|
20
|
+
return (
|
|
21
|
+
<Link
|
|
22
|
+
href={href}
|
|
23
|
+
className={`${styles.link} ${nested ? styles.linkNested : ""} ${active ? styles.active : ""}`}
|
|
24
|
+
aria-current={active ? "page" : undefined}
|
|
25
|
+
onClick={(event) => {
|
|
26
|
+
const [path, fragment] = href.split("#");
|
|
27
|
+
if (!fragment) return;
|
|
28
|
+
const here = window.location.pathname;
|
|
29
|
+
if (path && path !== here) return;
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
window.location.hash = fragment;
|
|
32
|
+
window.dispatchEvent(new HashChangeEvent("hashchange"));
|
|
33
|
+
}}
|
|
34
|
+
>
|
|
35
|
+
{label}
|
|
36
|
+
</Link>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function NavItem({ item }: { item: AppNavItem }) {
|
|
41
|
+
if (item.items && item.items.length > 0) {
|
|
42
|
+
return (
|
|
43
|
+
<li className={styles.item}>
|
|
44
|
+
<span className={styles.subgroupLabel}>{item.label}</span>
|
|
45
|
+
<ul className={styles.subList}>
|
|
46
|
+
{item.items.map((child, index) => (
|
|
47
|
+
<li key={navKey(child, index)}>
|
|
48
|
+
<NavLink {...child} nested />
|
|
49
|
+
</li>
|
|
50
|
+
))}
|
|
51
|
+
</ul>
|
|
52
|
+
</li>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<li className={styles.item}>
|
|
58
|
+
<NavLink {...item} />
|
|
59
|
+
</li>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function NavGroup({
|
|
64
|
+
group,
|
|
65
|
+
open,
|
|
66
|
+
onToggle,
|
|
67
|
+
}: {
|
|
68
|
+
group: AppNavGroup;
|
|
69
|
+
open: boolean;
|
|
70
|
+
onToggle: () => void;
|
|
71
|
+
}) {
|
|
72
|
+
const groupId = `nav-group-${group.label.replace(/\s+/g, "-").toLowerCase()}`;
|
|
73
|
+
const hasActive = groupHasActive(group);
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<li className={`${styles.group} ${open ? styles.isOpen : ""}`}>
|
|
77
|
+
<button
|
|
78
|
+
type="button"
|
|
79
|
+
className={`${styles.groupToggle} ${open ? styles.groupToggleOpen : ""} ${hasActive ? styles.groupToggleActive : ""}`}
|
|
80
|
+
aria-expanded={open}
|
|
81
|
+
aria-controls={groupId}
|
|
82
|
+
onClick={onToggle}
|
|
83
|
+
>
|
|
84
|
+
<span className={styles.groupLabel}>{group.label}</span>
|
|
85
|
+
<ChevronRight className={`${styles.chevron} ${open ? styles.chevronOpen : ""}`} size={14} strokeWidth={2} aria-hidden />
|
|
86
|
+
</button>
|
|
87
|
+
<div className={styles.accordion} id={groupId} aria-hidden={!open} inert={open ? undefined : true}>
|
|
88
|
+
<div className={styles.accordionInner}>
|
|
89
|
+
<ul className={styles.list}>
|
|
90
|
+
{group.items.map((item, index) => (
|
|
91
|
+
<NavItem key={navKey(item, index)} item={item} />
|
|
92
|
+
))}
|
|
93
|
+
</ul>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
</li>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function AppNav({ title, items = [], groups }: AppNavProps) {
|
|
101
|
+
const useGroups = Boolean(groups && groups.length > 0);
|
|
102
|
+
const activeLabel = useGroups ? groups!.find(groupHasActive)?.label ?? null : null;
|
|
103
|
+
const fallbackLabel = useGroups
|
|
104
|
+
? groups!.find((group) => group.defaultOpen !== false)?.label ?? groups![0].label
|
|
105
|
+
: null;
|
|
106
|
+
const [openLabel, setOpenLabel] = useState<string | null>(activeLabel ?? fallbackLabel);
|
|
107
|
+
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (activeLabel) setOpenLabel(activeLabel);
|
|
110
|
+
}, [activeLabel]);
|
|
111
|
+
|
|
112
|
+
const resolvedOpen = openLabel ?? activeLabel ?? fallbackLabel;
|
|
113
|
+
|
|
114
|
+
return (
|
|
115
|
+
<nav className={styles.nav} aria-label="Application">
|
|
116
|
+
{title ? <p className={styles.title}>{title}</p> : null}
|
|
117
|
+
{useGroups ? (
|
|
118
|
+
<ul className={styles.groupList}>
|
|
119
|
+
{groups!.map((group) => (
|
|
120
|
+
<NavGroup
|
|
121
|
+
key={group.label}
|
|
122
|
+
group={group}
|
|
123
|
+
open={resolvedOpen === group.label}
|
|
124
|
+
onToggle={() => setOpenLabel((current) => (current === group.label ? null : group.label))}
|
|
125
|
+
/>
|
|
126
|
+
))}
|
|
127
|
+
</ul>
|
|
128
|
+
) : (
|
|
129
|
+
<ul className={styles.list}>
|
|
130
|
+
{items.map((item, index) => (
|
|
131
|
+
<NavItem key={navKey(item, index)} item={item} />
|
|
132
|
+
))}
|
|
133
|
+
</ul>
|
|
134
|
+
)}
|
|
135
|
+
</nav>
|
|
136
|
+
);
|
|
137
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export interface AppNavLeaf {
|
|
2
|
+
href: string;
|
|
3
|
+
label: string;
|
|
4
|
+
active?: boolean;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
/** A nav link, optionally with one nested subgroup of leaves. */
|
|
8
|
+
export interface AppNavItem extends AppNavLeaf {
|
|
9
|
+
items?: AppNavLeaf[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface AppNavGroup {
|
|
13
|
+
label: string;
|
|
14
|
+
defaultOpen?: boolean;
|
|
15
|
+
items: AppNavItem[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface AppNavProps {
|
|
19
|
+
title?: string;
|
|
20
|
+
/** Flat list for simple shells (e.g. list-detail). Ignored when `groups` is provided. */
|
|
21
|
+
items?: AppNavItem[];
|
|
22
|
+
/** Grouped catalog nav for docs/playground shells. Takes precedence over `items`. */
|
|
23
|
+
groups?: AppNavGroup[];
|
|
24
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
.avatar {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
justify-content: center;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
flex-shrink: 0;
|
|
7
|
+
align-self: center;
|
|
8
|
+
aspect-ratio: 1 / 1;
|
|
9
|
+
border-radius: var(--radius-pill);
|
|
10
|
+
font-family: var(--font-sans);
|
|
11
|
+
font-weight: var(--type-weight-heading);
|
|
12
|
+
line-height: 1;
|
|
13
|
+
user-select: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.fallback {
|
|
17
|
+
background: var(--surface-muted);
|
|
18
|
+
color: var(--text-primary);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.sm {
|
|
22
|
+
width: var(--space-8);
|
|
23
|
+
height: var(--space-8);
|
|
24
|
+
font-size: var(--type-size-caption);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.md {
|
|
28
|
+
width: var(--space-10);
|
|
29
|
+
height: var(--space-10);
|
|
30
|
+
font-size: var(--type-size-body-sm);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.lg {
|
|
34
|
+
width: var(--space-12);
|
|
35
|
+
height: var(--space-12);
|
|
36
|
+
font-size: var(--type-size-body);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.image {
|
|
40
|
+
display: block;
|
|
41
|
+
width: 100%;
|
|
42
|
+
height: 100%;
|
|
43
|
+
object-fit: cover;
|
|
44
|
+
object-position: center 20%;
|
|
45
|
+
aspect-ratio: 1 / 1;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.icon {
|
|
49
|
+
width: 50%;
|
|
50
|
+
height: 50%;
|
|
51
|
+
color: inherit;
|
|
52
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from "react";
|
|
4
|
+
import { User } from "lucide-react";
|
|
5
|
+
import type { AvatarProps } from "./Avatar.types";
|
|
6
|
+
import styles from "./Avatar.module.css";
|
|
7
|
+
|
|
8
|
+
export type { AvatarProps, AvatarSize } from "./Avatar.types";
|
|
9
|
+
|
|
10
|
+
function lettersOf(value: string): string {
|
|
11
|
+
return Array.from(value)
|
|
12
|
+
.filter((ch) => /\p{L}/u.test(ch))
|
|
13
|
+
.join("");
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function deriveInitials(name: string): string {
|
|
17
|
+
const words = name
|
|
18
|
+
.trim()
|
|
19
|
+
.split(/\s+/)
|
|
20
|
+
.map(lettersOf)
|
|
21
|
+
.filter(Boolean);
|
|
22
|
+
|
|
23
|
+
if (words.length === 0) return "";
|
|
24
|
+
if (words.length === 1) return words[0].slice(0, 2).toUpperCase();
|
|
25
|
+
|
|
26
|
+
const first = words[0][0];
|
|
27
|
+
const last = words[words.length - 1][0];
|
|
28
|
+
return `${first}${last}`.toUpperCase();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function resolveInitials(name: string, initials?: string): string {
|
|
32
|
+
if (initials !== undefined) {
|
|
33
|
+
const override = lettersOf(initials).slice(0, 2).toUpperCase();
|
|
34
|
+
if (override) return override;
|
|
35
|
+
}
|
|
36
|
+
return deriveInitials(name);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function Avatar({ name, src, initials, size = "md" }: AvatarProps) {
|
|
40
|
+
const [failed, setFailed] = useState(false);
|
|
41
|
+
|
|
42
|
+
useEffect(() => {
|
|
43
|
+
setFailed(false);
|
|
44
|
+
}, [src]);
|
|
45
|
+
|
|
46
|
+
const label = resolveInitials(name, initials);
|
|
47
|
+
const showImage = Boolean(src) && !failed;
|
|
48
|
+
|
|
49
|
+
if (showImage) {
|
|
50
|
+
return (
|
|
51
|
+
<span className={`${styles.avatar} ${styles[size]}`}>
|
|
52
|
+
<img className={styles.image} src={src} alt={name} onError={() => setFailed(true)} />
|
|
53
|
+
</span>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<span className={`${styles.avatar} ${styles[size]} ${styles.fallback}`} role="img" aria-label={name}>
|
|
59
|
+
{label ? label : <User className={styles.icon} aria-hidden />}
|
|
60
|
+
</span>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
.group {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.item {
|
|
7
|
+
display: inline-flex;
|
|
8
|
+
position: relative;
|
|
9
|
+
flex-shrink: 0;
|
|
10
|
+
border-radius: var(--radius-pill);
|
|
11
|
+
box-shadow: 0 0 0 var(--space-px) var(--surface-page);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.item:not(:first-child) {
|
|
15
|
+
margin-inline-start: calc(-1 * var(--space-2));
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.count {
|
|
19
|
+
display: inline-flex;
|
|
20
|
+
align-items: center;
|
|
21
|
+
justify-content: center;
|
|
22
|
+
overflow: hidden;
|
|
23
|
+
flex-shrink: 0;
|
|
24
|
+
border-radius: var(--radius-pill);
|
|
25
|
+
font-family: var(--font-sans);
|
|
26
|
+
font-weight: var(--type-weight-heading);
|
|
27
|
+
line-height: 1;
|
|
28
|
+
user-select: none;
|
|
29
|
+
background: var(--surface-muted);
|
|
30
|
+
color: var(--text-secondary);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.sm {
|
|
34
|
+
width: var(--space-8);
|
|
35
|
+
height: var(--space-8);
|
|
36
|
+
font-size: var(--type-size-caption);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.md {
|
|
40
|
+
width: var(--space-10);
|
|
41
|
+
height: var(--space-10);
|
|
42
|
+
font-size: var(--type-size-body-sm);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.lg {
|
|
46
|
+
width: var(--space-12);
|
|
47
|
+
height: var(--space-12);
|
|
48
|
+
font-size: var(--type-size-body);
|
|
49
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Avatar } from "../Avatar";
|
|
2
|
+
import type { AvatarGroupProps } from "./AvatarGroup.types";
|
|
3
|
+
import styles from "./AvatarGroup.module.css";
|
|
4
|
+
|
|
5
|
+
export type { AvatarGroupItem, AvatarGroupProps, AvatarGroupSize } from "./AvatarGroup.types";
|
|
6
|
+
|
|
7
|
+
export function AvatarGroup({ items, size = "md", max = 3, ariaLabel }: AvatarGroupProps) {
|
|
8
|
+
const visible = items.slice(0, max);
|
|
9
|
+
const leftover = items.length - max;
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
<div className={styles.group} role="group" aria-label={ariaLabel}>
|
|
13
|
+
{visible.map((item, index) => (
|
|
14
|
+
<span key={`${item.name}-${index}`} className={styles.item} style={{ zIndex: index + 1 }}>
|
|
15
|
+
<Avatar name={item.name} src={item.src} initials={item.initials} size={size} />
|
|
16
|
+
</span>
|
|
17
|
+
))}
|
|
18
|
+
{leftover > 0 ? (
|
|
19
|
+
<span
|
|
20
|
+
className={`${styles.item} ${styles.count} ${styles[size]}`}
|
|
21
|
+
style={{ zIndex: visible.length + 1 }}
|
|
22
|
+
aria-label={`${leftover} more`}
|
|
23
|
+
>
|
|
24
|
+
+{leftover}
|
|
25
|
+
</span>
|
|
26
|
+
) : null}
|
|
27
|
+
</div>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AvatarSize } from "../Avatar/Avatar.types";
|
|
2
|
+
|
|
3
|
+
export type AvatarGroupSize = AvatarSize;
|
|
4
|
+
|
|
5
|
+
export interface AvatarGroupItem {
|
|
6
|
+
name: string;
|
|
7
|
+
src?: string;
|
|
8
|
+
initials?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface AvatarGroupProps {
|
|
12
|
+
items: AvatarGroupItem[];
|
|
13
|
+
size?: AvatarGroupSize;
|
|
14
|
+
max?: number;
|
|
15
|
+
ariaLabel?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
.badge {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: var(--space-1);
|
|
5
|
+
border-radius: var(--radius-control-sm);
|
|
6
|
+
border: 1px solid transparent;
|
|
7
|
+
font-family: var(--font-sans);
|
|
8
|
+
font-weight: var(--type-weight-label);
|
|
9
|
+
white-space: nowrap;
|
|
10
|
+
line-height: 1.25;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.sm {
|
|
14
|
+
padding: var(--space-1) var(--space-2);
|
|
15
|
+
font-size: var(--type-size-caption);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.md {
|
|
19
|
+
padding: var(--space-1) var(--space-2);
|
|
20
|
+
font-size: var(--type-size-label);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.lg {
|
|
24
|
+
padding: var(--space-2) var(--space-3);
|
|
25
|
+
font-size: var(--type-size-body-sm);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.neutral {
|
|
29
|
+
background-color: var(--surface-muted);
|
|
30
|
+
color: var(--text-secondary);
|
|
31
|
+
border-color: var(--border-faint);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.brand {
|
|
35
|
+
background-color: color-mix(in srgb, var(--action-primary) 12%, var(--surface-card));
|
|
36
|
+
color: var(--action-primary);
|
|
37
|
+
border-color: color-mix(in srgb, var(--action-primary) 35%, var(--surface-card));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.success {
|
|
41
|
+
background-color: var(--status-success-subtle);
|
|
42
|
+
color: var(--status-success);
|
|
43
|
+
border-color: var(--status-success-border);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.warning {
|
|
47
|
+
background-color: var(--status-warning-subtle);
|
|
48
|
+
color: var(--status-warning);
|
|
49
|
+
border-color: var(--status-warning-border);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.danger {
|
|
53
|
+
background-color: var(--status-danger-subtle);
|
|
54
|
+
color: var(--status-danger);
|
|
55
|
+
border-color: var(--status-danger-border);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.info {
|
|
59
|
+
background-color: var(--status-info-subtle);
|
|
60
|
+
color: var(--status-info);
|
|
61
|
+
border-color: var(--status-info-border);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.disabled {
|
|
65
|
+
opacity: 0.5;
|
|
66
|
+
pointer-events: none;
|
|
67
|
+
cursor: not-allowed;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.remove {
|
|
71
|
+
display: inline-flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
margin: 0;
|
|
75
|
+
padding: 0;
|
|
76
|
+
border: 0;
|
|
77
|
+
border-radius: var(--radius-control-sm);
|
|
78
|
+
background: transparent;
|
|
79
|
+
color: inherit;
|
|
80
|
+
cursor: pointer;
|
|
81
|
+
line-height: 0;
|
|
82
|
+
flex-shrink: 0;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.remove:disabled {
|
|
86
|
+
cursor: not-allowed;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
.remove:focus-visible {
|
|
90
|
+
outline: var(--border-focus-width) solid var(--focus-ring);
|
|
91
|
+
outline-offset: var(--space-inset-2xs);
|
|
92
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { X } from "lucide-react";
|
|
4
|
+
import type { BadgeProps } from "./Badge.types";
|
|
5
|
+
import styles from "./Badge.module.css";
|
|
6
|
+
|
|
7
|
+
export type { BadgeProps, BadgeTone, BadgeSize } from "./Badge.types";
|
|
8
|
+
|
|
9
|
+
const ICON_SIZE = { sm: 12, md: 14, lg: 16 } as const;
|
|
10
|
+
|
|
11
|
+
export function Badge({
|
|
12
|
+
children,
|
|
13
|
+
tone = "neutral",
|
|
14
|
+
size = "md",
|
|
15
|
+
removable = false,
|
|
16
|
+
disabled = false,
|
|
17
|
+
onRemove,
|
|
18
|
+
}: BadgeProps) {
|
|
19
|
+
const iconPx = ICON_SIZE[size];
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
<span
|
|
23
|
+
className={`${styles.badge} ${styles[tone]} ${styles[size]}${disabled ? ` ${styles.disabled}` : ""}`}
|
|
24
|
+
aria-disabled={disabled || undefined}
|
|
25
|
+
>
|
|
26
|
+
{children}
|
|
27
|
+
{removable ? (
|
|
28
|
+
<button
|
|
29
|
+
type="button"
|
|
30
|
+
className={styles.remove}
|
|
31
|
+
aria-label={`Remove ${children}`}
|
|
32
|
+
disabled={disabled}
|
|
33
|
+
onClick={() => {
|
|
34
|
+
if (disabled) return;
|
|
35
|
+
onRemove?.();
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
<X size={iconPx} color="currentColor" aria-hidden />
|
|
39
|
+
</button>
|
|
40
|
+
) : null}
|
|
41
|
+
</span>
|
|
42
|
+
);
|
|
43
|
+
}
|