@astryxdesign/cli 0.6.6-canary.fb78fa1 → 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 (115) hide show
  1. package/api/component/component-replacement.test.mjs +12 -0
  2. package/api/component/component.doc.mjs +5 -2
  3. package/api/docs/_adapter.mjs +48 -1
  4. package/api/docs/compiled-topics.test.mjs +1 -1
  5. package/api/docs/detail/section/section.d.mts +44 -0
  6. package/api/docs/detail/section/section.mjs +164 -13
  7. package/api/docs/detail/section/section.test.mjs +4 -4
  8. package/api/docs/docOverlays.test.mjs +28 -17
  9. package/api/docs/docs.doc.mjs +3 -3
  10. package/api/docs/docs.mjs +11 -16
  11. package/api/docs/docs.test.mjs +9 -10
  12. package/api/docs/integration-tree.test.mjs +26 -26
  13. package/api/docs/integrationDocs.test.mjs +2 -2
  14. package/api/docs/namespace-section.test.mjs +260 -0
  15. package/api/docs/token-tables.test.mjs +93 -0
  16. package/api/doctor/doctor.d.mts +6 -0
  17. package/api/doctor/doctor.mjs +149 -40
  18. package/api/doctor/doctor.test.mjs +104 -0
  19. package/api/gap-report/gap-report.doc.mjs +2 -1
  20. package/api/integration/validate-integration.mjs +20 -4
  21. package/api/integration/validate-integration.test.mjs +73 -0
  22. package/api/search/search.d.mts +3 -2
  23. package/api/search/search.domain-priority.test.mjs +35 -21
  24. package/api/search/search.mjs +30 -9
  25. package/api/swizzle/swizzle.doc.mjs +5 -2
  26. package/assets/docs/author-a-theme.doc.mjs +4 -4
  27. package/assets/docs/getting-started.doc.mjs +2 -2
  28. package/assets/docs/principles.doc.dense.mjs +3 -3
  29. package/assets/docs/principles.doc.mjs +4 -4
  30. package/assets/docs/principles.doc.zh.mjs +3 -3
  31. package/assets/docs/styling-overview.doc.mjs +5 -5
  32. package/assets/docs/tree/component-migration.doc.mjs +107 -0
  33. package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
  34. package/assets/docs/tree/font-setup.doc.mjs +122 -0
  35. package/assets/docs/tree/headers-and-footers.doc.mjs +0 -1
  36. package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
  37. package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
  38. package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
  39. package/assets/docs/tree/internationalization.doc.mjs +29 -0
  40. package/assets/docs/tree/layout.doc.mjs +3 -0
  41. package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
  42. package/assets/docs/tree/migration-verification.doc.mjs +67 -0
  43. package/assets/docs/tree/migration.doc.mjs +28 -0
  44. package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
  45. package/assets/docs/tree/other-libraries.doc.mjs +218 -0
  46. package/assets/docs/tree/responsive.doc.mjs +0 -4
  47. package/assets/docs/tree/scaffold.doc.mjs +0 -5
  48. package/assets/docs/tree/side-panels.doc.mjs +0 -1
  49. package/assets/docs/tree/structure.doc.mjs +0 -4
  50. package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
  51. package/assets/docs/tree/styling-basics.doc.mjs +181 -0
  52. package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
  53. package/assets/docs/tree/styling.doc.mjs +29 -0
  54. package/assets/docs/tree/tailwind.doc.mjs +65 -0
  55. package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
  56. package/assets/docs/tree/tokens-border.doc.mjs +46 -0
  57. package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
  58. package/assets/docs/tree/tokens-color.doc.mjs +438 -0
  59. package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
  60. package/assets/docs/tree/tokens-data.doc.mjs +323 -0
  61. package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
  62. package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
  63. package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
  64. package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
  65. package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
  66. package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
  67. package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
  68. package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
  69. package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
  70. package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
  71. package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
  72. package/assets/docs/tree/tokens-size.doc.mjs +54 -0
  73. package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
  74. package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
  75. package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
  76. package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
  77. package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
  78. package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
  79. package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
  80. package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
  81. package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
  82. package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
  83. package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
  84. package/assets/docs/tree/tokens.doc.mjs +28 -0
  85. package/assets/docs/tree/type-scale.doc.mjs +147 -0
  86. package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
  87. package/assets/docs/tree/typography.doc.mjs +29 -0
  88. package/assets/theme.template.ts +4 -3
  89. package/clients/cli/commands/component/index.mjs +4 -1
  90. package/clients/cli/commands/component-replacement.text.test.mjs +45 -0
  91. package/clients/cli/commands/docs.doc.mjs +2 -1
  92. package/clients/cli/commands/docs.test.mjs +13 -11
  93. package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
  94. package/clients/cli/commands/doctor.test.mjs +33 -0
  95. package/clients/cli/lib/component-format.mjs +13 -3
  96. package/foundation/agent-docs/agent-docs.mjs +14 -1
  97. package/foundation/config/project.test.mjs +1 -1
  98. package/foundation/discovery/docs-discovery.test.mjs +1 -1
  99. package/foundation/doc-compiler/bundle.mjs +52 -1
  100. package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
  101. package/foundation/doc-compiler/tree.d.mts +10 -0
  102. package/foundation/doc-compiler/tree.mjs +22 -0
  103. package/foundation/doc-compiler/tree.test.mjs +3 -2
  104. package/foundation/env/package-manager.d.mts +3 -0
  105. package/foundation/env/package-manager.mjs +71 -3
  106. package/foundation/env/package-manager.test.mjs +82 -1
  107. package/foundation/integrations/validate-contributions.d.mts +16 -0
  108. package/foundation/integrations/validate-contributions.mjs +56 -8
  109. package/package.json +9 -9
  110. package/assets/docs/styling-libraries.doc.mjs +0 -469
  111. package/assets/docs/styling.doc.mjs +0 -412
  112. package/assets/docs/tokens.doc.dense.mjs +0 -15
  113. package/assets/docs/tokens.doc.mjs +0 -1491
  114. package/assets/docs/tokens.doc.zh.mjs +0 -15
  115. package/assets/docs/typography.doc.mjs +0 -286
@@ -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
+ };
@@ -0,0 +1,181 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs styling/styling-basics`: overview of styling approaches,
5
+ * xstyle prop, Tailwind integration, className/style props, and rest props.
6
+ */
7
+
8
+ /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
9
+
10
+ export const docs = {
11
+ type: 'generic',
12
+ name: 'styling-basics',
13
+ title: 'Basics',
14
+ placement: {parent: 'namespace:styling', slot: 'guides', order: 10},
15
+ category: 'guide',
16
+ description:
17
+ 'Overview of styling approaches, xstyle prop, Tailwind integration, className/style props, and rest props.',
18
+ keywords: [
19
+ 'style',
20
+ 'rest props',
21
+ 'data-testid',
22
+ 'ref',
23
+ ],
24
+
25
+ sections: [
26
+ {
27
+ title: 'Overview',
28
+ content: [
29
+ {
30
+ type: 'prose',
31
+ text: 'Style components with `xstyle` (StyleX), `className` (Tailwind or your own CSS), or a styling library aliased to Astryx tokens. All of them resolve to the same tokens.',
32
+ },
33
+ {
34
+ type: 'table',
35
+ headers: ['Approach', 'Use for', 'Example'],
36
+ rows: [
37
+ ['StyleX', 'Component-specific overrides, reusable styles, pseudo-classes, and typed tokens', '`const styles = stylex.create(...); <Button xstyle={styles.save} />`'],
38
+ ['Tailwind utilities', 'Page layout, wrappers, and utility styling', '`className="flex gap-3 p-4"`'],
39
+ ['className', 'Integrating with external CSS or Tailwind on components', '`className="my-card shadow-lg"`'],
40
+ ['Styling-library token aliases', 'Keeping Panda, Chakra, MUI, Emotion, styled-components, UnoCSS, CSS Modules, or Sass in sync with the system', "`colors.surface = 'var(--color-background-surface)'`"],
41
+ ],
42
+ },
43
+ {
44
+ type: 'prose',
45
+ text: 'Theming and dark mode work whichever you choose. For external styling libraries, see {@link namespace:styling-libraries}; it covers Tailwind, StyleX, Panda, Chakra, MUI, CSS-in-JS, CSS Modules, Sass, and `useTheme()` for non-CSS processing.',
46
+ },
47
+ ],
48
+ },
49
+ {
50
+ title: 'xstyle Prop',
51
+ content: [
52
+ {
53
+ type: 'prose',
54
+ text: 'Every component accepts an `xstyle` prop for style customization. It accepts StyleX styles created via `stylex.create()`, not inline objects or class name strings. StyleX styles are compiled at build time for optimal deduplication and dead-code elimination.',
55
+ },
56
+ {
57
+ type: 'code',
58
+ lang: 'tsx',
59
+ label: 'Simple overrides',
60
+ code: `import * as stylex from '@stylexjs/stylex';
61
+
62
+ const overrides = stylex.create({
63
+ card: { maxWidth: 400, marginBlock: 16 },
64
+ saveButton: { alignSelf: 'flex-end' },
65
+ });
66
+
67
+ <Card xstyle={overrides.card} />
68
+ <Button label="Save" xstyle={overrides.saveButton} />`,
69
+ },
70
+ {
71
+ type: 'code',
72
+ lang: 'tsx',
73
+ label: 'Pseudo-classes and conditional styles',
74
+ code: `import * as stylex from '@stylexjs/stylex';
75
+
76
+ const overrides = stylex.create({
77
+ card: {
78
+ boxShadow: {
79
+ default: 'none',
80
+ ':hover': { '@media (hover: hover)': '0 4px 12px rgba(0,0,0,0.1)' },
81
+ },
82
+ },
83
+ });
84
+
85
+ <Card xstyle={overrides.card}>...</Card>`,
86
+ },
87
+ {
88
+ type: 'list',
89
+ style: 'unordered',
90
+ items: [
91
+ 'All xstyle values must come from stylex.create()',
92
+ 'Pseudo-classes (:hover, :focus-visible) are supported inside stylex.create',
93
+ 'All :hover styles MUST use @media (hover: hover) guard',
94
+ 'For non-StyleX styling (Tailwind, external CSS), use className instead',
95
+ ],
96
+ },
97
+ ],
98
+ },
99
+ {
100
+ title: 'Tailwind Integration',
101
+ content: [
102
+ {
103
+ type: 'prose',
104
+ text: 'The package ships a Tailwind v4 theme bridge that maps all design tokens to Tailwind utility classes. Import it once and use Tailwind classes backed by design tokens: colors, spacing, radius, shadows, and typography all resolve to the active theme.',
105
+ },
106
+ {
107
+ type: 'prose',
108
+ text: 'For the imports and the cascade-layer order to put in your global CSS, see {@link generic:tailwind}.',
109
+ },
110
+ {
111
+ type: 'code',
112
+ lang: 'tsx',
113
+ label: 'Tailwind utilities alongside components',
114
+ code: `<div className="text-primary bg-surface rounded-lg p-4 flex gap-3">
115
+ <Button label="Save" variant="primary" />
116
+ <Button label="Cancel" variant="secondary" />
117
+ </div>`,
118
+ },
119
+ {
120
+ type: 'prose',
121
+ text: 'The bridge is pure CSS with zero JS. Theme changes (dark mode, custom themes) apply automatically because the utilities reference the same CSS custom properties that components use. This is the paved Tailwind path; for other styling libraries that follow the same aliasing pattern, see {@link namespace:styling-libraries}.',
122
+ },
123
+ ],
124
+ },
125
+ {
126
+ title: 'className and style Props',
127
+ content: [
128
+ {
129
+ type: 'prose',
130
+ text: 'Every component also accepts standard `className` and `style` props. `className` is appended after the component\'s own classes. `style` is merged after StyleX inline styles, so consumer values win on conflict.',
131
+ },
132
+ {
133
+ type: 'code',
134
+ lang: 'tsx',
135
+ label: 'className with Tailwind utilities',
136
+ code: `<Card className="shadow-lg hover:shadow-xl transition-shadow">
137
+ ...
138
+ </Card>
139
+ <Button label="Save" className="my-app-save-btn" />`,
140
+ },
141
+ {
142
+ type: 'prose',
143
+ text: 'For layout and wrapper styling, Tailwind utilities on className work well. For component-specific overrides (padding, colors, borders), prefer xstyle; it integrates with StyleX deduplication and the component\'s internal style pipeline.',
144
+ },
145
+ ],
146
+ },
147
+ {
148
+ title: 'Rest Props (Prop Drilling)',
149
+ content: [
150
+ {
151
+ type: 'prose',
152
+ text: 'Components extend HTML attributes and spread rest props onto their root DOM element. This means data-* attributes, aria-* attributes, event handlers, and other HTML props pass through automatically.',
153
+ },
154
+ {
155
+ type: 'code',
156
+ lang: 'tsx',
157
+ label: 'Data attributes, event handlers, and ARIA',
158
+ code: `<Card
159
+ data-testid="user-card"
160
+ data-user-id={user.id}
161
+ onMouseEnter={handleHover}
162
+ aria-label="User profile card"
163
+ >
164
+ ...
165
+ </Card>`,
166
+ },
167
+ {
168
+ type: 'code',
169
+ lang: 'tsx',
170
+ label: 'Ref forwarding',
171
+ code: `const cardRef = useRef<HTMLDivElement>(null);
172
+ <Card ref={cardRef}>...</Card>`,
173
+ },
174
+ {
175
+ type: 'prose',
176
+ text: 'A few HTML attributes are intentionally omitted from the base type (contentEditable, dangerouslySetInnerHTML). children is not in the base type either; components that accept children declare it explicitly, so slot-based components don\'t silently drop JSX children.',
177
+ },
178
+ ],
179
+ },
180
+ ],
181
+ };
@@ -0,0 +1,30 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs styling-libraries`: the styling-libraries namespace.
5
+ * Groups guides for CSS/StyleX, Tailwind, other semantic-token libraries,
6
+ * and non-CSS token processing.
7
+ */
8
+
9
+ /** @type {import('@astryxdesign/cli/authoring').NamespaceDoc} */
10
+ export const docs = {
11
+ type: 'namespace',
12
+ name: 'styling-libraries',
13
+ title: 'Styling Library Interop',
14
+ summary:
15
+ 'Integrate Tailwind, StyleX, Panda, Chakra, MUI, CSS-in-JS, CSS Modules, and non-CSS renderers with system tokens.',
16
+ keywords: [
17
+ 'Tailwind',
18
+ 'StyleX',
19
+ 'Panda',
20
+ 'Chakra',
21
+ 'MUI',
22
+ 'Emotion',
23
+ 'styled-components',
24
+ 'CSS Modules',
25
+ 'interop',
26
+ ],
27
+ slots: {
28
+ guides: {title: 'Guides', accepts: {kinds: ['generic']}},
29
+ },
30
+ };
@@ -0,0 +1,29 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs styling`: the styling namespace. Groups guides for
5
+ * styling basics (xstyle, className, rest props), advanced patterns
6
+ * (compounds, data attrs, deprecated), and tokens + StyleX setup.
7
+ */
8
+
9
+ /** @type {import('@astryxdesign/cli/authoring').NamespaceDoc} */
10
+ export const docs = {
11
+ type: 'namespace',
12
+ name: 'styling',
13
+ title: 'Styling Components',
14
+ summary:
15
+ 'Customize component appearance: xstyle, Tailwind, className, rest props, compound components, data attribute selectors, tokens, and StyleX setup.',
16
+ keywords: [
17
+ 'styling',
18
+ 'xstyle',
19
+ 'className',
20
+ 'override',
21
+ 'customize',
22
+ 'css',
23
+ 'StyleX',
24
+ 'tokens',
25
+ ],
26
+ slots: {
27
+ guides: {title: 'Guides', accepts: {kinds: ['generic']}},
28
+ },
29
+ };
@@ -0,0 +1,65 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs styling-libraries/tailwind`: the Tailwind v4 bridge,
5
+ * cascade layer order, and utility-class usage backed by system tokens.
6
+ */
7
+
8
+ /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
9
+
10
+ export const docs = {
11
+ type: 'generic',
12
+ name: 'tailwind',
13
+ title: 'Tailwind',
14
+ placement: {parent: 'namespace:styling-libraries', slot: 'guides', order: 20},
15
+ category: 'guide',
16
+ description:
17
+ 'The Tailwind v4 bridge, cascade layer order, and utility-class usage backed by system tokens.',
18
+ keywords: [
19
+ 'tailwind-theme.css',
20
+ 'utility classes',
21
+ 'preflight',
22
+ ],
23
+
24
+ sections: [
25
+ {
26
+ title: 'Tailwind',
27
+ content: [
28
+ {
29
+ type: 'prose',
30
+ text: 'The Tailwind v4 bridge at `@astryxdesign/core/tailwind-theme.css` maps Tailwind theme variables to system CSS variables with `@theme reference inline`, so utility classes like `text-primary`, `bg-surface`, `border-border`, `rounded-lg`, and `shadow-md` stay in sync with the active theme without emitting competing runtime declarations.',
31
+ },
32
+ {
33
+ type: 'code',
34
+ lang: 'css',
35
+ label: 'globals.css',
36
+ code: `@layer reset, theme, base, astryx-base, astryx-theme, components, utilities;
37
+
38
+ @import "tailwindcss/theme.css" layer(theme);
39
+ @import "tailwindcss/preflight.css" layer(base);
40
+ @import "@astryxdesign/core/reset.css";
41
+ @import "@astryxdesign/core/astryx.css";
42
+ @import "@astryxdesign/theme-neutral/theme.css";
43
+ @import "@astryxdesign/core/tailwind-theme.css";
44
+ @import "tailwindcss/utilities.css" layer(utilities);`,
45
+ },
46
+ {
47
+ type: 'prose',
48
+ text: 'Pre-declare every layer before any imports. This keeps reset lowest, Tailwind preflight above reset, component/theme styles in the middle, and Tailwind utilities last so utility classes on `className` can intentionally override component defaults.',
49
+ },
50
+ {
51
+ type: 'code',
52
+ lang: 'tsx',
53
+ label: 'Tailwind classes backed by system tokens',
54
+ code: `<section className="rounded-lg border border-border bg-surface p-4 text-primary shadow-md">
55
+ <Button label="Save" variant="primary" />
56
+ </section>`,
57
+ },
58
+ {
59
+ type: 'prose',
60
+ text: 'The Tailwind bridge is the concrete example of the general interop pattern: expose another library\'s semantic API, but point the values at system token variables.',
61
+ },
62
+ ],
63
+ },
64
+ ],
65
+ };
@@ -0,0 +1,128 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /**
4
+ * @file `astryx docs styling/tokens-and-setup`: using design tokens in custom
5
+ * styles and configuring a StyleX compiler for swizzled components.
6
+ */
7
+
8
+ /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
9
+
10
+ export const docs = {
11
+ type: 'generic',
12
+ name: 'tokens-and-setup',
13
+ title: 'Tokens & Setup',
14
+ placement: {parent: 'namespace:styling', slot: 'guides', order: 30},
15
+ category: 'guide',
16
+ description:
17
+ 'Using design tokens in custom styles and configuring a StyleX compiler for swizzled components.',
18
+ keywords: [
19
+ 'StyleX setup',
20
+ 'swizzle',
21
+ 'webpack',
22
+ 'Vite',
23
+ 'Next.js',
24
+ ],
25
+
26
+ sections: [
27
+ {
28
+ title: 'Design Tokens',
29
+ content: [
30
+ {
31
+ type: 'prose',
32
+ text: 'When writing custom styles, use design tokens instead of hardcoded values. Tokens are CSS custom properties that adapt to the active theme and color mode. The system provides tokens for spacing, color, radius, shadow, typography, and size.',
33
+ },
34
+ {
35
+ type: 'code',
36
+ lang: 'tsx',
37
+ label: 'Using tokens in stylex.create',
38
+ code: `import * as stylex from '@stylexjs/stylex';
39
+
40
+ const styles = stylex.create({
41
+ surface: {
42
+ padding: 'var(--spacing-4)',
43
+ borderRadius: 'var(--radius-container)',
44
+ backgroundColor: 'var(--color-background-surface)',
45
+ },
46
+ });
47
+
48
+ <Card xstyle={styles.surface} />`,
49
+ },
50
+ {
51
+ type: 'code',
52
+ lang: 'tsx',
53
+ label: 'Using typed token imports in stylex.create',
54
+ code: `import {colorVars, spacingVars, radiusVars} from '@astryxdesign/core/theme/tokens.stylex';
55
+
56
+ const styles = stylex.create({
57
+ highlight: {
58
+ backgroundColor: colorVars['--color-accent-muted'],
59
+ padding: spacingVars['--spacing-3'],
60
+ borderRadius: radiusVars['--radius-element'],
61
+ },
62
+ });`,
63
+ },
64
+ {
65
+ type: 'prose',
66
+ text: 'Both approaches work: var() strings or typed imports from tokens.stylex. The typed imports give autocomplete and catch typos at build time.',
67
+ },
68
+ {
69
+ type: 'prose',
70
+ text: 'See {@link namespace:tokens} for the full token reference (all spacing, color, radius, shadow, and typography tokens with values). See {@link generic:author-a-theme} for how to override tokens via defineTheme.',
71
+ },
72
+ ],
73
+ },
74
+ {
75
+ id: 'stylex-setup',
76
+ title: 'StyleX Build Setup (required for swizzled components)',
77
+ content: [
78
+ {
79
+ type: 'prose',
80
+ text: 'Astryx components ship pre-compiled, so consuming the published package needs no StyleX setup. But `astryx swizzle <Component>` copies the raw StyleX *source* into your app, and StyleX source requires a build-time StyleX compiler to produce atomic CSS. Without one the component compiles but renders completely unstyled: no error, no warning. If a swizzled component looks unstyled, a missing StyleX compiler is almost always why. The same applies if you author your own StyleX with `stylex.create()`.',
81
+ },
82
+ {
83
+ type: 'table',
84
+ headers: ['Bundler', 'StyleX plugin'],
85
+ rows: [
86
+ ['Webpack', '@stylexjs/webpack-plugin'],
87
+ ['Vite / Rollup', '@stylexjs/rollup-plugin (or a community Vite plugin)'],
88
+ ['Babel (any bundler)', '@stylexjs/babel-plugin + @stylexjs/postcss-plugin'],
89
+ ['Next.js (App Router, SWC)', 'An SWC-based transform; see the Next.js note below'],
90
+ ],
91
+ },
92
+ {
93
+ type: 'prose',
94
+ text: 'Next.js (App Router) is the sharp edge. StyleX\'s canonical compiler is a Babel plugin, but introducing a Babel config in Next.js disables the SWC compiler, and with it SWC-dependent features like `next/font`.',
95
+ },
96
+ {
97
+ type: 'prose',
98
+ text: 'The repo\'s `apps/example-nextjs-stylex` takes the Babel path (`next/babel`, `@stylexjs/babel-plugin`, `@stylexjs/postcss-plugin`). Babel turns off SWC, so that app does not use `next/font`. To keep `next/font`, use an SWC transform such as `@stylexswc/nextjs-plugin`.',
99
+ },
100
+ {
101
+ type: 'code',
102
+ lang: 'js',
103
+ label: 'next.config.mjs: SWC-based StyleX transform (keeps next/font working)',
104
+ code: `import stylexPlugin from '@stylexswc/nextjs-plugin';
105
+
106
+ export default stylexPlugin({
107
+ rsOptions: {
108
+ // Resolve @astryxdesign/core's StyleX so swizzled component source compiles.
109
+ aliases: {'@/*': ['./src/*']},
110
+ unstable_moduleResolution: {type: 'commonJS'},
111
+ },
112
+ })({
113
+ // your existing Next.js config
114
+ });`,
115
+ },
116
+ {
117
+ type: 'list',
118
+ style: 'unordered',
119
+ items: [
120
+ 'Symptom of a missing compiler: swizzled component renders with no styles, but no build or runtime error.',
121
+ 'A Babel config turns off SWC in Next.js; skip it if you need `next/font`.',
122
+ 'Pure theming (defineTheme + astryx theme build) needs NO StyleX compiler; only swizzled/authored StyleX source does.',
123
+ ],
124
+ },
125
+ ],
126
+ },
127
+ ],
128
+ };
@@ -0,0 +1,46 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ // AUTO-GENERATED — do not edit manually.
4
+ // Source: packages/core/src/theme/tokens.stylex.ts,
5
+ // dataTokens.stylex.ts, and syntax/tokens.ts
6
+ // Run: node scripts/generate-token-docs.mjs
7
+
8
+ /** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
9
+
10
+ export const docs = {
11
+ "type": "generic",
12
+ "name": "tokens-border",
13
+ "title": "Border Tokens",
14
+ "placement": {
15
+ "parent": "namespace:tokens",
16
+ "slot": "guides",
17
+ "order": 60
18
+ },
19
+ "category": "foundations",
20
+ "description": "Border width for card and input borders.",
21
+ "sections": [
22
+ {
23
+ "title": "Border Tokens",
24
+ "content": [
25
+ {
26
+ "type": "prose",
27
+ "text": "Border width for card and input borders."
28
+ },
29
+ {
30
+ "type": "table",
31
+ "headers": [
32
+ "Token",
33
+ "Value"
34
+ ],
35
+ "rows": [
36
+ [
37
+ "--border-width",
38
+ "1px"
39
+ ]
40
+ ]
41
+ }
42
+ ],
43
+ "previewType": "border-line"
44
+ }
45
+ ]
46
+ };
@@ -0,0 +1,10 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** @type {import('@astryxdesign/cli/authoring').ReferenceTranslationDoc} */
4
+
5
+ export const docsDense = {
6
+ description: 'semantic colors, support light-dark() auto switching.',
7
+ sections: [
8
+ { section: 'Color Tokens', title: 'Color', content: [{ type: 'prose', text: 'semantic colors, support light-dark() auto switching.' }, null, null, null] },
9
+ ],
10
+ };