@aircall/ds 0.50.0 → 0.51.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/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 +20 -12
- package/dist/index.js +14 -10
- 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
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: aircall-ds/migrate-tractor/dropdown-menu
|
|
3
3
|
description: >
|
|
4
|
-
Migrate Tractor Dropdown and ActionMenu to the
|
|
5
|
-
Load when a file imports Dropdown,
|
|
6
|
-
Covers trigger render prop,
|
|
4
|
+
Migrate Tractor Dropdown (+ DropdownButton, Menu, MenuItem) and ActionMenu to the
|
|
5
|
+
@aircall/ds DropdownMenu compound. Load when a file imports Dropdown, DropdownButton or
|
|
6
|
+
ActionMenu from @aircall/tractor. Covers the trigger render prop, items array to
|
|
7
|
+
DropdownMenuItem, destructive item variant, icon placement, selectable items, and the
|
|
8
|
+
Group-wraps-Label rule.
|
|
7
9
|
type: sub-skill
|
|
8
10
|
library: aircall-ds
|
|
9
11
|
requires:
|
|
@@ -11,34 +13,41 @@ requires:
|
|
|
11
13
|
- aircall-ds/migrate-tractor
|
|
12
14
|
sources:
|
|
13
15
|
- "aircall/hydra:docs/migration-guides/tractor-to-ds/recipes/dropdown-menu.md"
|
|
16
|
+
- "aircall/hydra:packages/ds/src/components/dropdown-menu.tsx"
|
|
17
|
+
- "aircall/hydra:packages/ds/src/stories/DropdownMenu.stories.tsx"
|
|
14
18
|
---
|
|
15
19
|
|
|
16
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 dropdown-menu-specific steps below.
|
|
17
21
|
|
|
18
22
|
## 1. Component mapping
|
|
19
23
|
|
|
20
|
-
Tractor `Dropdown` (labelled
|
|
24
|
+
Tractor has two ways in. `Dropdown` takes a `trigger` element prop and any children (usually a `Menu` of `MenuItem`s; `DropdownButton` is its labelled-button trigger). `ActionMenu` takes a `trigger` and an `items` array (`{ name, prefix, onClick, disabled }`). Both map to the same DS `DropdownMenu` compound. The visual difference (labelled button vs icon-only "•••") is the `Button` variant/size you pass to `DropdownMenuTrigger`'s `render` prop.
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
If the `Dropdown` content is **not a list of actions** (a form, filters, free text, a `Typography` block), it is not a menu: use `Popover` (`aircall-ds/migrate-tractor/popover`). A `DropdownMenu` only holds items, groups, separators, checkbox and radio items.
|
|
27
|
+
|
|
28
|
+
| Tractor | DS compound part | Role |
|
|
23
29
|
| --- | --- | --- |
|
|
24
|
-
| `<Dropdown>` / `<ActionMenu>` | `<DropdownMenu>` | State owner (open
|
|
25
|
-
|
|
|
26
|
-
| `<
|
|
27
|
-
|
|
|
28
|
-
|
|
|
29
|
-
|
|
|
30
|
-
| _(no equivalent)_ | `<
|
|
31
|
-
|
|
|
30
|
+
| `<Dropdown trigger={…}>` / `<ActionMenu trigger={…}>` | `<DropdownMenu>` | State owner (`open`, `defaultOpen`, `onOpenChange`, `modal`) |
|
|
31
|
+
| the `trigger` element (`<Button>`, `<DropdownButton>`) | `<DropdownMenuTrigger render={<Button … />}>` | Trigger — compose any button via `render`; the label is the child of `DropdownMenuTrigger` |
|
|
32
|
+
| `<Menu>` | `<DropdownMenuContent>` | Floating panel (portal + positioner + popup) |
|
|
33
|
+
| `<MenuItem>` / `items[n]` of `ActionMenu` | `<DropdownMenuItem>` | Individual action item |
|
|
34
|
+
| `MenuItemPrefix` / `items[n].prefix` | icon as first child of `DropdownMenuItem` | Icon placement |
|
|
35
|
+
| `MenuItemSuffix` | `<DropdownMenuAddon>` | Trailing right-aligned slot (a badge, a value) |
|
|
36
|
+
| _(no equivalent)_ | `<DropdownMenuShortcut>` | Trailing keyboard-shortcut hint |
|
|
37
|
+
| `<MenuItemGroup title="X">` | `<DropdownMenuGroup><DropdownMenuLabel>X</DropdownMenuLabel>…</DropdownMenuGroup>` | `DropdownMenuLabel` must be inside a `DropdownMenuGroup` |
|
|
38
|
+
| `<MenuItemGroup divider>` | `<DropdownMenuSeparator>` | Horizontal rule between sections |
|
|
39
|
+
| `Menu selectionMode="single"` + `itemKey` | `<DropdownMenuRadioGroup value onValueChange>` + `<DropdownMenuRadioItem value>` | One selected option |
|
|
40
|
+
| `Menu selectionMode="multiple"` + `itemKey` | `<DropdownMenuCheckboxItem checked onCheckedChange>` per item | Independent toggles |
|
|
41
|
+
| _(no equivalent)_ | `<DropdownMenuSub>` + `<DropdownMenuSubTrigger>` + `<DropdownMenuSubContent>` | Nested submenu |
|
|
32
42
|
|
|
33
43
|
## 2. Verified DS exports (`packages/ds/src/index.ts`)
|
|
34
44
|
|
|
35
45
|
```
|
|
36
|
-
DropdownMenu, DropdownMenuContent, DropdownMenuGroup,
|
|
37
|
-
DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator,
|
|
38
|
-
|
|
39
|
-
DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent,
|
|
40
|
-
|
|
41
|
-
DropdownMenuPortal, DropdownMenuShortcut,
|
|
46
|
+
DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuGroup,
|
|
47
|
+
DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuAddon,
|
|
48
|
+
DropdownMenuShortcut, DropdownMenuCheckboxItem, DropdownMenuRadioGroup,
|
|
49
|
+
DropdownMenuRadioItem, DropdownMenuSub, DropdownMenuSubTrigger, DropdownMenuSubContent,
|
|
50
|
+
DropdownMenuPortal,
|
|
42
51
|
Button
|
|
43
52
|
```
|
|
44
53
|
|
|
@@ -57,32 +66,44 @@ import {
|
|
|
57
66
|
} from '@aircall/ds';
|
|
58
67
|
```
|
|
59
68
|
|
|
60
|
-
For ActionMenu (icon trigger + icon items), also import from `@aircall/react-icons
|
|
69
|
+
For an ActionMenu (icon trigger + icon items), also import from `@aircall/react-icons`. Icon names changed: there is no `*Fill`/`*Outlined` suffix. Use `MoreVertical` (was `MenuVerticalFilled`), `Pencil` (was `EditOutlined`), `Trash2` (was `TrashOutlined`). See `aircall-ds/migrate-icons` for the full map.
|
|
61
70
|
|
|
62
71
|
```tsx
|
|
63
|
-
import {
|
|
72
|
+
import { MoreVertical, Pencil, Trash2 } from '@aircall/react-icons';
|
|
64
73
|
```
|
|
65
74
|
|
|
66
75
|
## 4. Prop and pattern changes
|
|
67
76
|
|
|
68
77
|
| Tractor | DS | Notes |
|
|
69
78
|
| --- | --- | --- |
|
|
70
|
-
| `<Dropdown
|
|
71
|
-
| `<
|
|
72
|
-
| `<
|
|
73
|
-
| `
|
|
74
|
-
|
|
|
79
|
+
| `<Dropdown trigger={<Button>Options</Button>}>` | `<DropdownMenuTrigger render={<Button variant="outline" />}>Options</DropdownMenuTrigger>` | Trigger button is composed via `render`; the label moves to the trigger's children |
|
|
80
|
+
| `<Dropdown trigger={<DropdownButton>…</DropdownButton>}>` | `<DropdownMenuTrigger render={<Button variant="outline" />}>…<ChevronDown /></DropdownMenuTrigger>` | `DropdownButton`'s open/closed chevron swap is gone: put one chevron in the trigger |
|
|
81
|
+
| `<ActionMenu trigger={<Button mode="ghost" shape="circle" …><MenuVerticalFilled /></Button>}>` | `<DropdownMenuTrigger render={<Button variant="ghost" size="icon" aria-label="Actions" />}><MoreVertical /></DropdownMenuTrigger>` | Icon-only trigger uses `size="icon"` (`"icon-sm"` inside a table row) and needs an `aria-label` |
|
|
82
|
+
| `items={[{ name, prefix, onClick }]}` | `<DropdownMenuItem onClick>{icon}{name}</DropdownMenuItem>` per item | The `items` array becomes JSX; `map` it if it is data |
|
|
83
|
+
| `item.disabled` / `readOnly` | `disabled` on `DropdownMenuItem` | |
|
|
84
|
+
| a "critical" red item (custom styling) | `<DropdownMenuItem variant="destructive">` | Use the `variant` prop, not `className` |
|
|
85
|
+
| `side` (default `bottom`), `align` (default `center`), `sideOffset` (default 8), `alignOffset` | the same props on `<DropdownMenuContent>` | **Defaults differ:** DS is `align="start"`, `sideOffset={4}`. Pass `align="end"` for a trigger at the right edge |
|
|
86
|
+
| `visible` / `defaultVisible` / `onVisibilityChange` | `open` / `defaultOpen` / `onOpenChange` on `<DropdownMenu>` | `onOpenChange(open, details)` |
|
|
87
|
+
| `triggerOnHover` | `openOnHover` on `<DropdownMenuTrigger>` | Base UI `Menu.Trigger` prop (`delay` / `closeDelay` tune it) |
|
|
88
|
+
| `closeOnInsideClick` (default `true`) | a plain item closes the menu on click; `closeOnClick={false}` on it keeps the menu open (checkbox and radio items stay open by default) | Per item, not per menu |
|
|
89
|
+
| `maxWidth` / `maxHeight` / `minWidth` | `className` on `DropdownMenuContent` (e.g. `w-56`, `max-w-*`) | The content already caps at the available height and scrolls; `min-w-32` is built in |
|
|
90
|
+
| `data-test` | `data-test` on the part you target | |
|
|
91
|
+
| `<MenuItemGroup title>` | `<DropdownMenuGroup><DropdownMenuLabel>` | Label must be inside a `DropdownMenuGroup` |
|
|
92
|
+
|
|
93
|
+
A `Menu`/`MenuItem` on its own (not inside a `Dropdown`/`ActionMenu`) is a list, not an overlay: that is `ItemGroup` + `Item` (`aircall-ds/migrate-tractor/item`).
|
|
75
94
|
|
|
76
95
|
## 5. Before / After — plain Dropdown
|
|
77
96
|
|
|
78
97
|
### Before (Tractor)
|
|
79
98
|
|
|
80
99
|
```tsx
|
|
81
|
-
import { Dropdown,
|
|
100
|
+
import { Button, Dropdown, Menu, MenuItem } from '@aircall/tractor';
|
|
82
101
|
|
|
83
|
-
<Dropdown
|
|
84
|
-
<
|
|
85
|
-
|
|
102
|
+
<Dropdown trigger={<Button>Options</Button>} side="bottom" align="start">
|
|
103
|
+
<Menu>
|
|
104
|
+
<MenuItem onClick={handleEdit}>Edit</MenuItem>
|
|
105
|
+
<MenuItem onClick={handleDelete}>Delete</MenuItem>
|
|
106
|
+
</Menu>
|
|
86
107
|
</Dropdown>
|
|
87
108
|
```
|
|
88
109
|
|
|
@@ -98,7 +119,7 @@ import {
|
|
|
98
119
|
} from '@aircall/ds';
|
|
99
120
|
|
|
100
121
|
<DropdownMenu>
|
|
101
|
-
<DropdownMenuTrigger render={<Button variant="outline"
|
|
122
|
+
<DropdownMenuTrigger render={<Button variant="outline" />}>
|
|
102
123
|
Options
|
|
103
124
|
</DropdownMenuTrigger>
|
|
104
125
|
<DropdownMenuContent>
|
|
@@ -113,12 +134,22 @@ import {
|
|
|
113
134
|
### Before (Tractor)
|
|
114
135
|
|
|
115
136
|
```tsx
|
|
116
|
-
import {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
137
|
+
import { Button, ActionMenu } from '@aircall/tractor';
|
|
138
|
+
import { EditOutlined, MenuVerticalFilled, TrashOutlined } from '@aircall/icons';
|
|
139
|
+
|
|
140
|
+
<ActionMenu
|
|
141
|
+
trigger={
|
|
142
|
+
<Button mode="ghost" shape="circle" variant="secondary">
|
|
143
|
+
<MenuVerticalFilled />
|
|
144
|
+
</Button>
|
|
145
|
+
}
|
|
146
|
+
side="bottom"
|
|
147
|
+
align="end"
|
|
148
|
+
items={[
|
|
149
|
+
{ prefix: <EditOutlined />, name: 'Edit', onClick: handleEdit },
|
|
150
|
+
{ prefix: <TrashOutlined />, name: 'Delete', onClick: handleDelete }
|
|
151
|
+
]}
|
|
152
|
+
/>
|
|
122
153
|
```
|
|
123
154
|
|
|
124
155
|
### After (DS)
|
|
@@ -131,28 +162,32 @@ import {
|
|
|
131
162
|
DropdownMenuTrigger,
|
|
132
163
|
Button,
|
|
133
164
|
} from '@aircall/ds';
|
|
134
|
-
import {
|
|
165
|
+
import { MoreVertical, Pencil, Trash2 } from '@aircall/react-icons';
|
|
135
166
|
|
|
136
167
|
<DropdownMenu>
|
|
137
|
-
<DropdownMenuTrigger render={<Button variant="ghost" size="icon" />}>
|
|
138
|
-
<
|
|
168
|
+
<DropdownMenuTrigger render={<Button variant="ghost" size="icon" aria-label="More actions" />}>
|
|
169
|
+
<MoreVertical />
|
|
139
170
|
</DropdownMenuTrigger>
|
|
140
|
-
<DropdownMenuContent>
|
|
171
|
+
<DropdownMenuContent align="end">
|
|
141
172
|
<DropdownMenuItem onClick={handleEdit}>
|
|
142
|
-
<
|
|
173
|
+
<Pencil />
|
|
143
174
|
Edit
|
|
144
175
|
</DropdownMenuItem>
|
|
145
176
|
<DropdownMenuItem variant="destructive" onClick={handleDelete}>
|
|
146
|
-
<
|
|
177
|
+
<Trash2 />
|
|
147
178
|
Delete
|
|
148
179
|
</DropdownMenuItem>
|
|
149
180
|
</DropdownMenuContent>
|
|
150
181
|
</DropdownMenu>
|
|
151
182
|
```
|
|
152
183
|
|
|
184
|
+
The item is a flex row with `gap-2` and sizes any child `svg` to `size-4`, so a bare icon is enough: no `mr-2`, no `size-4`. (The `DropdownMenu` stories still add `className="mr-2"`; that doubles the gap.)
|
|
185
|
+
|
|
186
|
+
Inside a `DataTable` row, wrap the menu in `<div onClick={e => e.stopPropagation()}>` so opening it does not fire `onRowClick`; see `aircall-ds/migrate-tractor/data-table` §6d. Tractor's `DropdownTrigger` did this for you.
|
|
187
|
+
|
|
153
188
|
## 7. Sections with labels
|
|
154
189
|
|
|
155
|
-
`DropdownMenuLabel` must be placed inside a `DropdownMenuGroup` alongside its items.
|
|
190
|
+
`DropdownMenuLabel` must be placed inside a `DropdownMenuGroup` alongside its items. Rendered as a direct child of `DropdownMenuContent` it throws ("MenuGroupRootContext is missing").
|
|
156
191
|
|
|
157
192
|
```tsx
|
|
158
193
|
import {
|
|
@@ -167,7 +202,7 @@ import {
|
|
|
167
202
|
} from '@aircall/ds';
|
|
168
203
|
|
|
169
204
|
<DropdownMenu>
|
|
170
|
-
<DropdownMenuTrigger render={<Button variant="outline"
|
|
205
|
+
<DropdownMenuTrigger render={<Button variant="outline" />}>
|
|
171
206
|
Account
|
|
172
207
|
</DropdownMenuTrigger>
|
|
173
208
|
<DropdownMenuContent>
|
|
@@ -182,6 +217,29 @@ import {
|
|
|
182
217
|
</DropdownMenu>
|
|
183
218
|
```
|
|
184
219
|
|
|
220
|
+
## 7b. Selectable items (Tractor `Menu selectionMode`)
|
|
221
|
+
|
|
222
|
+
```tsx
|
|
223
|
+
import {
|
|
224
|
+
DropdownMenuCheckboxItem,
|
|
225
|
+
DropdownMenuRadioGroup,
|
|
226
|
+
DropdownMenuRadioItem,
|
|
227
|
+
} from '@aircall/ds';
|
|
228
|
+
|
|
229
|
+
// multiple -> one checkbox item per option
|
|
230
|
+
<DropdownMenuCheckboxItem checked={visible.status} onCheckedChange={checked => setVisible(v => ({ ...v, status: checked }))}>
|
|
231
|
+
Status
|
|
232
|
+
</DropdownMenuCheckboxItem>
|
|
233
|
+
|
|
234
|
+
// single -> radio group
|
|
235
|
+
<DropdownMenuRadioGroup value={sort} onValueChange={setSort}>
|
|
236
|
+
<DropdownMenuRadioItem value="name">Name</DropdownMenuRadioItem>
|
|
237
|
+
<DropdownMenuRadioItem value="date">Date modified</DropdownMenuRadioItem>
|
|
238
|
+
</DropdownMenuRadioGroup>
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Selection state is yours (`checked` / `value`); there is no `selectedKeys`. Checkbox and radio items keep the menu open by default (`closeOnClick` defaults to `false` on them, `true` on a plain `DropdownMenuItem`), so several can be toggled in one go. A "pick one from a long, searchable list" is a `Combobox`, not a menu.
|
|
242
|
+
|
|
185
243
|
## 8. Common Mistakes
|
|
186
244
|
|
|
187
245
|
### Mistake 1 — Using `className="text-destructive"` instead of `variant="destructive"`
|
|
@@ -198,7 +256,7 @@ import {
|
|
|
198
256
|
</DropdownMenuItem>
|
|
199
257
|
```
|
|
200
258
|
|
|
201
|
-
`DropdownMenuItem` has a first-class `variant` prop (`'default' | 'destructive'`).
|
|
259
|
+
`DropdownMenuItem` has a first-class `variant` prop (`'default' | 'destructive'`). `variant="destructive"` applies the destructive text colour, the tinted focus background (`destructive/10`, `destructive/20` in dark mode) and colours child icons via `data-[variant=destructive]` selectors. A bare `className="text-destructive"` only sets the text colour and loses the focus-state and dark-mode styling baked into the variant.
|
|
202
260
|
Source: `packages/ds/src/components/dropdown-menu.tsx`
|
|
203
261
|
|
|
204
262
|
---
|
|
@@ -206,7 +264,7 @@ Source: `packages/ds/src/components/dropdown-menu.tsx`
|
|
|
206
264
|
### Mistake 2 — Placing `DropdownMenuLabel` as a direct child of `DropdownMenuContent`
|
|
207
265
|
|
|
208
266
|
```tsx
|
|
209
|
-
// Wrong
|
|
267
|
+
// Wrong — throws "Base UI: MenuGroupRootContext is missing"
|
|
210
268
|
<DropdownMenuContent>
|
|
211
269
|
<DropdownMenuLabel>Account</DropdownMenuLabel>
|
|
212
270
|
<DropdownMenuItem>Profile</DropdownMenuItem>
|
|
@@ -221,7 +279,7 @@ Source: `packages/ds/src/components/dropdown-menu.tsx`
|
|
|
221
279
|
</DropdownMenuContent>
|
|
222
280
|
```
|
|
223
281
|
|
|
224
|
-
`DropdownMenuLabel` renders a Base UI `
|
|
282
|
+
`DropdownMenuLabel` renders a Base UI `Menu.GroupLabel`, which reads its enclosing `Menu.Group` for the `aria-labelledby` link and throws when there is none.
|
|
225
283
|
Source: `packages/ds/src/components/dropdown-menu.tsx`
|
|
226
284
|
|
|
227
285
|
---
|
|
@@ -235,31 +293,51 @@ Source: `packages/ds/src/components/dropdown-menu.tsx`
|
|
|
235
293
|
</DropdownMenuTrigger>
|
|
236
294
|
|
|
237
295
|
// Correct
|
|
238
|
-
<DropdownMenuTrigger render={<Button variant="outline"
|
|
296
|
+
<DropdownMenuTrigger render={<Button variant="outline" />}>
|
|
239
297
|
Options
|
|
240
298
|
</DropdownMenuTrigger>
|
|
241
299
|
```
|
|
242
300
|
|
|
243
|
-
Without a `render` prop, `DropdownMenuTrigger` renders a plain unstyled `<button>`. In the DS, trigger appearance is composed by passing a `Button` via the Base UI `render` prop — the button's variant and size control the visual style. This follows the DS-wide `render` prop pattern that replaces the old `asChild` prop.
|
|
301
|
+
Without a `render` prop, `DropdownMenuTrigger` renders a plain unstyled `<button>`. In the DS, trigger appearance is composed by passing a `Button` via the Base UI `render` prop — the button's variant and size control the visual style. The label is a child of `DropdownMenuTrigger`, not of the `Button` element you pass to `render`. This follows the DS-wide `render` prop pattern that replaces the old `asChild` prop.
|
|
244
302
|
Source: `packages/ds/src/components/dropdown-menu.tsx`
|
|
245
303
|
|
|
246
304
|
---
|
|
247
305
|
|
|
248
|
-
### Mistake 4 —
|
|
306
|
+
### Mistake 4 — Keeping Tractor's `prefix` / `items` shape instead of rendering the icon as a child
|
|
249
307
|
|
|
250
308
|
```tsx
|
|
251
|
-
// Wrong
|
|
252
|
-
|
|
253
|
-
<ActionMenuItem icon={EditOutlined}>Edit</ActionMenuItem>
|
|
309
|
+
// Wrong — Tractor ActionMenu data shape; DropdownMenuItem has no prefix or icon prop
|
|
310
|
+
<DropdownMenuItem prefix={<Pencil />}>Edit</DropdownMenuItem>
|
|
254
311
|
|
|
255
312
|
// Correct
|
|
256
313
|
import { DropdownMenuItem } from '@aircall/ds';
|
|
257
|
-
import {
|
|
314
|
+
import { Pencil } from '@aircall/react-icons';
|
|
258
315
|
<DropdownMenuItem>
|
|
259
|
-
<
|
|
316
|
+
<Pencil />
|
|
260
317
|
Edit
|
|
261
318
|
</DropdownMenuItem>
|
|
262
319
|
```
|
|
263
320
|
|
|
264
|
-
Tractor `
|
|
321
|
+
Tractor `ActionMenu` took `items: { prefix, name, onClick }[]`; `MenuItem` used `MenuItemPrefix` / `MenuItemLabel` children. DS `DropdownMenuItem` has no `prefix`/`icon` prop — the icon is placed as the first child. The `[&_svg:not([class*='size-'])]:size-4` selector on the item auto-sizes icon children that lack an explicit size class, and `gap-2` spaces them.
|
|
322
|
+
Source: `packages/ds/src/components/dropdown-menu.tsx`
|
|
323
|
+
|
|
324
|
+
---
|
|
325
|
+
|
|
326
|
+
### Mistake 5 — Putting non-menu content in a `DropdownMenu`
|
|
327
|
+
|
|
328
|
+
```tsx
|
|
329
|
+
// Wrong — a form or free text is not a menu item; keyboard navigation and focus break
|
|
330
|
+
<DropdownMenuContent>
|
|
331
|
+
<Input placeholder="Search" />
|
|
332
|
+
<p>Some explanation</p>
|
|
333
|
+
</DropdownMenuContent>
|
|
334
|
+
|
|
335
|
+
// Correct — a panel with arbitrary content is a Popover
|
|
336
|
+
<Popover>
|
|
337
|
+
<PopoverTrigger render={<Button variant="outline" />}>Filters</PopoverTrigger>
|
|
338
|
+
<PopoverContent>…</PopoverContent>
|
|
339
|
+
</Popover>
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
`DropdownMenuContent` is a `role="menu"` popup that roves focus across its items. Tractor `Dropdown` accepted any children, so a `Dropdown` that holds anything other than a `Menu` migrates to `Popover` (`aircall-ds/migrate-tractor/popover`).
|
|
265
343
|
Source: `packages/ds/src/components/dropdown-menu.tsx`
|
|
@@ -11,6 +11,8 @@ requires:
|
|
|
11
11
|
- aircall-ds/migrate-tractor
|
|
12
12
|
sources:
|
|
13
13
|
- "aircall/hydra:docs/migration-guides/tractor-to-ds/recipes/dropzone.md"
|
|
14
|
+
- "aircall/hydra:packages/ds/src/components/dropzone.tsx"
|
|
15
|
+
- "aircall/hydra:packages/ds/src/stories/Dropzone.stories.tsx"
|
|
14
16
|
---
|
|
15
17
|
|
|
16
18
|
This skill builds on aircall-ds/migrate-tractor.
|