Skip to content

Commit 3d7fb2a

Browse files
committed
update migration skill
1 parent a6bd663 commit 3d7fb2a

6 files changed

Lines changed: 255 additions & 154 deletions

File tree

packages/dev/s2-docs/migration-references/focused-app-setup.md

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 115 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,132 @@
11
# Manual fixes after the codemod
22

3-
## Known gaps to handle explicitly
3+
## Icons and illustrations
44

5-
- `@react-spectrum/toast` imports are not automatically migrated. Move them to S2, then re-check `ToastContainer` mounts and `ToastQueue` usages.
6-
- v3 `Provider` and `defaultTheme` wrappers in apps and tests need human review. S2 does not use the v3 theme object model.
5+
- If the codemod leaves `TODO(S2-upgrade)` next to an icon or illustration import, pick the nearest S2 replacement manually.
76

8-
## Imports and packages
7+
## Layout components
98

10-
- Collapse v3 component imports onto `@react-spectrum/s2`.
11-
- Keep using `@spectrum-icons/*` only when there is no S2 icon or illustration equivalent. Prefer `@react-spectrum/s2/icons/*` and `@react-spectrum/s2/illustrations` when possible.
12-
- If the codemod leaves `TODO(S2-upgrade)` next to an icon or illustration import, pick the nearest S2 replacement manually.
9+
`Flex`, `Grid`, `View`, and `Well` are not part of S2. These should be updated to `div` elements styled with the macro.
10+
11+
### Flex example
12+
13+
Before:
14+
15+
```jsx
16+
<Flex direction="column">
17+
<div>Item 1</div>
18+
<div>Item 2</div>
19+
<div>Item 3</div>
20+
</Flex>
21+
```
22+
23+
After:
24+
25+
```jsx
26+
<div className={style({display: 'flex', flexDirection: 'column'})}>
27+
<div>Item 1</div>
28+
<div>Item 2</div>
29+
<div>Item 3</div>
30+
</div>
31+
```
32+
33+
### Grid example
34+
35+
Before:
36+
37+
```jsx
38+
<Grid justifyContent="center">
39+
<div>Item 1</div>
40+
<div>Item 2</div>
41+
<div>Item 3</div>
42+
</Grid>
43+
```
44+
45+
After:
1346

14-
## App and Provider setup
47+
```jsx
48+
<div className={style({display: 'grid', justifyContent: 'center'})}>
49+
<div>Item 1</div>
50+
<div>Item 2</div>
51+
<div>Item 3</div>
52+
</div>
53+
```
1554

16-
- Full-page apps usually add `import '@react-spectrum/s2/page.css';` at the entrypoint and no longer need a mandatory root Provider just to supply `theme={defaultTheme}`.
17-
- Embedded sections still use S2 `Provider` with an explicit `background`.
18-
- Keep or add S2 `Provider` only when locale, router integration, color-scheme/background overrides, or SSR `elementType="html"` behavior are needed.
19-
- Preserve unrelated wrappers such as routing, store, analytics, i18n, and host-framework providers. Replace or remove only the React Spectrum-specific layer.
55+
### View example
2056

21-
## Style and layout follow-ups
57+
Before:
2258

23-
- Convert v3 style props and `UNSAFE_style` cases to the S2 style macro when possible.
24-
- `Flex` and `Grid` often become `div` elements styled with the macro.
25-
- Review `ClearSlots` and other direct `@react-spectrum/utils` imports manually. These are not part of the common S2 app surface.
59+
```jsx
60+
<View>
61+
Content
62+
</View>
63+
```
64+
65+
After:
66+
67+
```jsx
68+
<div>
69+
Content
70+
</div>
71+
```
72+
### Well example
73+
74+
Before:
75+
76+
```jsx
77+
<Well>
78+
Content
79+
</Well>
80+
```
81+
82+
After:
83+
84+
```jsx
85+
<div className={style({
86+
display: 'block',
87+
textAlign: 'start',
88+
padding: 16,
89+
minWidth: 160,
90+
marginTop: 4,
91+
borderWidth: 1,
92+
borderRadius: 'sm',
93+
borderStyle: 'solid',
94+
borderColor: 'transparent-black-75',
95+
font: 'body-sm'
96+
})}>
97+
Content
98+
</div>
99+
```
100+
101+
## UNSAFE_style and UNSAFE_className
102+
103+
Move `UNSAFE_style` usage to the S2 style macro when possible.
104+
105+
Move `UNSAFE_className` usage to the S2 style macro when possible.
26106

27107
## Dialogs and collections
28108

29109
- `DialogContainer` and `useDialogContainer` still exist in S2, but the import path changes and dismiss logic may need to move between `Dialog`, `DialogTrigger`, and `DialogContainer`.
30-
- When `Item` survives the codemod, rename it based on its parent: `MenuItem`, `PickerItem`, `ComboBoxItem`, `ListBoxItem`, `Tab`, `TabPanel`, `Tag`, `Breadcrumb`, and similar.
110+
- When `Item` survives the codemod, rename it based on its parent component:
111+
112+
| Parent component | v3 child | S2 child |
113+
|---|---|---|
114+
| Menu / ActionMenu | Item | MenuItem |
115+
| Picker | Item | PickerItem |
116+
| ComboBox | Item | ComboBoxItem |
117+
| ListBox | Item | ListBoxItem |
118+
| Tabs | Item | Tab / TabPanel |
119+
| TagGroup | Item | Tag |
120+
| Breadcrumbs | Item | Breadcrumb |
121+
31122
- Preserve React `key` when mapping arrays, but ensure collection data items expose `id` when S2 expects it.
32123
- Table and ListView migrations often need manual review for row headers, nested columns, and explicit item ids.
33124

34-
## Tests
125+
## Toast migration
35126

36-
- Replace v3 Provider/defaultTheme test wrappers with the minimal S2 `Provider` props the test actually needs, or remove the wrapper entirely if no S2 context is required.
37-
- Update toast mocks and assertions that still reference `@react-spectrum/toast` or old dialog markup.
127+
- Move `ToastContainer` and `ToastQueue` imports from `@react-spectrum/toast` to `@react-spectrum/s2`.
128+
- Keep a shared `ToastContainer` mounted near the app root or test harness, then update all queue calls to use the S2 import path.
129+
- S2 supports `ToastQueue.neutral`, `positive`, `negative`, and `info`.
130+
- Re-check options such as `timeout`, `actionLabel`, `onAction`, `shouldCloseOnAction`, and `onClose` after the import move.
131+
- The queue methods still return a close function. Keep programmatic dismissal logic when the existing UX depends on it.
132+
- Search for every `ToastContainer` mount and every `ToastQueue` usage after moving imports. Shared app roots, secondary entrypoints, and test harnesses are easy to miss.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Inspection checklist
2+
3+
## Minimum tool versions
4+
5+
These tools are not all strictly required, but if the project uses them they must be at these minimum versions to avoid issues with the `with {type: 'macro'}` import syntax:
6+
7+
- **TypeScript 5.3+** — required for the import attributes syntax (`with {type: 'macro'}`).
8+
- **Babel 7.27.0+** or the `@babel/plugin-syntax-import-attributes` plugin — enables Babel to parse import attributes. Alternatively, `@babel/preset-env` with `shippedProposals: true` also enables import attribute parsing.
9+
- **ESLint 9.14.0+** with `@typescript-eslint/parser`.
10+
- **Prettier 3.1.1+** — needed to format `with {type: 'macro'}` import syntax correctly.
11+
12+
## What to look for
13+
14+
- Search package manifests and source for `@adobe/react-spectrum`, `@react-spectrum/*`, and `@spectrum-icons/*`.
15+
- In monorepos or mixed-tooling repos, inspect the target package or app first instead of assuming the root manifest represents the runtime target being migrated.
16+
- Determine the package manager from the relevant lockfile or workspace setup.
17+
- Detect the bundler at the migration target level. The workspace root may include Storybook, Vite, or other tooling that does not represent the runtime bundler for the package being migrated.
18+
- **Parcel v2.12.0+** already supports S2 style macros natively.
19+
- **Vite, webpack, Next.js, Rollup, ESBuild** and similar toolchains need `unplugin-parcel-macros`. Keep plugin ordering correct so macros run before the rest of the toolchain.
20+
- If the repo already has a framework-specific S2 or macro setup, preserve it instead of layering a second macro configuration on top.
21+
- Find **all** app entrypoints, including standalone pages, alternate render roots, embedded sub-apps, utility apps, and test-only render targets. Do not assume there is only one entry.
22+
- Locate root providers, shared test wrappers, toast setup, and any direct `defaultTheme` usage.
23+
- Search for `ToastContainer`, `ToastQueue`, `DialogContainer`, `useDialogContainer`, `ClearSlots`, style props, and `UNSAFE_style`. These are common follow-up areas after the codemod.

packages/dev/s2-docs/migration-references/focused-toast.md

Lines changed: 0 additions & 22 deletions
This file was deleted.

packages/dev/s2-docs/migration-references/focused-workflow.md

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)