@astryxdesign/cli 0.6.6-canary.6ea1fb7 → 0.6.6-canary.7c8ddf2

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 (176) hide show
  1. package/README.md +83 -83
  2. package/api/build/_adapter.d.mts +15 -0
  3. package/api/build/_adapter.mjs +22 -0
  4. package/api/build/build.doc.mjs +1 -1
  5. package/api/build/build.type.d.mts +4 -0
  6. package/api/build/build.type.mjs +1 -0
  7. package/api/build/help/help.mjs +1 -1
  8. package/api/build/kit/kit.mjs +12 -1
  9. package/api/component/component-replacement.test.mjs +12 -0
  10. package/api/component/component.doc.mjs +5 -2
  11. package/api/docs/_adapter.mjs +48 -1
  12. package/api/docs/compiled-topics.test.mjs +1 -1
  13. package/api/docs/detail/section/section.d.mts +44 -0
  14. package/api/docs/detail/section/section.mjs +164 -13
  15. package/api/docs/detail/section/section.test.mjs +4 -4
  16. package/api/docs/docOverlays.test.mjs +28 -17
  17. package/api/docs/docs.doc.mjs +3 -3
  18. package/api/docs/docs.mjs +11 -16
  19. package/api/docs/docs.test.mjs +9 -10
  20. package/api/docs/integration-tree.test.mjs +26 -26
  21. package/api/docs/integrationDocs.test.mjs +2 -2
  22. package/api/docs/namespace-section.test.mjs +260 -0
  23. package/api/docs/token-tables.test.mjs +93 -0
  24. package/api/doctor/doctor.d.mts +6 -0
  25. package/api/doctor/doctor.mjs +149 -40
  26. package/api/doctor/doctor.test.mjs +104 -0
  27. package/api/doctor/theme-checks.mjs +1 -1
  28. package/api/gap-report/gap-report.doc.mjs +2 -1
  29. package/api/init/run/run.mjs +1 -0
  30. package/api/integration/validate-integration.mjs +20 -4
  31. package/api/integration/validate-integration.test.mjs +73 -0
  32. package/api/layout/check/check.d.mts +1 -0
  33. package/api/layout/check/check.mjs +1 -0
  34. package/api/layout/expand/expand.d.mts +1 -0
  35. package/api/layout/expand/expand.mjs +1 -0
  36. package/api/layout/grammar/grammar.d.mts +1 -0
  37. package/api/layout/grammar/grammar.mjs +1 -0
  38. package/api/layout/layoutCheck.doc.mjs +1 -1
  39. package/api/layout/layoutExpand.doc.mjs +1 -1
  40. package/api/layout/layoutGrammar.doc.mjs +1 -1
  41. package/api/search/search.d.mts +44 -0
  42. package/api/search/search.domain-priority.test.mjs +261 -0
  43. package/api/search/search.mjs +191 -29
  44. package/api/swizzle/swizzle.doc.mjs +5 -2
  45. package/api/template/copy/copy.mjs +12 -0
  46. package/api/template/template.doc.mjs +1 -1
  47. package/api/template/template.type.d.mts +3 -0
  48. package/api/template/template.type.mjs +3 -0
  49. package/api/theme/build/build.d.mts +70 -0
  50. package/api/theme/build/build.mjs +205 -41
  51. package/api/theme/build/font-warning.d.mts +11 -0
  52. package/api/theme/build/font-warning.mjs +28 -3
  53. package/assets/docs/author-a-theme.doc.mjs +16 -11
  54. package/assets/docs/getting-started.doc.mjs +2 -2
  55. package/assets/docs/principles.doc.dense.mjs +3 -3
  56. package/assets/docs/principles.doc.mjs +4 -4
  57. package/assets/docs/principles.doc.zh.mjs +3 -3
  58. package/assets/docs/styling-overview.doc.mjs +6 -6
  59. package/assets/docs/theme.doc.dense.mjs +1 -1
  60. package/assets/docs/theme.doc.zh.mjs +1 -1
  61. package/assets/docs/tree/component-migration.doc.mjs +107 -0
  62. package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
  63. package/assets/docs/tree/font-setup.doc.mjs +122 -0
  64. package/assets/docs/tree/headers-and-footers.doc.mjs +0 -1
  65. package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
  66. package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
  67. package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
  68. package/assets/docs/tree/internationalization.doc.mjs +29 -0
  69. package/assets/docs/tree/layout.doc.mjs +23 -0
  70. package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
  71. package/assets/docs/tree/migration-verification.doc.mjs +67 -0
  72. package/assets/docs/tree/migration.doc.mjs +28 -0
  73. package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
  74. package/assets/docs/tree/other-libraries.doc.mjs +218 -0
  75. package/assets/docs/tree/responsive.doc.mjs +0 -4
  76. package/assets/docs/tree/scaffold.doc.mjs +0 -5
  77. package/assets/docs/tree/side-panels.doc.mjs +0 -1
  78. package/assets/docs/tree/structure.doc.mjs +0 -4
  79. package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
  80. package/assets/docs/tree/styling-basics.doc.mjs +181 -0
  81. package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
  82. package/assets/docs/tree/styling.doc.mjs +29 -0
  83. package/assets/docs/tree/tailwind.doc.mjs +65 -0
  84. package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
  85. package/assets/docs/tree/tokens-border.doc.mjs +46 -0
  86. package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
  87. package/assets/docs/tree/tokens-color.doc.mjs +438 -0
  88. package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
  89. package/assets/docs/tree/tokens-data.doc.mjs +323 -0
  90. package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
  91. package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
  92. package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
  93. package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
  94. package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
  95. package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
  96. package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
  97. package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
  98. package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
  99. package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
  100. package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
  101. package/assets/docs/tree/tokens-size.doc.mjs +54 -0
  102. package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
  103. package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
  104. package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
  105. package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
  106. package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
  107. package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
  108. package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
  109. package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
  110. package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
  111. package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
  112. package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
  113. package/assets/docs/tree/tokens.doc.mjs +28 -0
  114. package/assets/docs/tree/type-scale.doc.mjs +147 -0
  115. package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
  116. package/assets/docs/tree/typography.doc.mjs +29 -0
  117. package/assets/docs/use-a-theme.doc.mjs +6 -3
  118. package/assets/templates/pages/incident-console/page.tsx +1 -1
  119. package/assets/theme.template.ts +4 -3
  120. package/clients/cli/commands/blog.mjs +3 -3
  121. package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
  122. package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
  123. package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
  124. package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
  125. package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
  126. package/clients/cli/commands/build-theme.mjs +68 -18
  127. package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
  128. package/clients/cli/commands/build.mjs +1 -0
  129. package/clients/cli/commands/component/index.mjs +4 -1
  130. package/clients/cli/commands/component-replacement.text.test.mjs +45 -0
  131. package/clients/cli/commands/docs.doc.mjs +2 -1
  132. package/clients/cli/commands/docs.test.mjs +15 -12
  133. package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
  134. package/clients/cli/commands/doctor.test.mjs +50 -1
  135. package/clients/cli/commands/import-hint-correctness.test.mjs +23 -0
  136. package/clients/cli/commands/layout-check.doc.mjs +1 -0
  137. package/clients/cli/commands/layout-expand.doc.mjs +1 -0
  138. package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
  139. package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
  140. package/clients/cli/commands/layout.doc.mjs +1 -0
  141. package/clients/cli/commands/layout.mjs +6 -11
  142. package/clients/cli/commands/search.test.mjs +6 -2
  143. package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
  144. package/clients/cli/commands/template.mjs +4 -3
  145. package/clients/cli/commands/theme-add-lifecycle.test.mjs +9 -6
  146. package/clients/cli/commands/theme-build.doc.mjs +3 -1
  147. package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
  148. package/clients/cli/index.mjs +1 -1
  149. package/clients/cli/lib/component-format.mjs +13 -3
  150. package/clients/cli/lib/component-format.test.mjs +1 -1
  151. package/clients/cli/lib/define-command.mjs +4 -0
  152. package/foundation/agent-docs/agent-docs.mjs +18 -2
  153. package/foundation/agent-docs/agent-docs.test.mjs +18 -0
  154. package/foundation/config/project.test.mjs +1 -1
  155. package/foundation/discovery/docs-discovery.test.mjs +1 -1
  156. package/foundation/discovery/template-needs.d.mts +31 -0
  157. package/foundation/discovery/template-needs.mjs +156 -0
  158. package/foundation/discovery/template-needs.test.mjs +203 -0
  159. package/foundation/doc-compiler/bundle.mjs +52 -1
  160. package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
  161. package/foundation/doc-compiler/tree.d.mts +10 -0
  162. package/foundation/doc-compiler/tree.mjs +22 -0
  163. package/foundation/doc-compiler/tree.test.mjs +3 -2
  164. package/foundation/env/package-manager.d.mts +31 -8
  165. package/foundation/env/package-manager.mjs +120 -13
  166. package/foundation/env/package-manager.test.mjs +174 -1
  167. package/foundation/integrations/validate-contributions.d.mts +16 -0
  168. package/foundation/integrations/validate-contributions.mjs +56 -8
  169. package/foundation/response/response-types.doc.mjs +4 -4
  170. package/package.json +9 -9
  171. package/assets/docs/styling-libraries.doc.mjs +0 -469
  172. package/assets/docs/styling.doc.mjs +0 -412
  173. package/assets/docs/tokens.doc.dense.mjs +0 -15
  174. package/assets/docs/tokens.doc.mjs +0 -1491
  175. package/assets/docs/tokens.doc.zh.mjs +0 -15
  176. package/assets/docs/typography.doc.mjs +0 -286
@@ -0,0 +1,67 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs migration/migration-verification`: post-migration
5
+ * verification checklist and AI migration prompt.
6
+ */
7
+
8
+ /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
9
+
10
+ export const docs = {
11
+ type: 'generic',
12
+ name: 'migration-verification',
13
+ title: 'Verification',
14
+ placement: {parent: 'namespace:migration', slot: 'guides', order: 30},
15
+ category: 'guide',
16
+ description:
17
+ 'Post-migration verification checklist and an AI migration prompt to paste into your coding tool.',
18
+ keywords: [
19
+ 'verification',
20
+ 'checklist',
21
+ 'AI prompt',
22
+ 'keyboard navigation',
23
+ ],
24
+
25
+ sections: [
26
+ {
27
+ title: 'Verification Checklist',
28
+ content: [
29
+ {
30
+ type: 'list',
31
+ style: 'unordered',
32
+ items: [
33
+ 'Run the app in light and dark mode and check that surfaces, borders, text, icons, hover states, focus rings, and status colors flow together.',
34
+ 'Open the command palette from the shell, type into it, select items by keyboard, and confirm focus returns to the trigger.',
35
+ 'Check the SideNav at collapsed, expanded, active, hover, nested, and mobile states.',
36
+ 'Verify settings popovers and dialogs in jsdom and in a real browser because the native dialog and [`Popover`](https://developer.mozilla.org/en-US/docs/Web/API/Popover_API) APIs may need test shims.',
37
+ 'Search for leftover hardcoded Tailwind colors, arbitrary hex values, and one-off hover colors after each route migration.',
38
+ 'Run component tests, build, and at least one browser screenshot pass for each migrated route.',
39
+ ],
40
+ },
41
+ ],
42
+ },
43
+ {
44
+ title: 'AI Migration Prompt',
45
+ content: [
46
+ {
47
+ type: 'prose',
48
+ text: 'When using an AI coding agent, give it an explicit migration loop instead of asking for a full-app rewrite.',
49
+ },
50
+ {
51
+ type: 'code',
52
+ lang: 'text',
53
+ label: 'Paste this into your AI',
54
+ code: `We are migrating this existing Tailwind/shadcn app to Astryx incrementally.
55
+
56
+ First run:
57
+ - astryx docs migration --dense
58
+ - astryx docs theme --dense
59
+ - astryx docs styling --dense
60
+ - astryx template AppShellTopNavWithSideNav --skeleton
61
+
62
+ Then migrate one route or shell surface at a time. Keep business logic and routing intact. Replace shadcn/Radix/Tailwind primitives with Astryx components, remove hardcoded colors, verify light and dark mode, and take screenshots before moving to the next surface.`,
63
+ },
64
+ ],
65
+ },
66
+ ],
67
+ };
@@ -0,0 +1,28 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs migration`: the migration namespace. Groups the
5
+ * incremental migration guides: setup (theme, CSS, layers), component
6
+ * replacement, and verification.
7
+ */
8
+
9
+ /** @type {import('@astryxdesign/cli/authoring').NamespaceDoc} */
10
+ export const docs = {
11
+ type: 'namespace',
12
+ name: 'migration',
13
+ title: 'Migration Guide',
14
+ summary:
15
+ 'Migrate an existing Tailwind, shadcn, or Radix app to the design system incrementally — setup, component replacement, and verification.',
16
+ keywords: [
17
+ 'migration',
18
+ 'migrate',
19
+ 'Tailwind',
20
+ 'shadcn',
21
+ 'Radix',
22
+ 'cascade layers',
23
+ 'coexistence',
24
+ ],
25
+ slots: {
26
+ guides: {title: 'Guides', accepts: {kinds: ['generic']}},
27
+ },
28
+ };
@@ -0,0 +1,112 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs styling-libraries/non-css-processing`: resolve token
5
+ * values outside the DOM for charts, canvas, SVG, and config objects.
6
+ */
7
+
8
+ /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
9
+
10
+ export const docs = {
11
+ type: 'generic',
12
+ name: 'non-css-processing',
13
+ title: 'Non-CSS Processing',
14
+ placement: {parent: 'namespace:styling-libraries', slot: 'guides', order: 40},
15
+ category: 'guide',
16
+ description:
17
+ 'Resolve token values outside the DOM for charts, canvas, SVG, and config objects using resolveThemeTokens() and useTheme().',
18
+ keywords: [
19
+ 'resolveThemeTokens',
20
+ 'resolveThemeToken',
21
+ 'useTheme',
22
+ 'chart',
23
+ 'canvas',
24
+ 'SVG',
25
+ 'non-CSS',
26
+ ],
27
+
28
+ sections: [
29
+ {
30
+ title: 'Non-CSS Processing',
31
+ content: [
32
+ {
33
+ type: 'prose',
34
+ text: 'Use `resolveThemeTokens()` or `resolveThemeToken()` when code outside React needs token values for a known theme and mode. Use `useTheme()` inside client components when the values should come from the nearest Theme and active mode.',
35
+ },
36
+ {
37
+ type: 'code',
38
+ lang: 'ts',
39
+ label: 'Resolve tokens without React context',
40
+ code: `import {resolveThemeTokens} from '@astryxdesign/core/theme/tokens';
41
+ import {neutralTheme} from '@astryxdesign/theme-neutral/built';
42
+
43
+ const tokens = resolveThemeTokens(neutralTheme, {mode: 'light'});
44
+
45
+ const chartOptions = {
46
+ textColor: tokens['--color-text-primary'],
47
+ mutedTextColor: tokens['--color-text-secondary'],
48
+ gridColor: tokens['--color-border'],
49
+ seriesColors: [
50
+ tokens['--color-data-categorical-blue'],
51
+ tokens['--color-data-categorical-orange'],
52
+ tokens['--color-data-categorical-purple'],
53
+ ],
54
+ };`,
55
+ },
56
+ {
57
+ type: 'code',
58
+ lang: 'tsx',
59
+ label: 'Resolve tokens from the nearest Theme',
60
+ code: `'use client';
61
+
62
+ import {useMemo} from 'react';
63
+ import {useTheme} from '@astryxdesign/core/theme';
64
+
65
+ function RevenueChart({data}: {data: Array<{x: string; y: number}>}) {
66
+ const {mode, tokens} = useTheme();
67
+
68
+ const chartOptions = useMemo(
69
+ () => ({
70
+ mode,
71
+ textColor: tokens['--color-text-primary'],
72
+ mutedTextColor: tokens['--color-text-secondary'],
73
+ gridColor: tokens['--color-border'],
74
+ seriesColors: [
75
+ tokens['--color-data-categorical-blue'],
76
+ tokens['--color-data-categorical-orange'],
77
+ tokens['--color-data-categorical-purple'],
78
+ ],
79
+ }),
80
+ [mode, tokens],
81
+ );
82
+
83
+ return <ThirdPartyChart data={data} options={chartOptions} />;
84
+ }`,
85
+ },
86
+ ],
87
+ },
88
+ {
89
+ id: 'non-css-best-practices',
90
+ title: 'Non-CSS Processing Best Practices',
91
+ content: [
92
+ {
93
+ type: 'list',
94
+ style: 'do',
95
+ items: [
96
+ 'Use the returned `tokens` object as a memo dependency; it is stable until the active theme or mode changes.',
97
+ 'Use data visualization tokens such as `--color-data-categorical-blue` for chart series instead of reusing arbitrary UI colors.',
98
+ 'Prefer CSS variables for SVG elements when possible (`fill="var(--color-accent)"`); use token resolver APIs when an API requires a string value in JavaScript.',
99
+ ],
100
+ },
101
+ {
102
+ type: 'list',
103
+ style: 'dont',
104
+ items: [
105
+ 'Use token resolver APIs for ordinary DOM styling. Use CSS variables, StyleX tokens, xstyle, or library aliases instead.',
106
+ 'Assume the returned values reflect every CSS cascade override. They resolve tokens for the current theme and mode; local media-surface overrides and arbitrary CSS overrides may not be represented in the returned map.',
107
+ ],
108
+ },
109
+ ],
110
+ },
111
+ ],
112
+ };
@@ -0,0 +1,218 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs styling-libraries/other-libraries`: Panda, Chakra, MUI,
5
+ * Emotion, styled-components, UnoCSS, and the interop checklist.
6
+ */
7
+
8
+ /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
9
+
10
+ export const docs = {
11
+ type: 'generic',
12
+ name: 'other-libraries',
13
+ title: 'Other Libraries',
14
+ placement: {parent: 'namespace:styling-libraries', slot: 'guides', order: 30},
15
+ category: 'guide',
16
+ description:
17
+ 'Panda, Chakra, MUI, Emotion, styled-components, Theme UI, UnoCSS, and the interop checklist.',
18
+ keywords: [
19
+ 'UnoCSS',
20
+ 'semantic tokens',
21
+ 'palette',
22
+ ],
23
+
24
+ sections: [
25
+ {
26
+ id: 'semantic-token-systems',
27
+ title: 'Panda, Chakra, and Other Semantic Token Systems',
28
+ content: [
29
+ {
30
+ type: 'prose',
31
+ text: 'Libraries like Panda CSS and Chakra UI have first-class semantic token objects. Put system CSS variables at the leaves of those objects so product code can use the library\'s semantic names while the system still owns the values.',
32
+ },
33
+ {
34
+ type: 'code',
35
+ lang: 'ts',
36
+ label: 'Semantic token aliases',
37
+ code: `semanticTokens: {
38
+ colors: {
39
+ text: {
40
+ primary: {value: 'var(--color-text-primary)'},
41
+ secondary: {value: 'var(--color-text-secondary)'},
42
+ },
43
+ background: {
44
+ surface: {value: 'var(--color-background-surface)'},
45
+ body: {value: 'var(--color-background-body)'},
46
+ },
47
+ border: {
48
+ default: {value: 'var(--color-border)'},
49
+ },
50
+ },
51
+ },
52
+ tokens: {
53
+ spacing: {
54
+ 4: {value: 'var(--spacing-4)'},
55
+ },
56
+ radii: {
57
+ container: {value: 'var(--radius-container)'},
58
+ },
59
+ }`,
60
+ },
61
+ {
62
+ type: 'code',
63
+ lang: 'tsx',
64
+ label: 'Panda-style usage',
65
+ code: `<section
66
+ className={css({
67
+ bg: 'background.surface',
68
+ color: 'text.primary',
69
+ borderColor: 'border.default',
70
+ p: '4',
71
+ rounded: 'container',
72
+ })}
73
+ />`,
74
+ },
75
+ {
76
+ type: 'prose',
77
+ text: 'If a semantic-token library needs to generate its own light/dark CSS from raw values, align its mode selector with Theme (`data-theme="light|dark"`) and generate that adapter from system theme data. Otherwise it can drift from nested or runtime themes.',
78
+ },
79
+ ],
80
+ },
81
+ {
82
+ title: 'MUI and Palette-Based Themes',
83
+ content: [
84
+ {
85
+ type: 'prose',
86
+ text: '`MUI` expects palette slots such as primary, background, text, and divider. Map those slots to system variables for ordinary component styling. Use raw values only when MUI or your code needs to parse colors for contrast, alpha, lighten, or darken calculations.',
87
+ },
88
+ {
89
+ type: 'code',
90
+ lang: 'ts',
91
+ label: 'MUI palette mapped to system vars',
92
+ code: `const theme = createTheme({
93
+ cssVariables: true,
94
+ colorSchemes: {
95
+ light: {
96
+ palette: {
97
+ primary: {main: 'var(--color-accent)'},
98
+ background: {
99
+ default: 'var(--color-background-body)',
100
+ paper: 'var(--color-background-surface)',
101
+ },
102
+ text: {
103
+ primary: 'var(--color-text-primary)',
104
+ secondary: 'var(--color-text-secondary)',
105
+ },
106
+ divider: 'var(--color-border)',
107
+ },
108
+ },
109
+ dark: {
110
+ palette: {
111
+ primary: {main: 'var(--color-accent)'},
112
+ background: {
113
+ default: 'var(--color-background-body)',
114
+ paper: 'var(--color-background-surface)',
115
+ },
116
+ text: {
117
+ primary: 'var(--color-text-primary)',
118
+ secondary: 'var(--color-text-secondary)',
119
+ },
120
+ divider: 'var(--color-border)',
121
+ },
122
+ },
123
+ },
124
+ });`,
125
+ },
126
+ {
127
+ type: 'prose',
128
+ text: 'If MUI owns color mode in an app, generate the light and dark palette values from system theme data and keep Theme mode synchronized. If Theme owns color mode, keep both MUI schemes pointing at the same system CSS variables.',
129
+ },
130
+ ],
131
+ },
132
+ {
133
+ id: 'css-in-js',
134
+ title: 'Emotion, styled-components, Theme UI, and Styled System',
135
+ content: [
136
+ {
137
+ type: 'prose',
138
+ text: 'Runtime CSS-in-JS libraries such as `Emotion` and `styled-components` usually accept arbitrary theme objects. Keep those objects semantic, but store system CSS variable references as the values. This keeps generated classes stable while the system updates values through the CSS cascade.',
139
+ },
140
+ {
141
+ type: 'code',
142
+ lang: 'ts',
143
+ label: 'Generic CSS-in-JS theme object',
144
+ code: `const appTheme = {
145
+ colors: {
146
+ textPrimary: 'var(--color-text-primary)',
147
+ textSecondary: 'var(--color-text-secondary)',
148
+ surface: 'var(--color-background-surface)',
149
+ border: 'var(--color-border)',
150
+ accent: 'var(--color-accent)',
151
+ },
152
+ spacing: {
153
+ 4: 'var(--spacing-4)',
154
+ },
155
+ radius: {
156
+ container: 'var(--radius-container)',
157
+ },
158
+ };`,
159
+ },
160
+ {
161
+ type: 'prose',
162
+ text: 'Avoid rebuilding CSS-in-JS theme objects with raw color values on every mode switch. CSS variables let the class names stay the same while the browser resolves the active values.',
163
+ },
164
+ ],
165
+ },
166
+ {
167
+ id: 'unocss',
168
+ title: 'UnoCSS and Custom Utility Systems',
169
+ content: [
170
+ {
171
+ type: 'prose',
172
+ text: 'Utility generators such as UnoCSS can put system variables in their theme config or shortcuts. Keep classes semantic (`bg-surface`, `text-primary`) and let the values point at system tokens.',
173
+ },
174
+ {
175
+ type: 'code',
176
+ lang: 'ts',
177
+ label: 'UnoCSS-style config',
178
+ code: `export default defineConfig({
179
+ theme: {
180
+ colors: {
181
+ surface: 'var(--color-background-surface)',
182
+ primary: 'var(--color-text-primary)',
183
+ border: 'var(--color-border)',
184
+ accent: 'var(--color-accent)',
185
+ },
186
+ spacing: {
187
+ 4: 'var(--spacing-4)',
188
+ },
189
+ },
190
+ shortcuts: {
191
+ 'astryx-card': 'bg-surface text-primary border border-border rounded-lg p-4',
192
+ },
193
+ });`,
194
+ },
195
+ {
196
+ type: 'prose',
197
+ text: 'Static utility extractors cannot see dynamically constructed class names. Prefer explicit class strings or the library\'s safelist/source-registration mechanism.',
198
+ },
199
+ ],
200
+ },
201
+ {
202
+ title: 'Interop Checklist',
203
+ content: [
204
+ {
205
+ type: 'list',
206
+ style: 'ordered',
207
+ items: [
208
+ 'Import the reset/base CSS and a theme CSS file early enough for first paint. For production SSR, prefer built themes from `astryx theme build` or published `/built` theme imports plus `theme.css`.',
209
+ 'Choose one owner for color mode. Theme uses `data-theme="light|dark"` and `color-scheme` to resolve `light-dark()` tokens.',
210
+ 'Map the external library\'s semantic layer to system variables by intent, not by exact naming. For example, MUI `background.paper` maps to `--color-background-surface`.',
211
+ 'Use {@link namespace:tokens} and focused token docs when building mappings. Keep mappings small at first: text, surface/body/card/popover, border, accent, status, spacing, radius, typography, shadow.',
212
+ 'Use token resolver APIs only for non-CSS APIs that need resolved values.',
213
+ ],
214
+ },
215
+ ],
216
+ },
217
+ ],
218
+ };
@@ -16,14 +16,10 @@ export const docs = {
16
16
  description:
17
17
  'Decide what each region does as width changes: divide, reveal, resize, or swap.',
18
18
  keywords: [
19
- 'responsive',
20
19
  'breakpoints',
21
20
  'useMediaQuery',
22
- 'mobileNav',
23
- 'MobileNav',
24
21
  'Dialog',
25
22
  'BottomSheet',
26
- 'contentWidth',
27
23
  'contract',
28
24
  ],
29
25
 
@@ -18,14 +18,9 @@ export const docs = {
18
18
  keywords: [
19
19
  'shell',
20
20
  'navigation',
21
- 'AppShell',
22
- 'SideNav',
23
- 'TopNav',
24
- 'MobileNav',
25
21
  'frame',
26
22
  'region',
27
23
  'width budget',
28
- 'contentWidth',
29
24
  ],
30
25
 
31
26
  sections: [
@@ -22,7 +22,6 @@ export const docs = {
22
22
  'ResizeHandle',
23
23
  'useResizable',
24
24
  'EmptyState',
25
- 'hasDivider',
26
25
  'isScrollable',
27
26
  'detail panel',
28
27
  'split view',
@@ -23,10 +23,6 @@ export const docs = {
23
23
  'List',
24
24
  'containers',
25
25
  'rows',
26
- 'Heading',
27
- 'Text',
28
- 'weight',
29
- 'color',
30
26
  'secondary',
31
27
  'Divider',
32
28
  ],
@@ -0,0 +1,159 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs styling/styling-advanced`: compound component styling,
5
+ * data-attribute selectors, deprecated bare classes, and what not to do.
6
+ */
7
+
8
+ /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
9
+
10
+ export const docs = {
11
+ type: 'generic',
12
+ name: 'styling-advanced',
13
+ title: 'Advanced',
14
+ placement: {parent: 'namespace:styling', slot: 'guides', order: 20},
15
+ category: 'guide',
16
+ description:
17
+ 'Compound component styling, data-attribute selectors, deprecated bare prop/state classes, and common anti-patterns.',
18
+ keywords: [
19
+ 'compound',
20
+ 'data attributes',
21
+ 'deprecated',
22
+ 'selector',
23
+ 'astryx-button',
24
+ 'data-variant',
25
+ ],
26
+
27
+ sections: [
28
+ {
29
+ title: 'Compound Components',
30
+ content: [
31
+ {
32
+ type: 'prose',
33
+ text: 'Complex components are composed from smaller components. Each sub-component accepts its own xstyle, className, and rest props. You style the parts individually; there\'s no single "drill into sub-part" prop.',
34
+ },
35
+ {
36
+ type: 'code',
37
+ lang: 'tsx',
38
+ label: 'Dialog with individually styled parts',
39
+ code: `import * as stylex from '@stylexjs/stylex';
40
+
41
+ const overrides = stylex.create({
42
+ dialog: { maxWidth: 500 },
43
+ content: { gap: 'var(--spacing-4)' },
44
+ });
45
+
46
+ <Dialog isOpen={isOpen} onOpenChange={close} xstyle={overrides.dialog}>
47
+ <Layout
48
+ header={
49
+ <LayoutHeader hasDivider>
50
+ <Heading level={2}>Edit Profile</Heading>
51
+ </LayoutHeader>
52
+ }
53
+ content={
54
+ <LayoutContent xstyle={overrides.content}>
55
+ <TextInput label="Name" value={name} onChange={setName} />
56
+ </LayoutContent>
57
+ }
58
+ footer={
59
+ <LayoutFooter hasDivider>
60
+ <Button label="Cancel" variant="secondary" onClick={close} />
61
+ <Button label="Save" variant="primary" onClick={save} />
62
+ </LayoutFooter>
63
+ }
64
+ />
65
+ </Dialog>`,
66
+ },
67
+ {
68
+ type: 'prose',
69
+ text: 'The pattern: the parent component (Dialog) controls structure and behavior, child components (Layout, Header, Button) control their own appearance. Style each piece where it lives.',
70
+ },
71
+ ],
72
+ },
73
+ {
74
+ id: 'preferred-selector-surface-data-attributes',
75
+ title: 'Data attribute selectors',
76
+ content: [
77
+ {
78
+ type: 'prose',
79
+ text: 'When external CSS needs to target an Astryx component by prop or state, combine the stable component class with reflected data attributes. The component class identifies the component (`.astryx-button`, `.astryx-card`); data attributes identify the axis and value (`data-variant`, `data-size`, `data-level`, etc.). This is the preferred selector surface for new CSS because it is explicit and collision-resistant.',
80
+ },
81
+ {
82
+ type: 'code',
83
+ lang: 'css',
84
+ code: `.my-app .astryx-button[data-variant="primary"] {
85
+ /* primary buttons in this app context */
86
+ }
87
+
88
+ .my-app .astryx-button[data-variant="primary"][data-size="sm"] {
89
+ /* small primary buttons */
90
+ }
91
+
92
+ .my-app .astryx-heading[data-level="2"] {
93
+ /* level 2 headings; numeric values stay literal in data attrs */
94
+ }`,
95
+ },
96
+ {
97
+ type: 'code',
98
+ lang: 'tsx',
99
+ label: 'What components reflect',
100
+ code: `// <Button variant="primary" size="sm" />
101
+ // preferred selector attrs: data-variant="primary" data-size="sm"
102
+
103
+ // <Card variant="elevated" />
104
+ // preferred selector attrs: data-variant="elevated"
105
+
106
+ // <Heading level={2} />
107
+ // preferred selector attrs: data-level="2"`,
108
+ },
109
+ {
110
+ type: 'prose',
111
+ text: 'For systematic theming, use defineTheme component overrides instead of raw CSS selectors. defineTheme keeps the higher-level `prop:value` API (`variant:primary`, `size:sm`) and handles selector generation for you. Run {@link generic:author-a-theme} for component theming.',
112
+ },
113
+ ],
114
+ },
115
+ {
116
+ id: 'deprecated-classes',
117
+ title: 'Deprecated: Bare Prop and State Classes',
118
+ content: [
119
+ {
120
+ type: 'prose',
121
+ text: 'Astryx still emits the deprecated bare classes (`.primary`, `.sm`, `.level-2`, `.checked`) and will remove them in a later release. Use data attributes for new CSS; `astryx upgrade --from <old version> --apply` rewrites qualified selectors in `.css` files.',
122
+ },
123
+ {
124
+ type: 'code',
125
+ lang: 'css',
126
+ code: `/* The upgrade preserves old consumer classes and adds the v0.6 prop match */
127
+ .my-app .astryx-button:is(.primary, [data-variant="primary"]) {
128
+ /* primary buttons or a consumer-supplied .primary class */
129
+ }
130
+
131
+ /* Numeric values stay literal in data attributes */
132
+ .my-app .astryx-heading:is(.level-2, [data-level="2"]) {
133
+ /* level 2 headings or a consumer-supplied .level-2 class */
134
+ }`,
135
+ },
136
+ {
137
+ type: 'prose',
138
+ text: 'The upgrade rewrites a selector only when an `.astryx-*` component class qualifies it, turning the old class into an `:is(...)` union of that class and the data attributes it stood for. The union keeps the selector\'s specificity and your own `className` matches, and keeps matching once the bare classes are gone; the `.astryx-*` classes themselves stay. It leaves unqualified classes (a bare `.primary`), unknown classes, and selectors in JavaScript or TypeScript alone: migrate those by hand, and only where they target Astryx.',
139
+ },
140
+ ],
141
+ },
142
+ {
143
+ title: 'What NOT to Do',
144
+ content: [
145
+ {
146
+ type: 'list',
147
+ style: 'dont',
148
+ items: [
149
+ 'style={{}} on raw <div> wrappers. Use xstyle on the component directly.',
150
+ 'Hardcoded colors (#fff, rgb(...)). Use var(--color-*) tokens or Tailwind semantic classes (text-primary, bg-surface).',
151
+ 'Hardcoded spacing (16px, 1rem). Use var(--spacing-*) tokens or Tailwind spacing utilities (p-4, gap-3).',
152
+ 'Wrapping a component in a <div> just to add margin. Use xstyle with stylex.create on the component.',
153
+ 'Using !important. If styles aren\'t applying, check specificity; xstyle is merged last.',
154
+ ],
155
+ },
156
+ ],
157
+ },
158
+ ],
159
+ };