@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
|
@@ -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.
|
|
@@ -13,6 +13,8 @@ requires:
|
|
|
13
13
|
- aircall-ds/migrate-tractor
|
|
14
14
|
sources:
|
|
15
15
|
- "aircall/hydra:docs/migration-guides/tractor-to-ds/recipes/card.md"
|
|
16
|
+
- "aircall/hydra:packages/ds/src/components/card.tsx"
|
|
17
|
+
- "aircall/hydra:packages/ds/src/stories/Card.stories.tsx"
|
|
16
18
|
---
|
|
17
19
|
|
|
18
20
|
This skill builds on aircall-ds/migrate-tractor.
|
|
@@ -34,7 +36,7 @@ Tractor had no `Card` component. Apps grew bespoke card implementations — `<di
|
|
|
34
36
|
## 2. Verified DS exports (`packages/ds/src/index.ts`)
|
|
35
37
|
|
|
36
38
|
```
|
|
37
|
-
Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle
|
|
39
|
+
Card, CardAction, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, cardVariants
|
|
38
40
|
```
|
|
39
41
|
|
|
40
42
|
## 3. Imports
|
|
@@ -57,12 +59,13 @@ Never import icons from `lucide-react` directly — always use `@aircall/react-i
|
|
|
57
59
|
|
|
58
60
|
## 4. Size prop
|
|
59
61
|
|
|
60
|
-
`Card` accepts a `size` prop (`"default" | "
|
|
62
|
+
`Card` accepts a `size` prop (`"sm" | "default" | "lg"`, default `"default"`). Setting it on the root sets the root's vertical padding and gap and propagates via `data-size` + Tailwind group selectors to **all** sub-components — horizontal padding and title style scale together. Never add per-part `p-*` overrides to achieve a compact variant; use `size="sm"` instead.
|
|
61
63
|
|
|
62
|
-
| DS `size` |
|
|
64
|
+
| DS `size` | Root padding / gap | Header, content, footer padding | Title |
|
|
63
65
|
| --- | --- | --- | --- |
|
|
64
|
-
| `"
|
|
65
|
-
| `"
|
|
66
|
+
| `"sm"` | `py-3` / `gap-3` | `px-3` (footer `p-3`) | `text-sm font-medium` |
|
|
67
|
+
| `"default"` (omit prop) | `py-4` / `gap-4` | `px-4` (footer `p-4`) | `text-base font-medium` |
|
|
68
|
+
| `"lg"` | `py-6` / `gap-6` | `px-6` (footer `p-6`) | `text-lg font-bold` |
|
|
66
69
|
|
|
67
70
|
## 5. Before / After
|
|
68
71
|
|
|
@@ -70,27 +73,28 @@ Never import icons from `lucide-react` directly — always use `@aircall/react-i
|
|
|
70
73
|
|
|
71
74
|
**Before (Tractor-era bespoke component):**
|
|
72
75
|
```tsx
|
|
73
|
-
import {
|
|
76
|
+
import { Button, Flex, Typography } from '@aircall/tractor';
|
|
74
77
|
|
|
75
|
-
<
|
|
76
|
-
className="rounded-xl border border-neutral-200 bg-white p-4 shadow-sm"
|
|
77
|
-
display="flex"
|
|
78
|
+
<Flex
|
|
78
79
|
flexDirection="column"
|
|
79
|
-
gap="
|
|
80
|
+
gap="s"
|
|
81
|
+
p="s"
|
|
82
|
+
border="1px solid"
|
|
83
|
+
borderColor="neutral-200"
|
|
84
|
+
borderRadius="sm"
|
|
85
|
+
backgroundColor="white"
|
|
80
86
|
>
|
|
81
|
-
<
|
|
82
|
-
<Typography variant="
|
|
83
|
-
<Typography variant="
|
|
87
|
+
<Flex flexDirection="column" gap="xxxs">
|
|
88
|
+
<Typography variant="headingBoldXS">Card title</Typography>
|
|
89
|
+
<Typography variant="bodyRegularS" color="text-secondary">
|
|
84
90
|
A short supporting description.
|
|
85
91
|
</Typography>
|
|
86
|
-
</
|
|
87
|
-
<
|
|
88
|
-
|
|
89
|
-
</Box>
|
|
90
|
-
<Box display="flex" justifyContent="flex-end">
|
|
92
|
+
</Flex>
|
|
93
|
+
<Typography variant="bodyRegularS">Card body content goes here.</Typography>
|
|
94
|
+
<Flex justifyContent="flex-end">
|
|
91
95
|
<Button variant="primary" size="small">Action</Button>
|
|
92
|
-
</
|
|
93
|
-
</
|
|
96
|
+
</Flex>
|
|
97
|
+
</Flex>
|
|
94
98
|
```
|
|
95
99
|
|
|
96
100
|
**After (DS):**
|
|
@@ -105,7 +109,7 @@ import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle,
|
|
|
105
109
|
<CardContent>
|
|
106
110
|
<p className="text-sm">Card body content goes here.</p>
|
|
107
111
|
</CardContent>
|
|
108
|
-
<CardFooter>
|
|
112
|
+
<CardFooter className="justify-end">
|
|
109
113
|
<Button variant="default" size="lg">Action</Button>
|
|
110
114
|
</CardFooter>
|
|
111
115
|
</Card>
|
|
@@ -115,18 +119,27 @@ Key changes:
|
|
|
115
119
|
- Delete all hand-rolled surface styles (border, shadow, radius, bg, padding) — `Card` owns all of it.
|
|
116
120
|
- Map title/subtitle to `CardTitle` + `CardDescription` inside `CardHeader`.
|
|
117
121
|
- Map body to `CardContent`; actions to `CardFooter`.
|
|
118
|
-
- `CardFooter` renders
|
|
122
|
+
- `CardFooter` renders `flex items-center border-t bg-muted/50 p-4` by default (a distinct action bar) and does not justify its children, so they sit at the start. Add `className="justify-end"` to right-align a Tractor-style action row, or `className="flex justify-between"` for Cancel left / Save right. For a plain footer add `className="bg-transparent border-none"`.
|
|
123
|
+
- A form save/discard bar is not a `CardFooter`: drop `CardSaveBar` from `@aircall/blocks` in as a direct child of `Card` instead (see `@aircall/blocks#aircall-blocks/migrate-dashboard/card`).
|
|
119
124
|
|
|
120
125
|
### 5b. Compact card using `size="sm"`
|
|
121
126
|
|
|
122
127
|
**Before:**
|
|
123
128
|
```tsx
|
|
124
|
-
import {
|
|
129
|
+
import { Flex, Typography } from '@aircall/tractor';
|
|
125
130
|
|
|
126
|
-
<
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
131
|
+
<Flex
|
|
132
|
+
flexDirection="column"
|
|
133
|
+
gap="xs"
|
|
134
|
+
p="xs"
|
|
135
|
+
border="1px solid"
|
|
136
|
+
borderColor="neutral-200"
|
|
137
|
+
borderRadius="sm"
|
|
138
|
+
backgroundColor="white"
|
|
139
|
+
>
|
|
140
|
+
<Typography variant="headingBoldXS">Compact card</Typography>
|
|
141
|
+
<Typography variant="supportingRegularS">Body content.</Typography>
|
|
142
|
+
</Flex>
|
|
130
143
|
```
|
|
131
144
|
|
|
132
145
|
**After:**
|
|
@@ -149,16 +162,21 @@ Setting `size="sm"` on `Card` scales all sub-components — no per-part padding
|
|
|
149
162
|
|
|
150
163
|
**Before:**
|
|
151
164
|
```tsx
|
|
152
|
-
import {
|
|
153
|
-
import {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
165
|
+
import { Flex, IconButton, Typography } from '@aircall/tractor';
|
|
166
|
+
import { MenuVerticalFilled } from '@aircall/icons';
|
|
167
|
+
|
|
168
|
+
<Flex
|
|
169
|
+
p="s"
|
|
170
|
+
border="1px solid"
|
|
171
|
+
borderColor="neutral-200"
|
|
172
|
+
borderRadius="sm"
|
|
173
|
+
backgroundColor="white"
|
|
174
|
+
justifyContent="space-between"
|
|
175
|
+
alignItems="flex-start"
|
|
176
|
+
>
|
|
177
|
+
<Typography variant="headingBoldXS">With action</Typography>
|
|
178
|
+
<IconButton component={MenuVerticalFilled} aria-label="Open menu" />
|
|
179
|
+
</Flex>
|
|
162
180
|
```
|
|
163
181
|
|
|
164
182
|
**After:**
|
|
@@ -178,7 +196,7 @@ import { MoreVertical } from '@aircall/react-icons';
|
|
|
178
196
|
</Card>
|
|
179
197
|
```
|
|
180
198
|
|
|
181
|
-
`CardAction` must live **inside** `CardHeader` — the header is a CSS grid
|
|
199
|
+
`CardAction` must live **inside** `CardHeader` — the header is a CSS grid (`has-data-[slot=card-action]:grid-cols-[1fr_auto]`) and `CardAction` places itself in column 2, row 1, pinned top-right (`col-start-2 row-start-1 justify-self-end`). With a `CardDescription` it also reaches down to row 2 so title and description share the height. Rendered outside `CardHeader` it loses that positioning entirely.
|
|
182
200
|
|
|
183
201
|
---
|
|
184
202
|
|
|
@@ -187,7 +205,7 @@ import { MoreVertical } from '@aircall/react-icons';
|
|
|
187
205
|
### Mistake 1 — Keeping hand-rolled surface styles on the root element
|
|
188
206
|
|
|
189
207
|
```tsx
|
|
190
|
-
// ❌ Wrong — double-styles the surface; shadow and
|
|
208
|
+
// ❌ Wrong — double-styles the surface; border, radius, shadow and padding are already owned by Card
|
|
191
209
|
<Card className="border border-neutral-200 rounded-xl shadow-sm bg-white p-4">
|
|
192
210
|
<CardContent>Content</CardContent>
|
|
193
211
|
</Card>
|
|
@@ -198,7 +216,7 @@ import { MoreVertical } from '@aircall/react-icons';
|
|
|
198
216
|
</Card>
|
|
199
217
|
```
|
|
200
218
|
|
|
201
|
-
`Card` already applies `rounded-xl border bg-card
|
|
219
|
+
`Card` already applies `rounded-xl border bg-card text-card-foreground shadow-xs` plus `overflow-hidden`, `flex flex-col`, and size-driven padding/gap (`py-4 gap-4` by default). Adding these again creates double borders and mismatched shadows that diverge from the design token.
|
|
202
220
|
|
|
203
221
|
Source: `packages/ds/src/components/card.tsx`
|
|
204
222
|
|
|
@@ -228,7 +246,7 @@ Source: `packages/ds/src/components/card.tsx`
|
|
|
228
246
|
</Card>
|
|
229
247
|
```
|
|
230
248
|
|
|
231
|
-
`CardHeader` uses `grid auto-rows-min has-data-[slot=card-action]:grid-cols-[1fr_auto]`. `CardAction` carries `data-slot="card-action"` and is placed via `col-start-2 row-
|
|
249
|
+
`CardHeader` uses `grid auto-rows-min has-data-[slot=card-action]:grid-cols-[1fr_auto]`. `CardAction` carries `data-slot="card-action"` and is placed via `col-start-2 row-start-1` (plus `row-end-3` when the header has a description). Outside `CardHeader`, no grid parent exists and the action renders in normal flow.
|
|
232
250
|
|
|
233
251
|
Source: `packages/ds/src/components/card.tsx`
|
|
234
252
|
|
|
@@ -252,7 +270,7 @@ Source: `packages/ds/src/components/card.tsx`
|
|
|
252
270
|
</Card>
|
|
253
271
|
```
|
|
254
272
|
|
|
255
|
-
`Card` propagates `data-size="sm"` to sub-components via the `group/card` modifier.
|
|
273
|
+
`Card` propagates `data-size="sm"` to sub-components via the `group/card` modifier. The root sets `py-3 gap-3`, and each part responds with `group-data-[size=sm]/card:px-3` (footer `p-3`) and the title with `group-data-[size=sm]/card:text-sm`. Overriding padding individually bypasses this mechanism and produces inconsistent spacing.
|
|
256
274
|
|
|
257
275
|
Source: `packages/ds/src/components/card.tsx`
|
|
258
276
|
|
|
@@ -274,4 +292,6 @@ Source: `packages/ds/src/components/card.tsx`
|
|
|
274
292
|
|
|
275
293
|
`Card` uses `has-data-[slot=card-footer]:pb-0` to remove its own bottom padding when a `CardFooter` is present, so the footer's rounded corners (`rounded-b-xl`) flush with the card edge. Forcing `pb-4` overrides this and leaves a visible gap.
|
|
276
294
|
|
|
295
|
+
The same mechanism lets `CardSaveBar` (`@aircall/blocks`) sit flush: it carries `data-slot="card-footer"` itself, so it goes directly inside `Card` with no `CardFooter` wrapper.
|
|
296
|
+
|
|
277
297
|
Source: `packages/ds/src/components/card.tsx`
|