@atomazing-org/design-system 2.0.1 → 3.7.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.
Files changed (28) hide show
  1. package/AGENTS.md +92 -0
  2. package/README.MD +263 -335
  3. package/dist/index.d.ts +11 -15
  4. package/dist/index.js +22 -22
  5. package/dist/presets/index.d.ts +15 -2
  6. package/dist/presets/index.js +315 -313
  7. package/dist/themePresets-CwgG5XEL.d.ts +65 -0
  8. package/dist/themePresets-CwgG5XEL.js +1 -0
  9. package/migrations/README.UPDATE.md +34 -20
  10. package/migrations/docs/migrations/design-system/README.md +48 -17
  11. package/migrations/docs/migrations/design-system/routes/adopt-existing/AEROCRM-EXAMPLE.md +197 -0
  12. package/migrations/docs/migrations/design-system/routes/adopt-existing/RUNBOOK.md +185 -25
  13. package/migrations/docs/migrations/design-system/routes/adopt-existing/migration.spec.json +84 -20
  14. package/migrations/docs/migrations/design-system/routes/greenfield/RUNBOOK.md +57 -25
  15. package/migrations/docs/migrations/design-system/routes/greenfield/migration.spec.json +37 -14
  16. package/migrations/docs/migrations/design-system/routes/mui4-to-latest/RUNBOOK.md +136 -77
  17. package/migrations/docs/migrations/design-system/routes/mui4-to-latest/migration.spec.json +104 -29
  18. package/migrations/docs/migrations/design-system/shared/WORKING-RULES.md +194 -0
  19. package/migrations/docs/migrations/design-system/shared/acceptance.md +76 -20
  20. package/migrations/docs/migrations/design-system/shared/common-regressions.md +218 -0
  21. package/migrations/docs/migrations/design-system/shared/gates.md +39 -3
  22. package/migrations/docs/migrations/design-system/shared/manual-qa-matrix.md +70 -0
  23. package/migrations/docs/migrations/design-system/shared/phase-exit-criteria.md +129 -0
  24. package/migrations/docs/migrations/design-system/shared/phases.md +377 -0
  25. package/migrations/skills/design-system-consumer-agent/SKILL.md +84 -0
  26. package/migrations/skills/design-system-migration-agent/SKILL.md +75 -9
  27. package/package.json +14 -4
  28. package/dist/typography-B-BeIk0v.d.ts +0 -120
@@ -1,81 +1,140 @@
1
- # Маршрут: MUI v4 → MUI v7 + @atomazing-org/design-system
2
-
3
- ## Когда использовать
4
-
5
- - В проекте есть `@material-ui/*` (Material-UI v4).
6
- - Есть собственные token-файлы/константы, которые используются напрямую в компонентах.
7
-
8
- ## Результат
9
-
10
- - Проект на `@mui/material` (v7) + Emotion.
11
- - Корневой провайдер темы: `ThemeProviderWrapper`.
12
- - Основные токены и типографика берутся из MUI theme.
13
-
14
- ## Шаги (высокий уровень)
15
-
16
- 1) Зафиксировать baseline: тесты/сборка зелёные.
17
- 2) Обновить зависимости и перейти с `@material-ui/*` на `@mui/*`.
18
- 3) Запустить официальные codemod'ы для v4 v5.
19
- 4) Довести проект до актуальной версии MUI (v6 → v7) по гайдам.
20
- 5) Подключить `@atomazing-org/design-system` и заменить корневой ThemeProvider.
21
- 6) Перенести токены: заменить импорты/использования локальных токенов на `theme.palette` и `theme.typography`.
22
- 7) Прогнать gates + тесты + сборку.
23
-
24
- ## Детальные команды (ориентир)
25
-
26
- > Порядок и точные команды могут отличаться в зависимости от пакетного менеджера и инфраструктуры.
27
-
28
- ### A) Preflight
29
-
30
- - Создайте ветку.
31
- - Выполните:
32
-
33
- ```bash
34
- npm ci
35
- npm test
36
- npm run build
37
- ```
38
-
39
- ### B) Upgrade deps до MUI v5 (первый major)
40
-
41
- - Удалите `@material-ui/*`.
42
- - Установите `@mui/material`, `@mui/icons-material`, `@emotion/react`, `@emotion/styled`.
43
-
44
- ### C) Codemod v4 v5
45
-
46
- Запустить preset-safe codemod на исходниках (обычно `src`):
47
-
48
- ```bash
49
- npx @mui/codemod@latest v5.0.0/preset-safe src
50
- ```
51
-
52
- После codemod:
53
- - исправить TODO/ошибки TypeScript;
54
- - пройтись по стилям JSS (`makeStyles/withStyles`) и заменить на совместимые подходы.
55
-
56
- ### D) Upgrade v5 → v6 → v7
57
-
58
- - Выполнить апгрейд до v6 по официальному гайду.
59
- - Затем апгрейд до v7 по официальному гайду.
60
-
61
- ### E) Подключение дизайн-системы
62
-
63
- - Установить `@atomazing-org/design-system`.
64
- - Подключить `ThemeProviderWrapper` на корне приложения.
65
-
66
- ### F) Перенос токенов
67
-
68
- 1) Соберите список файлов, где импортируются токены.
69
- 2) Заполните `token-map.csv` (пример в этом же каталоге).
70
- 3) Примените текстовые замены через скрипт `apply-replacements-from-csv.mjs` (см. `migration.spec.json`).
71
- 4) Для сложных случаев внесите правки вручную и отметьте это в отчёте.
72
-
73
- ## Ручной контроль (обязательно)
74
-
75
- - Проверить визуально минимум 5–10 ключевых экранов.
76
- - Проверить состояния компонентов (hover/active/disabled) для ключевых кнопок, инпутов, алертов.
77
- ## Shared gates (repo)
1
+ # Route: mui4-to-latest
2
+
3
+ Use this route when the target app still depends on Material-UI v4 and must land
4
+ on the `@atomazing-org/design-system` v2 contract with a MUI v7 baseline.
5
+
6
+ ## Use This Route When
7
+
8
+ - `package.json` still contains `@material-ui/*`
9
+ - the app still uses legacy styling APIs such as `makeStyles`, `withStyles`, or `createMuiTheme`
10
+ - a piecemeal integration would otherwise leave the repo in a mixed MUI v4 and MUI v7 state
11
+
12
+ ## Target Outcome
13
+
14
+ - the project runs on `@mui/material` v7 plus Emotion
15
+ - `ThemeProviderWrapper` is the only app-level theme root
16
+ - legacy MUI v4 imports and styling APIs are removed
17
+ - major UI surfaces and typography rely on modern MUI theme contracts instead of legacy local tokens
18
+ - the app boots cleanly after migration, not just after a codemod
19
+
20
+ Use `../../shared/phases.md` as the canonical step-by-step phase checklist, then
21
+ apply the route-specific requirements below.
22
+
23
+ ## Large-Project Execution Model
24
+
25
+ - keep the app runnable at the end of every phase
26
+ - keep one main change class per phase:
27
+ - dependency landing
28
+ - mechanical codemod
29
+ - legacy styling cleanup
30
+ - root theme unification
31
+ - runtime cleanup
32
+ - shared infrastructure
33
+ - domain waves
34
+ - final token cleanup
35
+ - do not mix shell rewrites, broad token cleanup, and dependency upgrades in one unvalidated batch
36
+ - checkpoint each phase with a commit or equivalent rollback point before continuing
37
+
38
+ ## Required Workflow (Phases)
39
+
40
+ 1. Inventory and segmentation
41
+ - map `@material-ui/*` dependencies and imports
42
+ - map `makeStyles`, `withStyles`, `createStyles`, `StylesProvider`, `ServerStyleSheets`, and `createMuiTheme`
43
+ - map local token modules, app shell entrypoints, shared overlays, auth-guarded routes, and build-system risks
44
+ - split the migration into shared-infrastructure scope plus domain waves
45
+ 2. Baseline and safety net
46
+ - run the repo's normal validation commands
47
+ - record pre-existing red checks separately from migration defects
48
+ - add or tighten smoke coverage for:
49
+ - the application shell
50
+ - at least one protected content route when route guards exist
51
+ - at least one stable overlay interaction when dialogs, drawers, or command surfaces are in scope
52
+ 3. Dependency landing zone
53
+ - remove `@material-ui/*`
54
+ - add `@mui/material`, `@mui/icons-material`, `@emotion/react`, `@emotion/styled`, and `@atomazing-org/design-system`
55
+ - separately align adjacent packages such as pickers, data-grid, lab, or other MUI ecosystem packages
56
+ 4. Mechanical v4 to v5 migration
57
+ - run the official MUI codemod
58
+ - resolve compile failures and TODO markers left by the codemod
59
+ - keep the output as a mechanical landing step, not a full visual cleanup
60
+ 5. Legacy styling and theme API cleanup
61
+ - replace `makeStyles`, `withStyles`, `createStyles`, and other JSS-specific patterns
62
+ - replace `createMuiTheme`, legacy `overrides` or `props`, and deprecated spacing or theme API usage
63
+ - remove legacy styling providers that no longer belong in the runtime
64
+ 6. Stabilize on modern MUI before design-system adoption
65
+ - get the app compiling and booting on modern MUI plus Emotion before changing the theme source of truth
66
+ - resolve duplicate React or Emotion runtime loading
67
+ - preserve the structural shell layout while removing legacy APIs
68
+ 7. Root theme unification
69
+ - connect `ThemeProviderWrapper` at the app root
70
+ - remove competing root `ThemeProvider` instances unless they are thin wrappers around the design system
71
+ - move preset selection into one explicit app-level theme module such as `src/theme/appThemes.ts`
72
+ 8. Runtime boot cleanup
73
+ - start the app with the repo's normal dev or start command
74
+ - open the first route in a real browser
75
+ - fix startup console errors before continuing
76
+ - fix migration-caused startup warnings before continuing
77
+ - remove module-scope code that depends on browser APIs, storage, or i18n locale activation
78
+ - move browser listeners such as `beforeinstallprompt`, `matchMedia`, or resize subscriptions into effects with cleanup
79
+ - if smoke mode disables auth redirects, seed a deterministic role-bearing user so protected routes can render real content
80
+ 9. Shared infrastructure migration
81
+ - stabilize the app shell, route wrappers, and shared layout containers first
82
+ - migrate shared primitives that should now use MUI directly or thin MUI wrappers
83
+ - restore shared dialogs, drawers, bottom sheets, and search overlays with stable semantics and layout contracts
84
+ - explicitly preserve `display`, grid or flex templates, `min-width`, `min-height`, `overflow`, and scroll behavior when refactoring shell containers
85
+ - if shell workspaces, route wrappers, or page roots were touched, verify the main content still fills the available content region instead of collapsing into partial-width cards or broken dashboard stacks
86
+ - audit compact shared UI such as chart legends, chips, segmented filters, and metric badges for preset drift; if they now read as ad hoc chip chrome, rebuild them with neutral MUI composition
87
+ 10. Token and consumer cleanup
88
+ - apply token remaps in controlled batches instead of one repo-wide blind replace
89
+ - replace hardcoded tokens with `theme.palette`, `theme.typography`, and MUI theme helpers
90
+ - remove zero-value wrappers and zero-value surface wrappers
91
+ - normalize visible text to `Typography` with explicit variants
92
+ - replace palette alpha suffix hacks with `alpha()`
93
+ - remove app-owned gradient or shadow chrome from normal consumer surfaces
94
+ - if codemods, token remaps, or file rewrites touched localized copy, keep files in UTF-8, scan for mojibake or replacement characters, and verify at least one real localized route renders readable text
95
+ 11. Domain waves
96
+ - migrate feature areas in waves after shared infrastructure is stable
97
+ - keep each wave small enough to validate independently
98
+ - run smoke and visual checks after each wave before moving to the next domain
99
+ 12. Final quality gates and closeout
100
+ - re-run lint, tests, build, and route-specific gates
101
+ - verify no `@material-ui/*` dependencies remain
102
+ - verify no `@material-ui/*` imports remain in source
103
+ - verify the app root uses `ThemeProviderWrapper`
104
+ - verify the first route boots without browser console startup errors or migration-caused runtime warnings
105
+
106
+ ## Common Failure Modes
107
+
108
+ - treating the codemod result as a finished migration instead of a mechanical landing step
109
+ - removing `@material-ui/*` but leaving JSS runtime or theme APIs in place
110
+ - adopting the design system before the app is stable on modern MUI plus Emotion
111
+ - mixing dependency upgrades, shell rewrites, and token cleanup into one giant diff that cannot be debugged safely
112
+ - module-scope `window`, `document`, `navigator`, or storage access that breaks startup once providers move
113
+ - module-scope i18n work that runs before locale activation
114
+ - duplicate React or Emotion runtimes after moving to modern MUI
115
+ - protected-route smoke checks that only render fallback pages instead of real product screens
116
+ - shared shell or overlay rewrites that accidentally drop layout constraints, semantics, or spacing
117
+ - route roots or page containers lose fill behavior, so the workspace shows partial-width cards, collapsed analytics grids, or unused content area
118
+ - compact legends, analytics chips, metric badges, or segmented filters drift into consumer-owned chip chrome that visibly fights the preset
119
+ - codemods or encoding fixes leave mojibake, replacement characters, or broken non-Latin text in screens, fixtures, or mock data
120
+ - repo-wide token replacements applied before shared infrastructure is stabilized
121
+
122
+ ## Practical Fix Patterns
123
+
124
+ - land on modern MUI plus Emotion first, then adopt `ThemeProviderWrapper`
125
+ - keep a dedicated app theme module for preset selection
126
+ - treat shell wrappers and overlay wrappers as behavior, not decoration
127
+ - if a shell exposes a workspace pane, keep route roots and page containers on explicit flex growth with preserved `min-width`, `min-height`, and width constraints so the page actually fills the workspace
128
+ - add smoke coverage before broad shared-component rewrites
129
+ - migrate shared infrastructure before feature-specific pages
130
+ - batch token replacement by shared area or domain instead of by global search alone
131
+ - if compact legends, chips, or segmented filters drift away from the preset, rebuild them from `Stack`, markers, and `Typography` instead of preserving ad hoc chip styling
132
+ - after bulk replacements or encoding-sensitive edits, run a mojibake scan and verify one localized route in a real browser before closing the migration
133
+ - expand repo-local design and typography gates once the broad cleanup begins
134
+
135
+ ## Shared Gates
78
136
 
79
137
  Use common gate definitions from:
138
+
80
139
  - `../../shared/gates.md`
81
140
  - `../../shared/acceptance.md`
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "../../schema/migration.spec.schema.json",
3
3
  "id": "mui4-to-latest",
4
- "title": "MUI v4 MUI v7 + adopt @atomazing-org/design-system",
4
+ "title": "MUI v4 to MUI v7 plus @atomazing-org/design-system",
5
5
  "detect": {
6
6
  "packageJson": {
7
7
  "anyDependencies": [
@@ -12,59 +12,134 @@
12
12
  }
13
13
  },
14
14
  "entryConditions": [
15
- "package.json содержит @material-ui/*",
16
- "тесты/сборка до миграции зелёные"
15
+ "package.json contains @material-ui/*",
16
+ "the migration needs a full route-based upgrade instead of piecemeal edits"
17
17
  ],
18
18
  "exitConditions": [
19
- "в package.json отсутствуют @material-ui/*",
20
- "код не импортирует @material-ui/*",
21
- "корень приложения использует ThemeProviderWrapper"
19
+ "package.json does not contain @material-ui/*",
20
+ "app source no longer imports @material-ui/*",
21
+ "the app root uses ThemeProviderWrapper",
22
+ "the app boots without migration-caused startup console errors",
23
+ "tests and build are green"
22
24
  ],
23
25
  "steps": [
24
26
  {
25
- "name": "Preflight",
26
- "run": ["npm ci", "npm test", "npm run build"]
27
+ "name": "Inventory and baseline",
28
+ "manualReview": [
29
+ "Map @material-ui/* imports and dependencies plus legacy styling APIs such as makeStyles, withStyles, createMuiTheme, StylesProvider, and ServerStyleSheets.",
30
+ "Record pre-existing failing checks separately from migration defects.",
31
+ "Split the repo into shared-infrastructure scope and domain migration waves before broad edits begin.",
32
+ "Run baseline checks with the target repository package manager (for example install/ci, tests, and build as available)."
33
+ ]
27
34
  },
28
35
  {
29
- "name": "Update package.json deps (v4 → v5 baseline + design-system)",
30
- "run": [
31
- "node migrations/scripts/migrations/design-system/actions/update-package-json.mjs --remove @material-ui/core --remove @material-ui/styles --remove @material-ui/icons --add @mui/material:^7 --add @mui/icons-material:^7 --add @emotion/react:^11 --add @emotion/styled:^11 --add @atomazing-org/design-system:<SET_VERSION>"
32
- ],
36
+ "name": "Add safety net",
33
37
  "manualReview": [
34
- "Проверьте наличие альтернативных зависимостей (mui lab, x-пакеты, date-pickers, data-grid) и обновите их отдельно."
38
+ "Add or tighten smoke coverage for the application shell before broad refactors.",
39
+ "If route guards exist, ensure at least one protected content route can be validated as a real screen.",
40
+ "If shared overlays will be touched, add at least one stable overlay interaction to smoke coverage."
41
+ ]
42
+ },
43
+ {
44
+ "name": "Update package.json deps (v4 to modern MUI plus design-system)",
45
+ "manualReview": [
46
+ "Edit package.json directly: remove @material-ui/core, @material-ui/styles, and @material-ui/icons; add @mui/material:^7, @mui/icons-material:^7, @emotion/react:^11, @emotion/styled:^11, and @atomazing-org/design-system:<SET_VERSION>.",
47
+ "Check for adjacent ecosystem packages such as mui lab, x packages, date-pickers, or data-grid and align them separately.",
48
+ "Treat this as a dependency landing step only; do not mix in broad visual cleanup."
35
49
  ]
36
50
  },
37
51
  {
38
52
  "name": "Install deps",
39
- "run": ["npm install"]
53
+ "manualReview": [
54
+ "Install dependencies with the target repository package manager (npm, pnpm, yarn, or bun)."
55
+ ]
40
56
  },
41
57
  {
42
- "name": "Run official codemod (v4 v5)",
43
- "run": ["npx @mui/codemod@latest v5.0.0/preset-safe src"],
58
+ "name": "Run official codemod (v4 to v5)",
44
59
  "manualReview": [
45
- "Просмотрите TODO и ошибки компиляции после codemod.",
46
- "Проверьте стили на JSS (makeStyles/withStyles)."
60
+ "Run the official MUI codemod with a package-manager-appropriate executor (for example pnpm dlx, npm exec, yarn dlx, or bunx): @mui/codemod@latest v5.0.0/preset-safe src.",
61
+ "Review TODO markers and compile errors left by the codemod.",
62
+ "Treat the codemod output as a mechanical landing step, not as a finished migration."
63
+ ]
64
+ },
65
+ {
66
+ "name": "Remove legacy styling and theme APIs",
67
+ "manualReview": [
68
+ "Replace makeStyles, withStyles, createStyles, and other JSS-only patterns.",
69
+ "Replace createMuiTheme, legacy overrides or props usage, and deprecated theme API calls such as theme.spacing.unit.",
70
+ "Remove legacy styling providers that no longer belong in the runtime."
71
+ ]
72
+ },
73
+ {
74
+ "name": "Stabilize on modern MUI baseline",
75
+ "manualReview": [
76
+ "Get the app compiling and booting on modern MUI plus Emotion before changing the theme root.",
77
+ "Resolve duplicate React or Emotion runtime loading before design-system adoption.",
78
+ "Preserve the structural shell layout while modernizing the underlying MUI stack."
79
+ ]
80
+ },
81
+ {
82
+ "name": "Connect design-system provider",
83
+ "manualReview": [
84
+ "Connect ThemeProviderWrapper at the application root.",
85
+ "Remove or collapse any competing root ThemeProvider so the design system becomes the single theme source of truth.",
86
+ "Move preset selection into one explicit app-level theme module instead of leaving it scattered across generic constants layers."
87
+ ]
88
+ },
89
+ {
90
+ "name": "Runtime boot cleanup",
91
+ "manualReview": [
92
+ "Start the app with the repo's normal dev or start command and open the first route in a real browser.",
93
+ "Fix startup console errors before continuing.",
94
+ "Fix migration-caused startup warnings before continuing, especially duplicate runtime singleton warnings for react, react-dom, @emotion/react, and @emotion/styled.",
95
+ "Remove module-scope code that requires browser APIs, storage, or i18n locale activation.",
96
+ "Move browser event listeners into effects with cleanup instead of render paths or module scope.",
97
+ "If smoke mode disables auth redirect, seed a deterministic role-bearing user so protected routes can render real content."
98
+ ]
99
+ },
100
+ {
101
+ "name": "Shared infrastructure migration",
102
+ "manualReview": [
103
+ "Stabilize the app shell, route wrappers, and shared layout containers before domain-by-domain work.",
104
+ "Migrate shared primitives that should now use MUI directly or thin MUI wrappers.",
105
+ "Restore dialog, drawer, bottom-sheet, and search-overlay semantics before broad feature cleanup.",
106
+ "Preserve display, grid or flex templates, min-width, min-height, overflow, and scroll behavior when refactoring shell containers.",
107
+ "If shell workspaces, route wrappers, or page roots were touched, verify the main content still fills the available content region and that dashboard or workflow grids did not collapse into partial-width stacks.",
108
+ "Audit compact shared UI such as chart legends, chips, segmented filters, and metric badges for preset drift; replace ad hoc chip-like chrome with neutral MUI composition when needed."
47
109
  ]
48
110
  },
49
111
  {
50
112
  "name": "Apply token remap (project-specific)",
51
- "run": [
52
- "node migrations/scripts/migrations/design-system/shared/apply-replacements-from-csv.mjs --csv migrations/docs/migrations/design-system/routes/mui4-to-latest/token-map.csv --root src"
53
- ],
54
113
  "manualReview": [
55
- "Включите нужные строки в token-map.csv (enabled=true) и проверьте дифф.",
56
- "Для сложных замен добавьте отдельные правила или выполните ручные правки."
114
+ "Use token-map.csv as a reference for targeted replacements and apply changes in controlled batches.",
115
+ "Enable only the rows needed in token-map.csv and review the diff in controlled batches.",
116
+ "For large repos, apply token replacement after shared infrastructure is stable instead of doing a blind repo-wide rewrite first.",
117
+ "For complex replacements, add dedicated rules or perform manual edits.",
118
+ "If bulk replacements or file rewrites touched localized copy, scan for mojibake or replacement characters and verify non-Latin UI text still renders readable strings."
119
+ ]
120
+ },
121
+ {
122
+ "name": "Domain migration waves",
123
+ "manualReview": [
124
+ "Migrate feature areas in waves after the shared shell and shared primitives are stable.",
125
+ "Keep each wave small enough to validate independently.",
126
+ "Re-run the relevant smoke or route checks after each wave before moving to the next domain."
57
127
  ]
58
128
  },
59
129
  {
60
130
  "name": "Quality gates",
61
- "run": [
62
- "node migrations/scripts/migrations/design-system/gates/no-legacy-material-ui.mjs --root src",
63
- "node migrations/scripts/migrations/design-system/gates/no-hardcoded-tokens.mjs --root src --config migrations/scripts/migrations/design-system/shared/token-gate.config.json",
64
- "npm test",
65
- "npm run build"
131
+ "manualReview": [
132
+ "Re-run the target repository closeout gates with its package manager: lint, tests, and build (when available).",
133
+ "Verify package.json and source contain no @material-ui/* dependencies or imports (for example with rg).",
134
+ "Run repo-local token/design-contract gates when available and manually verify forbidden legacy token usage is removed."
66
135
  ]
67
136
  }
68
137
  ],
69
- "gates": ["no-legacy-material-ui", "no-hardcoded-tokens", "tests", "build"]
138
+ "gates": [
139
+ "no-legacy-material-ui",
140
+ "no-hardcoded-tokens",
141
+ "lint",
142
+ "tests",
143
+ "build"
144
+ ]
70
145
  }
@@ -0,0 +1,194 @@
1
+ # Working Rules For Consumer Repositories
2
+
3
+ Use this document when integrating or maintaining `@atomazing-org/design-system`
4
+ inside an application repository.
5
+
6
+ ## Public Surface Only
7
+
8
+ - Import runtime APIs from `@atomazing-org/design-system`.
9
+ - Import shipped presets from `@atomazing-org/design-system/presets`.
10
+ - Do not import internal files from `src/*`, `dist/*`, or unpublished paths.
11
+
12
+ ## Standard Integration Contract
13
+
14
+ - Wrap the app with `ThemeProviderWrapper`.
15
+ - Use `useThemeSettings()` for runtime theme selection and dark-mode changes.
16
+ - Treat the design system as the single source of truth for theme state.
17
+ - Do not keep a second app-level theme state store unless it only mirrors design-system state.
18
+ - Let the active preset own the application background.
19
+ - Do not set app-level background colors or fills on root shells, route wrappers, or page containers when that would override the preset background supplied by the design system.
20
+ - Treat `theme.palette.background.paper` and other surface tokens as component surfaces, not as a replacement for the preset-controlled page background.
21
+ - If the app shell exposes a dedicated workspace or content pane, route roots and page containers must stretch to fill that region instead of shrinking to intrinsic content width.
22
+
23
+ ## Preset Selection Rules
24
+
25
+ - `defaultThemes`: baseline application presets.
26
+ - `landingPageThemes`: extended preset pack for landing pages and marketing surfaces.
27
+ - `allBuiltInThemes`: combined pack for showcases or apps that intentionally want both sets.
28
+ - Keep preset selection in one explicit app-owned theme module such as `src/theme/appThemes.ts`.
29
+ - Do not hide preset choice behind generic constants passthrough files such as `src/constants/themes/themes.ts`.
30
+
31
+ If the consumer app only needs one or two presets, prefer importing the named presets explicitly
32
+ instead of building a new parallel preset registry.
33
+ If the consumer needs a curated subset, export that subset from the app theme module instead of
34
+ rebuilding theme state or duplicating preset metadata elsewhere.
35
+
36
+ ## Landing Composition Rules
37
+
38
+ When the consumer app uses landing or marketing surfaces:
39
+
40
+ - use `landingPageThemes` intentionally
41
+ - let the active preset own the page background
42
+ - let the active preset own the surface character of landing panels
43
+ - do not hand-style landing `Paper` or `Card` surfaces with local glow, bloom, blur, decorative borders, gradient washes, or pseudo-element chrome
44
+ - app code may control layout, spacing, sizing, and content hierarchy, but the visual treatment of surfaces must come from the preset/theme layer
45
+ - prefer standard MUI composition for previews and proof blocks
46
+ - avoid custom decorative shapes and pseudo-graphics when a simple MUI layout can express the same state
47
+ - avoid nested rectangular surface hierarchies such as `card inside card inside card`
48
+ - keep one primary outer surface and use lightweight MUI primitives inside it
49
+ - if a preview block becomes dense, remove secondary content before tightening spacing
50
+
51
+ ## Surface Composition Rules
52
+
53
+ Across consumer components in general:
54
+
55
+ - one logical block should have one primary rectangular surface
56
+ - let the active preset own the visual treatment of `Paper`, `Card`, `Dialog`, `Drawer`, and similar surfaces
57
+ - do not hand-style consumer surfaces with local glow, halo, bloom, decorative borders, blur, gradient washes, or pseudo-element chrome
58
+ - do not keep zero-value surface wrappers such as a local `SurfaceCard` that only forwards props to MUI `Card` without adding real behavior
59
+ - do not keep large inline `sx` objects in JSX; if a component needs substantial styling, extract a local `styled(...)` component in the same file and keep those styled declarations near the bottom of the file
60
+ - keep app styling focused on layout, spacing, sizing, and content hierarchy; move distinct surface looks into presets or MUI theme overrides
61
+ - prefer `Stack`, `List`, `Divider`, `Typography`, `Chip`, and `Avatar` for internal composition
62
+ - do not add extra bordered or elevated rectangular layers unless they carry a separate semantic role
63
+ - do not restyle chart legends, compact filters, segmented controls, or status chips into ad hoc chip-like chrome that competes with the active preset; prefer neutral MUI composition and let the preset own the surface character
64
+
65
+ ## Design Token Hardening Rules
66
+
67
+ - Use theme helpers such as `alpha()` instead of string-concatenated palette hacks like `${theme.palette.primary.main}1a`.
68
+ - Decorative gradients and shadow styling are forbidden in normal consumer UI, especially on shared surfaces and shell infrastructure.
69
+ - If a component must visually preview preset data, such as a theme swatch, document that exception inline and keep it on a small explicit allowlist in the repo-local design-contract check.
70
+ - Repo-local design-contract lint should protect against decorative gradients, direct shadow styling, theme shadow-token drift, and palette alpha suffix hacks in addition to raw colors and numeric visual tokens.
71
+
72
+ ## MUI-First Component Rules
73
+
74
+ - Prefer direct MUI primitives for base UI elements such as buttons, icon buttons, labels, helper text, skeletons, lists, drawers, and dialog sections.
75
+ - Do not keep consumer-owned substitute atoms that merely recreate an existing MUI primitive with `div`, `label`, `span`, `Box`, or other generic wrappers.
76
+ - If a consumer abstraction is still useful, keep it as a thin wrapper around the MUI primitive rather than a parallel hand-rolled implementation.
77
+ - Remove zero-value wrappers that only rename a MUI primitive or surface without adding behavior, state policy, or accessibility value.
78
+ - Exceptions are allowed only when there is clear custom logic or a pattern MUI does not provide directly, such as drag-and-drop zones, app-specific charts, or brand artwork.
79
+ - Even when an exception is justified, compose it from MUI layout and surface primitives where possible.
80
+
81
+ ## Typography Contract Rules
82
+
83
+ - Visible application text should be rendered through `Typography`, not left as raw JSX text inside layout wrappers.
84
+ - Every `Typography` must declare an explicit `variant`.
85
+ - Pick variants by semantics, not convenience:
86
+ - headings and section titles: `h1` through `h6`
87
+ - main body copy and helper text: `subtitle1`, `body1`, `body2`
88
+ - button and action labels: compact standard variants such as `subtitle2` or `button`
89
+ - chip, badge, and compact status labels: compact standard variants such as `caption`
90
+ - When MUI interactive components such as `Button`, `ToggleButton`, `MenuItem`, `Chip`, or `Alert` need visible text, wrap that text in `Typography component="span"` with an explicit variant.
91
+ - If the repo has a typography contract lint or script, keep it green as part of the migration gate.
92
+ - If bulk replacements or file rewrites touch localized copy, keep files in UTF-8 and scan touched files for mojibake or replacement characters before closeout.
93
+ - Validate at least one real route with non-Latin copy when the migration touched translated strings, mocks, or fixtures.
94
+
95
+ ## Overlay And Semantic Contract Rules
96
+
97
+ - Dialogs, drawers, bottom sheets, and other overlay containers must expose stable `aria-labelledby` and `aria-describedby` semantics.
98
+ - Shared dialog-title abstractions should accept stable title and subtitle ids so the overlay can wire those semantics directly instead of relying on incidental text structure.
99
+ - Close buttons inside shared overlays must have explicit accessible labels.
100
+ - Command palettes, searchable pickers, and other overlay search surfaces should use `combobox` plus `listbox` semantics when they own filtered keyboard navigation.
101
+ - Decorative overlay chrome such as drag handles or visual grabbers should be hidden from assistive technology when it does not convey state.
102
+ - Prefer stable overlay test hooks or landmarks for smoke coverage, and avoid brittle tests that depend on incidental navigation paths just to reach a modal.
103
+
104
+ ## Workflow Composition Rules
105
+
106
+ - If multiple pages share the same workflow shell, form layout, or section grid, extract one shared layout contract instead of duplicating the page structure per role or route.
107
+ - Keep role-specific behavior in headers, sections, and policy hooks; keep shared structure in a dedicated workflow layout component.
108
+ - Prefer direct local imports for chunk-sensitive app internals when a barrel re-export introduces circular chunk warnings in build output.
109
+ - Do not preserve convenience barrels for local app modules when they make execution order less reliable than direct feature-local imports.
110
+
111
+ ## Custom Preset Rules
112
+
113
+ Custom presets must follow `ThemePreset` exactly:
114
+
115
+ - stable string `id`
116
+ - human-readable `label`
117
+ - `colorSchemes.light`
118
+ - `colorSchemes.dark`
119
+
120
+ Each scheme should define:
121
+
122
+ - `palette.background.default`
123
+ - `palette.background.paper`
124
+ - `palette.text.primary`
125
+ - `palette.text.secondary`
126
+ - `palette.divider`
127
+
128
+ ## SSR And Next.js Rules
129
+
130
+ - Keep `ThemeProviderWrapper` inside a client boundary.
131
+ - Do not access `window`, `document`, `navigator`, or `localStorage` at module scope.
132
+ - If theme preference must be bridged through cookies or storage, keep the browser-specific logic client-safe.
133
+
134
+ ## Runtime Startup Rules
135
+
136
+ - A green build is not enough to close a migration.
137
+ - After dependency, provider, or theme-state changes, start the app with the repo's normal dev/start command.
138
+ - Open the app in a real browser and fix startup console errors before closeout.
139
+ - Fix migration-caused startup warnings before closeout when they indicate broken runtime alignment.
140
+ - If runtime singleton warnings appear for `react`, `react-dom`, `@emotion/react`, or `@emotion/styled`, align the bundler config so only one runtime copy loads.
141
+ - Avoid module-scope calls that require browser APIs, storage, or an activated i18n locale.
142
+ - Register browser event listeners such as `beforeinstallprompt`, `matchMedia`, or other window-driven subscriptions inside effects with cleanup instead of render paths or module scope.
143
+ - Verify that the app background still comes from the active preset after migration.
144
+ - If the consumer uses root shells such as `AppShell`, `Layout`, `PageContainer`, or route wrappers, keep them transparent unless they intentionally represent a surface layer.
145
+ - If token drift is broad, add or tighten a repo-local design contract gate for hardcoded colors, raw numeric type scale, ad hoc radius/opacity values, decorative gradients, shadow styling, and palette alpha suffix hacks, and keep it green.
146
+
147
+ ## Build Hygiene Rules
148
+
149
+ - Fix consumer-owned build warnings that come from the app's own config, imports, or chunking strategy.
150
+ - If PWA or Workbox config references asset names, keep those glob patterns aligned with the actual files emitted from `public/` or equivalent static assets.
151
+ - If Vite or Rollup reports oversized consumer-owned chunks, prefer targeted `manualChunks` or additional lazy boundaries over simply increasing `chunkSizeWarningLimit`.
152
+ - Do not silence a real warning when the app can fix the underlying config or bundling cause directly.
153
+ - If the only remaining warning comes from an upstream toolchain package outside the consumer app's control, record the exact package and file instead of misclassifying it as an app regression.
154
+
155
+ ## Anti-Patterns
156
+
157
+ Avoid these patterns:
158
+
159
+ - deep imports from internal design-system files
160
+ - a second competing root `ThemeProvider`
161
+ - hardcoded theme colors when a theme token exists
162
+ - hardcoded root-level page backgrounds that override the active preset background
163
+ - hand-rolled substitute primitives for components MUI already provides
164
+ - zero-value wrapper components that only rename a stock MUI primitive or surface
165
+ - decorative gradients or shadow styling applied directly in consumer shells and shared surfaces
166
+ - string-concatenated palette alpha hacks instead of theme helpers such as `alpha()`
167
+ - local storage access outside SSR-safe guards
168
+ - dialogs, drawers, or bottom sheets without stable semantic labeling
169
+ - browser event listeners attached from render flow without cleanup
170
+ - maintaining a parallel dark-mode enum or persistence format
171
+ - role-based workflow pages that duplicate the same layout shell instead of sharing one structural contract
172
+ - local barrel re-exports that introduce circular chunk warnings for app internals
173
+
174
+ ## When Migration Is Required
175
+
176
+ Do not treat these as small integration tasks. Use route-based migration instead:
177
+
178
+ - the app still uses `@material-ui/*`
179
+ - the app has a custom token layer that should be replaced or normalized
180
+ - the app mixes multiple theme providers or theme sources of truth
181
+ - the user asks to standardize the project on this library
182
+ - the migration touches a broad set of colors, typography, spacing, or component overrides
183
+
184
+ ## Route Selection
185
+
186
+ - `mui4-to-latest`: legacy Material UI v4 imports or dependencies
187
+ - `greenfield`: new app, or no legacy theme/token migration required
188
+ - `adopt-existing`: app already uses modern MUI but needs theme/token adoption
189
+
190
+ ## Recommended User Request
191
+
192
+ Use a request like this with an AI agent:
193
+
194
+ `Adopt @atomazing-org/design-system in this repo. If the current theme stack is legacy or custom, choose the correct migration route and execute the migration runbook.`