@aircall/ds 0.50.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-BgeS8KWP.d.ts → data-table-B5VqWPmw.d.ts} +3 -4
- package/dist/data-table.d.ts +1 -1
- package/dist/globals.css +1 -1
- package/dist/index.d.ts +12 -9
- package/dist/index.js +11 -8
- 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
|
@@ -12,26 +12,29 @@ requires:
|
|
|
12
12
|
- aircall-ds/migrate-tractor
|
|
13
13
|
sources:
|
|
14
14
|
- "aircall/hydra:docs/migration-guides/tractor-to-ds/recipes/item.md"
|
|
15
|
+
- "aircall/hydra:packages/ds/src/components/item.tsx"
|
|
16
|
+
- "aircall/hydra:packages/ds/src/stories/Item.stories.tsx"
|
|
15
17
|
---
|
|
16
18
|
|
|
17
19
|
This skill builds on aircall-ds/migrate-tractor.
|
|
18
20
|
|
|
19
21
|
## 1. Component mapping
|
|
20
22
|
|
|
21
|
-
Tractor's `Menu`/`MenuItem` and `List`/`ListItem` are two separate component families. DS collapses them into a single `Item` family. Use `DropdownMenu` instead if the list lives inside a popover/context-menu trigger.
|
|
23
|
+
Tractor's `Menu`/`MenuItem` and `List`/`ListItem` are two separate component families. DS collapses them into a single `Item` family. Use `DropdownMenu` instead if the list lives inside a popover/context-menu trigger. `Item` has no selection state: Tractor `Menu` `selectionMode` / `selectedKeys` / `itemKey` / `onItemSelected` have no `Item` equivalent. For a selectable popover list use `DropdownMenu` (checkbox / radio items, see `@aircall/ds#aircall-ds/migrate-tractor/dropdown-menu`); for an inline single choice use `RadioGroup` or `Select`.
|
|
22
24
|
|
|
23
25
|
| Tractor | @aircall/ds | Notes |
|
|
24
26
|
| --- | --- | --- |
|
|
25
|
-
| `<Menu>` / `<List>` | `<ItemGroup>` | Wrapper; manages layout and stacking |
|
|
26
|
-
| `<
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
27
|
+
| `<Menu>` / `<List>` (+ `<ListView>`) | `<ItemGroup>` | Wrapper; manages layout and stacking. Tractor `bordered` / the `List` border → `stackedItems` + `variant="outline"` items (see below). `ListView` `maxH` scroll → wrap in `ScrollArea` |
|
|
28
|
+
| `<ListFooter>` | sibling element below `ItemGroup` | No DS slot |
|
|
29
|
+
| `<MenuItem>` / `<ListItem>` | `<Item>` | Single row; supports `variant` and `size`. Tractor `MenuItem` `disabled` / `readOnly` / `onClick` have no `Item` props: `onClick` goes straight on `Item` (or use `render` to make it an `<a>` / `<button>`) |
|
|
30
|
+
| `<MenuItemPrefix>` (icon) / avatar | `<ItemMedia variant="icon">` for an icon; a DS `Avatar` placed directly in `Item` for a person | `variant="image"` is for a square `<img>` thumbnail, not for avatars |
|
|
31
|
+
| `<MenuItemLabel>` / primary text | `<ItemTitle>` | Inside `<ItemContent>` |
|
|
32
|
+
| `<MenuItemDescription>` / secondary text | `<ItemDescription>` | Inside `<ItemContent>`, renders as `<p>` |
|
|
30
33
|
| Text content wrapper | `<ItemContent>` | Grows to fill; direct parent of Title + Description |
|
|
31
|
-
|
|
|
34
|
+
| `<MenuItemSuffix>` / right slot (buttons, switches, badges) | `<ItemActions>` | Flex row, shrinks to content |
|
|
32
35
|
| — | `<ItemHeader>` | Full-width row spanning the top of the item (optional) |
|
|
33
36
|
| — | `<ItemFooter>` | Full-width row spanning the bottom of the item (optional) |
|
|
34
|
-
|
|
|
37
|
+
| `<MenuItemGroup divider>` | `<ItemSeparator>` between items | Horizontal rule (`my-2`) for a non-stacked `ItemGroup`; unnecessary inside `stackedItems` |
|
|
35
38
|
|
|
36
39
|
## 2. Imports
|
|
37
40
|
|
|
@@ -53,7 +56,7 @@ import {
|
|
|
53
56
|
For icons, import from `@aircall/react-icons` — never from `lucide-react` directly:
|
|
54
57
|
|
|
55
58
|
```tsx
|
|
56
|
-
import {
|
|
59
|
+
import { PhoneCall } from '@aircall/react-icons';
|
|
57
60
|
```
|
|
58
61
|
|
|
59
62
|
## 3. Key props
|
|
@@ -62,7 +65,7 @@ import { PhoneCallFill } from '@aircall/react-icons';
|
|
|
62
65
|
|
|
63
66
|
| Prop | Type | Default | Effect |
|
|
64
67
|
| --- | --- | --- | --- |
|
|
65
|
-
| `stackedItems` | `boolean` | `false` |
|
|
68
|
+
| `stackedItems` | `boolean` | `false` | Collapses the items into one stack: no gap between rows, adjoining borders and radii merged. Without it, rows are spaced apart (`gap-4`; `gap-2.5` for `sm`, `gap-2` for `xs`). The border/background come from the items (`variant="outline"` or `muted`), not from the group |
|
|
66
69
|
|
|
67
70
|
### Item
|
|
68
71
|
|
|
@@ -72,35 +75,36 @@ import { PhoneCallFill } from '@aircall/react-icons';
|
|
|
72
75
|
| `size` | `xs` \| `sm` \| `default` | `default` |
|
|
73
76
|
| `render` | Base UI render element | — |
|
|
74
77
|
|
|
75
|
-
`size="xs"` is the dropdown-menu density. `variant="outline"` adds a visible border
|
|
78
|
+
`size="xs"` is the dropdown-menu density. `variant="outline"` adds a visible border and an opaque `bg-background`. `variant="muted"` adds a tinted background (`bg-muted/50`). `default` is transparent and borderless (flush inline rows).
|
|
76
79
|
|
|
77
80
|
### ItemMedia
|
|
78
81
|
|
|
79
82
|
| Prop | Values | Default | Effect |
|
|
80
83
|
| --- | --- | --- | --- |
|
|
81
|
-
| `variant` | `default` \| `icon` \| `image` | `default` | `icon` auto-sizes SVGs to 16 px; `image` gives a square slot (40 px
|
|
84
|
+
| `variant` | `default` \| `icon` \| `image` | `default` | `default` is a plain transparent slot (an inline icon or an `Avatar` you size yourself); `icon` only auto-sizes child SVGs to 16 px (no box is drawn); `image` gives a square clipped slot (40 px; 32 px in `size="sm"`, 24 px in `size="xs"`) with `rounded-sm` and `[&_img]:size-full object-cover`, for `<img>` thumbnails |
|
|
82
85
|
|
|
83
86
|
## 4. Before / After examples
|
|
84
87
|
|
|
85
|
-
### Settings row (Tractor `Menu` with a
|
|
88
|
+
### Settings row (Tractor `Menu` with a `Toggle`)
|
|
86
89
|
|
|
87
90
|
```tsx
|
|
88
91
|
// Before
|
|
89
|
-
import { Menu, MenuItem } from '@aircall/tractor';
|
|
92
|
+
import { Menu, MenuItem, MenuItemDescription, MenuItemLabel, MenuItemSuffix, Toggle } from '@aircall/tractor';
|
|
90
93
|
|
|
91
94
|
<Menu>
|
|
92
|
-
<MenuItem
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
95
|
+
<MenuItem>
|
|
96
|
+
<MenuItemLabel>Enable notifications</MenuItemLabel>
|
|
97
|
+
<MenuItemDescription>Get a desktop alert for incoming calls.</MenuItemDescription>
|
|
98
|
+
<MenuItemSuffix>
|
|
99
|
+
<Toggle checked={enabled} onChange={setEnabled} />
|
|
100
|
+
</MenuItemSuffix>
|
|
101
|
+
</MenuItem>
|
|
97
102
|
</Menu>
|
|
98
103
|
```
|
|
99
104
|
|
|
100
105
|
```tsx
|
|
101
106
|
// After
|
|
102
|
-
import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemTitle } from '@aircall/ds';
|
|
103
|
-
import { Switch } from '@aircall/ds';
|
|
107
|
+
import { Item, ItemActions, ItemContent, ItemDescription, ItemGroup, ItemTitle, Switch } from '@aircall/ds';
|
|
104
108
|
|
|
105
109
|
<ItemGroup>
|
|
106
110
|
<Item>
|
|
@@ -119,20 +123,31 @@ import { Switch } from '@aircall/ds';
|
|
|
119
123
|
|
|
120
124
|
```tsx
|
|
121
125
|
// Before
|
|
122
|
-
import { List, ListItem } from '@aircall/tractor';
|
|
123
|
-
|
|
124
|
-
<List>
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
key={c.id}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
126
|
+
import { Avatar, AvatarImg, Flex, List, ListItem, ListView, Typography } from '@aircall/tractor';
|
|
127
|
+
|
|
128
|
+
<List fluid>
|
|
129
|
+
<ListView>
|
|
130
|
+
{contacts.map(c => (
|
|
131
|
+
<ListItem key={c.id}>
|
|
132
|
+
<Flex alignItems="center" gap="xs" p="xs">
|
|
133
|
+
<Avatar>
|
|
134
|
+
<AvatarImg src={c.avatar} />
|
|
135
|
+
</Avatar>
|
|
136
|
+
<Flex flexDirection="column">
|
|
137
|
+
<Typography variant="bodyMediumS">{c.name}</Typography>
|
|
138
|
+
<Typography variant="supportingRegularS" color="text-secondary">
|
|
139
|
+
{c.lastMessage}
|
|
140
|
+
</Typography>
|
|
141
|
+
</Flex>
|
|
142
|
+
</Flex>
|
|
143
|
+
</ListItem>
|
|
144
|
+
))}
|
|
145
|
+
</ListView>
|
|
133
146
|
</List>
|
|
134
147
|
```
|
|
135
148
|
|
|
149
|
+
Tractor's `ListItem` only renders its `children` in an `<li>`; the `avatar` / `primaryText` / `secondaryText` / `dropdownOptions` props belong to `@dashboard/library`'s `ListItem` (see `@aircall/blocks#aircall-blocks/migrate-dashboard/list`).
|
|
150
|
+
|
|
136
151
|
```tsx
|
|
137
152
|
// After
|
|
138
153
|
import {
|
|
@@ -145,27 +160,24 @@ import {
|
|
|
145
160
|
ItemContent,
|
|
146
161
|
ItemDescription,
|
|
147
162
|
ItemGroup,
|
|
148
|
-
ItemMedia,
|
|
149
163
|
ItemTitle
|
|
150
164
|
} from '@aircall/ds';
|
|
151
|
-
import {
|
|
165
|
+
import { PhoneCall } from '@aircall/react-icons';
|
|
152
166
|
|
|
153
167
|
<ItemGroup>
|
|
154
168
|
{contacts.map(c => (
|
|
155
169
|
<Item key={c.id}>
|
|
156
|
-
<
|
|
157
|
-
<
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
</Avatar>
|
|
161
|
-
</ItemMedia>
|
|
170
|
+
<Avatar>
|
|
171
|
+
<AvatarImage src={c.avatar} alt={c.name} />
|
|
172
|
+
<AvatarFallback>{initials(c.name)}</AvatarFallback>
|
|
173
|
+
</Avatar>
|
|
162
174
|
<ItemContent>
|
|
163
175
|
<ItemTitle>{c.name}</ItemTitle>
|
|
164
176
|
<ItemDescription>{c.lastMessage}</ItemDescription>
|
|
165
177
|
</ItemContent>
|
|
166
178
|
<ItemActions>
|
|
167
|
-
<Button variant="ghost" size="icon-
|
|
168
|
-
<
|
|
179
|
+
<Button variant="ghost" size="icon" aria-label={`Call ${c.name}`}>
|
|
180
|
+
<PhoneCall />
|
|
169
181
|
</Button>
|
|
170
182
|
</ItemActions>
|
|
171
183
|
</Item>
|
|
@@ -173,6 +185,8 @@ import { PhoneCallFill } from '@aircall/react-icons';
|
|
|
173
185
|
</ItemGroup>
|
|
174
186
|
```
|
|
175
187
|
|
|
188
|
+
The Avatar sits directly in `Item` (as in the `Item` stories). Do not wrap it in `ItemMedia variant="image"`: that slot is 40 px (32 px / 24 px for `sm` / `xs`) with `overflow-hidden`, so it clips larger avatars. Add `<ItemSeparator />` between items for the `List` divider look in a non-stacked group.
|
|
189
|
+
|
|
176
190
|
### Stacked settings group with dividers
|
|
177
191
|
|
|
178
192
|
```tsx
|
|
@@ -180,13 +194,13 @@ import { PhoneCallFill } from '@aircall/react-icons';
|
|
|
180
194
|
import { Item, ItemContent, ItemDescription, ItemGroup, ItemTitle } from '@aircall/ds';
|
|
181
195
|
|
|
182
196
|
<ItemGroup stackedItems>
|
|
183
|
-
<Item>
|
|
197
|
+
<Item variant="outline">
|
|
184
198
|
<ItemContent>
|
|
185
199
|
<ItemTitle>Notifications</ItemTitle>
|
|
186
200
|
<ItemDescription>Alert on incoming calls</ItemDescription>
|
|
187
201
|
</ItemContent>
|
|
188
202
|
</Item>
|
|
189
|
-
<Item>
|
|
203
|
+
<Item variant="outline">
|
|
190
204
|
<ItemContent>
|
|
191
205
|
<ItemTitle>Do not disturb</ItemTitle>
|
|
192
206
|
<ItemDescription>Silence all alerts</ItemDescription>
|
|
@@ -195,7 +209,7 @@ import { Item, ItemContent, ItemDescription, ItemGroup, ItemTitle } from '@airca
|
|
|
195
209
|
</ItemGroup>
|
|
196
210
|
```
|
|
197
211
|
|
|
198
|
-
`stackedItems`
|
|
212
|
+
`stackedItems` removes the gap between rows and merges adjoining borders and radii (`border-t-0` / `rounded-none` on the joins). The border itself comes from the items: use `variant="outline"` (or `muted`), because `default` items have a transparent border and would show no divider at all.
|
|
199
213
|
|
|
200
214
|
## 5. Common mistakes
|
|
201
215
|
|
|
@@ -221,29 +235,36 @@ Source: `packages/ds/src/components/item.tsx` — `ItemContent` carries `flex-1
|
|
|
221
235
|
|
|
222
236
|
---
|
|
223
237
|
|
|
224
|
-
### Mistake 2:
|
|
238
|
+
### Mistake 2: Wrapping an `Avatar` in `ItemMedia variant="image"` (or `variant="icon"`)
|
|
225
239
|
|
|
226
240
|
```tsx
|
|
227
|
-
// Wrong — variant="
|
|
228
|
-
|
|
241
|
+
// Wrong — variant="image" is a fixed 40 px clipped square (overflow-hidden), so it crops the avatar;
|
|
242
|
+
// variant="icon" only auto-sizes bare SVGs and does nothing for an Avatar
|
|
243
|
+
<ItemMedia variant="image">
|
|
229
244
|
<Avatar>
|
|
230
245
|
<AvatarImage src={user.avatar} alt={user.name} />
|
|
231
246
|
<AvatarFallback>JD</AvatarFallback>
|
|
232
247
|
</Avatar>
|
|
233
248
|
</ItemMedia>
|
|
234
249
|
|
|
235
|
-
// Correct —
|
|
236
|
-
<
|
|
250
|
+
// Correct — the Avatar goes directly in Item (as in the Item stories)
|
|
251
|
+
<Item>
|
|
237
252
|
<Avatar>
|
|
238
253
|
<AvatarImage src={user.avatar} alt={user.name} />
|
|
239
254
|
<AvatarFallback>JD</AvatarFallback>
|
|
240
255
|
</Avatar>
|
|
256
|
+
<ItemContent>…</ItemContent>
|
|
257
|
+
</Item>
|
|
258
|
+
|
|
259
|
+
// Correct — ItemMedia variant="image" is for a plain <img> thumbnail
|
|
260
|
+
<ItemMedia variant="image">
|
|
261
|
+
<img src={album.cover} alt="" />
|
|
241
262
|
</ItemMedia>
|
|
242
263
|
```
|
|
243
264
|
|
|
244
|
-
`
|
|
265
|
+
`itemMediaVariants` in `item.tsx`: `icon` is `[&_svg:not([class*='size-'])]:size-4` (16 px SVGs, no container sizing); `image` is `size-10 overflow-hidden rounded-sm` (`size-8` in `size="sm"`, `size-6` in `size="xs"`) with `[&_img]:size-full [&_img]:object-cover`. Use `variant="icon"` for a leading icon, `variant="image"` for a square `<img>`, and no `ItemMedia` at all for an `Avatar`.
|
|
245
266
|
|
|
246
|
-
Source: `packages/ds/src/components/item.tsx` — `itemMediaVariants`
|
|
267
|
+
Source: `packages/ds/src/components/item.tsx` — `itemMediaVariants`; `packages/ds/src/stories/Item.stories.tsx` — `MediaVariants` ("Avatar Media") and `Examples` ("Contact List").
|
|
247
268
|
|
|
248
269
|
---
|
|
249
270
|
|
|
@@ -258,40 +279,41 @@ Source: `packages/ds/src/components/item.tsx` — `itemMediaVariants` defines `i
|
|
|
258
279
|
|
|
259
280
|
// Correct — use DropdownMenu for popover menus triggered by a button
|
|
260
281
|
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, Button } from '@aircall/ds';
|
|
282
|
+
import { MoreVertical } from '@aircall/react-icons';
|
|
261
283
|
|
|
262
284
|
<DropdownMenu>
|
|
263
|
-
<DropdownMenuTrigger render={<Button variant="ghost" size="icon" />}>
|
|
285
|
+
<DropdownMenuTrigger render={<Button variant="ghost" size="icon" aria-label="Actions" />}>
|
|
264
286
|
<MoreVertical />
|
|
265
287
|
</DropdownMenuTrigger>
|
|
266
288
|
<DropdownMenuContent>
|
|
267
|
-
<DropdownMenuItem
|
|
268
|
-
<DropdownMenuItem
|
|
289
|
+
<DropdownMenuItem onClick={onEdit}>Edit</DropdownMenuItem>
|
|
290
|
+
<DropdownMenuItem onClick={onDelete}>Delete</DropdownMenuItem>
|
|
269
291
|
</DropdownMenuContent>
|
|
270
292
|
</DropdownMenu>
|
|
271
293
|
```
|
|
272
294
|
|
|
273
|
-
`ItemGroup`/`Item` is a layout primitive with `role="list"` — it has no focus trap, keyboard navigation, or popover positioning. Tractor's `Menu` was sometimes used for both inline lists and popover menus; DS splits these concerns into `Item` (inline) and `DropdownMenu` (popover).
|
|
295
|
+
`ItemGroup`/`Item` is a layout primitive with `role="list"` — it has no focus trap, keyboard navigation, or popover positioning. Tractor's `Menu` was sometimes used for both inline lists and popover menus; DS splits these concerns into `Item` (inline) and `DropdownMenu` (popover). `DropdownMenuItem` is a Base UI `Menu.Item`: handle activation with `onClick` (there is no `onSelect`).
|
|
274
296
|
|
|
275
|
-
Source: `packages/ds/src/components/item.tsx` — `ItemGroup` renders a `<div role="list">` with no floating/portal behavior.
|
|
297
|
+
Source: `packages/ds/src/components/item.tsx` — `ItemGroup` renders a `<div role="list">` with no floating/portal behavior; `packages/ds/src/components/dropdown-menu.tsx` — `DropdownMenuItem` wraps `MenuPrimitive.Item`.
|
|
276
298
|
|
|
277
299
|
---
|
|
278
300
|
|
|
279
301
|
### Mistake 4: Omitting `stackedItems` and expecting automatic borders between items
|
|
280
302
|
|
|
281
303
|
```tsx
|
|
282
|
-
// Wrong — without stackedItems, items are
|
|
304
|
+
// Wrong — without stackedItems, outlined items are separate bordered cards with a gap
|
|
283
305
|
<ItemGroup>
|
|
284
306
|
<Item variant="outline">Row A</Item>
|
|
285
307
|
<Item variant="outline">Row B</Item>
|
|
286
308
|
</ItemGroup>
|
|
287
309
|
|
|
288
|
-
// Correct —
|
|
310
|
+
// Correct — stackedItems merges the outlined rows into one stack with shared inner borders
|
|
289
311
|
<ItemGroup stackedItems>
|
|
290
|
-
<Item>Row A</Item>
|
|
291
|
-
<Item>Row B</Item>
|
|
312
|
+
<Item variant="outline">Row A</Item>
|
|
313
|
+
<Item variant="outline">Row B</Item>
|
|
292
314
|
</ItemGroup>
|
|
293
315
|
```
|
|
294
316
|
|
|
295
|
-
Without `stackedItems`, `ItemGroup` uses `gap-4` (or `gap-2.5` / `gap-2` for smaller sizes) between items. The `stackedItems` prop removes the gap and applies CSS sibling selectors that collapse adjacent borders into a single shared edge, producing a classic settings-panel appearance.
|
|
317
|
+
Without `stackedItems`, `ItemGroup` uses `gap-4` (or `gap-2.5` / `gap-2` for smaller sizes) between items. The `stackedItems` prop removes the gap and applies CSS sibling selectors (`border-t-0`, `rounded-t-none` / `rounded-b-none` on the joins) that collapse adjacent borders into a single shared edge, producing a classic settings-panel appearance. The group itself draws nothing, so the items must carry the border: `variant="default"` rows are borderless and show no divider even when stacked.
|
|
296
318
|
|
|
297
|
-
Source: `packages/ds/src/components/item.tsx` — `ItemGroup` applies `stackedItems` via `data-stacked` and sibling border-collapse selectors.
|
|
319
|
+
Source: `packages/ds/src/components/item.tsx` — `ItemGroup` applies `stackedItems` via `data-stacked` and sibling border-collapse selectors; `packages/ds/src/stories/Item.stories.tsx` — `StackedItems`.
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: aircall-ds/migrate-tractor/link
|
|
3
3
|
description: >
|
|
4
|
-
Migrate Tractor Link (from @aircall/tractor Typography family) to @aircall/ds
|
|
5
|
-
|
|
6
|
-
Link from @aircall/tractor.
|
|
4
|
+
Migrate Tractor Link (from @aircall/tractor Typography family) to the @aircall/ds
|
|
5
|
+
Anchor. Anchor is the text link for navigation; a click-only Link becomes a
|
|
6
|
+
Button (ghost). Load when a file imports Link from @aircall/tractor.
|
|
7
7
|
type: sub-skill
|
|
8
8
|
library: aircall-ds
|
|
9
9
|
requires:
|
|
10
10
|
- aircall-ds/setup
|
|
11
11
|
- aircall-ds/migrate-tractor
|
|
12
12
|
sources:
|
|
13
|
+
- "aircall/hydra:packages/ds/src/components/anchor.tsx"
|
|
14
|
+
- "aircall/hydra:packages/ds/src/stories/Anchor.stories.tsx"
|
|
13
15
|
- "aircall/hydra:packages/ds/src/components/button.tsx"
|
|
14
16
|
---
|
|
15
17
|
|
|
@@ -17,29 +19,41 @@ This skill builds on aircall-ds/migrate-tractor. Apply all cross-cutting rules f
|
|
|
17
19
|
|
|
18
20
|
## 1. Key premise
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
Tractor's `Link` (from `Typography/Link.tsx`) was a styled inline `<a>` built on `Typography`: `bodyMediumS`, primary colour, underline on hover. The DS equivalent is **`Anchor`**, which renders an `<a>` styled as a text link (primary colour, underlined, `font-medium`). It takes the size of the surrounding text, so it needs no `size` or `variant` prop.
|
|
23
|
+
|
|
24
|
+
`@aircall/ds` has no component called `Link`. Pick by what the Tractor link did:
|
|
25
|
+
|
|
26
|
+
| Tractor `Link` does | DS |
|
|
27
|
+
| --- | --- |
|
|
28
|
+
| Navigates (`href`, router `to`) | `Anchor` |
|
|
29
|
+
| Triggers an action (`onClick` only, no destination) | `Button variant="ghost"` (renders a `<button>`) |
|
|
30
|
+
|
|
31
|
+
`Anchor` JSDoc: "Use instead of `<Button variant="link" render={<a>}>` for any navigational action." Do not build a navigation link out of `Button`. The `@aircall/blocks` catch-up checklist (`Links & navigation`) agrees: `Anchor` for navigation, `Button variant="ghost"` (or another variant) for an action, and `Button variant="link"` is the pattern to move away from. `variant="link"` still exists on `Button` (underlined primary text); use it only where the underlined look must be kept for an action.
|
|
21
32
|
|
|
22
33
|
## 2. Component mapping
|
|
23
34
|
|
|
24
35
|
| Tractor | @aircall/ds | Notes |
|
|
25
36
|
| --- | --- | --- |
|
|
26
|
-
| `<Link href="…">text</Link>` | `<
|
|
27
|
-
| `<Link href="…" target="_blank">` | `<
|
|
28
|
-
| `<Link as={RouterLink} to="…">` | `<
|
|
29
|
-
| `<Link onClick={fn}>text</Link>` | `<Button variant="
|
|
37
|
+
| `<Link href="…">text</Link>` | `<Anchor href="…">text</Anchor>` | Real `<a>`, `href` is a direct prop |
|
|
38
|
+
| `<Link href="…" target="_blank" rel="noreferrer">` | `<Anchor href="…" target="_blank" rel="noopener noreferrer">` | `target` / `rel` are direct props; keep `rel` on `_blank` |
|
|
39
|
+
| `<Link as={RouterLink} to="…">` | `<Anchor render={<RouterLink to="…" />}>` | Router links use `render`, not `as` |
|
|
40
|
+
| `<Link onClick={fn}>text</Link>` (no href) | `<Button variant="ghost" onClick={fn}>text</Button>` | Click-only: a `<button>` is the right element |
|
|
30
41
|
|
|
31
42
|
## 3. Verified DS exports (`packages/ds/src/index.ts`)
|
|
32
43
|
|
|
33
44
|
```
|
|
45
|
+
Anchor, anchorVariants
|
|
34
46
|
Button, buttonVariants
|
|
35
47
|
```
|
|
36
48
|
|
|
49
|
+
`Anchor` renders an `<a>` and sets `data-slot="anchor"`.
|
|
50
|
+
|
|
37
51
|
There is no `Link` export. `PaginationLink` exists but is scoped to the Pagination compound and must not be used here.
|
|
38
52
|
|
|
39
53
|
## 4. Imports
|
|
40
54
|
|
|
41
55
|
```tsx
|
|
42
|
-
import { Button } from '@aircall/ds';
|
|
56
|
+
import { Anchor, Button } from '@aircall/ds';
|
|
43
57
|
```
|
|
44
58
|
|
|
45
59
|
Icons (if needed alongside a link):
|
|
@@ -54,15 +68,13 @@ Never import icons from `lucide-react` directly — always use `@aircall/react-i
|
|
|
54
68
|
|
|
55
69
|
| Tractor `Link` prop | DS equivalent | Notes |
|
|
56
70
|
| --- | --- | --- |
|
|
57
|
-
| `href` |
|
|
58
|
-
| `
|
|
59
|
-
| `
|
|
60
|
-
| `
|
|
61
|
-
| `
|
|
62
|
-
| `
|
|
63
|
-
| `
|
|
64
|
-
| `ellipsis` | `className="truncate"` | Tailwind utility; wrap in a sized container |
|
|
65
|
-
| `disabled` | `disabled` | Direct prop, unchanged |
|
|
71
|
+
| `href`, `target`, `rel` | Same props on `Anchor` | `Anchor` is an `<a>`; all anchor attributes pass through |
|
|
72
|
+
| `as={RouterLink}` + `to` | `render={<RouterLink to="…" />}` | Base UI render-prop pattern; the DS styles land on the element you pass |
|
|
73
|
+
| `onClick` | `onClick` | Direct prop |
|
|
74
|
+
| `variant` (Typography) | _(removed)_ | Text size comes from the parent (`text-sm`, `text-base`…); override with `className` |
|
|
75
|
+
| Typography props (`color`, `fontWeight`, `m`, `p`…) | `className` | Tailwind utilities |
|
|
76
|
+
| `ellipsis` | `<Anchor className="max-w-48" …><span className="truncate">{text}</span></Anchor>` | `Anchor` is `inline-flex`, and `text-overflow` does not apply to the text of a flex container, so put `truncate` on a child `<span>` and cap the width of the `Anchor` |
|
|
77
|
+
| `disabled` | `aria-disabled="true"` | An `<a>` has no `disabled` attribute. `Anchor` styles `aria-disabled` (50% opacity, no pointer events) |
|
|
66
78
|
|
|
67
79
|
## 6. Before / After examples
|
|
68
80
|
|
|
@@ -77,11 +89,9 @@ import { Link } from '@aircall/tractor';
|
|
|
77
89
|
|
|
78
90
|
**After (DS):**
|
|
79
91
|
```tsx
|
|
80
|
-
import {
|
|
92
|
+
import { Anchor } from '@aircall/ds';
|
|
81
93
|
|
|
82
|
-
<
|
|
83
|
-
Read the docs
|
|
84
|
-
</Button>
|
|
94
|
+
<Anchor href="https://aircall.io/docs">Read the docs</Anchor>
|
|
85
95
|
```
|
|
86
96
|
|
|
87
97
|
### 6b. External link (new tab)
|
|
@@ -97,11 +107,11 @@ import { Link } from '@aircall/tractor';
|
|
|
97
107
|
|
|
98
108
|
**After (DS):**
|
|
99
109
|
```tsx
|
|
100
|
-
import {
|
|
110
|
+
import { Anchor } from '@aircall/ds';
|
|
101
111
|
|
|
102
|
-
<
|
|
112
|
+
<Anchor href="https://aircall.io" target="_blank" rel="noopener noreferrer">
|
|
103
113
|
Open Aircall
|
|
104
|
-
</
|
|
114
|
+
</Anchor>
|
|
105
115
|
```
|
|
106
116
|
|
|
107
117
|
### 6c. React Router link
|
|
@@ -118,12 +128,12 @@ import { Link as RouterLink } from 'react-router-dom';
|
|
|
118
128
|
|
|
119
129
|
**After (DS):**
|
|
120
130
|
```tsx
|
|
121
|
-
import {
|
|
131
|
+
import { Anchor } from '@aircall/ds';
|
|
122
132
|
import { Link as RouterLink } from 'react-router-dom';
|
|
123
133
|
|
|
124
|
-
<
|
|
134
|
+
<Anchor render={<RouterLink to="/settings" />}>
|
|
125
135
|
Settings
|
|
126
|
-
</
|
|
136
|
+
</Anchor>
|
|
127
137
|
```
|
|
128
138
|
|
|
129
139
|
### 6d. Click-only inline action (no navigation)
|
|
@@ -139,10 +149,10 @@ import { Link } from '@aircall/tractor';
|
|
|
139
149
|
```tsx
|
|
140
150
|
import { Button } from '@aircall/ds';
|
|
141
151
|
|
|
142
|
-
<Button variant="
|
|
152
|
+
<Button variant="ghost" onClick={handleRetry}>Retry</Button>
|
|
143
153
|
```
|
|
144
154
|
|
|
145
|
-
> No `render`
|
|
155
|
+
> No `render` and no `Anchor` here: there is no navigation target, so the default `<button>` is the correct element. If the underlined text look must stay, `variant="link"` is the same underlined primary text, at the button's height (`h-8`) and padding (`px-2`).
|
|
146
156
|
|
|
147
157
|
### 6e. Link with trailing icon
|
|
148
158
|
|
|
@@ -158,15 +168,28 @@ import { ExternalLink } from '@aircall/react-icons';
|
|
|
158
168
|
|
|
159
169
|
**After (DS):**
|
|
160
170
|
```tsx
|
|
161
|
-
import {
|
|
171
|
+
import { Anchor } from '@aircall/ds';
|
|
162
172
|
import { ExternalLink } from '@aircall/react-icons';
|
|
163
173
|
|
|
164
|
-
<
|
|
165
|
-
Docs
|
|
166
|
-
|
|
174
|
+
<Anchor href="https://aircall.io/docs" target="_blank" rel="noopener noreferrer">
|
|
175
|
+
Docs
|
|
176
|
+
<ExternalLink />
|
|
177
|
+
</Anchor>
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
> Drop the `size` prop from the icon: `Anchor` sizes icons at `1em` (the current text size) and spaces them with `gap-1.5`. Do not add a `{' '}` between the text and the icon.
|
|
181
|
+
|
|
182
|
+
### 6f. Link inside a sentence
|
|
183
|
+
|
|
184
|
+
```tsx
|
|
185
|
+
import { Anchor } from '@aircall/ds';
|
|
186
|
+
|
|
187
|
+
<p className="text-sm text-muted-foreground">
|
|
188
|
+
Read our <Anchor href="/privacy">privacy policy</Anchor> for details.
|
|
189
|
+
</p>
|
|
167
190
|
```
|
|
168
191
|
|
|
169
|
-
>
|
|
192
|
+
> `Anchor` has no size prop. It follows the text size of its parent, so the link in the sentence above is `text-sm` too.
|
|
170
193
|
|
|
171
194
|
## 7. Common mistakes
|
|
172
195
|
|
|
@@ -180,83 +203,77 @@ import { Link } from '@aircall/ds';
|
|
|
180
203
|
```
|
|
181
204
|
|
|
182
205
|
```tsx
|
|
183
|
-
// CORRECT — use
|
|
184
|
-
import {
|
|
206
|
+
// CORRECT — use Anchor
|
|
207
|
+
import { Anchor } from '@aircall/ds';
|
|
185
208
|
|
|
186
|
-
<
|
|
209
|
+
<Anchor href="/settings">Settings</Anchor>
|
|
187
210
|
```
|
|
188
211
|
|
|
189
|
-
`@aircall/ds` exports `PaginationLink` but not a general `Link`. Importing `Link` from `@aircall/ds`
|
|
212
|
+
`@aircall/ds` exports `PaginationLink` and `Anchor` but not a general `Link`. Importing `Link` from `@aircall/ds` is a TypeScript named-export error at compile time and `undefined` at runtime.
|
|
190
213
|
|
|
191
|
-
`Source: packages/ds/src/index.ts` — only `PaginationLink` exists; no standalone `Link`.
|
|
214
|
+
`Source: packages/ds/src/index.ts` — exports `Anchor`; only `PaginationLink` exists besides it; no standalone `Link`.
|
|
192
215
|
|
|
193
216
|
---
|
|
194
217
|
|
|
195
|
-
### Mistake 2:
|
|
218
|
+
### Mistake 2: Using `Button` (any variant) for navigation
|
|
196
219
|
|
|
197
220
|
```tsx
|
|
198
|
-
// WRONG — Button has no href prop
|
|
199
|
-
// that ignores it, breaking navigation entirely
|
|
221
|
+
// WRONG — Button has no href prop, and a <button> is not a link
|
|
200
222
|
import { Button } from '@aircall/ds';
|
|
201
223
|
|
|
202
224
|
<Button variant="link" href="/settings">Settings</Button>
|
|
225
|
+
<Button variant="link" render={<a href="/settings" />}>Settings</Button>
|
|
203
226
|
```
|
|
204
227
|
|
|
205
228
|
```tsx
|
|
206
|
-
// CORRECT —
|
|
207
|
-
import {
|
|
229
|
+
// CORRECT — Anchor is an <a>
|
|
230
|
+
import { Anchor } from '@aircall/ds';
|
|
208
231
|
|
|
209
|
-
<
|
|
232
|
+
<Anchor href="/settings">Settings</Anchor>
|
|
210
233
|
```
|
|
211
234
|
|
|
212
|
-
`Button` wraps Base UI's `ButtonPrimitive`, which renders a `<button
|
|
235
|
+
`Button` wraps Base UI's `ButtonPrimitive`, which renders a `<button>`; `href` is not part of its props. A `<button>` cannot be middle-clicked to open in a new tab and has no `link` role. `Anchor` renders an `<a>`, so navigation, middle-click and the browser's link menu all work.
|
|
213
236
|
|
|
214
|
-
`Source: packages/ds/src/components/button.tsx` — `Button` extends `ButtonPrimitive.Props
|
|
237
|
+
`Source: packages/ds/src/components/anchor.tsx` — `useRender({ defaultTagName: 'a' })`; `packages/ds/src/components/button.tsx` — `Button` extends `ButtonPrimitive.Props`, no `href`.
|
|
215
238
|
|
|
216
239
|
---
|
|
217
240
|
|
|
218
241
|
### Mistake 3: Using `as` instead of `render` for router links
|
|
219
242
|
|
|
220
243
|
```tsx
|
|
221
|
-
// WRONG — DS
|
|
222
|
-
import {
|
|
244
|
+
// WRONG — DS components are built on Base UI, not Radix; there is no `as` prop
|
|
245
|
+
import { Anchor } from '@aircall/ds';
|
|
223
246
|
import { Link as RouterLink } from 'react-router-dom';
|
|
224
247
|
|
|
225
|
-
<
|
|
248
|
+
<Anchor as={RouterLink} to="/settings">Settings</Anchor>
|
|
226
249
|
```
|
|
227
250
|
|
|
228
251
|
```tsx
|
|
229
252
|
// CORRECT — Base UI uses the render prop; pass router-specific props on the element
|
|
230
|
-
import {
|
|
253
|
+
import { Anchor } from '@aircall/ds';
|
|
231
254
|
import { Link as RouterLink } from 'react-router-dom';
|
|
232
255
|
|
|
233
|
-
<
|
|
256
|
+
<Anchor render={<RouterLink to="/settings" />}>Settings</Anchor>
|
|
234
257
|
```
|
|
235
258
|
|
|
236
|
-
Base UI replaced Radix UI in `@aircall/ds`. The `asChild
|
|
259
|
+
Base UI replaced Radix UI in `@aircall/ds`. The `asChild` / `as` pattern is gone. The `render` prop accepts a JSX element, and the DS classes are merged onto it — all element-specific props (`to`, `href`) go on that element.
|
|
237
260
|
|
|
238
|
-
`Source: packages/ds/src/components/
|
|
261
|
+
`Source: packages/ds/src/components/anchor.tsx` — `AnchorProps` extends `useRender.ComponentProps<'a'>`; `packages/ds/src/stories/Anchor.stories.tsx` — `RouterLink` story.
|
|
239
262
|
|
|
240
263
|
---
|
|
241
264
|
|
|
242
|
-
### Mistake 4:
|
|
265
|
+
### Mistake 4: Using `disabled` on a link
|
|
243
266
|
|
|
244
267
|
```tsx
|
|
245
|
-
// WRONG —
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
<Button variant="link">Read the docs</Button>
|
|
268
|
+
// WRONG — <a> has no `disabled` attribute; it is ignored and the link stays clickable
|
|
269
|
+
<Anchor href="/billing" disabled>Billing</Anchor>
|
|
249
270
|
```
|
|
250
271
|
|
|
251
272
|
```tsx
|
|
252
|
-
// CORRECT —
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
<Button variant="link" render={<a href="https://aircall.io/docs" />}>
|
|
256
|
-
Read the docs
|
|
257
|
-
</Button>
|
|
273
|
+
// CORRECT — Anchor styles aria-disabled
|
|
274
|
+
<Anchor href="/billing" aria-disabled="true">Billing</Anchor>
|
|
258
275
|
```
|
|
259
276
|
|
|
260
|
-
|
|
277
|
+
`anchorVariants` includes `aria-disabled:pointer-events-none aria-disabled:opacity-50`. `disabled` is not a valid prop of an `<a>`. Also drop the `href` if the link must not be reachable by keyboard.
|
|
261
278
|
|
|
262
|
-
`Source: packages/ds/src/components/
|
|
279
|
+
`Source: packages/ds/src/components/anchor.tsx` — `aria-disabled:pointer-events-none aria-disabled:opacity-50`.
|