@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.
- package/README.md +83 -83
- package/api/build/_adapter.d.mts +15 -0
- package/api/build/_adapter.mjs +22 -0
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.type.d.mts +4 -0
- package/api/build/build.type.mjs +1 -0
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/kit.mjs +12 -1
- package/api/component/component-replacement.test.mjs +12 -0
- package/api/component/component.doc.mjs +5 -2
- package/api/docs/_adapter.mjs +48 -1
- package/api/docs/compiled-topics.test.mjs +1 -1
- package/api/docs/detail/section/section.d.mts +44 -0
- package/api/docs/detail/section/section.mjs +164 -13
- package/api/docs/detail/section/section.test.mjs +4 -4
- package/api/docs/docOverlays.test.mjs +28 -17
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.mjs +11 -16
- package/api/docs/docs.test.mjs +9 -10
- package/api/docs/integration-tree.test.mjs +26 -26
- package/api/docs/integrationDocs.test.mjs +2 -2
- package/api/docs/namespace-section.test.mjs +260 -0
- package/api/docs/token-tables.test.mjs +93 -0
- package/api/doctor/doctor.d.mts +6 -0
- package/api/doctor/doctor.mjs +149 -40
- package/api/doctor/doctor.test.mjs +104 -0
- package/api/doctor/theme-checks.mjs +1 -1
- package/api/gap-report/gap-report.doc.mjs +2 -1
- package/api/init/run/run.mjs +1 -0
- package/api/integration/validate-integration.mjs +20 -4
- package/api/integration/validate-integration.test.mjs +73 -0
- package/api/layout/check/check.d.mts +1 -0
- package/api/layout/check/check.mjs +1 -0
- package/api/layout/expand/expand.d.mts +1 -0
- package/api/layout/expand/expand.mjs +1 -0
- package/api/layout/grammar/grammar.d.mts +1 -0
- package/api/layout/grammar/grammar.mjs +1 -0
- package/api/layout/layoutCheck.doc.mjs +1 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -1
- package/api/search/search.d.mts +44 -0
- package/api/search/search.domain-priority.test.mjs +261 -0
- package/api/search/search.mjs +191 -29
- package/api/swizzle/swizzle.doc.mjs +5 -2
- package/api/template/copy/copy.mjs +12 -0
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.type.d.mts +3 -0
- package/api/template/template.type.mjs +3 -0
- package/api/theme/build/build.d.mts +70 -0
- package/api/theme/build/build.mjs +205 -41
- package/api/theme/build/font-warning.d.mts +11 -0
- package/api/theme/build/font-warning.mjs +28 -3
- package/assets/docs/author-a-theme.doc.mjs +16 -11
- package/assets/docs/getting-started.doc.mjs +2 -2
- package/assets/docs/principles.doc.dense.mjs +3 -3
- package/assets/docs/principles.doc.mjs +4 -4
- package/assets/docs/principles.doc.zh.mjs +3 -3
- package/assets/docs/styling-overview.doc.mjs +6 -6
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/component-migration.doc.mjs +107 -0
- package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
- package/assets/docs/tree/font-setup.doc.mjs +122 -0
- package/assets/docs/tree/headers-and-footers.doc.mjs +0 -1
- package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
- package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
- package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
- package/assets/docs/tree/internationalization.doc.mjs +29 -0
- package/assets/docs/tree/layout.doc.mjs +23 -0
- package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
- package/assets/docs/tree/migration-verification.doc.mjs +67 -0
- package/assets/docs/tree/migration.doc.mjs +28 -0
- package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
- package/assets/docs/tree/other-libraries.doc.mjs +218 -0
- package/assets/docs/tree/responsive.doc.mjs +0 -4
- package/assets/docs/tree/scaffold.doc.mjs +0 -5
- package/assets/docs/tree/side-panels.doc.mjs +0 -1
- package/assets/docs/tree/structure.doc.mjs +0 -4
- package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
- package/assets/docs/tree/styling-basics.doc.mjs +181 -0
- package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
- package/assets/docs/tree/styling.doc.mjs +29 -0
- package/assets/docs/tree/tailwind.doc.mjs +65 -0
- package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
- package/assets/docs/tree/tokens-border.doc.mjs +46 -0
- package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-color.doc.mjs +438 -0
- package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-data.doc.mjs +323 -0
- package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
- package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
- package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
- package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
- package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
- package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
- package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.mjs +54 -0
- package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
- package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
- package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
- package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
- package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
- package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
- package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens.doc.mjs +28 -0
- package/assets/docs/tree/type-scale.doc.mjs +147 -0
- package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
- package/assets/docs/tree/typography.doc.mjs +29 -0
- package/assets/docs/use-a-theme.doc.mjs +6 -3
- package/assets/templates/pages/incident-console/page.tsx +1 -1
- package/assets/theme.template.ts +4 -3
- package/clients/cli/commands/blog.mjs +3 -3
- package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
- package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
- package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
- package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +68 -18
- package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
- package/clients/cli/commands/build.mjs +1 -0
- package/clients/cli/commands/component/index.mjs +4 -1
- package/clients/cli/commands/component-replacement.text.test.mjs +45 -0
- package/clients/cli/commands/docs.doc.mjs +2 -1
- package/clients/cli/commands/docs.test.mjs +15 -12
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
- package/clients/cli/commands/doctor.test.mjs +50 -1
- package/clients/cli/commands/import-hint-correctness.test.mjs +23 -0
- package/clients/cli/commands/layout-check.doc.mjs +1 -0
- package/clients/cli/commands/layout-expand.doc.mjs +1 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
- package/clients/cli/commands/layout.doc.mjs +1 -0
- package/clients/cli/commands/layout.mjs +6 -11
- package/clients/cli/commands/search.test.mjs +6 -2
- package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
- package/clients/cli/commands/template.mjs +4 -3
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +9 -6
- package/clients/cli/commands/theme-build.doc.mjs +3 -1
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/component-format.mjs +13 -3
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +4 -0
- package/foundation/agent-docs/agent-docs.mjs +18 -2
- package/foundation/agent-docs/agent-docs.test.mjs +18 -0
- package/foundation/config/project.test.mjs +1 -1
- package/foundation/discovery/docs-discovery.test.mjs +1 -1
- package/foundation/discovery/template-needs.d.mts +31 -0
- package/foundation/discovery/template-needs.mjs +156 -0
- package/foundation/discovery/template-needs.test.mjs +203 -0
- package/foundation/doc-compiler/bundle.mjs +52 -1
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
- package/foundation/doc-compiler/tree.d.mts +10 -0
- package/foundation/doc-compiler/tree.mjs +22 -0
- package/foundation/doc-compiler/tree.test.mjs +3 -2
- package/foundation/env/package-manager.d.mts +31 -8
- package/foundation/env/package-manager.mjs +120 -13
- package/foundation/env/package-manager.test.mjs +174 -1
- package/foundation/integrations/validate-contributions.d.mts +16 -0
- package/foundation/integrations/validate-contributions.mjs +56 -8
- package/foundation/response/response-types.doc.mjs +4 -4
- package/package.json +9 -9
- package/assets/docs/styling-libraries.doc.mjs +0 -469
- package/assets/docs/styling.doc.mjs +0 -412
- package/assets/docs/tokens.doc.dense.mjs +0 -15
- package/assets/docs/tokens.doc.mjs +0 -1491
- package/assets/docs/tokens.doc.zh.mjs +0 -15
- package/assets/docs/typography.doc.mjs +0 -286
|
@@ -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
|
+
};
|