@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
@@ -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
  };
@@ -112,7 +112,7 @@ export const docs = {
112
112
  },
113
113
  {
114
114
  type: 'prose',
115
- text: 'For Tailwind v3, see the layer workaround in {@link generic:migration}.',
115
+ text: 'For Tailwind v3, see the layer workaround in {@link generic:migration-setup}.',
116
116
  },
117
117
  ],
118
118
  },
@@ -122,7 +122,7 @@ export const docs = {
122
122
  content: [
123
123
  {
124
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.',
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
126
  },
127
127
  {
128
128
  type: 'code',
@@ -155,7 +155,7 @@ export const docs = {
155
155
  },
156
156
  {
157
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:styling} for bundler config examples.',
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
159
  },
160
160
  ],
161
161
  },
@@ -199,10 +199,10 @@ export const docs = {
199
199
  type: 'list',
200
200
  style: 'unordered',
201
201
  items: [
202
- '{@link generic:styling} \u2014 xstyle, className, data-attribute selectors, design tokens in code.',
203
- '{@link generic:styling-libraries} \u2014 Tailwind bridge details, Panda, Chakra, MUI, CSS Modules, and non-CSS token resolution.',
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
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 generic:migration} \u2014 cascade layer audit, Tailwind v3 coexistence, and foundation smoke test.',
205
+ '{@link namespace:migration} \u2014 cascade layer audit, Tailwind v3 coexistence, and foundation smoke test.',
206
206
  ],
207
207
  },
208
208
  ],
@@ -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
  {
@@ -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
+ };
@@ -0,0 +1,122 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs typography/font-setup`: font families, custom fonts,
5
+ * font sizes, and font weights.
6
+ */
7
+
8
+ /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
9
+
10
+ export const docs = {
11
+ type: 'generic',
12
+ name: 'font-setup',
13
+ title: 'Font Setup',
14
+ placement: {parent: 'namespace:typography', slot: 'guides', order: 10},
15
+ category: 'foundations',
16
+ description:
17
+ 'Font families, custom font loading, geometric font sizes, and semantic font weights.',
18
+ keywords: [
19
+ 'font family',
20
+ 'custom fonts',
21
+ 'webfont',
22
+ 'Google Fonts',
23
+ 'font-face',
24
+ 'font size',
25
+ 'font weight',
26
+ 'geometric scale',
27
+ ],
28
+
29
+ sections: [
30
+ {
31
+ title: 'Overview',
32
+ content: [
33
+ {
34
+ type: 'prose',
35
+ text: 'Typography is built on a geometric type scale: base size × ratio^step, with 14px and 1.2 as defaults. Every text style is a semantic token that composes font size, weight, and line-height, so components express intent (heading, body, label) rather than raw values.',
36
+ },
37
+ {
38
+ type: 'prose',
39
+ text: 'Two layers work together: raw size tokens (--font-size-xs ... --font-size-5xl) form the geometric scale, and semantic type scale tokens (--text-heading-1-size, --text-body-leading, etc.) reference them by var(). Themes override the entire scale by adjusting base and ratio in defineTheme; all semantic tokens recompute automatically.',
40
+ },
41
+ ],
42
+ },
43
+ {
44
+ title: 'Font Families',
45
+ content: [
46
+ {
47
+ type: 'prose',
48
+ text: 'Three font roles: body (UI text), heading (titles and headings), and code (monospace). By default, body and heading share the same system font stack; code uses a monospace stack. Custom themes can assign different families per role; heading inherits from body when not explicitly set.',
49
+ },
50
+ {
51
+ type: 'token-ref',
52
+ topic: 'tokens',
53
+ section: 'Font Family Tokens',
54
+ },
55
+ ],
56
+ },
57
+ {
58
+ id: 'loading-custom-fonts',
59
+ title: 'Custom fonts',
60
+ content: [
61
+ {
62
+ type: 'prose',
63
+ text: 'Astryx never loads font files. defineTheme and the built CSS only set font-family: naming a webfont (Fraunces, JetBrains Mono, and so on) makes every browser look for it, and quietly fall back when the app has not loaded it. `astryx theme build` warns when a theme names families that are neither CSS generics nor common system fonts and prints the snippet to add; loading the font is always the app\'s job.',
64
+ },
65
+ {
66
+ type: 'code',
67
+ lang: 'html',
68
+ label: 'Google Fonts: add to your document <head>',
69
+ code: `<link rel="preconnect" href="https://fonts.googleapis.com" />
70
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
71
+ <link
72
+ rel="stylesheet"
73
+ href="https://fonts.googleapis.com/css2?family=Fraunces:wght@400;600;700&family=JetBrains+Mono&display=swap"
74
+ />`,
75
+ },
76
+ {
77
+ type: 'code',
78
+ lang: 'css',
79
+ label: 'Self-hosted: one @font-face per family and weight',
80
+ code: `@font-face {
81
+ font-family: 'Fraunces';
82
+ src: url('/fonts/fraunces.woff2') format('woff2');
83
+ font-weight: 400 700; /* variable-font range, or one weight per file */
84
+ font-display: swap; /* fallback text stays visible while the font loads */
85
+ }`,
86
+ },
87
+ {
88
+ type: 'prose',
89
+ text: "Always pair a webfont with a real fallback stack (metric-similar system fonts plus a generic) so text stays readable before the font loads and wherever it never does: defineTheme({typography: {heading: {family: 'Fraunces', fallbacks: 'Georgia, serif'}}}).",
90
+ },
91
+ ],
92
+ },
93
+ {
94
+ title: 'Font Sizes',
95
+ content: [
96
+ {
97
+ type: 'prose',
98
+ text: 'Geometric scale: round(base × ratio^step), expressed in rem. The default scale is 14px × 1.2, producing 12 steps from 4xs (6px) to 5xl (42px). Adjusting base and ratio in defineTheme regenerates every size token while preserving proportional relationships.',
99
+ },
100
+ {
101
+ type: 'token-ref',
102
+ topic: 'tokens',
103
+ section: 'Font Size Tokens',
104
+ },
105
+ ],
106
+ },
107
+ {
108
+ title: 'Font Weights',
109
+ content: [
110
+ {
111
+ type: 'prose',
112
+ text: 'Four semantic weights: normal (400, body/code), medium (500, labels/data), semibold (600, headings/titles), bold (700, strong emphasis). Type scale tokens reference these by var() so themes can remap numeric values.',
113
+ },
114
+ {
115
+ type: 'token-ref',
116
+ topic: 'tokens',
117
+ section: 'Font Weight Tokens',
118
+ },
119
+ ],
120
+ },
121
+ ],
122
+ };
@@ -19,7 +19,6 @@ export const docs = {
19
19
  'LayoutHeader',
20
20
  'LayoutFooter',
21
21
  'Toolbar',
22
- 'hasDivider',
23
22
  'defaultHasDividers',
24
23
  'pinned header',
25
24
  'pinned footer',
@@ -0,0 +1,167 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs internationalization/i18n-library-integration`: override
5
+ * default text, coexist with your own i18n library, or use astryx as your
6
+ * i18n library.
7
+ */
8
+
9
+ /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
10
+
11
+ export const docs = {
12
+ type: 'generic',
13
+ name: 'i18n-library-integration',
14
+ title: 'Library Integration',
15
+ placement: {parent: 'namespace:internationalization', slot: 'guides', order: 20},
16
+ category: 'guide',
17
+ description:
18
+ "Override astryx's default text, coexist with react-intl / i18next / next-intl / LinguiJS, or use astryx as your i18n library.",
19
+ keywords: [
20
+ 'react-intl',
21
+ 'i18next',
22
+ 'next-intl',
23
+ 'LinguiJS',
24
+ 'overrides',
25
+ 'useTranslator',
26
+ ],
27
+
28
+ sections: [
29
+ {
30
+ title: "Overriding astryx's default text",
31
+ content: [
32
+ {
33
+ type: 'prose',
34
+ text: 'Use `overrides` to change individual strings without shipping a full catalog. Overrides are keyed by locale and merged on top of the built-in and user-supplied catalogs.',
35
+ },
36
+ {
37
+ type: 'code',
38
+ lang: 'tsx',
39
+ label: 'Change one string in English',
40
+ code: `<InternationalizationProvider
41
+ locale="en"
42
+ overrides={{en: {'@astryx.pagination.next': 'Next →'}}}
43
+ >
44
+ <App />
45
+ </InternationalizationProvider>`,
46
+ },
47
+ {
48
+ type: 'prose',
49
+ text: 'Overrides win over both bundled English and any `messages` catalog for the same key. Use them for brand voice tweaks or one-off wording changes.',
50
+ },
51
+ ],
52
+ },
53
+ {
54
+ title: 'Using astryx with your own i18n library',
55
+ content: [
56
+ {
57
+ type: 'prose',
58
+ text: "Astryx components render astryx strings through astryx's provider. Consumer components render consumer strings through whatever i18n library you already use: react-intl, i18next, next-intl, LinguiJS, and so on. The two systems coexist and read from the same source of truth for the active locale.",
59
+ },
60
+ {
61
+ type: 'code',
62
+ lang: 'tsx',
63
+ label: 'Astryx + react-intl side by side',
64
+ code: `import {InternationalizationProvider} from '@astryxdesign/core/i18n';
65
+ import {Selector} from '@astryxdesign/core/Selector';
66
+ import {Button} from '@astryxdesign/core/Button';
67
+ import {FormattedMessage, IntlProvider, useIntl} from 'react-intl';
68
+ import astryxFr from './locales/astryx/fr.json'; // astryx's UI, in French
69
+ import appFr from './locales/app/fr.json'; // your app strings, in French
70
+
71
+ function Pricing() {
72
+ // Consumer strings — resolved by react-intl.
73
+ const intl = useIntl();
74
+
75
+ return (
76
+ <section>
77
+ <h1><FormattedMessage id="pricing.heading" /></h1>
78
+
79
+ {/* Astryx Selector — trigger placeholder, search-box placeholder,
80
+ clear-button aria-label all resolved by
81
+ <InternationalizationProvider>. Options come from react-intl. */}
82
+ <Selector
83
+ label={intl.formatMessage({id: 'pricing.region.label'})}
84
+ options={[
85
+ {value: 'na', label: intl.formatMessage({id: 'pricing.region.na'})},
86
+ {value: 'eu', label: intl.formatMessage({id: 'pricing.region.eu'})},
87
+ ]}
88
+ hasSearch
89
+ hasClear
90
+ />
91
+
92
+ <Button label={intl.formatMessage({id: 'pricing.cta.subscribe'})} />
93
+ </section>
94
+ );
95
+ }
96
+
97
+ export default function App() {
98
+ return (
99
+ // Same locale, two providers reading their own catalogs.
100
+ <IntlProvider locale="fr" messages={appFr}>
101
+ <InternationalizationProvider locale="fr" messages={{fr: astryxFr}}>
102
+ <Pricing />
103
+ </InternationalizationProvider>
104
+ </IntlProvider>
105
+ );
106
+ }`,
107
+ },
108
+ {
109
+ type: 'prose',
110
+ text: 'Keep the two providers in sync on locale, and each library owns its own catalog. Astryx never sees your app strings, and your i18n library never sees astryx internals. Runtime locale swap works the same way: re-render both providers with a new `locale` prop and the whole tree updates live.',
111
+ },
112
+ {
113
+ type: 'prose',
114
+ text: "Single-catalog usage (where an external i18n runtime like react-intl or i18next resolves both your app strings AND astryx's strings through one provider) is on the roadmap via a `Translator` adapter. Track [facebook/astryx#4029](https://github.com/facebook/astryx/issues/4029). For now, run the two providers side by side as shown above.",
115
+ },
116
+ ],
117
+ },
118
+ {
119
+ title: 'Using astryx as your i18n library',
120
+ content: [
121
+ {
122
+ type: 'prose',
123
+ text: "For production apps with substantial localization needs, we recommend a dedicated i18n library such as react-intl, i18next, next-intl, or LinguiJS. If your app is small or you do not want another runtime, you can resolve your own strings through astryx too. Keep app keys in a separate namespace from `@astryx.*`, and include your own `en` catalog because astryx's built-in English fallback only contains astryx component strings.",
124
+ },
125
+ {
126
+ type: 'code',
127
+ lang: 'tsx',
128
+ label: 'Translate app strings with astryx',
129
+ code: `import {Button} from '@astryxdesign/core/Button';
130
+ import {
131
+ InternationalizationProvider,
132
+ useTranslator,
133
+ type Catalog,
134
+ type MessagesByLocale,
135
+ } from '@astryxdesign/core/i18n';
136
+
137
+ const en: Catalog = {
138
+ '@myapp.actions.save': {defaultMessage: 'Save'},
139
+ };
140
+
141
+ const fr: Catalog = {
142
+ '@myapp.actions.save': {defaultMessage: 'Enregistrer'},
143
+ };
144
+
145
+ const messages: MessagesByLocale = {en, fr};
146
+
147
+ function SaveButton() {
148
+ const t = useTranslator();
149
+ return <Button label={t('@myapp.actions.save')} />;
150
+ }
151
+
152
+ export default function App() {
153
+ return (
154
+ <InternationalizationProvider locale="fr" messages={messages}>
155
+ <SaveButton />
156
+ </InternationalizationProvider>
157
+ );
158
+ }`,
159
+ },
160
+ {
161
+ type: 'prose',
162
+ text: '`Catalog` types the rich `{defaultMessage, description?}` authoring shape. `RuntimeCatalog` types the generated key-to-message string map. `ProviderMessagesByLocale` accepts either shape for the provider, while `MessagesByLocale` keeps the original rich-only context shape.',
163
+ },
164
+ ],
165
+ },
166
+ ],
167
+ };