@aircall/ds 0.49.0 → 0.50.2
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/dist/{data-table-B3ahtFLP.js → data-table-AX0Mgu6K.js} +5 -0
- package/dist/{data-table-BgeS8KWP.d.ts → data-table-B5VqWPmw.d.ts} +3 -4
- package/dist/data-table.d.ts +1 -1
- package/dist/data-table.js +1 -1
- package/dist/globals.css +1 -1
- package/dist/index.d.ts +53 -16
- package/dist/index.js +113 -20
- package/package.json +2 -2
- package/skills/aircall-ds/migrate-audio-player/SKILL.md +14 -3
- package/skills/aircall-ds/migrate-icons/SKILL.md +45 -16
- package/skills/aircall-ds/migrate-tractor/SKILL.md +34 -31
- package/skills/aircall-ds/migrate-tractor/accordion/SKILL.md +25 -15
- package/skills/aircall-ds/migrate-tractor/alert/SKILL.md +107 -20
- package/skills/aircall-ds/migrate-tractor/avatar/SKILL.md +57 -26
- package/skills/aircall-ds/migrate-tractor/badge/SKILL.md +71 -25
- package/skills/aircall-ds/migrate-tractor/button/SKILL.md +68 -32
- package/skills/aircall-ds/migrate-tractor/card/SKILL.md +62 -42
- package/skills/aircall-ds/migrate-tractor/combobox/SKILL.md +233 -149
- package/skills/aircall-ds/migrate-tractor/data-table/SKILL.md +102 -108
- package/skills/aircall-ds/migrate-tractor/data-table/references/column-widths-and-pinning.md +50 -0
- package/skills/aircall-ds/migrate-tractor/data-table/references/infinite-scroll.md +51 -0
- package/skills/aircall-ds/migrate-tractor/data-table/references/row-actions.md +34 -0
- package/skills/aircall-ds/migrate-tractor/date-picker/SKILL.md +100 -47
- package/skills/aircall-ds/migrate-tractor/dialog/SKILL.md +115 -20
- package/skills/aircall-ds/migrate-tractor/dropdown-menu/SKILL.md +135 -57
- package/skills/aircall-ds/migrate-tractor/dropzone/SKILL.md +2 -0
- package/skills/aircall-ds/migrate-tractor/form-and-field/SKILL.md +111 -49
- package/skills/aircall-ds/migrate-tractor/gauge/SKILL.md +6 -4
- package/skills/aircall-ds/migrate-tractor/input/SKILL.md +165 -59
- package/skills/aircall-ds/migrate-tractor/item/SKILL.md +85 -63
- package/skills/aircall-ds/migrate-tractor/link/SKILL.md +85 -68
- package/skills/aircall-ds/migrate-tractor/popover/SKILL.md +115 -74
- package/skills/aircall-ds/migrate-tractor/select/SKILL.md +117 -64
- package/skills/aircall-ds/migrate-tractor/sheet-vs-drawer/SKILL.md +55 -32
- package/skills/aircall-ds/migrate-tractor/skeleton/SKILL.md +40 -11
- package/skills/aircall-ds/migrate-tractor/styling/SKILL.md +11 -7
- package/skills/aircall-ds/migrate-tractor/tabs/SKILL.md +62 -55
- package/skills/aircall-ds/migrate-tractor/toast/SKILL.md +58 -12
- package/skills/aircall-ds/migrate-tractor/tooltip/SKILL.md +65 -40
- package/skills/aircall-ds/migrate-tractor/tree/SKILL.md +23 -6
- package/skills/aircall-ds/setup/SKILL.md +53 -8
|
@@ -11,6 +11,10 @@ requires:
|
|
|
11
11
|
- aircall-ds/migrate-tractor
|
|
12
12
|
sources:
|
|
13
13
|
- "aircall/hydra:docs/migration-guides/tractor-to-ds/recipes/avatar.md"
|
|
14
|
+
- "aircall/hydra:packages/ds/src/components/avatar.tsx"
|
|
15
|
+
- "aircall/hydra:packages/ds/src/stories/Avatar.stories.tsx"
|
|
16
|
+
- "aircall/hydra:packages/blocks/src/components/entity-avatar.tsx"
|
|
17
|
+
- "aircall/hydra:packages/blocks/src/components/entity-group.tsx"
|
|
14
18
|
---
|
|
15
19
|
|
|
16
20
|
This skill builds on aircall-ds/migrate-tractor.
|
|
@@ -19,13 +23,19 @@ This skill builds on aircall-ds/migrate-tractor.
|
|
|
19
23
|
|
|
20
24
|
| Tractor part | DS replacement | Notes |
|
|
21
25
|
| --- | --- | --- |
|
|
22
|
-
| `<Avatar src
|
|
23
|
-
| `<QuickAvatar>` | `<Avatar>`
|
|
24
|
-
| `name="Jane Doe"` prop | `<AvatarFallback>JD</AvatarFallback>` | Derive initials yourself; DS has no auto-initials prop |
|
|
25
|
-
|
|
|
26
|
-
|
|
|
26
|
+
| `<Avatar>` + `<AvatarImg src>` + `<AvatarFallback>` (`AvatarText` / `AvatarIcon`) | `<Avatar size><AvatarImage /><AvatarFallback /></Avatar>` | Compound — image and fallback are explicit children |
|
|
27
|
+
| `<QuickAvatar src name initials icon size>` | `<Avatar>` + `<AvatarImage>` + `<AvatarFallback>` | `QuickAvatar` built the image, initials and icon children from props. In DS you write them as children (see 5b) |
|
|
28
|
+
| `name="Jane Doe"` / `initials` prop (`QuickAvatar`, `AvatarText`) | `<AvatarFallback>JD</AvatarFallback>` | Derive initials yourself; DS has no auto-initials prop. `getEntityInitials(name)` from `@aircall/blocks` does it (up to two uppercase letters) |
|
|
29
|
+
| `icon={SomeIcon}` (`QuickAvatar`) / `<AvatarIcon>` | `<AvatarFallback><UserRound /></AvatarFallback>` | A direct `<svg>` child of `AvatarFallback` is sized from the avatar `size`; no `size-*` class needed |
|
|
30
|
+
| `variant="green" \| "blue" \| …` (fallback tint) | `className` on `AvatarFallback` (e.g. `bg-primary/10 text-primary`) | DS has no `variant` prop; the fallback is `bg-muted text-muted-foreground` |
|
|
31
|
+
| `shape="rounded"` | — | No `shape` prop; DS avatars are always circular |
|
|
32
|
+
| `disabled` | `className="opacity-50 grayscale"` on `Avatar` | No `disabled` prop |
|
|
33
|
+
| Tractor `Badge` wrapped around an avatar | `<AvatarBadge className="bg-…" />` | Child of `Avatar`; color set via `className` |
|
|
34
|
+
| Hand-rolled overlapping stack (Tractor has no avatar group) | `<AvatarGroup>` | Wraps `Avatar` children with overlap ring |
|
|
27
35
|
| Overflow chip `+N` | `<AvatarGroupCount>+3</AvatarGroupCount>` | Last child inside `AvatarGroup` |
|
|
28
36
|
|
|
37
|
+
**Entity avatars (users, contacts, teams, AI agents).** For an avatar that stands for a product entity, `@aircall/blocks` has purpose-built wrappers that already decide the media (picture, then emoji or icon, then initials), the 20/24px sizes, the accessible name and the presence dot: `UserAvatar` (`name`, `src`, `presence`), `ContactAvatar`, `TeamAvatar`, `AiAgentAvatar`, `IntegrationAvatar`, `AddonAvatar`, plus `EntityGroup` for a capped stack with a "+N" counter (`max` default 3, `overflowCount`). Prefer them over hand-building `Avatar` + `AvatarFallback` for those objects. They are marked `@experimental`. Source: `packages/blocks/src/components/entity-avatar.tsx`, `entity-user.tsx`, `entity-group.tsx`.
|
|
38
|
+
|
|
29
39
|
## 2. Verified DS exports (`packages/ds/src/index.ts`)
|
|
30
40
|
|
|
31
41
|
```
|
|
@@ -49,12 +59,12 @@ import {
|
|
|
49
59
|
|
|
50
60
|
| Tractor `size` | DS `size` | Rendered px |
|
|
51
61
|
| --- | --- | --- |
|
|
52
|
-
| `small` | `sm` | 24 px |
|
|
53
|
-
| `regular` (default) | `default` | 32 px |
|
|
54
|
-
| `large` | `xl` | 48 px |
|
|
55
|
-
| `xLarge` | `xl` | 48 px |
|
|
56
|
-
| _(
|
|
57
|
-
| _(
|
|
62
|
+
| `small` (24 px) | `sm` | 24 px |
|
|
63
|
+
| `regular` (default, 32 px) | `default` | 32 px |
|
|
64
|
+
| `large` (48 px) | `xl` | 48 px |
|
|
65
|
+
| `xLarge` (64 px) | `xl` | 48 px |
|
|
66
|
+
| _(custom string, e.g. 20 px)_ | `xs` | 20 px |
|
|
67
|
+
| _(custom string, e.g. 40 px)_ | `lg` | 40 px |
|
|
58
68
|
|
|
59
69
|
There is no 64 px size in DS. Map Tractor `xLarge` (64 px) to `xl` (48 px) — the closest available size.
|
|
60
70
|
|
|
@@ -64,15 +74,26 @@ There is no 64 px size in DS. Map Tractor `xLarge` (64 px) to `xl` (48 px) — t
|
|
|
64
74
|
|
|
65
75
|
**Before (Tractor):**
|
|
66
76
|
```tsx
|
|
67
|
-
import {
|
|
77
|
+
import { QuickAvatar } from '@aircall/tractor';
|
|
68
78
|
|
|
69
|
-
<
|
|
79
|
+
<QuickAvatar
|
|
70
80
|
src="https://example.com/photo.jpg"
|
|
71
81
|
name="Jane Doe"
|
|
72
82
|
size="regular"
|
|
73
83
|
/>
|
|
74
84
|
```
|
|
75
85
|
|
|
86
|
+
Or the composed form, which maps to the same DS compound:
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { Avatar, AvatarFallback, AvatarImg, AvatarText } from '@aircall/tractor';
|
|
90
|
+
|
|
91
|
+
<Avatar size="regular">
|
|
92
|
+
<AvatarImg src="https://example.com/photo.jpg" />
|
|
93
|
+
<AvatarFallback><AvatarText name="Jane Doe" /></AvatarFallback>
|
|
94
|
+
</Avatar>
|
|
95
|
+
```
|
|
96
|
+
|
|
76
97
|
**After (DS):**
|
|
77
98
|
```tsx
|
|
78
99
|
import { Avatar, AvatarFallback, AvatarImage } from '@aircall/ds';
|
|
@@ -98,7 +119,7 @@ import { Avatar, AvatarFallback, AvatarImage } from '@aircall/ds';
|
|
|
98
119
|
|
|
99
120
|
<Avatar size="xl">
|
|
100
121
|
<AvatarImage src={photoUrl} alt="" />
|
|
101
|
-
<AvatarFallback
|
|
122
|
+
<AvatarFallback>{initials}</AvatarFallback>
|
|
102
123
|
</Avatar>
|
|
103
124
|
```
|
|
104
125
|
|
|
@@ -106,9 +127,13 @@ import { Avatar, AvatarFallback, AvatarImage } from '@aircall/ds';
|
|
|
106
127
|
|
|
107
128
|
**Before (Tractor):**
|
|
108
129
|
```tsx
|
|
109
|
-
import { Avatar } from '@aircall/tractor';
|
|
130
|
+
import { Avatar, AvatarText, Badge } from '@aircall/tractor';
|
|
110
131
|
|
|
111
|
-
<
|
|
132
|
+
<Badge variant="primary" offsetRight="3px" offsetTop="3px">
|
|
133
|
+
<Avatar>
|
|
134
|
+
<AvatarText name="Jane Doe" />
|
|
135
|
+
</Avatar>
|
|
136
|
+
</Badge>
|
|
112
137
|
```
|
|
113
138
|
|
|
114
139
|
**After (DS):**
|
|
@@ -122,15 +147,21 @@ import { Avatar, AvatarBadge, AvatarFallback, AvatarImage } from '@aircall/ds';
|
|
|
122
147
|
</Avatar>
|
|
123
148
|
```
|
|
124
149
|
|
|
125
|
-
`AvatarBadge` auto-positions at bottom-right and sizes itself from the parent `Avatar`'s `size`
|
|
150
|
+
`AvatarBadge` auto-positions at bottom-right (with a 2px ring in the background colour) and sizes itself from the parent `Avatar`'s `size`: 8px at `xs`/`sm`, 10px at `default`, 12px at `lg`/`xl`. It ships without a colour: pass a Tailwind background utility via `className` (`bg-success`, or `bg-green-500` as the stories do). An `<svg>` child is hidden at `xs`/`sm` and drawn at 8px from `default` up. For user presence (available, in-call, wrap-up, ringing, unavailable, offline) use `UserAvatar presence` from `@aircall/blocks` instead of colouring the badge by hand.
|
|
126
151
|
|
|
127
152
|
### 5d. Overlapping avatar group with overflow count
|
|
128
153
|
|
|
129
|
-
**Before (Tractor):**
|
|
154
|
+
**Before (Tractor has no avatar group; this was typically hand-rolled):**
|
|
130
155
|
```tsx
|
|
131
|
-
import { Avatar,
|
|
132
|
-
|
|
133
|
-
<
|
|
156
|
+
import { Avatar, AvatarImg, Flex } from '@aircall/tractor';
|
|
157
|
+
|
|
158
|
+
<Flex>
|
|
159
|
+
{users.slice(0, 3).map((user, index) => (
|
|
160
|
+
<Avatar key={user.id} style={{ marginLeft: index === 0 ? 0 : -8 }}>
|
|
161
|
+
<AvatarImg src={user.photo} />
|
|
162
|
+
</Avatar>
|
|
163
|
+
))}
|
|
164
|
+
</Flex>
|
|
134
165
|
```
|
|
135
166
|
|
|
136
167
|
**After (DS):**
|
|
@@ -156,7 +187,7 @@ import {
|
|
|
156
187
|
</AvatarGroup>
|
|
157
188
|
```
|
|
158
189
|
|
|
159
|
-
DS has no built-in `max` or `users` props — slice the array yourself before rendering and compute the overflow count explicitly.
|
|
190
|
+
DS has no built-in `max` or `users` props — slice the array yourself before rendering and compute the overflow count explicitly. `AvatarGroupCount` sizes itself from the avatars in the group (`xs`/`sm`/`lg`/`xl`; 32px otherwise). For entity avatars, `EntityGroup` from `@aircall/blocks` does the slicing and the "+N" counter for you.
|
|
160
191
|
|
|
161
192
|
## 6. Common mistakes
|
|
162
193
|
|
|
@@ -179,9 +210,9 @@ import { Avatar, AvatarFallback, AvatarImage } from '@aircall/ds';
|
|
|
179
210
|
</Avatar>
|
|
180
211
|
```
|
|
181
212
|
|
|
182
|
-
DS `Avatar` has no `name` prop.
|
|
213
|
+
DS `Avatar` has no `name` prop. It is a type error, and the value is passed to the Base UI root `<div>` as a stray attribute; nothing renders, so the avatar is a blank circle instead of initials.
|
|
183
214
|
|
|
184
|
-
Source: packages/ds/src/components/avatar.tsx — `AvatarProps`
|
|
215
|
+
Source: packages/ds/src/components/avatar.tsx — `AvatarProps` is `AvatarPrimitive.Root.Props & VariantProps<typeof avatarVariants>`, which has no `name` field.
|
|
185
216
|
|
|
186
217
|
---
|
|
187
218
|
|
|
@@ -266,6 +297,6 @@ import { Avatar, AvatarFallback, AvatarImage } from '@aircall/ds';
|
|
|
266
297
|
</Avatar>
|
|
267
298
|
```
|
|
268
299
|
|
|
269
|
-
DS has no `"large"` size token and no 64 px size.
|
|
300
|
+
DS has no `"large"` size token and no 64 px size. `size` is typed `'xs' | 'sm' | 'default' | 'lg' | 'xl'`, so `"large"` is a type error. If it slips through, none of the `size-*` classes apply (the `default` size is only the fallback when `size` is undefined), so the avatar has no width or height of its own and `AvatarBadge` / `AvatarGroupCount` scale to nothing. Tractor `large` (48 px) maps to `xl`; the closest DS size to Tractor `xLarge` (64 px) is `xl` (48 px).
|
|
270
301
|
|
|
271
|
-
Source: packages/ds/src/components/avatar.tsx — `
|
|
302
|
+
Source: packages/ds/src/components/avatar.tsx — `avatarVariants` size keys are `xs | sm | default | lg | xl` (`size-5`, `size-6`, `size-8`, `size-10`, `size-12`).
|
|
@@ -4,7 +4,8 @@ description: >
|
|
|
4
4
|
Migrate Tractor Tag and CounterBadge to @aircall/ds Badge, CounterBadge, BadgeGroup,
|
|
5
5
|
and BadgeGroupCount. Load when a file imports Tag or CounterBadge from @aircall/tractor.
|
|
6
6
|
Maps Tractor variant (grey/primary/blue/red/yellow/green/purple/pink/dark* prefixes)
|
|
7
|
-
to the DS color + tone two-axis model,
|
|
7
|
+
to the DS color + tone two-axis model, Tractor status Badge (dot) to AvatarBadge,
|
|
8
|
+
and removable Tag (TagDeleteIcon) to Chip + ChipRemove.
|
|
8
9
|
type: sub-skill
|
|
9
10
|
library: aircall-ds
|
|
10
11
|
requires:
|
|
@@ -12,6 +13,11 @@ requires:
|
|
|
12
13
|
- aircall-ds/migrate-tractor
|
|
13
14
|
sources:
|
|
14
15
|
- "aircall/hydra:docs/migration-guides/tractor-to-ds/recipes/badge.md"
|
|
16
|
+
- "aircall/hydra:packages/ds/src/components/badge.tsx"
|
|
17
|
+
- "aircall/hydra:packages/ds/src/components/counter-badge.tsx"
|
|
18
|
+
- "aircall/hydra:packages/ds/src/components/chip.tsx"
|
|
19
|
+
- "aircall/hydra:packages/ds/src/stories/Badge.stories.tsx"
|
|
20
|
+
- "aircall/hydra:packages/ds/src/stories/CounterBadge.stories.tsx"
|
|
15
21
|
---
|
|
16
22
|
|
|
17
23
|
This skill builds on aircall-ds/migrate-tractor.
|
|
@@ -22,8 +28,11 @@ Tractor's badge surface had three distinct concepts that map to different DS com
|
|
|
22
28
|
|
|
23
29
|
| Tractor component | DS replacement | Notes |
|
|
24
30
|
| --- | --- | --- |
|
|
25
|
-
| `<Tag>` | `<Badge>` | Color model changes from single `variant` to `color` + `tone` |
|
|
26
|
-
| `<
|
|
31
|
+
| `<Tag>` | `<Badge>` | Color model changes from single `variant` to `color` + `tone`. Tag was fully rounded (`rounded-full`), `Badge` is `rounded-md` |
|
|
32
|
+
| `<Tag onClick>` | `<Badge render={<button type="button" onClick={…} />}>` | `Badge` is read-only; `render` makes it a button or link without changing its look |
|
|
33
|
+
| `<Tag>` + `<TagDeleteIcon onClick>` (removable) | `<Chip>` + `<ChipRemove onClick>` | `Badge` is never removable; `Chip` is the removable token (fixed 24px, `overflowMode="truncate"`) |
|
|
34
|
+
| `<Tag maxWidth>` / long labels | `<Badge overflowMode="truncate">` | Caps the width at `max-w-36` and ellipsizes text |
|
|
35
|
+
| `<CounterBadge count maxCount>` | `<CounterBadge>` | No `count`/`maxCount` props — cap the value yourself and pass it as children |
|
|
27
36
|
| `<Badge>` (status dot) | `<AvatarBadge>` | Tractor's dot-indicator badge is unrelated to DS `Badge`; see the avatar skill |
|
|
28
37
|
| _(grouping)_ | `<BadgeGroup>` + `<BadgeGroupCount>` | Wraps multiple badges; `BadgeGroupCount` renders the overflow "+N" chip |
|
|
29
38
|
|
|
@@ -49,7 +58,9 @@ Icons inside badges import from `@aircall/react-icons` — never from `lucide-re
|
|
|
49
58
|
DS Badge uses two orthogonal props instead of Tractor's single `variant`:
|
|
50
59
|
|
|
51
60
|
- `color`: `charcoal` (default) · `red` · `green` · `blue` · `purple` · `yellow` · `pink`
|
|
52
|
-
- `tone`: `dark` · `medium-dark` · `medium-light` · `light`
|
|
61
|
+
- `tone`: `dark` (default) · `medium-dark` · `medium-light` · `light`
|
|
62
|
+
|
|
63
|
+
`Badge` with no `color` / `tone` renders `charcoal` / `dark`: a solid dark chip (`bg-secondary`), not a light one. Always pass a `tone` when migrating a `Tag`.
|
|
53
64
|
|
|
54
65
|
| Tractor `variant` | DS `color` | DS `tone` |
|
|
55
66
|
| --- | --- | --- |
|
|
@@ -57,6 +68,7 @@ DS Badge uses two orthogonal props instead of Tractor's single `variant`:
|
|
|
57
68
|
| `secondary` | `charcoal` | `medium-light` |
|
|
58
69
|
| `lightSecondary` | `charcoal` | `light` |
|
|
59
70
|
| `darkSecondary` | `charcoal` | `medium-dark` |
|
|
71
|
+
| `darkGrey` | `charcoal` | `dark` |
|
|
60
72
|
| `primary` | `green` | `medium-light` |
|
|
61
73
|
| `lightPrimary` | `green` | `light` |
|
|
62
74
|
| `darkPrimary` | `green` | `dark` |
|
|
@@ -76,42 +88,52 @@ DS Badge uses two orthogonal props instead of Tractor's single `variant`:
|
|
|
76
88
|
|
|
77
89
|
### Hard-coded hex colors (`bg` prop)
|
|
78
90
|
|
|
79
|
-
When Tractor used a hard-coded hex (e.g. `bg="#0761B5"
|
|
91
|
+
When Tractor used a hard-coded hex (e.g. `bg="#0761B5"`, or a colour stored with the tag), pass it via `customColor`. It paints the hex as the fill and picks a black or white foreground by WCAG contrast, so any colour stays legible. A value that is not a hex is ignored. It is not theme-aware, so prefer `color` + `tone` whenever the colour comes from a fixed set.
|
|
80
92
|
|
|
81
93
|
```tsx
|
|
82
|
-
<Badge
|
|
94
|
+
<Badge customColor="#0761B5">Sales</Badge>
|
|
83
95
|
```
|
|
84
96
|
|
|
97
|
+
`legacyColor` is **deprecated**: it resolves only the 13 hexes of the old `TagColorPicker` palette to a `color` + `tone` and silently turns every other hex into `charcoal` / `dark` (it covers about 54% of production tag data). Existing call sites keep working; do not add new ones. `customColor` also works on `Chip`.
|
|
98
|
+
|
|
85
99
|
## 5. Size mapping
|
|
86
100
|
|
|
87
101
|
| Tractor `size` | DS `size` |
|
|
88
102
|
| --- | --- |
|
|
89
|
-
| `xSmall` | `default` (20px) |
|
|
90
|
-
| `small` | `default` (20px) |
|
|
91
|
-
| `regular` (default) | `default` (20px) |
|
|
92
|
-
| `large` | `lg` (24px) |
|
|
103
|
+
| `xSmall` (16px) | `default` (20px) |
|
|
104
|
+
| `small` (24px) | `default` (20px) |
|
|
105
|
+
| `regular` (default, 26px) | `default` (20px) |
|
|
106
|
+
| `large` (34px) | `lg` (24px) |
|
|
93
107
|
|
|
94
108
|
DS has no `mode` prop (`outline` / `fill`). Use a lighter `tone` (e.g. `light`) to approximate the old outline look.
|
|
95
109
|
|
|
96
110
|
## 6. CounterBadge
|
|
97
111
|
|
|
98
|
-
DS `CounterBadge`
|
|
112
|
+
Tractor's `CounterBadge` took `count`, `maxCount` (default 99, shows `99+`), `showEmptyBubble`, `offsetTop` / `offsetRight`, and wrapped its children: it overlaid the pill on them and rendered nothing but the children when `count` was 0. DS `CounterBadge` is a plain pill (`<span>`) with no `count`, `maxCount`, `showEmptyBubble` or offset props. Hide it at 0 and cap the displayed value yourself, then pass it as children:
|
|
99
113
|
|
|
100
114
|
```tsx
|
|
101
|
-
<CounterBadge>{count > 99 ? '99+' : count}</CounterBadge>
|
|
115
|
+
{count > 0 && <CounterBadge>{count > 99 ? '99+' : count}</CounterBadge>}
|
|
102
116
|
```
|
|
103
117
|
|
|
104
118
|
Available `variant` values: `default` (destructive background) · `secondary` · `ghost`.
|
|
105
119
|
|
|
120
|
+
| Tractor `variant` | DS |
|
|
121
|
+
| --- | --- |
|
|
122
|
+
| `red` (default) | `variant="default"` (destructive red) |
|
|
123
|
+
| `black` | `variant="secondary"` |
|
|
124
|
+
| `primary` | no variant — `className="bg-primary text-primary-foreground"` |
|
|
125
|
+
|
|
126
|
+
The pill is always 20px tall (`h-5 min-w-5`). Tractor `small` (16px) / `large` (24px) need a `className` override (`h-4 min-w-4`, `h-6 min-w-6`). To overlay it on another element (the old wrapping behaviour), position it yourself: `relative` on the wrapper and `className="absolute -top-1 -right-1"` on the badge. A `CounterBadge` in a `render` slot can be made a link or button.
|
|
127
|
+
|
|
106
128
|
## 7. Grouping badges
|
|
107
129
|
|
|
108
|
-
Use `BadgeGroup` to wrap a set of badges
|
|
130
|
+
Use `BadgeGroup` to wrap a set of badges in a wrapping row (`flex flex-wrap items-center gap-2`), and `BadgeGroupCount` for the trailing overflow chip. `BadgeGroupCount` is a 20px (or 24px with `size="lg"`) square ghost `CounterBadge`: give it the same `size` as the badges and children such as `+3`:
|
|
109
131
|
|
|
110
132
|
```tsx
|
|
111
133
|
<BadgeGroup>
|
|
112
134
|
<Badge color="blue" tone="medium-light">Support</Badge>
|
|
113
135
|
<Badge color="green" tone="medium-light">Active</Badge>
|
|
114
|
-
<BadgeGroupCount
|
|
136
|
+
<BadgeGroupCount>+{overflow}</BadgeGroupCount>
|
|
115
137
|
</BadgeGroup>
|
|
116
138
|
```
|
|
117
139
|
|
|
@@ -164,7 +186,7 @@ import { Tag } from '@aircall/tractor';
|
|
|
164
186
|
```tsx
|
|
165
187
|
import { Badge } from '@aircall/ds';
|
|
166
188
|
|
|
167
|
-
<Badge
|
|
189
|
+
<Badge customColor="#0761B5">Sales</Badge>
|
|
168
190
|
```
|
|
169
191
|
|
|
170
192
|
### 8d. CounterBadge with max cap
|
|
@@ -173,14 +195,14 @@ import { Badge } from '@aircall/ds';
|
|
|
173
195
|
```tsx
|
|
174
196
|
import { CounterBadge } from '@aircall/tractor';
|
|
175
197
|
|
|
176
|
-
<CounterBadge count={count}
|
|
198
|
+
<CounterBadge count={count} maxCount={99} />
|
|
177
199
|
```
|
|
178
200
|
|
|
179
201
|
**After (DS):**
|
|
180
202
|
```tsx
|
|
181
203
|
import { CounterBadge } from '@aircall/ds';
|
|
182
204
|
|
|
183
|
-
<CounterBadge>{count > 99 ? '99+' : count}</CounterBadge>
|
|
205
|
+
{count > 0 && <CounterBadge>{count > 99 ? '99+' : count}</CounterBadge>}
|
|
184
206
|
```
|
|
185
207
|
|
|
186
208
|
### 8e. Icon inside a Badge
|
|
@@ -203,19 +225,43 @@ import { CheckCircle } from '@aircall/react-icons';
|
|
|
203
225
|
|
|
204
226
|
> DS auto-sizes SVG children via `[&>svg]:size-3!` (default) or `[&>svg]:size-4!` (lg). Do not pass a `size` prop to the icon.
|
|
205
227
|
|
|
228
|
+
### 8f. Removable Tag → Chip
|
|
229
|
+
|
|
230
|
+
**Before (Tractor):**
|
|
231
|
+
```tsx
|
|
232
|
+
import { Tag, TagDeleteIcon } from '@aircall/tractor';
|
|
233
|
+
|
|
234
|
+
<Tag variant="blue">
|
|
235
|
+
Support
|
|
236
|
+
<TagDeleteIcon aria-label="Remove Support" onClick={onRemove} />
|
|
237
|
+
</Tag>
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
**After (DS):**
|
|
241
|
+
```tsx
|
|
242
|
+
import { Chip, ChipRemove } from '@aircall/ds';
|
|
243
|
+
|
|
244
|
+
<Chip color="blue">
|
|
245
|
+
Support
|
|
246
|
+
<ChipRemove aria-label="Remove Support" onClick={onRemove} />
|
|
247
|
+
</Chip>
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
`Chip` defaults to `tone="medium-light"` and `overflowMode="truncate"`, is always `size="lg"` (24px) and cannot be rendered as another element (`render` is omitted from its props). For chips bound to a combobox selection, see the combobox skill.
|
|
251
|
+
|
|
206
252
|
## 9. Common mistakes
|
|
207
253
|
|
|
208
254
|
### Mistake 1: Using `variant` instead of `color` + `tone`
|
|
209
255
|
|
|
210
256
|
```tsx
|
|
211
|
-
// Wrong — DS Badge has no `variant` prop
|
|
257
|
+
// Wrong — DS Badge has no `variant` prop (type error)
|
|
212
258
|
<Badge variant="primary">Active</Badge>
|
|
213
259
|
|
|
214
260
|
// Correct — map to the two-axis color + tone model
|
|
215
261
|
<Badge color="green" tone="medium-light">Active</Badge>
|
|
216
262
|
```
|
|
217
263
|
|
|
218
|
-
**Mechanism:** DS Badge replaced Tractor's single `variant` string with two orthogonal props `color` and `tone`. Passing `variant` goes to the underlying `span` as an unknown HTML attribute and has no visual effect — the badge renders with the default charcoal/
|
|
264
|
+
**Mechanism:** DS Badge replaced Tractor's single `variant` string with two orthogonal props `color` and `tone`. Passing `variant` goes to the underlying `span` as an unknown HTML attribute and has no visual effect — the badge renders with the default charcoal/dark appearance instead of the intended color.
|
|
219
265
|
|
|
220
266
|
Source: `packages/ds/src/components/badge.tsx` — `badgeVariants` has `color` and `tone` keys, no `variant` key.
|
|
221
267
|
|
|
@@ -245,23 +291,23 @@ Source: `packages/ds/src/components/badge.tsx` — `Badge` is a label chip; `pac
|
|
|
245
291
|
### Mistake 3: Relying on DS `CounterBadge` to cap overflow automatically
|
|
246
292
|
|
|
247
293
|
```tsx
|
|
248
|
-
// Wrong — DS CounterBadge has no `
|
|
249
|
-
<CounterBadge
|
|
294
|
+
// Wrong — DS CounterBadge has no `maxCount` / `count` props; it renders its children
|
|
295
|
+
<CounterBadge maxCount={99} count={count} />
|
|
250
296
|
|
|
251
297
|
// Correct — cap the value yourself before passing as children
|
|
252
298
|
<CounterBadge>{count > 99 ? '99+' : count}</CounterBadge>
|
|
253
299
|
```
|
|
254
300
|
|
|
255
|
-
**Mechanism:** Tractor's `CounterBadge` accepted
|
|
301
|
+
**Mechanism:** Tractor's `CounterBadge` accepted `count` and `maxCount` and formatted "99+" internally. DS `CounterBadge` is a presentational span that renders whatever children it receives — the cap logic is the caller's responsibility. Passing `maxCount` and `count` as props results in an empty badge with two unknown HTML attributes instead of the formatted string.
|
|
256
302
|
|
|
257
|
-
Source: `packages/ds/src/components/counter-badge.tsx` — `CounterBadge.Props` extends `useRender.ComponentProps<'span'>` with only a `variant` prop; no `
|
|
303
|
+
Source: `packages/ds/src/components/counter-badge.tsx` — `CounterBadge.Props` extends `useRender.ComponentProps<'span'>` with only a `variant` prop; no `maxCount` or `count` keys.
|
|
258
304
|
|
|
259
305
|
---
|
|
260
306
|
|
|
261
307
|
### Mistake 4: Using `outline` / `fill` mode to style a badge
|
|
262
308
|
|
|
263
309
|
```tsx
|
|
264
|
-
// Wrong — DS Badge has no `mode` prop
|
|
310
|
+
// Wrong — DS Badge has no `mode` prop (type error)
|
|
265
311
|
<Badge color="blue" mode="outline">Beta</Badge>
|
|
266
312
|
|
|
267
313
|
// Correct — reach for a lighter tone to approximate the outline look
|
|
@@ -270,4 +316,4 @@ Source: `packages/ds/src/components/counter-badge.tsx` — `CounterBadge.Props`
|
|
|
270
316
|
|
|
271
317
|
**Mechanism:** Tractor's `Tag` supported a `mode` prop (`outline` / `fill`) that toggled between a bordered and a filled appearance. DS Badge has no `mode` prop — the visual weight is controlled entirely by `tone`. A lighter tone (`light` or `medium-light`) produces a softer background that approximates the old outline look.
|
|
272
318
|
|
|
273
|
-
Source: `packages/ds/src/components/badge.tsx` — `badgeVariants` has `size`, `color`, and `
|
|
319
|
+
Source: `packages/ds/src/components/badge.tsx` — `badgeVariants` has `size`, `color`, `tone` and `overflowMode` variants; no `mode` variant.
|
|
@@ -12,6 +12,9 @@ requires:
|
|
|
12
12
|
- aircall-ds/migrate-tractor
|
|
13
13
|
sources:
|
|
14
14
|
- "aircall/hydra:packages/ds/src/components/button.tsx"
|
|
15
|
+
- "aircall/hydra:packages/ds/src/stories/Button.stories.tsx"
|
|
16
|
+
- "aircall/hydra:packages/ds/src/components/spinner.tsx"
|
|
17
|
+
- "aircall/hydra:packages/blocks/src/components/submit-button.tsx"
|
|
15
18
|
---
|
|
16
19
|
|
|
17
20
|
This skill builds on aircall-ds/migrate-tractor. Apply all cross-cutting rules from that skill (prop renames, `render` prop, data attributes) before the button-specific steps below.
|
|
@@ -23,7 +26,8 @@ Tractor had two separate components: `Button` (text + optional icon) and `IconBu
|
|
|
23
26
|
| Tractor component | DS replacement | Notes |
|
|
24
27
|
| --- | --- | --- |
|
|
25
28
|
| `<Button>` | `<Button>` | Drop-in with prop renames (see tables below) |
|
|
26
|
-
| `<IconButton component={X}>` | `<Button size="icon"><X /></Button>` | Icon becomes a child; `component` prop is removed |
|
|
29
|
+
| `<IconButton component={X}>` | `<Button variant="ghost" size="icon"><X /></Button>` | Icon becomes a child; `component` prop is removed. Tractor `IconButton` was a bare icon with a hover disc, so use `variant="ghost"`. The default `Button` variant is a solid primary fill |
|
|
30
|
+
| `LoadingButton` / `SaveButton` / `AddButton` (`@dashboard/library`) | `Button` + `Spinner`, or `form.SubmitButton` | See section 6, "Loading state" |
|
|
27
31
|
|
|
28
32
|
## 2. Verified DS export (`packages/ds/src/index.ts`)
|
|
29
33
|
|
|
@@ -42,22 +46,28 @@ Never import icons from `lucide-react` directly — always use `@aircall/react-i
|
|
|
42
46
|
|
|
43
47
|
## 4. Variant mapping (Tractor → DS)
|
|
44
48
|
|
|
45
|
-
Tractor had two orthogonal props — `variant` (
|
|
49
|
+
Tractor had two orthogonal props — `variant` (`primary` (default) | `secondary` | `critical` | `warning` | `informative`) and `mode` (`fill` (default) | `outline` | `ghost` | `link`). DS collapses both into a single `variant` prop. Use the combined (variant × mode) pair to pick the DS variant.
|
|
46
50
|
|
|
47
51
|
| Tractor `variant` | Tractor `mode` | DS `variant` |
|
|
48
52
|
| --- | --- | --- |
|
|
49
|
-
| `primary` | _(default /
|
|
53
|
+
| `primary` | _(default / `fill`)_ | `default` |
|
|
50
54
|
| `primary` | `outline` | `outline` |
|
|
51
|
-
| `
|
|
55
|
+
| `primary` | `ghost` | `ghost` |
|
|
56
|
+
| `secondary` | _(default / `fill`)_ | `secondary` |
|
|
52
57
|
| `secondary` | `outline` | `outline` |
|
|
53
58
|
| `secondary` | `ghost` | `ghost` |
|
|
54
|
-
| `
|
|
55
|
-
| `
|
|
56
|
-
|
|
|
59
|
+
| `primary` / `secondary` | `link` | `link` |
|
|
60
|
+
| `critical` | _(default / `fill`)_ | `destructive` |
|
|
61
|
+
| `critical` | `ghost` | `ghost` + `className="text-destructive"` |
|
|
62
|
+
| `critical` | `outline` | `outline` + `className="text-destructive"` |
|
|
63
|
+
| `critical` | `link` | `link` + `className="text-destructive"` |
|
|
64
|
+
| `warning` / `informative` | any | no DS equivalent: use `default` (filled) or `outline` |
|
|
57
65
|
|
|
58
66
|
> When both `variant` and `mode` appear on the same Tractor button, derive the DS variant from the **combination**, not from either prop alone. Dropping `mode` without updating `variant` is the most common migration error.
|
|
59
67
|
|
|
60
|
-
> `
|
|
68
|
+
> `critical` outside `fill` has no single DS variant: DS `destructive` is a tinted fill (`bg-destructive/10 text-destructive`), not an outline or text button. Map to `ghost` / `outline` / `link` and add `className="text-destructive"` to keep the destructive color — the plain variant silently loses it.
|
|
69
|
+
|
|
70
|
+
> `variant="link"` is underlined text styled like `Anchor`, but it renders a `<button>`. For navigation to a page use `Anchor` (see `aircall-ds/migrate-tractor/link`), not `Button variant="link"`. For an action, the blocks catch-up checklist prefers `Button variant="ghost"` (or another variant) over `variant="link"`.
|
|
61
71
|
|
|
62
72
|
## 5. Size mapping (Tractor → DS)
|
|
63
73
|
|
|
@@ -67,19 +77,41 @@ Tractor had two orthogonal props — `variant` (color role) and `mode` (fill sty
|
|
|
67
77
|
| `small` (40px) | `size="lg"` (40px) | exact |
|
|
68
78
|
| `regular` (48px, default) | `size="lg"` (40px) | −8px |
|
|
69
79
|
| `large` (56px) | `className="h-14"` | no built-in size |
|
|
70
|
-
| _(icon-only button)_ | `icon` | size-8 |
|
|
71
|
-
| _(icon-only, small)_ | `icon-sm` | size-6 |
|
|
72
|
-
| _(icon-only, large)_ | `icon-lg` | size-10 |
|
|
80
|
+
| _(icon-only button)_ | `icon` | size-8 (32px) |
|
|
81
|
+
| _(icon-only, small)_ | `icon-sm` | size-6 (24px) |
|
|
82
|
+
| _(icon-only, large)_ | `icon-lg` | size-10 (40px), icon drawn at 24px |
|
|
83
|
+
|
|
84
|
+
`sm` is 24px (`h-6`), `default` 32px (`h-8`), `lg` 40px (`h-10`).
|
|
73
85
|
|
|
74
86
|
## 6. Other prop changes
|
|
75
87
|
|
|
76
88
|
| Tractor prop | DS equivalent | Notes |
|
|
77
89
|
| --- | --- | --- |
|
|
78
|
-
| `block` | `block` | Identical — `true` makes the button full-width |
|
|
90
|
+
| `block` | `block` | Identical — `true` makes the button full-width (`w-full`) |
|
|
91
|
+
| `shape="circle"` | `className="rounded-full"` | No `shape` prop |
|
|
92
|
+
| `readOnly` | _(removed)_ | No equivalent; use `disabled` or do not render a button |
|
|
79
93
|
| `component={X}` (IconButton) | _(removed)_ | Icon becomes a JSX child instead |
|
|
80
|
-
| `isLoading` | _(removed)_ | Render your own spinner as a child |
|
|
81
|
-
| `leftIcon` / `rightIcon` | _(removed)_ | Pass the icon as a child; position is inferred from DOM order |
|
|
82
94
|
| `as` | `render` | Base UI render-prop pattern (see cross-cutting skill) |
|
|
95
|
+
| `type` (default `button`) | `type` | Same default: a Base UI native button is `type="button"`. Pass `type="submit"` explicitly |
|
|
96
|
+
| icon beside the label | child `<svg>` | Pass the icon as a child; position is inferred from DOM order. Tractor spaced the children for you, DS uses a `gap-1.5` |
|
|
97
|
+
|
|
98
|
+
**Loading state.** Neither Tractor `Button` nor DS `Button` has a loading prop. The `@dashboard/library` `LoadingButton` (`loading`, `loadingText`) becomes `disabled` plus a `Spinner` from `@aircall/ds` (`size` `sm` | `default` | `lg` | `xl`, always animated, announces itself with `role="status"`):
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
<Button disabled={loading} onClick={onSave}>
|
|
102
|
+
{loading && <Spinner size="sm" />}
|
|
103
|
+
{loading ? 'Saving…' : 'Save'}
|
|
104
|
+
</Button>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Inside an `@aircall/blocks` form, use `form.SubmitButton` instead: it reads `canSubmit` / `isSubmitting` from the form, disables itself and shows `loadingLabel` (default "Saving…"). See `aircall-blocks/migrate-dashboard/form-wizard`.
|
|
108
|
+
|
|
109
|
+
Other `@dashboard/library` button wrappers:
|
|
110
|
+
|
|
111
|
+
| `@dashboard/library` | DS |
|
|
112
|
+
| --- | --- |
|
|
113
|
+
| `AddButton` (`isLarge`) | `isLarge`: `<Button variant="outline" size="lg"><PlusCircle />Label</Button>`. Default: a small text action, `<Button variant="ghost" size="sm">+ Label</Button>` (it was `mode="link"`, `xSmall`) |
|
|
114
|
+
| `SaveButton` (`status` `unsaved` \| `saving` \| `saved`) | `unsaved`: `<Button>Save changes</Button>`; `saving`: `<Button disabled><Spinner size="sm" />…</Button>`; `saved`: `<Button variant="outline" disabled><Check />Saved</Button>`. In a blocks form prefer `form.SubmitButton` / `CardSaveBar` |
|
|
83
115
|
|
|
84
116
|
## 7. Before / After examples
|
|
85
117
|
|
|
@@ -109,11 +141,11 @@ import { Button } from '@aircall/ds';
|
|
|
109
141
|
|
|
110
142
|
**Before (Tractor):**
|
|
111
143
|
```tsx
|
|
112
|
-
import {
|
|
113
|
-
import { Button } from '@aircall/tractor';
|
|
144
|
+
import { PlayFilled } from '@aircall/icons';
|
|
145
|
+
import { Button, Icon } from '@aircall/tractor';
|
|
114
146
|
|
|
115
147
|
<Button variant="primary" size="small" onClick={onLaunch}>
|
|
116
|
-
<Icon component={
|
|
148
|
+
<Icon component={PlayFilled} size={16} />
|
|
117
149
|
Launch
|
|
118
150
|
</Button>
|
|
119
151
|
```
|
|
@@ -131,17 +163,17 @@ import { Button } from '@aircall/ds';
|
|
|
131
163
|
|
|
132
164
|
> Tractor `small` = 40px → DS `size="lg"` = 40px (exact match).
|
|
133
165
|
|
|
134
|
-
> DS sizes SVGs automatically via `[&_svg:not([class*='size-'])]:size-4
|
|
166
|
+
> DS sizes SVGs automatically via `[&_svg:not([class*='size-'])]:size-4` (`size-5` for `lg`, `size-6` for `icon-lg`). Do not pass a `size` prop to the icon.
|
|
135
167
|
|
|
136
168
|
### 7c. IconButton → icon-only Button
|
|
137
169
|
|
|
138
170
|
**Before (Tractor):**
|
|
139
171
|
```tsx
|
|
140
|
-
import {
|
|
172
|
+
import { MenuVerticalFilled } from '@aircall/icons';
|
|
141
173
|
import { IconButton } from '@aircall/tractor';
|
|
142
174
|
|
|
143
175
|
<IconButton
|
|
144
|
-
component={
|
|
176
|
+
component={MenuVerticalFilled}
|
|
145
177
|
aria-label="More actions"
|
|
146
178
|
disabled={isLoading}
|
|
147
179
|
/>
|
|
@@ -152,20 +184,22 @@ import { IconButton } from '@aircall/tractor';
|
|
|
152
184
|
import { MoreVertical } from '@aircall/react-icons';
|
|
153
185
|
import { Button } from '@aircall/ds';
|
|
154
186
|
|
|
155
|
-
<Button size="icon" aria-label="More actions" disabled={isLoading}>
|
|
187
|
+
<Button variant="ghost" size="icon" aria-label="More actions" disabled={isLoading}>
|
|
156
188
|
<MoreVertical />
|
|
157
189
|
</Button>
|
|
158
190
|
```
|
|
159
191
|
|
|
192
|
+
> `variant="ghost"` keeps the bare-icon look of Tractor's `IconButton` (a hover background on an otherwise transparent button). Icon-only buttons need an `aria-label`.
|
|
193
|
+
|
|
160
194
|
### 7d. Ghost icon-only button (mode + variant combination)
|
|
161
195
|
|
|
162
196
|
**Before (Tractor):**
|
|
163
197
|
```tsx
|
|
164
|
-
import {
|
|
165
|
-
import { Button } from '@aircall/tractor';
|
|
198
|
+
import { PauseFilled } from '@aircall/icons';
|
|
199
|
+
import { Button, Icon } from '@aircall/tractor';
|
|
166
200
|
|
|
167
201
|
<Button mode="ghost" variant="secondary" size="xSmall" aria-label="Pause">
|
|
168
|
-
<
|
|
202
|
+
<Icon component={PauseFilled} />
|
|
169
203
|
</Button>
|
|
170
204
|
```
|
|
171
205
|
|
|
@@ -179,7 +213,7 @@ import { Button } from '@aircall/ds';
|
|
|
179
213
|
</Button>
|
|
180
214
|
```
|
|
181
215
|
|
|
182
|
-
### 7e.
|
|
216
|
+
### 7e. Button rendered as a router link using `render`
|
|
183
217
|
|
|
184
218
|
**Before (Tractor):**
|
|
185
219
|
```tsx
|
|
@@ -196,24 +230,26 @@ import { Link } from 'react-router-dom';
|
|
|
196
230
|
import { Button } from '@aircall/ds';
|
|
197
231
|
import { Link } from 'react-router-dom';
|
|
198
232
|
|
|
199
|
-
<Button variant="ghost" render={<Link to="/settings" />}>
|
|
233
|
+
<Button variant="ghost" nativeButton={false} render={<Link to="/settings" />}>
|
|
200
234
|
Settings
|
|
201
235
|
</Button>
|
|
202
236
|
```
|
|
203
237
|
|
|
238
|
+
> Pass `nativeButton={false}` when `render` is not a `<button>`: Base UI otherwise logs a dev warning that the button expected a native `<button>`. It also adds `role="button"` to the rendered element, so the link is announced as a button. That is right for a link styled as a button (`DashboardPageHeaderNavBack` and `PaginationLink` do it). For a plain text link, use `Anchor` instead (`aircall-ds/migrate-tractor/link`).
|
|
239
|
+
|
|
204
240
|
## 8. Common mistakes
|
|
205
241
|
|
|
206
242
|
### Mistake 1: Keeping `mode` as a separate prop
|
|
207
243
|
|
|
208
244
|
```tsx
|
|
209
|
-
// WRONG — DS Button has no `mode` prop
|
|
245
|
+
// WRONG — DS Button has no `mode` prop (type error)
|
|
210
246
|
<Button variant="secondary" mode="outline">Cancel</Button>
|
|
211
247
|
|
|
212
248
|
// CORRECT — fold mode into variant
|
|
213
249
|
<Button variant="outline">Cancel</Button>
|
|
214
250
|
```
|
|
215
251
|
|
|
216
|
-
**Mechanism:** DS collapses Tractor's orthogonal (variant × mode) space into a single `variant`.
|
|
252
|
+
**Mechanism:** DS collapses Tractor's orthogonal (variant × mode) space into a single `variant`. If `mode` slips through it reaches the DOM as an unknown attribute and does nothing — the button renders with the `secondary` fill instead of the outline style.
|
|
217
253
|
|
|
218
254
|
`Source: packages/ds/src/components/button.tsx` — `buttonVariants` has no `mode` key.
|
|
219
255
|
|
|
@@ -233,7 +269,7 @@ import { Link } from 'react-router-dom';
|
|
|
233
269
|
</Button>
|
|
234
270
|
```
|
|
235
271
|
|
|
236
|
-
**Mechanism:** The `icon` sizes set `size-8` (width AND height), producing a square. Non-icon sizes add horizontal padding and a fixed height only — the button will be wider than it is tall, misaligning the icon visually.
|
|
272
|
+
**Mechanism:** The `icon` sizes set `size-8` (width AND height), producing a square. Non-icon sizes add horizontal padding and a fixed height only — the button will be wider than it is tall, misaligning the icon visually. The default `Button` variant is also a solid primary fill; add `variant="ghost"` when migrating a bare Tractor `IconButton`.
|
|
237
273
|
|
|
238
274
|
`Source: packages/ds/src/components/button.tsx` — `size.icon = 'size-8'`, `size.default = 'h-8 gap-1.5 px-2 …'`.
|
|
239
275
|
|
|
@@ -258,7 +294,7 @@ import { Link } from 'react-router-dom';
|
|
|
258
294
|
### Mistake 4: Passing a `size` number to the icon child
|
|
259
295
|
|
|
260
296
|
```tsx
|
|
261
|
-
// WRONG —
|
|
297
|
+
// WRONG — redundant size prop; the icon size is owned by the button
|
|
262
298
|
<Button size="lg">
|
|
263
299
|
<Play size={16} />
|
|
264
300
|
Launch
|
|
@@ -271,6 +307,6 @@ import { Link } from 'react-router-dom';
|
|
|
271
307
|
</Button>
|
|
272
308
|
```
|
|
273
309
|
|
|
274
|
-
**Mechanism:** DS applies `[&_svg:not([class*='size-'])]:size-4` (
|
|
310
|
+
**Mechanism:** DS applies `[&_svg:not([class*='size-'])]:size-4` (`size-5` for `lg`, `size-6` for `icon-lg`) to every svg without its own `size-*` class. That rule sets CSS `width`/`height`, which beats the `width`/`height` attributes an icon `size` prop produces, so the prop does nothing useful. To size one icon differently, give that icon a `size-*` class (`<Play className="size-6" />`).
|
|
275
311
|
|
|
276
|
-
`Source: packages/ds/src/components/button.tsx` — base class includes `[&_svg:not([class*='size-'])]:size-4
|
|
312
|
+
`Source: packages/ds/src/components/button.tsx` — base class includes `[&_svg:not([class*='size-'])]:size-4`; `size.lg` and `size['icon-lg']` override it.
|