Skip to content

Commit 80d9703

Browse files
committed
add more content to skill content
1 parent eacd571 commit 80d9703

6 files changed

Lines changed: 240 additions & 444 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# App setup and style macro
2+
3+
## Full-page apps
4+
5+
- Import `@react-spectrum/s2/page.css` in the app entrypoint so the page background and color scheme are applied before JavaScript runs.
6+
- Do not carry over a v3 root `Provider theme={defaultTheme}` wrapper just to make the app render. S2 does not require that pattern.
7+
- Do not assume there is only one app root. Standalone pages, alternate entrypoints, utility apps, embedded sub-apps, and test-only render targets may each need their own `page.css` or Provider cleanup.
8+
9+
## Embedded sections
10+
11+
- If S2 renders as part of a larger page instead of owning the whole document, keep the S2 subtree inside `<Provider background="...">` rather than importing `page.css` globally.
12+
13+
## Provider decisions
14+
15+
- Use S2 `Provider` when you need locale overrides, router integration, explicit color-scheme/background control, or SSR with `elementType="html"`.
16+
- Remove `theme={defaultTheme}` and other v3 theme props. They do not carry forward to S2.
17+
- Preserve surrounding app-shell providers such as routing, Redux/store, analytics, i18n/intl, and product-framework host providers. Replace only the React Spectrum-specific wrapper instead of flattening the whole provider stack.
18+
- For tests, wrap only the cases that actually need S2 context such as locale or background. Do not recreate a full v3 theme wrapper by default.
19+
20+
## Bundlers
21+
22+
- Detect the bundler at the migration target level, especially in monorepos. The workspace root may include Storybook, Vite, or other tooling that does not represent the runtime bundler for the package being migrated.
23+
- Parcel v2.12.0+ already supports S2 macros. Most Parcel repos only need the package install and the right entrypoint CSS import.
24+
- Non-Parcel bundlers need `unplugin-parcel-macros` and the appropriate framework setup. Keep plugin ordering correct so macros run before the rest of the toolchain.
25+
- If the repo already has a framework-specific S2 setup, preserve it instead of layering a second macro configuration on top.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Manual fixes after the codemod
2+
3+
## Known gaps to handle explicitly
4+
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.
7+
8+
## Imports and packages
9+
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.
13+
14+
## App and Provider setup
15+
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.
20+
21+
## Style and layout follow-ups
22+
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.
26+
27+
## Dialogs and collections
28+
29+
- `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.
31+
- Preserve React `key` when mapping arrays, but ensure collection data items expose `id` when S2 expects it.
32+
- Table and ListView migrations often need manual review for row headers, nested columns, and explicit item ids.
33+
34+
## Tests
35+
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.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Toast migration
2+
3+
## Import changes
4+
5+
- Move `ToastContainer` and `ToastQueue` imports from `@react-spectrum/toast` to `@react-spectrum/s2`.
6+
- Keep a shared `ToastContainer` mounted near the app root or test harness, then update all queue calls to use the S2 import path.
7+
8+
## Queue methods
9+
10+
- S2 supports `ToastQueue.neutral`, `positive`, `negative`, and `info`.
11+
- Re-check options such as `timeout`, `actionLabel`, `onAction`, `shouldCloseOnAction`, and `onClose` after the import move.
12+
- The queue methods still return a close function. Keep programmatic dismissal logic when the existing UX depends on it.
13+
14+
## Common post-codemod blind spots
15+
16+
- Search for every `ToastContainer` mount and every `ToastQueue` usage after moving imports. Shared app roots, secondary entrypoints, and test harnesses are easy to miss.
17+
18+
## Tests and mocks
19+
20+
- Update every toast mock to point at `@react-spectrum/s2`.
21+
- If a test mounted `ToastContainer` from the old package, swap it to the S2 import as part of the same change.
22+
- Re-run the affected tests after the import move. Toast helpers are often mocked in many files and are easy to miss.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Codemod-first workflow
2+
3+
## Inspect before editing
4+
5+
- Search package manifests and source for `@adobe/react-spectrum`, `@react-spectrum/*`, and `@spectrum-icons/*`.
6+
- In monorepos or mixed-tooling repos, inspect the target package or app first instead of assuming the root manifest, Storybook config, or workspace tooling represents the runtime target being migrated.
7+
- Determine the package manager from the relevant lockfile or workspace setup, then choose the codemod runner that matches that repo or package.
8+
- Detect the bundler at the migration target level before touching setup files. Parcel v2.12.0+ already supports S2 style macros. Vite, webpack, Next.js, Rollup, ESBuild, and similar toolchains need explicit macro-plugin setup.
9+
- Find app entrypoints, standalone pages, alternate entrypoints, embedded sub-apps, utility apps, test-only render targets, root providers, shared test wrappers, toast setup, and any direct `defaultTheme` usage before the codemod changes imports.
10+
- Search for `ToastContainer`, `ToastQueue`, `DialogContainer`, `useDialogContainer`, `ClearSlots`, style props, and `UNSAFE_style`. These are common follow-up areas after the codemod.
11+
12+
## Run the codemod first
13+
14+
Prefer the repo-native non-interactive command so the upgrade stays deterministic:
15+
16+
```bash
17+
npx @react-spectrum/codemods s1-to-s2 --agent
18+
yarn dlx @react-spectrum/codemods s1-to-s2 --agent
19+
pnpm dlx @react-spectrum/codemods s1-to-s2 --agent
20+
```
21+
22+
Use `npx` for npm and Yarn 1 repos, `yarn dlx` for Yarn Berry or Yarn PnP repos, and `pnpm dlx` for pnpm repos. Use the equivalent workspace-native runner if the repo uses another package manager.
23+
Use `--path <dir>` for monorepos or when only one package should migrate first. In a monorepo, run the codemod against the target subtree first instead of the whole workspace.
24+
Use `--components A,B` when the user explicitly wants an incremental rollout by component family.
25+
Use `--dry` when you need to preview scope before editing.
26+
27+
## Resolve follow-up work in order
28+
29+
1. Install or verify `@react-spectrum/s2` and clean up imports.
30+
2. Add S2 app setup such as `@react-spectrum/s2/page.css` or `Provider` changes.
31+
3. Search for `TODO(S2-upgrade)` and fix every remaining comment.
32+
4. Resolve style prop, layout, and dialog/collection follow-ups.
33+
5. Migrate icons, illustrations, and toast imports.
34+
6. Update tests, mocks, and validation commands.
35+
36+
## Validate with repo-native commands
37+
38+
Prefer the narrowest existing scripts from `package.json`:
39+
40+
- dependency install if manifests changed
41+
- typecheck or compile
42+
- focused tests for touched areas
43+
- build
44+
45+
For monorepos, validate the affected package or subtree first with its own scripts before escalating to workspace-wide checks.

0 commit comments

Comments
 (0)