@helixds/react 0.0.0-stage → 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 +292 -0
- package/LICENSE +21 -0
- package/README.md +49 -2
- package/dist/components/Accordion/Accordion.d.ts +14 -0
- package/dist/components/Accordion/Accordion.doc.d.ts +4 -0
- package/dist/components/Accordion/Accordion.doc.js +27 -0
- package/dist/components/Accordion/Accordion.js +76 -0
- package/dist/components/Accordion/Accordion.types.d.ts +24 -0
- package/dist/components/Accordion/Accordion.types.js +2 -0
- package/dist/components/Accordion/index.d.ts +9 -0
- package/dist/components/Accordion/index.js +2 -0
- package/dist/components/Avatar/Avatar.d.ts +14 -0
- package/dist/components/Avatar/Avatar.doc.d.ts +4 -0
- package/dist/components/Avatar/Avatar.doc.js +34 -0
- package/dist/components/Avatar/Avatar.js +14 -0
- package/dist/components/Avatar/Avatar.types.d.ts +20 -0
- package/dist/components/Avatar/Avatar.types.js +2 -0
- package/dist/components/Avatar/index.d.ts +9 -0
- package/dist/components/Avatar/index.js +2 -0
- package/dist/components/AvatarGroup/AvatarGroup.d.ts +14 -0
- package/dist/components/AvatarGroup/AvatarGroup.doc.d.ts +4 -0
- package/dist/components/AvatarGroup/AvatarGroup.doc.js +30 -0
- package/dist/components/AvatarGroup/AvatarGroup.js +15 -0
- package/dist/components/AvatarGroup/AvatarGroup.types.d.ts +21 -0
- package/dist/components/AvatarGroup/AvatarGroup.types.js +2 -0
- package/dist/components/AvatarGroup/index.d.ts +9 -0
- package/dist/components/AvatarGroup/index.js +2 -0
- package/dist/components/Badge/Badge.d.ts +16 -0
- package/dist/components/Badge/Badge.doc.d.ts +4 -0
- package/dist/components/Badge/Badge.doc.js +69 -0
- package/dist/components/Badge/Badge.js +23 -0
- package/dist/components/Badge/Badge.types.d.ts +22 -0
- package/dist/components/Badge/Badge.types.js +2 -0
- package/dist/components/Badge/index.d.ts +9 -0
- package/dist/components/Badge/index.js +2 -0
- package/dist/components/Button/Button.d.ts +11 -0
- package/dist/components/Button/Button.doc.d.ts +4 -0
- package/dist/components/Button/Button.doc.js +98 -0
- package/dist/components/Button/Button.js +80 -0
- package/dist/components/Button/Button.types.d.ts +29 -0
- package/dist/components/Button/Button.types.js +2 -0
- package/dist/components/Button/index.d.ts +9 -0
- package/dist/components/Button/index.js +2 -0
- package/dist/components/Card/Card.d.ts +14 -0
- package/dist/components/Card/Card.doc.d.ts +4 -0
- package/dist/components/Card/Card.doc.js +44 -0
- package/dist/components/Card/Card.js +9 -0
- package/dist/components/Card/Card.types.d.ts +19 -0
- package/dist/components/Card/Card.types.js +2 -0
- package/dist/components/Card/index.d.ts +9 -0
- package/dist/components/Card/index.js +2 -0
- package/dist/components/Chart/Chart.d.ts +14 -0
- package/dist/components/Chart/Chart.doc.d.ts +4 -0
- package/dist/components/Chart/Chart.doc.js +49 -0
- package/dist/components/Chart/Chart.js +184 -0
- package/dist/components/Chart/Chart.types.d.ts +21 -0
- package/dist/components/Chart/Chart.types.js +2 -0
- package/dist/components/Chart/index.d.ts +9 -0
- package/dist/components/Chart/index.js +2 -0
- package/dist/components/Checkbox/Checkbox.d.ts +12 -0
- package/dist/components/Checkbox/Checkbox.doc.d.ts +4 -0
- package/dist/components/Checkbox/Checkbox.doc.js +54 -0
- package/dist/components/Checkbox/Checkbox.js +23 -0
- package/dist/components/Checkbox/Checkbox.types.d.ts +22 -0
- package/dist/components/Checkbox/Checkbox.types.js +2 -0
- package/dist/components/Checkbox/index.d.ts +9 -0
- package/dist/components/Checkbox/index.js +2 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.d.ts +13 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.doc.d.ts +4 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.doc.js +56 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.js +27 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.types.d.ts +28 -0
- package/dist/components/CheckboxGroup/CheckboxGroup.types.js +2 -0
- package/dist/components/CheckboxGroup/index.d.ts +9 -0
- package/dist/components/CheckboxGroup/index.js +2 -0
- package/dist/components/Chip/Chip.d.ts +11 -0
- package/dist/components/Chip/Chip.doc.d.ts +4 -0
- package/dist/components/Chip/Chip.doc.js +105 -0
- package/dist/components/Chip/Chip.js +30 -0
- package/dist/components/Chip/Chip.types.d.ts +31 -0
- package/dist/components/Chip/Chip.types.js +2 -0
- package/dist/components/Chip/index.d.ts +9 -0
- package/dist/components/Chip/index.js +2 -0
- package/dist/components/ChipGroup/ChipGroup.d.ts +12 -0
- package/dist/components/ChipGroup/ChipGroup.doc.d.ts +4 -0
- package/dist/components/ChipGroup/ChipGroup.doc.js +31 -0
- package/dist/components/ChipGroup/ChipGroup.js +9 -0
- package/dist/components/ChipGroup/ChipGroup.types.d.ts +27 -0
- package/dist/components/ChipGroup/ChipGroup.types.js +2 -0
- package/dist/components/ChipGroup/index.d.ts +9 -0
- package/dist/components/ChipGroup/index.js +2 -0
- package/dist/components/FAB/FAB.d.ts +11 -0
- package/dist/components/FAB/FAB.doc.d.ts +4 -0
- package/dist/components/FAB/FAB.doc.js +52 -0
- package/dist/components/FAB/FAB.js +133 -0
- package/dist/components/FAB/FAB.types.d.ts +37 -0
- package/dist/components/FAB/FAB.types.js +2 -0
- package/dist/components/FAB/index.d.ts +9 -0
- package/dist/components/FAB/index.js +2 -0
- package/dist/components/Icon/Icon.d.ts +14 -0
- package/dist/components/Icon/Icon.doc.d.ts +4 -0
- package/dist/components/Icon/Icon.doc.js +38 -0
- package/dist/components/Icon/Icon.js +15 -0
- package/dist/components/Icon/Icon.types.d.ts +47 -0
- package/dist/components/Icon/Icon.types.js +2 -0
- package/dist/components/Icon/createIconAdapter.d.ts +24 -0
- package/dist/components/Icon/createIconAdapter.js +28 -0
- package/dist/components/Icon/iconStroke.d.ts +20 -0
- package/dist/components/Icon/iconStroke.js +54 -0
- package/dist/components/Icon/index.d.ts +12 -0
- package/dist/components/Icon/index.js +4 -0
- package/dist/components/IconButton/IconButton.d.ts +11 -0
- package/dist/components/IconButton/IconButton.doc.d.ts +4 -0
- package/dist/components/IconButton/IconButton.doc.js +76 -0
- package/dist/components/IconButton/IconButton.js +20 -0
- package/dist/components/IconButton/IconButton.types.d.ts +25 -0
- package/dist/components/IconButton/IconButton.types.js +2 -0
- package/dist/components/IconButton/index.d.ts +9 -0
- package/dist/components/IconButton/index.js +2 -0
- package/dist/components/Input/Input.d.ts +11 -0
- package/dist/components/Input/Input.doc.d.ts +4 -0
- package/dist/components/Input/Input.doc.js +68 -0
- package/dist/components/Input/Input.js +48 -0
- package/dist/components/Input/Input.types.d.ts +36 -0
- package/dist/components/Input/Input.types.js +2 -0
- package/dist/components/Input/index.d.ts +9 -0
- package/dist/components/Input/index.js +2 -0
- package/dist/components/Menu/Menu.d.ts +14 -0
- package/dist/components/Menu/Menu.doc.d.ts +4 -0
- package/dist/components/Menu/Menu.doc.js +46 -0
- package/dist/components/Menu/Menu.js +105 -0
- package/dist/components/Menu/Menu.types.d.ts +34 -0
- package/dist/components/Menu/Menu.types.js +2 -0
- package/dist/components/Menu/index.d.ts +9 -0
- package/dist/components/Menu/index.js +2 -0
- package/dist/components/Modal/Modal.d.ts +14 -0
- package/dist/components/Modal/Modal.doc.d.ts +4 -0
- package/dist/components/Modal/Modal.doc.js +52 -0
- package/dist/components/Modal/Modal.js +30 -0
- package/dist/components/Modal/Modal.types.d.ts +36 -0
- package/dist/components/Modal/Modal.types.js +2 -0
- package/dist/components/Modal/index.d.ts +9 -0
- package/dist/components/Modal/index.js +2 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +17 -0
- package/dist/components/MultiSelect/MultiSelect.doc.d.ts +4 -0
- package/dist/components/MultiSelect/MultiSelect.doc.js +37 -0
- package/dist/components/MultiSelect/MultiSelect.js +165 -0
- package/dist/components/MultiSelect/MultiSelect.types.d.ts +50 -0
- package/dist/components/MultiSelect/MultiSelect.types.js +2 -0
- package/dist/components/MultiSelect/index.d.ts +9 -0
- package/dist/components/MultiSelect/index.js +2 -0
- package/dist/components/NavItem/NavItem.d.ts +14 -0
- package/dist/components/NavItem/NavItem.doc.d.ts +4 -0
- package/dist/components/NavItem/NavItem.doc.js +31 -0
- package/dist/components/NavItem/NavItem.js +21 -0
- package/dist/components/NavItem/NavItem.types.d.ts +20 -0
- package/dist/components/NavItem/NavItem.types.js +2 -0
- package/dist/components/NavItem/index.d.ts +9 -0
- package/dist/components/NavItem/index.js +2 -0
- package/dist/components/RadioButton/RadioButton.d.ts +14 -0
- package/dist/components/RadioButton/RadioButton.doc.d.ts +4 -0
- package/dist/components/RadioButton/RadioButton.doc.js +35 -0
- package/dist/components/RadioButton/RadioButton.js +15 -0
- package/dist/components/RadioButton/RadioButton.types.d.ts +33 -0
- package/dist/components/RadioButton/RadioButton.types.js +2 -0
- package/dist/components/RadioButton/index.d.ts +9 -0
- package/dist/components/RadioButton/index.js +2 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +12 -0
- package/dist/components/RadioGroup/RadioGroup.doc.d.ts +4 -0
- package/dist/components/RadioGroup/RadioGroup.doc.js +80 -0
- package/dist/components/RadioGroup/RadioGroup.js +19 -0
- package/dist/components/RadioGroup/RadioGroup.types.d.ts +28 -0
- package/dist/components/RadioGroup/RadioGroup.types.js +2 -0
- package/dist/components/RadioGroup/index.d.ts +9 -0
- package/dist/components/RadioGroup/index.js +2 -0
- package/dist/components/SegmentedControl/SegmentedControl.d.ts +13 -0
- package/dist/components/SegmentedControl/SegmentedControl.doc.d.ts +4 -0
- package/dist/components/SegmentedControl/SegmentedControl.doc.js +50 -0
- package/dist/components/SegmentedControl/SegmentedControl.js +64 -0
- package/dist/components/SegmentedControl/SegmentedControl.types.d.ts +26 -0
- package/dist/components/SegmentedControl/SegmentedControl.types.js +2 -0
- package/dist/components/SegmentedControl/index.d.ts +9 -0
- package/dist/components/SegmentedControl/index.js +2 -0
- package/dist/components/Select/Select.d.ts +13 -0
- package/dist/components/Select/Select.doc.d.ts +4 -0
- package/dist/components/Select/Select.doc.js +66 -0
- package/dist/components/Select/Select.js +138 -0
- package/dist/components/Select/Select.types.d.ts +36 -0
- package/dist/components/Select/Select.types.js +2 -0
- package/dist/components/Select/index.d.ts +9 -0
- package/dist/components/Select/index.js +2 -0
- package/dist/components/SidePanel/SidePanel.d.ts +14 -0
- package/dist/components/SidePanel/SidePanel.doc.d.ts +4 -0
- package/dist/components/SidePanel/SidePanel.doc.js +29 -0
- package/dist/components/SidePanel/SidePanel.js +19 -0
- package/dist/components/SidePanel/SidePanel.types.d.ts +28 -0
- package/dist/components/SidePanel/SidePanel.types.js +2 -0
- package/dist/components/SidePanel/index.d.ts +9 -0
- package/dist/components/SidePanel/index.js +2 -0
- package/dist/components/Switch/Switch.d.ts +13 -0
- package/dist/components/Switch/Switch.doc.d.ts +4 -0
- package/dist/components/Switch/Switch.doc.js +56 -0
- package/dist/components/Switch/Switch.js +45 -0
- package/dist/components/Switch/Switch.types.d.ts +21 -0
- package/dist/components/Switch/Switch.types.js +2 -0
- package/dist/components/Switch/index.d.ts +9 -0
- package/dist/components/Switch/index.js +2 -0
- package/dist/components/Table/Table.d.ts +34 -0
- package/dist/components/Table/Table.doc.d.ts +4 -0
- package/dist/components/Table/Table.doc.js +48 -0
- package/dist/components/Table/Table.js +17 -0
- package/dist/components/Table/Table.types.d.ts +30 -0
- package/dist/components/Table/Table.types.js +2 -0
- package/dist/components/Table/index.d.ts +9 -0
- package/dist/components/Table/index.js +2 -0
- package/dist/components/Textarea/Textarea.d.ts +9 -0
- package/dist/components/Textarea/Textarea.doc.d.ts +4 -0
- package/dist/components/Textarea/Textarea.doc.js +60 -0
- package/dist/components/Textarea/Textarea.js +24 -0
- package/dist/components/Textarea/Textarea.types.d.ts +22 -0
- package/dist/components/Textarea/Textarea.types.js +2 -0
- package/dist/components/Textarea/index.d.ts +9 -0
- package/dist/components/Textarea/index.js +2 -0
- package/dist/components/Toast/Toast.d.ts +16 -0
- package/dist/components/Toast/Toast.doc.d.ts +4 -0
- package/dist/components/Toast/Toast.doc.js +37 -0
- package/dist/components/Toast/Toast.js +134 -0
- package/dist/components/Toast/Toast.types.d.ts +11 -0
- package/dist/components/Toast/Toast.types.js +2 -0
- package/dist/components/Toast/index.d.ts +10 -0
- package/dist/components/Toast/index.js +2 -0
- package/dist/components/Toast/toastStore.d.ts +36 -0
- package/dist/components/Toast/toastStore.js +57 -0
- package/dist/components/Tooltip/Tooltip.d.ts +14 -0
- package/dist/components/Tooltip/Tooltip.doc.d.ts +4 -0
- package/dist/components/Tooltip/Tooltip.doc.js +33 -0
- package/dist/components/Tooltip/Tooltip.js +105 -0
- package/dist/components/Tooltip/Tooltip.types.d.ts +21 -0
- package/dist/components/Tooltip/Tooltip.types.js +2 -0
- package/dist/components/Tooltip/index.d.ts +9 -0
- package/dist/components/Tooltip/index.js +2 -0
- package/dist/contracts/Accordion.json +174 -0
- package/dist/contracts/AppShell.json +118 -0
- package/dist/contracts/Avatar.json +157 -0
- package/dist/contracts/AvatarGroup.json +169 -0
- package/dist/contracts/Badge.json +212 -0
- package/dist/contracts/Button.json +295 -0
- package/dist/contracts/Card.json +125 -0
- package/dist/contracts/Chart.json +167 -0
- package/dist/contracts/Checkbox.json +333 -0
- package/dist/contracts/CheckboxGroup.json +200 -0
- package/dist/contracts/Chip.json +320 -0
- package/dist/contracts/ChipGroup.json +182 -0
- package/dist/contracts/FAB.json +215 -0
- package/dist/contracts/Icon.json +306 -0
- package/dist/contracts/IconButton.json +213 -0
- package/dist/contracts/Input.json +400 -0
- package/dist/contracts/Menu.json +197 -0
- package/dist/contracts/Modal.json +192 -0
- package/dist/contracts/MultiSelect.json +244 -0
- package/dist/contracts/NavItem.json +148 -0
- package/dist/contracts/PageHeader.json +134 -0
- package/dist/contracts/RadioButton.json +202 -0
- package/dist/contracts/RadioGroup.json +228 -0
- package/dist/contracts/SegmentedControl.json +193 -0
- package/dist/contracts/Select.json +241 -0
- package/dist/contracts/SideNav.json +138 -0
- package/dist/contracts/SidePanel.json +153 -0
- package/dist/contracts/Switch.json +201 -0
- package/dist/contracts/Table.json +130 -0
- package/dist/contracts/Textarea.json +353 -0
- package/dist/contracts/Toast.json +186 -0
- package/dist/contracts/Tooltip.json +168 -0
- package/dist/contracts/TopBar.json +127 -0
- package/dist/contracts/manifest.json +675 -0
- package/dist/index.d.ts +109 -0
- package/dist/index.js +73 -0
- package/dist/layout/AppShell/AppShell.d.ts +14 -0
- package/dist/layout/AppShell/AppShell.doc.d.ts +4 -0
- package/dist/layout/AppShell/AppShell.doc.js +27 -0
- package/dist/layout/AppShell/AppShell.js +9 -0
- package/dist/layout/AppShell/AppShell.types.d.ts +18 -0
- package/dist/layout/AppShell/AppShell.types.js +2 -0
- package/dist/layout/AppShell/index.d.ts +9 -0
- package/dist/layout/AppShell/index.js +2 -0
- package/dist/layout/PageHeader/PageHeader.d.ts +14 -0
- package/dist/layout/PageHeader/PageHeader.doc.d.ts +4 -0
- package/dist/layout/PageHeader/PageHeader.doc.js +30 -0
- package/dist/layout/PageHeader/PageHeader.js +10 -0
- package/dist/layout/PageHeader/PageHeader.types.d.ts +21 -0
- package/dist/layout/PageHeader/PageHeader.types.js +2 -0
- package/dist/layout/PageHeader/index.d.ts +9 -0
- package/dist/layout/PageHeader/index.js +2 -0
- package/dist/layout/SideNav/SideNav.d.ts +14 -0
- package/dist/layout/SideNav/SideNav.doc.d.ts +4 -0
- package/dist/layout/SideNav/SideNav.doc.js +32 -0
- package/dist/layout/SideNav/SideNav.js +9 -0
- package/dist/layout/SideNav/SideNav.types.d.ts +18 -0
- package/dist/layout/SideNav/SideNav.types.js +2 -0
- package/dist/layout/SideNav/index.d.ts +9 -0
- package/dist/layout/SideNav/index.js +2 -0
- package/dist/layout/TopBar/TopBar.d.ts +14 -0
- package/dist/layout/TopBar/TopBar.doc.d.ts +4 -0
- package/dist/layout/TopBar/TopBar.doc.js +28 -0
- package/dist/layout/TopBar/TopBar.js +9 -0
- package/dist/layout/TopBar/TopBar.types.d.ts +16 -0
- package/dist/layout/TopBar/TopBar.types.js +2 -0
- package/dist/layout/TopBar/index.d.ts +9 -0
- package/dist/layout/TopBar/index.js +2 -0
- package/dist/lib/component-doc.d.ts +34 -0
- package/dist/lib/component-doc.js +2 -0
- package/dist/lib/motionPresets.d.ts +37 -0
- package/dist/lib/motionPresets.js +35 -0
- package/dist/lib/resolveTokenPx.d.ts +11 -0
- package/dist/lib/resolveTokenPx.js +17 -0
- package/dist/lib/useDialogTransition.d.ts +21 -0
- package/dist/lib/useDialogTransition.js +86 -0
- package/dist/lib/useDisclosureTransition.d.ts +19 -0
- package/dist/lib/useDisclosureTransition.js +41 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.js +6 -0
- package/dist/patterns/action-bar.md +127 -0
- package/dist/patterns/border-always.md +40 -0
- package/dist/patterns/data-analytics.md +15 -0
- package/dist/patterns/disabled-state.md +80 -0
- package/dist/patterns/empty-state.md +130 -0
- package/dist/patterns/expand-collapse-chevron.md +101 -0
- package/dist/patterns/form-field-group.md +139 -0
- package/dist/patterns/form-field-spacing.md +99 -0
- package/dist/patterns/group-spacing.md +54 -0
- package/dist/patterns/motion-effects.md +100 -0
- package/dist/patterns/same-row-sizing.md +52 -0
- package/dist/patterns/search-filter.md +118 -0
- package/dist/patterns/show-hide-parts.md +53 -0
- package/dist/patterns/stat-card.md +105 -0
- package/dist/patterns/status-row.md +130 -0
- package/dist/patterns/view-toggle.md +81 -0
- package/dist/prop-map.md +80 -0
- package/package.json +70 -3
- package/src/globals.css +3195 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: same-row-sizing
|
|
3
|
+
category: layout
|
|
4
|
+
components: [Button, IconButton, Input, Select]
|
|
5
|
+
when: "Placing two or more controls side by side on one line — a top bar, a filter row, a toolbar, an action bar."
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Pattern: Same-row sizing
|
|
9
|
+
|
|
10
|
+
**A rule, not a component.** Controls that sit next to each other on the same line share the same `size`
|
|
11
|
+
(ADR-004's control ladder: `s` → 24px, `m` → 32px, `l` → 40px), so their heights match.
|
|
12
|
+
|
|
13
|
+
## Why
|
|
14
|
+
|
|
15
|
+
A 24px search field next to 32px icon buttons reads as a mistake, not a hierarchy: the eye sees two
|
|
16
|
+
edges that almost line up but don't. Mixed heights in one row look unfinished even when every control is
|
|
17
|
+
correct on its own. The Team dashboard's top bar had exactly this: `Input size="s"` (24px) beside
|
|
18
|
+
`IconButton size="m"` (32px).
|
|
19
|
+
|
|
20
|
+
## Rule
|
|
21
|
+
|
|
22
|
+
- **Same row → same `size`.** Pick one size for the row and pass it to every control in it: `Input`,
|
|
23
|
+
`Select`, `Button`, `IconButton`.
|
|
24
|
+
- **Default to `m`** unless the whole row has a reason to be denser (`s`, e.g. a bulk-action bar inside a
|
|
25
|
+
table) or larger (`l`).
|
|
26
|
+
- **Applies wherever controls line up:** top bars, filter rows (search + selects + buttons), toolbars,
|
|
27
|
+
action bars, view toggles, a form's inline submit row.
|
|
28
|
+
- **Doesn't apply to** non-control content in the row: text, `Badge`, `Chip`, `Avatar`. Those follow
|
|
29
|
+
their own density model (see ADR-004's documented exceptions) and are vertically centered, not matched
|
|
30
|
+
in height.
|
|
31
|
+
- **`SegmentedControl` has no `size` prop.** It is always 24px (`semantic.size.s`), so put it in a
|
|
32
|
+
row of `s` controls, or accept the mismatch knowingly. Don't stretch it with `style`.
|
|
33
|
+
|
|
34
|
+
## Code
|
|
35
|
+
|
|
36
|
+
```tsx
|
|
37
|
+
<TopBar
|
|
38
|
+
start={<Input label="Search" hideLabel icon={IconSearch} placeholder="Search members…" size="m" />}
|
|
39
|
+
end={
|
|
40
|
+
<>
|
|
41
|
+
<IconButton variant="ghost" size="m" icon={IconBell} label="Notifications" />
|
|
42
|
+
<IconButton variant="ghost" size="m" icon={IconHelp} label="Help" />
|
|
43
|
+
</>
|
|
44
|
+
}
|
|
45
|
+
/>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Anti-patterns
|
|
49
|
+
|
|
50
|
+
- `Input size="s"` next to `IconButton size="m"`: 24px beside 32px.
|
|
51
|
+
- A `Select` at the default `m` next to a `Button size="s"` in the same filter row.
|
|
52
|
+
- Faking a match with a hardcoded `height` in `style` instead of choosing the same `size`.
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: search-filter
|
|
3
|
+
category: form
|
|
4
|
+
components: [Input, Button, Chip]
|
|
5
|
+
when: "Filtering a list or table with a search field + optional filter buttons."
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Pattern: Search + Filter
|
|
9
|
+
|
|
10
|
+
## When to use
|
|
11
|
+
|
|
12
|
+
- Tables/lists where the user needs to find items quickly
|
|
13
|
+
- Any collection with more than ~20 items
|
|
14
|
+
|
|
15
|
+
## Anatomy
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
┌────────────────────────────────────────────────────────────┐
|
|
19
|
+
│ 🔍 Search projects… [Clear] │
|
|
20
|
+
│ │
|
|
21
|
+
│ Active filters: [Status: Active ×] [Date: This week ×] │
|
|
22
|
+
└────────────────────────────────────────────────────────────┘
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Code
|
|
26
|
+
|
|
27
|
+
```tsx
|
|
28
|
+
import { useState } from 'react';
|
|
29
|
+
import { Input, Button, Chip } from '@helixds/react';
|
|
30
|
+
import { IconSearch } from '@tabler/icons-react';
|
|
31
|
+
// icon/iconEnd take the Tabler icon component by reference — never a pre-instantiated
|
|
32
|
+
// element like `icon={<IconSearch size={16} />}` — see root CLAUDE.md rule 2.
|
|
33
|
+
|
|
34
|
+
type ActiveFilter = { key: string; label: string };
|
|
35
|
+
|
|
36
|
+
function SearchFilter({
|
|
37
|
+
placeholder = 'Search…',
|
|
38
|
+
onSearch,
|
|
39
|
+
filters,
|
|
40
|
+
activeFilters,
|
|
41
|
+
onRemoveFilter,
|
|
42
|
+
onClearAll,
|
|
43
|
+
}: {
|
|
44
|
+
placeholder?: string;
|
|
45
|
+
onSearch: (query: string) => void;
|
|
46
|
+
filters?: React.ReactNode;
|
|
47
|
+
activeFilters?: ActiveFilter[];
|
|
48
|
+
onRemoveFilter?: (key: string) => void;
|
|
49
|
+
onClearAll?: () => void;
|
|
50
|
+
}) {
|
|
51
|
+
const [query, setQuery] = useState('');
|
|
52
|
+
const hasActive = (activeFilters?.length ?? 0) > 0;
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div
|
|
56
|
+
data-helix-pattern="search-filter"
|
|
57
|
+
style={{ display: 'flex', flexDirection: 'column', gap: 'var(--helix-primitive-spacing-75)' }}
|
|
58
|
+
>
|
|
59
|
+
{/* Search + filter controls — 4px (spacing-2xs) between the field and its buttons */}
|
|
60
|
+
<div style={{ display: 'flex', alignItems: 'center', gap: 'var(--helix-spacing-2xs)' }}>
|
|
61
|
+
<Input
|
|
62
|
+
label="Search"
|
|
63
|
+
hideLabel
|
|
64
|
+
icon={IconSearch}
|
|
65
|
+
placeholder={placeholder}
|
|
66
|
+
value={query}
|
|
67
|
+
onChange={e => { setQuery(e.target.value); onSearch(e.target.value); }}
|
|
68
|
+
fullWidth
|
|
69
|
+
/>
|
|
70
|
+
{filters}
|
|
71
|
+
{hasActive && (
|
|
72
|
+
<Button variant="secondary" onClick={onClearAll}>
|
|
73
|
+
Clear
|
|
74
|
+
</Button>
|
|
75
|
+
)}
|
|
76
|
+
</div>
|
|
77
|
+
|
|
78
|
+
{/* Active filter chips */}
|
|
79
|
+
{hasActive && (
|
|
80
|
+
<div
|
|
81
|
+
aria-label="Active filters"
|
|
82
|
+
style={{ display: 'flex', gap: 'var(--helix-spacing-2xs)', flexWrap: 'wrap' }}
|
|
83
|
+
>
|
|
84
|
+
{activeFilters?.map(f => (
|
|
85
|
+
<Chip
|
|
86
|
+
key={f.key}
|
|
87
|
+
variant="neutral"
|
|
88
|
+
size="s"
|
|
89
|
+
label={f.label}
|
|
90
|
+
dismissible
|
|
91
|
+
onDismiss={() => onRemoveFilter?.(f.key)}
|
|
92
|
+
/>
|
|
93
|
+
))}
|
|
94
|
+
</div>
|
|
95
|
+
)}
|
|
96
|
+
</div>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Rules
|
|
102
|
+
|
|
103
|
+
1. The search Input must have `label` (use `hideLabel` if visually hidden — still needed for a11y)
|
|
104
|
+
2. Active filter chips use the real `<Chip>` component (`dismissible`/`onDismiss`, default
|
|
105
|
+
look, `variant="neutral"`, smallest size `s` (24px)) — not
|
|
106
|
+
`<Badge>` (not interactive) and not a plain `<Button>` (Chip's whole `purpose` is "a compact selectable
|
|
107
|
+
label for filters, categories, or short choices" — this is precisely that case; an earlier version of
|
|
108
|
+
this doc predated Chip's existence and used Button instead, now corrected)
|
|
109
|
+
3. Clear all is a `variant="secondary"` Button with no icon, same size as the search field (same-row-sizing.md)
|
|
110
|
+
4. `aria-label="Active filters"` on the chip container is required for screen readers
|
|
111
|
+
|
|
112
|
+
## Anti-patterns
|
|
113
|
+
|
|
114
|
+
- ❌ Using `<Badge>` for active filter chips — they're not interactive; use `<Chip>`
|
|
115
|
+
- ❌ Using a plain `<Button>` for active filter chips — `<Chip>` already models `dismissible`
|
|
116
|
+
states with the right ARIA (`aria-pressed`, `aria-label="Dismiss {label}"`) for free
|
|
117
|
+
- ❌ Hiding the search label entirely with no `aria-label` fallback
|
|
118
|
+
- ❌ Triggering search on button click instead of `onChange` — users expect immediate filtering
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: show-hide-parts
|
|
3
|
+
category: foundation
|
|
4
|
+
components: [Chip, Button, Input, Badge, Select, NavItem]
|
|
5
|
+
when: "A component has an optional part that is either there or not — an icon, a trailing icon, a dismiss ×, a spinner, a description line."
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Pattern: Show/hide parts
|
|
9
|
+
|
|
10
|
+
**A rule for building components, in code and in Figma.** An optional part that only appears or disappears —
|
|
11
|
+
it doesn't change any color, size or state of the rest of the component — is a **boolean** in code and a
|
|
12
|
+
**BOOLEAN property** in Figma. Never a VARIANT.
|
|
13
|
+
|
|
14
|
+
## Why
|
|
15
|
+
|
|
16
|
+
Every VARIANT axis multiplies the Figma variant count. Chip with `dismissible` as a variant had 100 variants;
|
|
17
|
+
as a boolean it has 50. A boolean also maps 1:1 to the code prop, so designers and developers toggle the same
|
|
18
|
+
thing.
|
|
19
|
+
|
|
20
|
+
A Figma BOOLEAN can only show or hide a layer — it can't change a padding. So the rule only works if the
|
|
21
|
+
component is **built so that showing or hiding the part never changes any other spacing**.
|
|
22
|
+
|
|
23
|
+
## Rule
|
|
24
|
+
|
|
25
|
+
1. **The part brings its own spacing.** Whatever space it needs between itself and its neighbour lives on
|
|
26
|
+
the part itself (a padding on its own wrapper), not on the container. The container's paddings are the
|
|
27
|
+
same with or without it.
|
|
28
|
+
- Chip: `chip-icon` carries 2px on the label side, `chip-icon-end` and `chip-dismiss` too; the chip keeps
|
|
29
|
+
12px on both ends whether or not any of them is shown. Hiding one removes exactly its own width.
|
|
30
|
+
2. **Code mirrors Figma.** The part is rendered in the normal flow inside the container that holds the
|
|
31
|
+
paddings (no absolute positioning that needs the container to reserve room for it, no padding that
|
|
32
|
+
switches with the prop). If the part has a hover surface bigger than itself (the ×'s round hover), draw
|
|
33
|
+
it with a pseudo-element that takes no layout space.
|
|
34
|
+
3. **In Figma:** a BOOLEAN property bound to the part's visibility (`componentPropertyReferences.visible`),
|
|
35
|
+
named exactly like the code prop (`icon`, `iconEnd`, `dismissible`, `loading`…). An icon slot gets the
|
|
36
|
+
BOOLEAN plus an INSTANCE_SWAP (components-to-figma.md).
|
|
37
|
+
4. **When it can't be a boolean:** only if showing the part changes something else's color, size or state
|
|
38
|
+
(e.g. `loading` replacing the label and dimming the button) — then it's a VARIANT, and the contract's
|
|
39
|
+
`figma.properties` says why.
|
|
40
|
+
|
|
41
|
+
## Code stays implicit (decided 2026-10-03)
|
|
42
|
+
|
|
43
|
+
The boolean doesn't need its own prop in code. An icon slot is shown by passing `icon`; an optional text
|
|
44
|
+
part (`description`, `errorMessage`…) is shown by passing its text. Figma mirrors that with two properties
|
|
45
|
+
on the same layer: a BOOLEAN named exactly like the prop (`description`) for visibility and a TEXT
|
|
46
|
+
`description text` for the content — the same pairing as `icon` + `icon swap`. `.ai/maps/figma-map.md` marks
|
|
47
|
+
these rows as `BOOLEAN` + `TEXT`; a component whose Figma set lacks one of them is out of date.
|
|
48
|
+
|
|
49
|
+
## Checklist when building a component
|
|
50
|
+
|
|
51
|
+
- [ ] Every optional part is a boolean prop in code
|
|
52
|
+
- [ ] Toggling it doesn't change any padding or gap outside the part (measure both states)
|
|
53
|
+
- [ ] In Figma it's a BOOLEAN on the part's visibility, same name as the prop
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: stat-card
|
|
3
|
+
category: data-display
|
|
4
|
+
components: [Card, Badge]
|
|
5
|
+
when: "Showing a single labeled metric with an optional trend delta — a dashboard KPI, an analytics summary tile."
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Pattern: Stat Card
|
|
9
|
+
|
|
10
|
+
## When to use
|
|
11
|
+
|
|
12
|
+
- Dashboard KPI rows (Members, Revenue, Active users, ...)
|
|
13
|
+
- Analytics summary tiles
|
|
14
|
+
- Any "label + big number + optional up/down delta" widget
|
|
15
|
+
|
|
16
|
+
**This is a composition, not a component.** It used to be a standalone `StatCard` component; it was
|
|
17
|
+
folded back into a `Card` recipe because it has no anatomy, ARIA, or interaction of its own beyond what
|
|
18
|
+
`Card` already provides — it's `Card` plus a fixed internal text layout. There is nothing here that
|
|
19
|
+
justifies its own contract/tokens/export surface. Copy the code below into your own file rather than
|
|
20
|
+
expecting an import.
|
|
21
|
+
|
|
22
|
+
## Anatomy
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
┌───────────────────────┐
|
|
26
|
+
│ MEMBERS [↗ +14] │ ← delta Badge (xs) on the label's line, right-aligned
|
|
27
|
+
│ 103 │
|
|
28
|
+
└───────────────────────┘
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Code
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { Card, Badge } from '@helixds/react';
|
|
35
|
+
import { IconArrowUpRight, IconArrowDownRight } from '@tabler/icons-react';
|
|
36
|
+
|
|
37
|
+
type Trend = 'up' | 'down';
|
|
38
|
+
|
|
39
|
+
function StatCard({
|
|
40
|
+
label, value, delta, trend,
|
|
41
|
+
}: { label: string; value: string; delta?: string; trend?: Trend }) {
|
|
42
|
+
return (
|
|
43
|
+
<Card>
|
|
44
|
+
{/* Header row: label on the left, delta Badge on the right, both centered on the label's line */}
|
|
45
|
+
<div style={{
|
|
46
|
+
display: 'flex',
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
justifyContent: 'space-between',
|
|
49
|
+
gap: 'var(--helix-spacing-xs)',
|
|
50
|
+
marginBottom: 'var(--helix-spacing-xs)',
|
|
51
|
+
}}>
|
|
52
|
+
<div style={{
|
|
53
|
+
// semantic.textStyle.label-uppercase — its token description asks for text-transform +
|
|
54
|
+
// letter-spacing at the call site, so both come from here (letter-spacing from its token).
|
|
55
|
+
fontFamily: 'var(--helix-textStyle-label-uppercase-fontFamily)',
|
|
56
|
+
fontSize: 'var(--helix-textStyle-label-uppercase-fontSize)',
|
|
57
|
+
fontWeight: 'var(--helix-textStyle-label-uppercase-fontWeight)',
|
|
58
|
+
lineHeight: 'var(--helix-textStyle-label-uppercase-lineHeight)',
|
|
59
|
+
textTransform: 'uppercase',
|
|
60
|
+
letterSpacing: 'var(--helix-primitive-letterSpacing-wide)',
|
|
61
|
+
color: 'var(--helix-color-text-neutral-lightest)',
|
|
62
|
+
}}>
|
|
63
|
+
{label}
|
|
64
|
+
</div>
|
|
65
|
+
{delta && (
|
|
66
|
+
// The delta is a Badge: success when up, danger when down, neutral with no trend — its icon slot
|
|
67
|
+
// carries the trend arrow.
|
|
68
|
+
<Badge
|
|
69
|
+
variant={trend === 'up' ? 'success' : trend === 'down' ? 'danger' : 'neutral'}
|
|
70
|
+
size="xs"
|
|
71
|
+
label={delta}
|
|
72
|
+
{...(trend ? { icon: trend === 'up' ? IconArrowUpRight : IconArrowDownRight } : {})}
|
|
73
|
+
/>
|
|
74
|
+
)}
|
|
75
|
+
</div>
|
|
76
|
+
<div style={{
|
|
77
|
+
fontFamily: 'var(--helix-textStyle-heading-3xl-bold-fontFamily)',
|
|
78
|
+
fontSize: 'var(--helix-textStyle-heading-3xl-bold-fontSize)',
|
|
79
|
+
fontWeight: 'var(--helix-textStyle-heading-3xl-bold-fontWeight)',
|
|
80
|
+
lineHeight: 'var(--helix-textStyle-heading-3xl-bold-lineHeight)',
|
|
81
|
+
letterSpacing: 'var(--helix-primitive-letterSpacing-tight)',
|
|
82
|
+
color: 'var(--helix-color-text-neutral)',
|
|
83
|
+
fontVariantNumeric: 'tabular-nums',
|
|
84
|
+
}}>
|
|
85
|
+
{value}
|
|
86
|
+
</div>
|
|
87
|
+
</Card>
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Rules
|
|
93
|
+
|
|
94
|
+
1. `value` is a pre-formatted string from the consumer (`'103'`, `'89%'`) — this pattern never formats numbers itself
|
|
95
|
+
2. The delta is a `Badge`: `success` + up arrow when `trend="up"`, `danger` + down arrow when `trend="down"`.
|
|
96
|
+
Omit `trend` for a delta with no clear direction — a `neutral` Badge with no icon
|
|
97
|
+
3. Lay several of these out with a real CSS grid (`grid-template-columns: repeat(auto-fit, minmax(200px, 1fr))`), not `display: flex` with no basis — flex items without an explicit width just hug their own content, so cards end up different widths with no logic. See `apps/storybook/stories/Dashboard.stories.tsx`'s KPI row.
|
|
98
|
+
4. No shadow — Card is flat by design (see [ADR-005](../../docs/ADR/ADR-005-elevation-policy.md))
|
|
99
|
+
|
|
100
|
+
## Anti-patterns
|
|
101
|
+
|
|
102
|
+
- ❌ Reaching for a `StatCard` import — it doesn't exist; copy the code above
|
|
103
|
+
- ❌ Hardcoded px/hex values instead of the tokens shown above
|
|
104
|
+
- ❌ The delta as loose colored text + a separate Icon — it's a Badge, which already pairs color, icon and text
|
|
105
|
+
- ❌ A `box-shadow` on the card to make it "pop" — see ADR-005
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: status-row
|
|
3
|
+
category: data-display
|
|
4
|
+
components: [Badge]
|
|
5
|
+
when: "Displaying an item with its current status in a list, table row, or detail view."
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Pattern: Status Row
|
|
9
|
+
|
|
10
|
+
## When to use
|
|
11
|
+
|
|
12
|
+
- Table rows with a status column (active, inactive, pending)
|
|
13
|
+
- Detail view headers showing the current state of a record
|
|
14
|
+
- Notification/activity feed items
|
|
15
|
+
- Task list items with completion state
|
|
16
|
+
|
|
17
|
+
## Anatomy
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
┌─────────────────────────────────────────────────────────┐
|
|
21
|
+
│ ○ Deploy to production [Success] 2 min ago │
|
|
22
|
+
│ ○ Run test suite [Warning] 5 min ago │
|
|
23
|
+
│ ○ Build Docker image [Neutral] 12 min ago │
|
|
24
|
+
│ ○ Code review [Danger] 1 hr ago │
|
|
25
|
+
└─────────────────────────────────────────────────────────┘
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Badge variant → semantic meaning
|
|
29
|
+
|
|
30
|
+
| Variant | Use for |
|
|
31
|
+
|-----------|--------------------------------------------------|
|
|
32
|
+
| `success` | Completed, active, healthy, published, verified |
|
|
33
|
+
| `warning` | Pending, in review, needs attention, expiring |
|
|
34
|
+
| `danger` | Failed, blocked, overdue, expired, error |
|
|
35
|
+
| `info` | Scheduled, queued, in progress |
|
|
36
|
+
| `neutral` | Draft, inactive, archived, unknown |
|
|
37
|
+
|
|
38
|
+
**Rule: Never use color alone to communicate status.** The Badge label must also communicate the status.
|
|
39
|
+
|
|
40
|
+
## Code
|
|
41
|
+
|
|
42
|
+
```tsx
|
|
43
|
+
import { Badge } from '@helixds/react';
|
|
44
|
+
import type { BadgeVariant } from '@helixds/react';
|
|
45
|
+
|
|
46
|
+
type Status = 'active' | 'pending' | 'failed' | 'draft' | 'scheduled';
|
|
47
|
+
|
|
48
|
+
const statusConfig: Record<Status, { variant: BadgeVariant; label: string }> = {
|
|
49
|
+
active: { variant: 'success', label: 'Active' },
|
|
50
|
+
pending: { variant: 'warning', label: 'Pending' },
|
|
51
|
+
failed: { variant: 'danger', label: 'Failed' },
|
|
52
|
+
draft: { variant: 'neutral', label: 'Draft' },
|
|
53
|
+
scheduled: { variant: 'info', label: 'Scheduled' },
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// A list of rows that share columns, so every Badge lines up in one column, left-aligned. Each row is a
|
|
57
|
+
// subgrid of the list's three columns (label · status · meta); a per-row flex layout would instead
|
|
58
|
+
// start each Badge wherever that row's label happened to end.
|
|
59
|
+
function StatusList({ children }: { children: React.ReactNode }) {
|
|
60
|
+
return (
|
|
61
|
+
<div
|
|
62
|
+
data-helix-pattern="status-row-list"
|
|
63
|
+
style={{
|
|
64
|
+
display: 'grid',
|
|
65
|
+
gridTemplateColumns: '1fr auto auto',
|
|
66
|
+
columnGap: 'var(--helix-primitive-spacing-75)',
|
|
67
|
+
}}
|
|
68
|
+
>
|
|
69
|
+
{children}
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function StatusRow({ label, status, meta }: { label: string; status: Status; meta?: string }) {
|
|
75
|
+
const { variant, label: statusLabel } = statusConfig[status];
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<div
|
|
79
|
+
data-helix-pattern="status-row"
|
|
80
|
+
style={{
|
|
81
|
+
display: 'grid',
|
|
82
|
+
gridColumn: '1 / -1',
|
|
83
|
+
gridTemplateColumns: 'subgrid',
|
|
84
|
+
alignItems: 'center',
|
|
85
|
+
justifyItems: 'start',
|
|
86
|
+
padding: 'var(--helix-primitive-spacing-75) var(--helix-primitive-spacing-100)',
|
|
87
|
+
borderBottom: '1px solid var(--helix-color-border-neutral-light)',
|
|
88
|
+
}}
|
|
89
|
+
>
|
|
90
|
+
<span style={{
|
|
91
|
+
fontSize: 'var(--helix-primitive-fontSize-s)',
|
|
92
|
+
color: 'var(--helix-color-text-neutral)',
|
|
93
|
+
fontWeight: 'var(--helix-primitive-fontWeight-medium)',
|
|
94
|
+
}}>
|
|
95
|
+
{label}
|
|
96
|
+
</span>
|
|
97
|
+
|
|
98
|
+
<Badge variant={variant} label={statusLabel} />
|
|
99
|
+
|
|
100
|
+
<span style={{
|
|
101
|
+
justifySelf: 'end',
|
|
102
|
+
fontSize: 'var(--helix-primitive-fontSize-s)',
|
|
103
|
+
color: 'var(--helix-color-text-neutral-lightest)',
|
|
104
|
+
}}>
|
|
105
|
+
{meta}
|
|
106
|
+
</span>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// <StatusList>
|
|
112
|
+
// <StatusRow label="Deploy to production" status="active" meta="2 min ago" />
|
|
113
|
+
// <StatusRow label="Code review" status="failed" meta="1 hr ago" />
|
|
114
|
+
// </StatusList>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## Rules
|
|
118
|
+
|
|
119
|
+
1. Badge label must describe the status in words — not just color
|
|
120
|
+
2. Use the semantic variant that matches the emotional valence (success = good, danger = bad)
|
|
121
|
+
3. When status is dynamic (changes without page reload), add `role="status"` to the Badge
|
|
122
|
+
4. Avoid mixing `size="s"` and `size="m"` badges in the same table column
|
|
123
|
+
5. Rows go inside a `StatusList` (shared columns) so the badges line up, left-aligned, in one column
|
|
124
|
+
|
|
125
|
+
## Anti-patterns
|
|
126
|
+
|
|
127
|
+
- ❌ Custom `<div style={{ background: 'red' }}>Failed</div>` — use Badge
|
|
128
|
+
- ❌ `variant="danger"` for "pending" — pending is `warning`
|
|
129
|
+
- ❌ `variant="info"` for "active" — active is `success`
|
|
130
|
+
- ❌ Using Badge without a text label (icon-only Badge) — always include a label
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: view-toggle
|
|
3
|
+
category: layout
|
|
4
|
+
components: [IconButton]
|
|
5
|
+
when: "Letting the user switch how the same data is displayed — e.g. table vs. cards."
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# Pattern: View toggle
|
|
9
|
+
|
|
10
|
+
**Not a component** — same status as `stat-card.md`. A copy-paste recipe built from `IconButton`, not a
|
|
11
|
+
new formal DS primitive. Two buttons and a `useState` don't earn a contract of their own; commissioning a
|
|
12
|
+
`SegmentedControl`/`ToggleGroup` component is a separate, larger decision (grouped-selection semantics,
|
|
13
|
+
`role="radiogroup"` or `role="tablist"`, keyboard arrow navigation) — do that only when a second, unrelated
|
|
14
|
+
use case needs the same grouped-exclusive-choice behavior, not for one view switch.
|
|
15
|
+
|
|
16
|
+
## When to use
|
|
17
|
+
|
|
18
|
+
- The same underlying data can be usefully displayed two (rarely three) different ways — a dense table for
|
|
19
|
+
scanning, a card grid for visual browsing.
|
|
20
|
+
|
|
21
|
+
## Anatomy
|
|
22
|
+
|
|
23
|
+
```
|
|
24
|
+
┌──────────────┐
|
|
25
|
+
│ [▤] [▦] │ ← two IconButtons, one active (variant="secondary"), one not (variant="ghost")
|
|
26
|
+
└──────────────┘
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Code
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { useState } from 'react';
|
|
33
|
+
import { IconButton } from '@helixds/react';
|
|
34
|
+
import { IconTable, IconLayoutGrid } from '@tabler/icons-react';
|
|
35
|
+
|
|
36
|
+
function ViewToggle({ view, onViewChange }: { view: 'table' | 'cards'; onViewChange: (v: 'table' | 'cards') => void }) {
|
|
37
|
+
return (
|
|
38
|
+
<div
|
|
39
|
+
data-helix-pattern="view-toggle"
|
|
40
|
+
role="group"
|
|
41
|
+
aria-label="View"
|
|
42
|
+
style={{ display: 'inline-flex', gap: 'var(--helix-spacing-2xs)' }}
|
|
43
|
+
>
|
|
44
|
+
<IconButton
|
|
45
|
+
icon={IconTable}
|
|
46
|
+
label="Table view"
|
|
47
|
+
variant={view === 'table' ? 'secondary' : 'ghost'}
|
|
48
|
+
aria-pressed={view === 'table'}
|
|
49
|
+
onClick={() => onViewChange('table')}
|
|
50
|
+
/>
|
|
51
|
+
<IconButton
|
|
52
|
+
icon={IconLayoutGrid}
|
|
53
|
+
label="Cards view"
|
|
54
|
+
variant={view === 'cards' ? 'secondary' : 'ghost'}
|
|
55
|
+
aria-pressed={view === 'cards'}
|
|
56
|
+
onClick={() => onViewChange('cards')}
|
|
57
|
+
/>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Rules
|
|
64
|
+
|
|
65
|
+
1. `role="group"` + `aria-label` on the wrapper — screen readers need to know these two buttons are related.
|
|
66
|
+
2. `aria-pressed` on each `IconButton` reflects whether that view is active — even though IconButton's own
|
|
67
|
+
contract lists "a toggle/pressed state" under `neverUseFor` for a *single* icon button used in isolation,
|
|
68
|
+
a pair of them forming a mutually-exclusive group is exactly the "compose a dedicated toggle control
|
|
69
|
+
instead" escape hatch that rule points to. This recipe *is* that composition.
|
|
70
|
+
3. The active button uses `variant="secondary"` (visibly selected), the inactive one `variant="ghost"` —
|
|
71
|
+
never both `ghost` (no way to tell which is active) or both `primary` (two competing CTAs).
|
|
72
|
+
4. State lives with whatever owns the data being displayed — don't let the toggle own its own disconnected
|
|
73
|
+
state if the two views need to show the same underlying items (see
|
|
74
|
+
`apps/storybook/stories/ReorderableTeamList.stories.tsx` for a worked example where both views share one
|
|
75
|
+
ordering state).
|
|
76
|
+
|
|
77
|
+
## Anti-patterns
|
|
78
|
+
|
|
79
|
+
- ❌ Building a third, unused "list" view "just in case" — two options is the common case; add a third only
|
|
80
|
+
when a real third display mode exists.
|
|
81
|
+
- ❌ Using `Chip` for this — Chip's purpose is filters/categories, not layout mode switching.
|
package/dist/prop-map.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Helix DS — Canonical Prop Vocabulary
|
|
2
|
+
|
|
3
|
+
The `verify:props` script rejects any prop name in the "Never" column found in `packages/**/*.tsx`.
|
|
4
|
+
|
|
5
|
+
## Core variants + sizes
|
|
6
|
+
|
|
7
|
+
| ✅ Canonical | ❌ Anti-synonyms | Notes |
|
|
8
|
+
|-------------|------------------------|-------------------------------------------------|
|
|
9
|
+
| `variant` | `type`, `kind`, `mode` | Visual style selector (primary/secondary/etc.) |
|
|
10
|
+
| `size` | `scale`, `sz` | Size selector: `xs` `s` `m` `l` `xl` |
|
|
11
|
+
| `weight` | `fontWeight` | Typography weight |
|
|
12
|
+
|
|
13
|
+
## Boolean states
|
|
14
|
+
|
|
15
|
+
| ✅ Canonical | ❌ Anti-synonyms | Notes |
|
|
16
|
+
|-------------|----------------------------------|---------------------------------------------------|
|
|
17
|
+
| `isLoading` | `loading`, `pending`, `isPending`, `busy` | Authored loading state — `is`-prefixed, the name agents reach for (ADR-022) |
|
|
18
|
+
| `disabled` | `isDisabled`, `readonly` | Native + authored disabled state |
|
|
19
|
+
| `current` | `active`, `isActive`, `selected` | Navigation/tab current item |
|
|
20
|
+
| `expanded` | `isExpanded`, `open`, `isOpen` | Disclosure open state |
|
|
21
|
+
| `checked` | `isChecked`, `selected` | Checkbox/radio selected state |
|
|
22
|
+
| `invalid` | `hasError`, `isError`, `error` | Form field validation failure state |
|
|
23
|
+
| `required` | `isRequired` | Form field required state |
|
|
24
|
+
|
|
25
|
+
## Naming variants
|
|
26
|
+
|
|
27
|
+
| ✅ Canonical | ❌ Anti-synonyms | Notes |
|
|
28
|
+
|-------------|----------------------------------|---------------------------------------------------|
|
|
29
|
+
| `danger` | `error`, `destructive`, `delete` | Red variant for destructive actions |
|
|
30
|
+
| `success` | `positive`, `ok`, `valid` | Green variant for confirmation |
|
|
31
|
+
| `warning` | `caution`, `alert` | Amber variant for warnings |
|
|
32
|
+
| `info` | `information`, `tip`, `note` | Blue variant for informational |
|
|
33
|
+
| `neutral` | `default`, `muted`, `subtle` | Gray/neutral variant |
|
|
34
|
+
|
|
35
|
+
## Event handlers
|
|
36
|
+
|
|
37
|
+
| ✅ Canonical | ❌ Anti-synonyms | Notes |
|
|
38
|
+
|-------------|----------------------------------|---------------------------------------------------|
|
|
39
|
+
| `onClick` | `onPress`, `onTap`, `onAction` | Primary action — React's own handler, the name agents reach for (ADR-022) |
|
|
40
|
+
| `onChange` | `onValueChange`, `onUpdate` | Value change handler |
|
|
41
|
+
| `onFocus` | `onFocused` | Focus event |
|
|
42
|
+
| `onBlur` | `onBlurred` | Blur event |
|
|
43
|
+
| `onDismiss` | `onClose`, `onCancel` | Dismissal/close action |
|
|
44
|
+
|
|
45
|
+
## Content + layout
|
|
46
|
+
|
|
47
|
+
| ✅ Canonical | ❌ Anti-synonyms | Notes |
|
|
48
|
+
|-------------|----------------------------------|---------------------------------------------------|
|
|
49
|
+
| `label` | `title`, `name`, `text` | Visible or accessible label |
|
|
50
|
+
| `description`| `subtitle`, `hint`, `helper` | Supporting text under label |
|
|
51
|
+
| `placeholder`| `hintText`, `ghostText` | Empty-state hint text |
|
|
52
|
+
| `icon` | `leftIcon`, `startIcon`, `leadingIcon` | Leading icon — a Tabler icon component passed by reference (e.g. `IconPlus`), not a pre-instantiated element or string |
|
|
53
|
+
| `iconEnd` | `rightIcon`, `endIcon`, `trailingIcon` | Trailing icon — same reference convention as `icon` |
|
|
54
|
+
| `labelEnd` | `meta`, `suffix`, `trailingText`, `rightText`, `secondaryText` | Short secondary text aligned to the end of an option (a value, a count, a percentage) — same `End` convention as `iconEnd` |
|
|
55
|
+
| `children` | `content`, `body`, `slot` | React children slot |
|
|
56
|
+
| `options` | `items`, `choices`, `list` | The items a group, select or menu draws — an array of `{ value, label }`. In Figma: a VARIANT `options` = how many (2…7), `list-count` rule in contracts/figma-conversion.json |
|
|
57
|
+
|
|
58
|
+
## Width + alignment
|
|
59
|
+
|
|
60
|
+
| ✅ Canonical | ❌ Anti-synonyms | Notes |
|
|
61
|
+
|-------------|----------------------------------|---------------------------------------------------|
|
|
62
|
+
| `fullWidth` | `block`, `fluid`, `stretch` | 100% width behavior |
|
|
63
|
+
| `align` | `textAlign`, `justifyContent` | Content alignment within component |
|
|
64
|
+
|
|
65
|
+
## Anatomy size values
|
|
66
|
+
|
|
67
|
+
Always use the short single-letter scale:
|
|
68
|
+
|
|
69
|
+
| ✅ Use | ❌ Never |
|
|
70
|
+
|--------|-----------|
|
|
71
|
+
| `xs` | `xsmall`, `extra-small`, `tiny` |
|
|
72
|
+
| `s` | `sm`, `small` |
|
|
73
|
+
| `m` | `md`, `medium`, `base`, `default` |
|
|
74
|
+
| `l` | `lg`, `large` |
|
|
75
|
+
| `xl` | `xlarge`, `extra-large` |
|
|
76
|
+
| `2xl` | `xxl`, `2xl` (ok in tokens, not in props) |
|
|
77
|
+
|
|
78
|
+
Prop *type* classification (boolean, variant/enum, text, icon reference, event handler, nested content)
|
|
79
|
+
and how each converts into a Figma component property live in `.ai/skills/components-to-figma.md` →
|
|
80
|
+
"Prop taxonomy" — that's process/build documentation, not naming vocabulary, so it stays out of this file.
|