@astryxdesign/cli 0.6.6-canary.fcf255b → 0.6.6-canary.ffa4f72

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 (184) 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/_adapter.d.mts +7 -0
  25. package/api/doctor/_adapter.mjs +48 -0
  26. package/api/doctor/doctor.d.mts +6 -0
  27. package/api/doctor/doctor.mjs +154 -43
  28. package/api/doctor/doctor.test.mjs +104 -0
  29. package/api/doctor/theme-checks.d.mts +12 -0
  30. package/api/doctor/theme-checks.mjs +115 -1
  31. package/api/doctor/theme-checks.test.mjs +142 -1
  32. package/api/gap-report/gap-report.doc.mjs +2 -1
  33. package/api/init/run/run.mjs +1 -0
  34. package/api/integration/validate-integration.mjs +20 -4
  35. package/api/integration/validate-integration.test.mjs +73 -0
  36. package/api/layout/check/check.d.mts +1 -0
  37. package/api/layout/check/check.mjs +1 -0
  38. package/api/layout/expand/expand.d.mts +1 -0
  39. package/api/layout/expand/expand.mjs +1 -0
  40. package/api/layout/grammar/grammar.d.mts +1 -0
  41. package/api/layout/grammar/grammar.mjs +1 -0
  42. package/api/layout/layoutCheck.doc.mjs +1 -1
  43. package/api/layout/layoutExpand.doc.mjs +1 -1
  44. package/api/layout/layoutGrammar.doc.mjs +1 -1
  45. package/api/search/search.d.mts +44 -0
  46. package/api/search/search.domain-priority.test.mjs +261 -0
  47. package/api/search/search.mjs +191 -29
  48. package/api/swizzle/swizzle.doc.mjs +5 -2
  49. package/api/template/copy/copy.mjs +12 -0
  50. package/api/template/template.doc.mjs +1 -1
  51. package/api/template/template.type.d.mts +3 -0
  52. package/api/template/template.type.mjs +3 -0
  53. package/api/theme/build/build.d.mts +70 -0
  54. package/api/theme/build/build.mjs +205 -41
  55. package/api/theme/build/font-warning.d.mts +11 -0
  56. package/api/theme/build/font-warning.mjs +28 -3
  57. package/assets/docs/author-a-theme.doc.mjs +19 -14
  58. package/assets/docs/getting-started.doc.mjs +2 -2
  59. package/assets/docs/principles.doc.dense.mjs +3 -3
  60. package/assets/docs/principles.doc.mjs +4 -4
  61. package/assets/docs/principles.doc.zh.mjs +3 -3
  62. package/assets/docs/styling-overview.doc.mjs +211 -0
  63. package/assets/docs/theme.doc.dense.mjs +1 -1
  64. package/assets/docs/theme.doc.mjs +5 -5
  65. package/assets/docs/theme.doc.zh.mjs +1 -1
  66. package/assets/docs/tree/component-migration.doc.mjs +107 -0
  67. package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
  68. package/assets/docs/tree/font-setup.doc.mjs +122 -0
  69. package/assets/docs/tree/headers-and-footers.doc.mjs +0 -1
  70. package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
  71. package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
  72. package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
  73. package/assets/docs/tree/internationalization.doc.mjs +29 -0
  74. package/assets/docs/tree/layout.doc.mjs +23 -0
  75. package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
  76. package/assets/docs/tree/migration-verification.doc.mjs +67 -0
  77. package/assets/docs/tree/migration.doc.mjs +28 -0
  78. package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
  79. package/assets/docs/tree/other-libraries.doc.mjs +218 -0
  80. package/assets/docs/tree/responsive.doc.mjs +0 -4
  81. package/assets/docs/tree/scaffold.doc.mjs +0 -5
  82. package/assets/docs/tree/side-panels.doc.mjs +0 -1
  83. package/assets/docs/tree/structure.doc.mjs +0 -4
  84. package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
  85. package/assets/docs/tree/styling-basics.doc.mjs +181 -0
  86. package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
  87. package/assets/docs/tree/styling.doc.mjs +29 -0
  88. package/assets/docs/tree/tailwind.doc.mjs +65 -0
  89. package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
  90. package/assets/docs/tree/tokens-border.doc.mjs +46 -0
  91. package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
  92. package/assets/docs/tree/tokens-color.doc.mjs +438 -0
  93. package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
  94. package/assets/docs/tree/tokens-data.doc.mjs +323 -0
  95. package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
  96. package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
  97. package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
  98. package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
  99. package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
  100. package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
  101. package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
  102. package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
  103. package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
  104. package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
  105. package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
  106. package/assets/docs/tree/tokens-size.doc.mjs +54 -0
  107. package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
  108. package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
  109. package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
  110. package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
  111. package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
  112. package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
  113. package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
  114. package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
  115. package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
  116. package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
  117. package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
  118. package/assets/docs/tree/tokens.doc.mjs +28 -0
  119. package/assets/docs/tree/type-scale.doc.mjs +147 -0
  120. package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
  121. package/assets/docs/tree/typography.doc.mjs +29 -0
  122. package/assets/docs/use-a-theme.doc.mjs +162 -47
  123. package/assets/templates/pages/incident-console/page.tsx +1 -1
  124. package/assets/templates/pages/table-comparison/template.doc.mjs +1 -1
  125. package/assets/theme.template.ts +4 -3
  126. package/authoring/doctypes/template/type.ts +1 -0
  127. package/clients/cli/commands/blog.mjs +3 -3
  128. package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
  129. package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
  130. package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
  131. package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
  132. package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
  133. package/clients/cli/commands/build-theme.mjs +68 -18
  134. package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
  135. package/clients/cli/commands/build.mjs +1 -0
  136. package/clients/cli/commands/component/index.mjs +4 -1
  137. package/clients/cli/commands/component-replacement.text.test.mjs +45 -0
  138. package/clients/cli/commands/docs.doc.mjs +2 -1
  139. package/clients/cli/commands/docs.test.mjs +16 -13
  140. package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
  141. package/clients/cli/commands/doctor.doc.mjs +1 -1
  142. package/clients/cli/commands/doctor.test.mjs +50 -1
  143. package/clients/cli/commands/import-hint-correctness.test.mjs +23 -0
  144. package/clients/cli/commands/layout-check.doc.mjs +1 -0
  145. package/clients/cli/commands/layout-expand.doc.mjs +1 -0
  146. package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
  147. package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
  148. package/clients/cli/commands/layout.doc.mjs +1 -0
  149. package/clients/cli/commands/layout.mjs +6 -11
  150. package/clients/cli/commands/search.test.mjs +6 -2
  151. package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
  152. package/clients/cli/commands/template.mjs +4 -3
  153. package/clients/cli/commands/theme-add-lifecycle.test.mjs +9 -6
  154. package/clients/cli/commands/theme-build.doc.mjs +3 -1
  155. package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
  156. package/clients/cli/index.mjs +1 -1
  157. package/clients/cli/lib/component-format.mjs +13 -3
  158. package/clients/cli/lib/component-format.test.mjs +1 -1
  159. package/clients/cli/lib/define-command.mjs +4 -0
  160. package/foundation/agent-docs/agent-docs.mjs +18 -2
  161. package/foundation/agent-docs/agent-docs.test.mjs +18 -0
  162. package/foundation/config/project.test.mjs +1 -1
  163. package/foundation/discovery/docs-discovery.test.mjs +1 -1
  164. package/foundation/discovery/template-needs.d.mts +31 -0
  165. package/foundation/discovery/template-needs.mjs +156 -0
  166. package/foundation/discovery/template-needs.test.mjs +203 -0
  167. package/foundation/doc-compiler/bundle.mjs +52 -1
  168. package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
  169. package/foundation/doc-compiler/tree.d.mts +10 -0
  170. package/foundation/doc-compiler/tree.mjs +22 -0
  171. package/foundation/doc-compiler/tree.test.mjs +3 -2
  172. package/foundation/env/package-manager.d.mts +31 -8
  173. package/foundation/env/package-manager.mjs +120 -13
  174. package/foundation/env/package-manager.test.mjs +174 -1
  175. package/foundation/integrations/validate-contributions.d.mts +16 -0
  176. package/foundation/integrations/validate-contributions.mjs +56 -8
  177. package/foundation/response/response-types.doc.mjs +4 -4
  178. package/package.json +9 -9
  179. package/assets/docs/styling-libraries.doc.mjs +0 -469
  180. package/assets/docs/styling.doc.mjs +0 -412
  181. package/assets/docs/tokens.doc.dense.mjs +0 -15
  182. package/assets/docs/tokens.doc.mjs +0 -1491
  183. package/assets/docs/tokens.doc.zh.mjs +0 -15
  184. package/assets/docs/typography.doc.mjs +0 -286
@@ -45,8 +45,8 @@ export const docs = {
45
45
  'Use components for everything they cover',
46
46
  'Page layout is frame-first: pick the shell and budget regions before writing content (see {@link namespace:layout})',
47
47
  'Dense data renders as rows (Table, List/Item), edge-to-edge with dividers; Card is for widgets, galleries, and settings groups',
48
- 'StyleX or Tailwind for custom styling; both are first-class (see {@link generic:styling})',
49
- 'Semantic tokens, not hardcoded values (see {@link generic:tokens})',
48
+ 'StyleX or Tailwind for custom styling; both are first-class (see {@link namespace:styling})',
49
+ 'Semantic tokens, not hardcoded values (see {@link namespace:tokens})',
50
50
  'CSS custom properties for colors, not hex values',
51
51
  'Form inputs are controlled (value + onChange)',
52
52
  'Use useLinkComponent() for navigation so consumers can plug in their framework router via LinkProvider',
@@ -64,7 +64,7 @@ export const docs = {
64
64
  },
65
65
  {
66
66
  type: 'prose',
67
- text: 'See {@link generic:styling} for the complete guide with examples.',
67
+ text: 'See {@link namespace:styling} for the complete guide with examples.',
68
68
  },
69
69
  ],
70
70
  },
@@ -97,7 +97,7 @@ export const docs = {
97
97
  content: [
98
98
  {
99
99
  type: 'prose',
100
- text: 'The design system provides semantic design tokens for spacing, color, radius, shadow, typography, and size. Tokens adapt to the active theme and color mode. Run {@link generic:tokens} for the full reference with all values.',
100
+ text: 'The design system provides semantic design tokens for spacing, color, radius, shadow, typography, and size. Tokens adapt to the active theme and color mode. Run {@link namespace:tokens} for the full reference with all values.',
101
101
  },
102
102
  ],
103
103
  },
@@ -6,9 +6,9 @@ export const docsZh = {
6
6
  description: 'Astryx 核心设计原则和规则。',
7
7
  sections: [
8
8
  { section: 'Design Philosophy', title: '设计哲学', content: [{ type: 'prose', text: '一个注重一致性、适应性和开发者体验的设计系统。核心理念:' }, { type: 'list', items: ['组件优于原始元素 — 优先使用 Astryx 组件', '语义化令牌优于硬编码值', '主题无关的代码 — 深色模式自动生效', '开放的内部机制 — 所有基础组件均可导出和组合'] }] },
9
- { section: 'Rules', title: '规则', content: [{ type: 'prose', text: '让应用代码保持在设计系统之内的八条规则。' }, { type: 'list', items: ['所有支持的场景都使用 Astryx 组件', '布局采用框架优先:先选定外壳并规划区域尺寸,再编写内容(见 {@link namespace:layout})', '密集数据使用行(Table、List/Item)通栏渲染;Card 用于小部件、画廊和设置分组', '使用 StyleX 或 Tailwind 进行样式设置(见 {@link generic:styling})', '使用语义化令牌,不使用硬编码值(见 {@link generic:tokens})', '使用 CSS 变量设置颜色,不使用十六进制值', '表单输入为受控组件(value + onChange)', '使用 useLinkComponent() 进行导航'] }] },
10
- { section: 'Styling Approach', title: '样式方法', content: [{ type: 'prose', text: '组件覆盖使用 xstyle 属性。布局使用 StyleX 或 Tailwind。' }, { type: 'prose', text: '完整指南见 {@link generic:styling}。' }] },
9
+ { section: 'Rules', title: '规则', content: [{ type: 'prose', text: '让应用代码保持在设计系统之内的八条规则。' }, { type: 'list', items: ['所有支持的场景都使用 Astryx 组件', '布局采用框架优先:先选定外壳并规划区域尺寸,再编写内容(见 {@link namespace:layout})', '密集数据使用行(Table、List/Item)通栏渲染;Card 用于小部件、画廊和设置分组', '使用 StyleX 或 Tailwind 进行样式设置(见 {@link namespace:styling})', '使用语义化令牌,不使用硬编码值(见 {@link namespace:tokens})', '使用 CSS 变量设置颜色,不使用十六进制值', '表单输入为受控组件(value + onChange)', '使用 useLinkComponent() 进行导航'] }] },
10
+ { section: 'Styling Approach', title: '样式方法', content: [{ type: 'prose', text: '组件覆盖使用 xstyle 属性。布局使用 StyleX 或 Tailwind。' }, { type: 'prose', text: '完整指南见 {@link namespace:styling}。' }] },
11
11
  { section: 'Anti-Patterns', title: '反模式', content: [{ type: 'prose', text: '会破坏主题、路由或布局的写法,以及应改用的做法。' }, { type: 'list', items: ['不要在原始元素上使用内联样式', '不要硬编码颜色 — 使用令牌或 Tailwind 语义类', '不要硬编码间距', '不要硬编码 <a> 元素 — 使用 useLinkComponent()', '不要把每个列表项都包在 Card 里 — 先定框架,密集数据用行渲染(见 {@link namespace:layout})', '不要把 Badge 当装饰 — 状态请使用 StatusDot 或 Token', '不要自创属性。先阅读组件文档'] }] },
12
- { section: 'Design Tokens', title: '设计令牌', content: [{ type: 'prose', text: '完整令牌参考见 {@link generic:tokens}。' }] },
12
+ { section: 'Design Tokens', title: '设计令牌', content: [{ type: 'prose', text: '完整令牌参考见 {@link namespace:tokens}。' }] },
13
13
  ],
14
14
  };
@@ -0,0 +1,211 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs styling-overview`
5
+ *
6
+ * One question: "How do I set up CSS?"
7
+ * Three paths, each with its exact imports.
8
+ */
9
+
10
+ /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
11
+
12
+ export const docs = {
13
+ name: 'styling-overview',
14
+ title: 'Styling overview',
15
+ category: 'guide',
16
+ description:
17
+ 'How to set up CSS — exact imports for three paths: plain, Tailwind, and StyleX from source.',
18
+ keywords: [
19
+ 'styling',
20
+ 'CSS',
21
+ 'setup',
22
+ 'imports',
23
+ 'StyleX',
24
+ 'Tailwind',
25
+ 'astryx.css',
26
+ 'globals.css',
27
+ ],
28
+
29
+ sections: [
30
+ {
31
+ id: 'pick-a-path',
32
+ title: 'Pick a path',
33
+ content: [
34
+ {
35
+ type: 'table',
36
+ headers: ['Path', 'Good for', 'Build step?'],
37
+ rows: [
38
+ [
39
+ 'Plain CSS',
40
+ 'Most apps. Style with className, xstyle, or any CSS library.',
41
+ 'None.',
42
+ ],
43
+ [
44
+ 'Tailwind',
45
+ 'Apps on Tailwind v4. A CSS bridge maps utility classes to design tokens.',
46
+ "None beyond Tailwind's own.",
47
+ ],
48
+ [
49
+ 'StyleX from source',
50
+ 'Swizzled (ejected) components. Raw StyleX source needs a compiler plugin.',
51
+ 'Yes \u2014 a StyleX bundler plugin.',
52
+ ],
53
+ ],
54
+ },
55
+ {
56
+ type: 'prose',
57
+ text: 'All three resolve to the same design tokens and support theming and dark mode. You can mix them in one app.',
58
+ },
59
+ ],
60
+ },
61
+ {
62
+ id: 'plain',
63
+ title: 'Plain CSS',
64
+ content: [
65
+ {
66
+ type: 'code',
67
+ lang: 'bash',
68
+ label: 'Install',
69
+ code: 'npm install @astryxdesign/core @stylexjs/stylex @astryxdesign/theme-neutral',
70
+ },
71
+ {
72
+ type: 'code',
73
+ lang: 'css',
74
+ label: 'globals.css',
75
+ code: `@import "@astryxdesign/core/reset.css";
76
+ @import "@astryxdesign/core/astryx.css";
77
+ @import "@astryxdesign/theme-neutral/theme.css";`,
78
+ },
79
+ {
80
+ type: 'prose',
81
+ text: "Done. Components work out of the box \u2014 style them with `className`, `xstyle`, or `style`. Swap `theme-neutral` for any theme package (`astryx theme list` shows what's available).",
82
+ },
83
+ ],
84
+ },
85
+ {
86
+ id: 'tailwind',
87
+ title: 'Tailwind',
88
+ content: [
89
+ {
90
+ type: 'code',
91
+ lang: 'bash',
92
+ label: 'Install (add to an existing Tailwind v4 app)',
93
+ code: 'npm install @astryxdesign/core @stylexjs/stylex @astryxdesign/theme-neutral',
94
+ },
95
+ {
96
+ type: 'code',
97
+ lang: 'css',
98
+ label: 'globals.css',
99
+ code: `@layer reset, theme, base, astryx-base, astryx-theme, components, utilities;
100
+
101
+ @import "tailwindcss/theme.css" layer(theme);
102
+ @import "tailwindcss/preflight.css" layer(base);
103
+ @import "@astryxdesign/core/reset.css";
104
+ @import "@astryxdesign/core/astryx.css";
105
+ @import "@astryxdesign/theme-neutral/theme.css";
106
+ @import "@astryxdesign/core/tailwind-theme.css";
107
+ @import "tailwindcss/utilities.css" layer(utilities);`,
108
+ },
109
+ {
110
+ type: 'prose',
111
+ text: 'The `@layer` declaration is critical \u2014 without it, component styles outrank Tailwind utilities and `className` overrides stop working. The bridge (`tailwind-theme.css`) maps classes like `text-primary`, `bg-surface`, and `rounded-lg` to design tokens with no JS.',
112
+ },
113
+ {
114
+ type: 'prose',
115
+ text: 'For Tailwind v3, see the layer workaround in {@link generic:migration-setup}.',
116
+ },
117
+ ],
118
+ },
119
+ {
120
+ id: 'stylex-from-source',
121
+ title: 'StyleX from source',
122
+ content: [
123
+ {
124
+ type: 'prose',
125
+ text: 'Only needed when you swizzle a component (`astryx swizzle <Component>`) or write your own StyleX. The plain path already supports `xstyle` overrides \u2014 this path is for editing component internals. Some built-in page templates also use StyleX for layout; if you scaffold one and see "Unexpected stylex.create call at runtime", add the compiler plugin for your bundler below.',
126
+ },
127
+ {
128
+ type: 'code',
129
+ lang: 'bash',
130
+ label: 'Install',
131
+ code: 'npm install @astryxdesign/core @stylexjs/stylex @astryxdesign/theme-neutral',
132
+ },
133
+ {
134
+ type: 'code',
135
+ lang: 'css',
136
+ label: 'globals.css',
137
+ code: `@layer reset, astryx-base, astryx-theme;
138
+
139
+ @import "@astryxdesign/core/reset.css";
140
+ @import "@astryxdesign/theme-neutral/theme.css";`,
141
+ },
142
+ {
143
+ type: 'prose',
144
+ text: 'No `astryx.css` \u2014 the StyleX compiler produces component styles from source. Add the plugin for your bundler:',
145
+ },
146
+ {
147
+ type: 'table',
148
+ headers: ['Bundler', 'Plugin'],
149
+ rows: [
150
+ ['Webpack', '@stylexjs/webpack-plugin'],
151
+ ['Vite / Rollup', '@stylexjs/rollup-plugin'],
152
+ ['Babel (any)', '@stylexjs/babel-plugin + @stylexjs/postcss-plugin'],
153
+ ['Next.js (keep next/font)', '@stylexswc/nextjs-plugin'],
154
+ ],
155
+ },
156
+ {
157
+ type: 'prose',
158
+ text: 'If a swizzled component renders with no styles and no error, a missing compiler is almost always why. See the StyleX Build Setup section of {@link generic:tokens-and-setup} for bundler config examples.',
159
+ },
160
+ ],
161
+ },
162
+ {
163
+ id: 'what-each-file-does',
164
+ title: 'What each import does',
165
+ content: [
166
+ {
167
+ type: 'table',
168
+ headers: ['Import', 'Layer', 'Purpose'],
169
+ rows: [
170
+ [
171
+ 'reset.css',
172
+ 'reset',
173
+ 'Cross-browser reset (box-sizing, margins, color-scheme). Zero specificity via :where().',
174
+ ],
175
+ [
176
+ 'astryx.css',
177
+ 'astryx-base',
178
+ 'Pre-compiled component styles. Required for plain and Tailwind. Omit when compiling from source.',
179
+ ],
180
+ [
181
+ 'theme.css',
182
+ 'astryx-theme',
183
+ 'Design tokens (colors, spacing, radius, typography) as CSS custom properties. Swap the package for a different theme.',
184
+ ],
185
+ [
186
+ 'tailwind-theme.css',
187
+ '\u2014',
188
+ 'Tailwind v4 bridge. Maps utility classes to design tokens. Pure CSS, no JS. Tailwind path only.',
189
+ ],
190
+ ],
191
+ },
192
+ ],
193
+ },
194
+ {
195
+ id: 'further-reading',
196
+ title: 'Further reading',
197
+ content: [
198
+ {
199
+ type: 'list',
200
+ style: 'unordered',
201
+ items: [
202
+ '{@link namespace:styling} \u2014 xstyle, className, data-attribute selectors, design tokens in code.',
203
+ '{@link namespace:styling-libraries} \u2014 Tailwind bridge details, Panda, Chakra, MUI, CSS Modules, and non-CSS token resolution.',
204
+ '{@link generic:use-a-theme} \u2014 applying themes, dark mode, nested themes. {@link generic:author-a-theme} \u2014 defineTheme, overrides, production builds.',
205
+ '{@link namespace:migration} \u2014 cascade layer audit, Tailwind v3 coexistence, and foundation smoke test.',
206
+ ],
207
+ },
208
+ ],
209
+ },
210
+ ],
211
+ };
@@ -9,7 +9,7 @@ export const docsDense = {
9
9
  section: 'Wrap your app in a theme',
10
10
  title: 'Quick start',
11
11
  content: [
12
- {type: 'prose', text: 'Install a theme, wrap in `<Theme>`. {@link generic:use-a-theme} for full guide.'},
12
+ {type: 'prose', text: "Install a theme, wrap in `<Theme>` (`import {Theme} from '@astryxdesign/core'`). {@link generic:use-a-theme} for full guide."},
13
13
  ],
14
14
  },
15
15
  {
@@ -17,13 +17,13 @@ export const docs = {
17
17
  content: [
18
18
  {
19
19
  type: 'prose',
20
- text: 'Install a theme package, wrap your app in `<Theme>`, and pick light or dark mode. For the full guide — available themes, integration themes, dark mode, nested themes, and production builds — see {@link generic:use-a-theme}.',
20
+ text: 'Install a theme, import it with the CLI, and wire the generated module once. For the full guide — available themes, integration themes, dark mode, nested themes, and production builds — see {@link generic:use-a-theme}.',
21
21
  },
22
22
  {
23
23
  type: 'code',
24
24
  lang: 'tsx',
25
- label: 'Basic theme setup',
26
- code: "import {Theme} from '@astryxdesign/core';\nimport {neutralTheme} from '@astryxdesign/theme-neutral';\n\nfunction App() {\n return (\n <Theme theme={neutralTheme}>\n <YourApp />\n </Theme>\n );\n}",
25
+ label: 'Wire the generated module once',
26
+ code: "import {Theme} from '@astryxdesign/core';\nimport {themes, defaultThemeSlug} from './astryx-themes';\n\nfunction App() {\n return (\n <Theme theme={themes[defaultThemeSlug]}>\n <YourApp />\n </Theme>\n );\n}",
27
27
  },
28
28
  ],
29
29
  },
@@ -39,7 +39,7 @@ export const docs = {
39
39
  type: 'code',
40
40
  lang: 'bash',
41
41
  label: 'Quick start',
42
- code: 'astryx theme template # annotated starter file\nastryx theme add stone # copy an existing theme\nastryx theme build ./src/themes/my-theme.ts',
42
+ code: 'astryx theme add stone --import # use an existing theme\nastryx theme eject stone # fork its source to customize\nastryx theme build src/themes/stone/stoneTheme.ts',
43
43
  },
44
44
  ],
45
45
  },
@@ -64,7 +64,7 @@ export const docs = {
64
64
  content: [
65
65
  {
66
66
  type: 'prose',
67
- text: 'Install an integration and Astryx discovers its themes automatically. Copy one into your project with `astryx theme add <name> --package <integration>`. For the full walkthrough, see {@link generic:use-a-theme}.',
67
+ text: 'Install an integration and Astryx discovers its themes automatically. Import one with `astryx theme add <name> --import --package <integration>`. Use `theme eject` only for an independent source fork. For the full walkthrough, see {@link generic:use-a-theme}.',
68
68
  },
69
69
  ],
70
70
  },
@@ -11,7 +11,7 @@ export const docsZh = {
11
11
  content: [
12
12
  {
13
13
  type: 'prose',
14
- text: '安装主题包,用 `<Theme>` 包裹应用,选择浅色或深色模式。完整指南——可用主题、集成主题、深色模式、嵌套主题和生产构建——请参阅 {@link generic:use-a-theme}。',
14
+ text: "安装主题包,用 `<Theme>`(`import {Theme} from '@astryxdesign/core'`)包裹应用,选择浅色或深色模式。完整指南——可用主题、集成主题、深色模式、嵌套主题和生产构建——请参阅 {@link generic:use-a-theme}。",
15
15
  },
16
16
  ],
17
17
  },
@@ -0,0 +1,107 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs migration/component-migration`: migrate the app frame,
5
+ * map shadcn/Radix primitives, and wire up command palette, settings, and
6
+ * theme controls.
7
+ */
8
+
9
+ /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
10
+
11
+ export const docs = {
12
+ type: 'generic',
13
+ name: 'component-migration',
14
+ title: 'Component Migration',
15
+ placement: {parent: 'namespace:migration', slot: 'guides', order: 20},
16
+ category: 'guide',
17
+ description:
18
+ 'Move the app frame first, map shadcn and Radix primitives to components, and wire up command palette, settings, and theme controls.',
19
+ keywords: [
20
+ 'Button',
21
+ 'TextInput',
22
+ 'CommandPalette',
23
+ ],
24
+
25
+ sections: [
26
+ {
27
+ title: 'Move the App Frame First',
28
+ content: [
29
+ {
30
+ type: 'prose',
31
+ text: 'Start with AppShell so page migration happens inside the final navigation, spacing, surface, and responsive frame. This also exposes theme and color issues early because every route shares the same shell.',
32
+ },
33
+ {
34
+ type: 'table',
35
+ headers: ['Legacy surface', 'Component', 'Notes'],
36
+ rows: [
37
+ ['Header', 'TopNav', 'Use for product identity, global actions, account entry, and command/search trigger.'],
38
+ ['Sidebar', 'SideNav', 'Use sections and nested nav items for route groups. Keep selection state driven by the router.'],
39
+ ['Main page wrapper', 'AppShell + Layout', 'Let the shell own persistent structure; let route components own page content.'],
40
+ ['Mobile drawer nav', 'MobileNav or AppShell mobile behavior', 'Verify focus, close behavior, and route changes on narrow viewports.'],
41
+ ['Settings menu', 'Popover + Layout + Switch', 'Use as the home for theme mode and app preferences.'],
42
+ ],
43
+ },
44
+ ],
45
+ },
46
+ {
47
+ title: 'Map shadcn and Radix Primitives',
48
+ content: [
49
+ {
50
+ type: 'prose',
51
+ text: 'Do not wrap old shadcn components in design system styles. Replace the primitive with the component that owns the behavior, accessibility, state classes, and token usage.',
52
+ },
53
+ {
54
+ type: 'table',
55
+ headers: ['Existing primitive', 'Component', 'Migration note'],
56
+ rows: [
57
+ ['button / shadcn Button', 'Button or IconButton', 'Use Button for labeled commands and IconButton for icon-only toolbar actions.'],
58
+ ['input', 'TextInput', 'Keep validation state in status props rather than ad hoc border classes.'],
59
+ ['textarea', 'TextArea', 'Use when multiline editing is the primary action.'],
60
+ ['switch', 'Switch', 'Use for persisted boolean settings, including theme mode when represented as a binary choice.'],
61
+ ['checkbox', 'CheckboxInput or CheckboxList', 'Use list variants for grouped selection.'],
62
+ ['radio group', 'RadioList', 'Use when one option must be selected from a visible set.'],
63
+ ['select / combobox', 'Selector or Typeahead', 'Use Selector for bounded options and Typeahead for searchable async options.'],
64
+ ['tabs used as page nav', 'TabList', 'Use route state or current page state as the source of truth.'],
65
+ ['command dialog', 'CommandPalette', 'Keep app-specific search sources outside the shell and feed searchable items.'],
66
+ ['dropdown action menu', 'DropdownMenu or MoreMenu', 'Use MoreMenu for compact overflow actions.'],
67
+ ['alert / callout', 'Banner or Toast', 'Use Banner for page or section messages and Toast for transient feedback.'],
68
+ ['dialog', 'Dialog or AlertDialog', 'Use AlertDialog for destructive confirmation and Dialog for task flows.'],
69
+ ['card-like list row', 'ListItem', 'Prefer ListItem for selectable rows instead of styling Button as a row.'],
70
+ ],
71
+ },
72
+ ],
73
+ },
74
+ {
75
+ id: 'command-palette',
76
+ title: 'Command Palette, Settings, and Theme',
77
+ content: [
78
+ {
79
+ type: 'prose',
80
+ text: 'Move global search to CommandPalette once the shell exists. Treat the palette as a view over app commands: routes, contextual actions, create actions, filters, recent items, and entity results. Keep data normalization in app code so search sources always return arrays of searchable items.',
81
+ },
82
+ {
83
+ type: 'prose',
84
+ text: 'Put light and dark mode controls in the settings popover or account menu. The switch or selector should update the mode passed to Theme, not toggle isolated body classes.',
85
+ },
86
+ {
87
+ type: 'code',
88
+ lang: 'tsx',
89
+ label: 'Settings popover theme control',
90
+ code: `function ThemeModeSwitch() {
91
+ const {mode, setMode} = useSettings();
92
+ const isDark = mode === 'dark';
93
+
94
+ return (
95
+ <Switch
96
+ label="Dark mode"
97
+ description="Use the dark color theme"
98
+ value={isDark}
99
+ onChange={next => setMode(next ? 'dark' : 'light')}
100
+ />
101
+ );
102
+ }`,
103
+ },
104
+ ],
105
+ },
106
+ ],
107
+ };
@@ -0,0 +1,150 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs styling-libraries/css-and-stylex`: core integration
5
+ * principle, plain CSS / CSS Modules, and StyleX typed-token imports.
6
+ */
7
+
8
+ /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
9
+
10
+ export const docs = {
11
+ type: 'generic',
12
+ name: 'css-and-stylex',
13
+ title: 'CSS & StyleX',
14
+ placement: {parent: 'namespace:styling-libraries', slot: 'guides', order: 10},
15
+ category: 'guide',
16
+ description:
17
+ 'Core integration principle, plain CSS / CSS Modules, and StyleX typed-token imports.',
18
+
19
+ sections: [
20
+ {
21
+ title: 'Core Principle',
22
+ content: [
23
+ {
24
+ type: 'prose',
25
+ text: 'Keep the system as the source of truth for theme values. Components read design tokens from CSS custom properties such as `--color-text-primary`, `--color-background-surface`, `--spacing-4`, and `--radius-container`. Other styling libraries should map their own semantic tokens, utility names, or theme objects to those system CSS variables whenever possible.',
26
+ },
27
+ {
28
+ type: 'prose',
29
+ text: 'Use CSS variables for ordinary DOM styling because they inherit through the tree, follow `data-theme` color mode, respect nested `data-astryx-theme` scopes, and update when themes switch. Use token resolver APIs only for non-CSS consumers such as SVG attribute values, canvas, chart configuration, color calculations, or static config generation.',
30
+ },
31
+ {
32
+ type: 'prose',
33
+ text: 'For available token names and values, run {@link namespace:tokens}. Focused references are also available with {@link generic:color}, {@link generic:spacing}, {@link generic:shape}, {@link namespace:typography}, {@link generic:elevation}, and {@link generic:motion}.',
34
+ },
35
+ ],
36
+ },
37
+ {
38
+ title: 'Choose an Integration Path',
39
+ content: [
40
+ {
41
+ type: 'prose',
42
+ text: 'Choose the narrowest integration path that fits the styling library. Most DOM styling should stay on the CSS-variable path; JavaScript token resolution is for APIs that cannot consume CSS custom properties.',
43
+ },
44
+ {
45
+ type: 'table',
46
+ headers: ['Path', 'Use when', 'Value shape'],
47
+ rows: [
48
+ [
49
+ 'CSS variable aliases',
50
+ 'The library ultimately writes CSS and accepts string values',
51
+ '`var(--color-text-primary)`',
52
+ ],
53
+ [
54
+ 'StyleX token imports',
55
+ 'You are writing StyleX styles in application code',
56
+ "`colorVars['--color-text-primary']`",
57
+ ],
58
+ [
59
+ 'Tailwind bridge',
60
+ 'You want utility classes backed by active system tokens',
61
+ '`@astryxdesign/core/tailwind-theme.css`',
62
+ ],
63
+ [
64
+ 'Design token resolver APIs',
65
+ 'JavaScript needs token values for charts, canvas, SVG, or config objects',
66
+ "`resolveThemeToken(theme, '--color-data-categorical-blue', {mode})`",
67
+ ],
68
+ ],
69
+ },
70
+ ],
71
+ },
72
+ {
73
+ title: 'Best Practices',
74
+ content: [
75
+ {
76
+ type: 'list',
77
+ style: 'do',
78
+ items: [
79
+ 'Map by semantic intent: text, surface, border, accent, status, radius, spacing, typography.',
80
+ 'Let the system own color mode. The root Theme syncs `data-theme="light|dark"` and `data-astryx-theme` to `<html>` for portals and first-level theme scope.',
81
+ 'Prefer CSS variables for runtime theme switching and nested themes.',
82
+ ],
83
+ },
84
+ {
85
+ type: 'list',
86
+ style: 'dont',
87
+ items: [
88
+ 'Copy raw hex/px values into a second theme object when a `var(...)` reference would work.',
89
+ 'Run a second unsynchronized dark-mode provider that disagrees with Theme.',
90
+ 'Make another library\'s CSS variables the source of truth for the system. Some consumers need token values outside the DOM.',
91
+ ],
92
+ },
93
+ ],
94
+ },
95
+ {
96
+ title: 'Plain CSS and CSS Modules',
97
+ content: [
98
+ {
99
+ type: 'prose',
100
+ text: 'The simplest integration is direct CSS variable usage. CSS Modules scope class names, but system token variables are global/inherited values supplied by package CSS and the active theme.',
101
+ },
102
+ {
103
+ type: 'code',
104
+ lang: 'css',
105
+ label: 'Card.module.css',
106
+ code: `.card {
107
+ background: var(--color-background-surface);
108
+ color: var(--color-text-primary);
109
+ border: 1px solid var(--color-border);
110
+ border-radius: var(--radius-container);
111
+ padding: var(--spacing-4);
112
+ }`,
113
+ },
114
+ {
115
+ type: 'prose',
116
+ text: 'Sass variables are compile-time only. They are useful for generating static CSS, but they do not update when the system switches theme or color mode. Use native CSS custom properties for themeable values.',
117
+ },
118
+ ],
119
+ },
120
+ {
121
+ title: 'StyleX',
122
+ content: [
123
+ {
124
+ type: 'prose',
125
+ text: 'For StyleX styles, prefer the typed token exports from `@astryxdesign/core/theme/tokens.stylex`. They provide autocomplete and catch token-name typos while still resolving through the same system CSS variables at runtime.',
126
+ },
127
+ {
128
+ type: 'code',
129
+ lang: 'tsx',
130
+ label: 'Typed token imports',
131
+ code: `import * as stylex from '@stylexjs/stylex';
132
+ import {colorVars, spacingVars, radiusVars} from '@astryxdesign/core/theme/tokens.stylex';
133
+
134
+ const styles = stylex.create({
135
+ panel: {
136
+ backgroundColor: colorVars['--color-background-surface'],
137
+ color: colorVars['--color-text-primary'],
138
+ padding: spacingVars['--spacing-4'],
139
+ borderRadius: radiusVars['--radius-container'],
140
+ },
141
+ });`,
142
+ },
143
+ {
144
+ type: 'prose',
145
+ text: 'Use `xstyle` for component overrides and `stylex.props()` for your own DOM nodes. Use `className` when integrating a non-StyleX styling library.',
146
+ },
147
+ ],
148
+ },
149
+ ],
150
+ };