@astryxdesign/cli 0.6.6-canary.4ec0d0e → 0.6.6-canary.5275d89
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/api/docs/_adapter.mjs +48 -1
- package/api/docs/compiled-topics.test.mjs +1 -1
- package/api/docs/detail/section/section.test.mjs +4 -4
- package/api/docs/docOverlays.test.mjs +28 -17
- package/api/docs/docs.doc.mjs +1 -1
- package/api/docs/docs.test.mjs +2 -2
- package/api/docs/integration-tree.test.mjs +26 -26
- package/api/docs/integrationDocs.test.mjs +2 -2
- package/api/docs/token-tables.test.mjs +93 -0
- package/assets/docs/author-a-theme.doc.mjs +4 -4
- 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 +5 -5
- 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 +3 -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/theme.template.ts +4 -3
- package/clients/cli/commands/docs.test.mjs +1 -2
- package/foundation/agent-docs/agent-docs.mjs +14 -1
- package/foundation/config/project.test.mjs +1 -1
- package/foundation/discovery/docs-discovery.test.mjs +1 -1
- 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/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
package/api/docs/_adapter.mjs
CHANGED
|
@@ -732,10 +732,57 @@ export async function packageDocsProblems(integration, discovered) {
|
|
|
732
732
|
export function referenceTargets(catalog, lang) {
|
|
733
733
|
return async topic => {
|
|
734
734
|
const target = catalog.resolve(topic);
|
|
735
|
-
|
|
735
|
+
if (target) return lowerTopic(catalog, target, lang);
|
|
736
|
+
return namespaceReferenceTarget(catalog, topic, lang);
|
|
736
737
|
};
|
|
737
738
|
}
|
|
738
739
|
|
|
740
|
+
/**
|
|
741
|
+
* A docs-tree namespace as the target of a token reference: every guide placed
|
|
742
|
+
* below it, lowered for `lang` and read in tree order as one topic. A flat
|
|
743
|
+
* topic split into a namespace keeps answering the references its readers
|
|
744
|
+
* wrote, so `{type: 'token-ref', topic: 'tokens', section: 'Color Tokens'}`
|
|
745
|
+
* finds the guide that now holds that table. Null for any other route.
|
|
746
|
+
* @param {DocsCatalog} catalog
|
|
747
|
+
* @param {string} route
|
|
748
|
+
* @param {string | null} lang
|
|
749
|
+
* @returns {Promise<import('../../foundation/doc-compiler/compile.mjs').CompiledReferenceNode | null>}
|
|
750
|
+
*/
|
|
751
|
+
async function namespaceReferenceTarget(catalog, route, lang) {
|
|
752
|
+
const tree = await projectTree(catalog);
|
|
753
|
+
const node = tree.get(route) ?? tree.getFolded(route);
|
|
754
|
+
if (!node || node.kind !== 'namespace' || node.generated) return null;
|
|
755
|
+
/** @type {any[]} */
|
|
756
|
+
const sections = [];
|
|
757
|
+
/** @type {Record<string, string>} */
|
|
758
|
+
const sourceTitles = {};
|
|
759
|
+
/** @param {TreeNode} parent */
|
|
760
|
+
const walk = async parent => {
|
|
761
|
+
for (const slot of parent.slots) {
|
|
762
|
+
for (const childRoute of slot.children) {
|
|
763
|
+
const child = tree.get(childRoute);
|
|
764
|
+
if (!child || child.parent !== parent.route) continue;
|
|
765
|
+
if (child.kind === 'namespace') {
|
|
766
|
+
await walk(child);
|
|
767
|
+
} else if (child.kind === 'generic' && child.ref?.topicFile) {
|
|
768
|
+
const lowered = await lowerTopic(catalog, guideEntry(child), lang);
|
|
769
|
+
sections.push(...lowered.doc.sections);
|
|
770
|
+
for (const [key, title] of Object.entries(lowered.sourceTitles)) {
|
|
771
|
+
sourceTitles[key] ??= title;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
await walk(node);
|
|
778
|
+
if (sections.length === 0) return null;
|
|
779
|
+
return /** @type {any} */ ({
|
|
780
|
+
id: node.route,
|
|
781
|
+
doc: {sections},
|
|
782
|
+
sourceTitles,
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
|
|
739
786
|
/**
|
|
740
787
|
* Each reference block in one integration's docs that cannot include what it
|
|
741
788
|
* names (spec:AST-047 FR9): a target that names no doc, a field its schema
|
|
@@ -53,7 +53,7 @@ describe('reads that share a catalog', () => {
|
|
|
53
53
|
'never let one read change another',
|
|
54
54
|
async () => {
|
|
55
55
|
const catalog = await loadDocsCatalog();
|
|
56
|
-
const tokens = catalog.resolve('
|
|
56
|
+
const tokens = catalog.resolve('color');
|
|
57
57
|
const first = detailView(await compileTopic(catalog, tokens));
|
|
58
58
|
for (const section of first.sections) {
|
|
59
59
|
section.title = 'EDITED';
|
|
@@ -16,7 +16,7 @@ const SLOW = 30_000;
|
|
|
16
16
|
|
|
17
17
|
describe('docs.detail.section leaf', () => {
|
|
18
18
|
it('resolves a named section (case-insensitive) into a docs.detail.section envelope', async () => {
|
|
19
|
-
const res = await section('tokens', 'spacing');
|
|
19
|
+
const res = await section('tokens/tokens-spacing', 'spacing');
|
|
20
20
|
expect(res.type).toBe('docs.detail.section');
|
|
21
21
|
expect(res.data.title.toLowerCase()).toContain('spacing');
|
|
22
22
|
}, SLOW);
|
|
@@ -24,7 +24,7 @@ describe('docs.detail.section leaf', () => {
|
|
|
24
24
|
it('throws ERR_UNKNOWN_SECTION for an unknown section', async () => {
|
|
25
25
|
let err;
|
|
26
26
|
try {
|
|
27
|
-
await section('tokens', 'zzzznope');
|
|
27
|
+
await section('tokens/tokens-spacing', 'zzzznope');
|
|
28
28
|
} catch (e) {
|
|
29
29
|
err = e;
|
|
30
30
|
}
|
|
@@ -44,10 +44,10 @@ describe('docs.detail.section leaf', () => {
|
|
|
44
44
|
}, SLOW);
|
|
45
45
|
|
|
46
46
|
it('does not return the first section for an empty section name', async () => {
|
|
47
|
-
await expect(section('tokens', '')).rejects.toMatchObject({
|
|
47
|
+
await expect(section('tokens/tokens-spacing', '')).rejects.toMatchObject({
|
|
48
48
|
code: 'ERR_UNKNOWN_SECTION',
|
|
49
49
|
});
|
|
50
|
-
await expect(section('tokens', ' ')).rejects.toMatchObject({
|
|
50
|
+
await expect(section('tokens/tokens-spacing', ' ')).rejects.toMatchObject({
|
|
51
51
|
code: 'ERR_UNKNOWN_SECTION',
|
|
52
52
|
});
|
|
53
53
|
}, SLOW);
|
|
@@ -114,26 +114,37 @@ describe('reference doc overlays (#2182)', () => {
|
|
|
114
114
|
|
|
115
115
|
describe('the reported defect: docs tokens --dense (#2182)', () => {
|
|
116
116
|
it('does not print the colour table under the Spacing heading', async () => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
117
|
+
// The spacing table lives in its own guide; the spacing topic shows it
|
|
118
|
+
// through a token reference to the tokens namespace. Both, read dense.
|
|
119
|
+
for (const topic of ['tokens/tokens-spacing', 'spacing']) {
|
|
120
|
+
const result = await docs(topic, null, {dense: true});
|
|
121
|
+
const spacing = result.data.sections.find(s =>
|
|
122
|
+
JSON.stringify(s).includes('--spacing-'),
|
|
123
|
+
);
|
|
124
|
+
expect(spacing, `${topic} --dense should show the spacing table`).toBeTruthy();
|
|
125
|
+
const text = JSON.stringify(spacing);
|
|
126
|
+
expect(
|
|
127
|
+
text.includes('--color-'),
|
|
128
|
+
`The "${spacing.title}" section of \`docs ${topic} --dense\` contains ` +
|
|
129
|
+
`colour tokens. An agent reading this learns that spacing tokens are ` +
|
|
130
|
+
`named --color-*.`,
|
|
131
|
+
).toBe(false);
|
|
132
|
+
}
|
|
129
133
|
});
|
|
130
134
|
|
|
131
135
|
it('keeps every base section reachable, even without an overlay entry', async () => {
|
|
132
|
-
// The tokens
|
|
133
|
-
// still render (in English), not vanish or
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
136
|
+
// The tokens overlays compress 5 of 15 category tables. Read through the
|
|
137
|
+
// namespace, the other 10 must still render (in English), not vanish or
|
|
138
|
+
// absorb a neighbour's title.
|
|
139
|
+
const full = await docs('tokens', null, {depth: 'all', detail: 'full'});
|
|
140
|
+
const dense = await docs('tokens', null, {depth: 'all', detail: 'full', dense: true});
|
|
141
|
+
const titles = read =>
|
|
142
|
+
read.data.slots.flatMap(slot =>
|
|
143
|
+
slot.children.flatMap(child => (child.sections ?? []).map(s => s.title)),
|
|
144
|
+
);
|
|
145
|
+
expect(titles(dense).length).toBe(titles(full).length);
|
|
146
|
+
expect(titles(dense)).toContain('Color');
|
|
147
|
+
expect(titles(dense)).toContain('Font Size Tokens');
|
|
137
148
|
});
|
|
138
149
|
|
|
139
150
|
it('does not lose a section from docs theme --dense', async () => {
|
package/api/docs/docs.doc.mjs
CHANGED
|
@@ -168,7 +168,7 @@ export const doc = {
|
|
|
168
168
|
label: 'A whole guide from the docs tree',
|
|
169
169
|
code: "await docs('cli/integrations/quick-start');",
|
|
170
170
|
},
|
|
171
|
-
{label: 'One section by key', code: "await docs('
|
|
171
|
+
{label: 'One section by key', code: "await docs('spacing', 'scale');"},
|
|
172
172
|
],
|
|
173
173
|
command: 'docs',
|
|
174
174
|
related: ['search', 'component', 'hook', 'template'],
|
package/api/docs/docs.test.mjs
CHANGED
|
@@ -53,7 +53,7 @@ describe('docs() dispatcher routing', () => {
|
|
|
53
53
|
|
|
54
54
|
it('reads a shortened section by its old key, which its title still derives', async () => {
|
|
55
55
|
const r = await docs(
|
|
56
|
-
'styling',
|
|
56
|
+
'styling/tokens-and-setup',
|
|
57
57
|
'stylex-build-setup-required-for-swizzled-components',
|
|
58
58
|
);
|
|
59
59
|
expect(r.type).toBe('docs.detail.section');
|
|
@@ -92,7 +92,7 @@ describe('docs() dispatcher routing', () => {
|
|
|
92
92
|
|
|
93
93
|
it("lists the docs tree's namespaces in meta, so every data entry reads as a topic", async () => {
|
|
94
94
|
const res = await docs();
|
|
95
|
-
expect(res.meta.namespaces.map(entry => entry.topic)).toEqual(['cli', 'layout', 'unorganized']);
|
|
95
|
+
expect(res.meta.namespaces.map(entry => entry.topic)).toEqual(['cli', 'internationalization', 'layout', 'migration', 'styling', 'styling-libraries', 'tokens', 'typography', 'unorganized']);
|
|
96
96
|
for (const entry of res.data) {
|
|
97
97
|
expect((await docs(entry.topic)).type).toBe('docs.detail');
|
|
98
98
|
}
|
|
@@ -247,7 +247,7 @@ describe('integration docs in the docs tree', () => {
|
|
|
247
247
|
scaffold({
|
|
248
248
|
...kit(),
|
|
249
249
|
'unorganized.doc.mjs': {...NAMESPACE, name: 'unorganized', title: 'Mine', summary: 'Mine.'},
|
|
250
|
-
'
|
|
250
|
+
'use-a-theme.doc.mjs': {...NAMESPACE, name: 'use-a-theme', title: 'Acme use-a-theme', summary: 'Acme use-a-theme.'},
|
|
251
251
|
'cli.doc.mjs': flat('cli'),
|
|
252
252
|
});
|
|
253
253
|
const listed = await docs(undefined, undefined, {cwd: tmpDir});
|
|
@@ -257,24 +257,24 @@ describe('integration docs in the docs tree', () => {
|
|
|
257
257
|
expect.objectContaining({topic: 'unorganized', package: '@astryxdesign/cli'}),
|
|
258
258
|
]),
|
|
259
259
|
);
|
|
260
|
-
expect(listed.meta.namespaces.filter(n => ['
|
|
260
|
+
expect(listed.meta.namespaces.filter(n => ['use-a-theme', 'unorganized'].includes(n.topic) && n.package === '@acme/kit')).toEqual([]);
|
|
261
261
|
expect(listed.data.map(entry => entry.topic)).not.toContain('cli');
|
|
262
262
|
// Each name opens the CLI's doc, and a CLI topic keeps its home.
|
|
263
263
|
expect((await docs('cli', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'cli', package: '@astryxdesign/cli'});
|
|
264
264
|
expect((await docs('unorganized', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'unorganized', package: '@astryxdesign/cli'});
|
|
265
|
-
const tokens = await docs('
|
|
265
|
+
const tokens = await docs('use-a-theme', undefined, {cwd: tmpDir});
|
|
266
266
|
expect(tokens.type).toBe('docs.detail');
|
|
267
267
|
expect(tokens.data.links.up).toBe('astryx docs unorganized');
|
|
268
268
|
// The project doctor and the package doctor both name the claims.
|
|
269
269
|
const check = await checkDocsTree({docsCatalog: await loadDocsCatalog(tmpDir)});
|
|
270
270
|
expect(check.status).toBe('warn');
|
|
271
271
|
expect(check.message).toContain('takes the route "unorganized", which the CLI\'s own docs keep');
|
|
272
|
-
expect(check.message).toContain('takes the route "
|
|
272
|
+
expect(check.message).toContain('takes the route "use-a-theme"');
|
|
273
273
|
expect(check.message).toContain('both have the route "cli"');
|
|
274
274
|
const result = await integrationDocConflicts('@acme/kit', {cwd: tmpDir});
|
|
275
275
|
const graph = result.data.issues.filter(issue => issue.code === 'invalid_doc_graph').map(issue => issue.message).join('\n');
|
|
276
276
|
expect(graph).toContain('takes the route "unorganized"');
|
|
277
|
-
expect(graph).toContain('takes the route "
|
|
277
|
+
expect(graph).toContain('takes the route "use-a-theme"');
|
|
278
278
|
expect(graph).toContain('route "cli"');
|
|
279
279
|
}, SLOW);
|
|
280
280
|
|
|
@@ -298,8 +298,8 @@ describe('integration docs in the docs tree', () => {
|
|
|
298
298
|
`export const docs = ${JSON.stringify(flat('Unorganized'), null, 2)};\n`,
|
|
299
299
|
);
|
|
300
300
|
fs.writeFileSync(
|
|
301
|
-
path.join(nested, 'caps-
|
|
302
|
-
`export const docs = ${JSON.stringify(flat('
|
|
301
|
+
path.join(nested, 'caps-use-a-theme.doc.mjs'),
|
|
302
|
+
`export const docs = ${JSON.stringify(flat('USE-A-THEME'), null, 2)};\n`,
|
|
303
303
|
);
|
|
304
304
|
expect((await docs('cli', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'cli', package: '@astryxdesign/cli'});
|
|
305
305
|
expect((await docs('unorganized', undefined, {cwd: tmpDir})).data).toMatchObject({route: 'unorganized', package: '@astryxdesign/cli'});
|
|
@@ -315,10 +315,10 @@ describe('integration docs in the docs tree', () => {
|
|
|
315
315
|
expect(check.status).toBe('warn');
|
|
316
316
|
expect(check.message).toContain('route "CLI"');
|
|
317
317
|
expect(check.message).toContain('takes the route "Unorganized"');
|
|
318
|
-
// `
|
|
319
|
-
const tokens = await docs('
|
|
320
|
-
expect(tokens.data).toMatchObject({name: '
|
|
321
|
-
expect(tokens.data.title).not.toBe('Acme
|
|
318
|
+
// `USE-A-THEME` is the CLI's topic `use-a-theme` in another spelling: the CLI's wins.
|
|
319
|
+
const tokens = await docs('USE-A-THEME', undefined, {cwd: tmpDir, index: true});
|
|
320
|
+
expect(tokens.data).toMatchObject({name: 'use-a-theme', links: {up: 'astryx docs unorganized'}});
|
|
321
|
+
expect(tokens.data.title).not.toBe('Acme USE-A-THEME');
|
|
322
322
|
const result = await integrationDocConflicts('@acme/kit', {cwd: tmpDir});
|
|
323
323
|
const graph = result.data.issues
|
|
324
324
|
.filter(issue => issue.code === 'invalid_doc_graph')
|
|
@@ -329,7 +329,7 @@ describe('integration docs in the docs tree', () => {
|
|
|
329
329
|
}, SLOW);
|
|
330
330
|
|
|
331
331
|
it("keeps a replaced name for the topic that replaces it, over another integration's namespace", async () => {
|
|
332
|
-
scaffold({...kit(), '
|
|
332
|
+
scaffold({...kit(), 'use-a-theme-ns.doc.mjs': {...NAMESPACE, name: 'use-a-theme', title: 'Kit use-a-theme', summary: 'Kit use-a-theme.'}});
|
|
333
333
|
const two = path.join(tmpDir, 'node_modules', '@acme', 'two');
|
|
334
334
|
fs.mkdirSync(path.join(two, 'docs'), {recursive: true});
|
|
335
335
|
fs.writeFileSync(path.join(two, 'package.json'), JSON.stringify({name: '@acme/two', version: '1.0.0'}));
|
|
@@ -341,7 +341,7 @@ describe('integration docs in the docs tree', () => {
|
|
|
341
341
|
name: 'acme-tokens',
|
|
342
342
|
title: 'Acme tokens',
|
|
343
343
|
description: 'Acme tokens.',
|
|
344
|
-
replaces: '
|
|
344
|
+
replaces: 'use-a-theme',
|
|
345
345
|
sections: [{title: 'One', content: [{type: 'prose', text: 'One.'}]}],
|
|
346
346
|
}, null, 2)};\n`,
|
|
347
347
|
);
|
|
@@ -350,8 +350,8 @@ describe('integration docs in the docs tree', () => {
|
|
|
350
350
|
"export default {integrations: ['@acme/kit', '@acme/two']};\n",
|
|
351
351
|
);
|
|
352
352
|
const listed = await docs(undefined, undefined, {cwd: tmpDir});
|
|
353
|
-
expect(listed.meta.namespaces.map(entry => entry.topic)).not.toContain('
|
|
354
|
-
const read = await docs('
|
|
353
|
+
expect(listed.meta.namespaces.map(entry => entry.topic)).not.toContain('use-a-theme');
|
|
354
|
+
const read = await docs('use-a-theme', undefined, {cwd: tmpDir, index: true});
|
|
355
355
|
expect(read.data.name).toBe('acme-tokens');
|
|
356
356
|
const check = await checkDocsTree({docsCatalog: await loadDocsCatalog(tmpDir)});
|
|
357
357
|
expect(check.status).toBe('warn');
|
|
@@ -359,7 +359,7 @@ describe('integration docs in the docs tree', () => {
|
|
|
359
359
|
}, SLOW);
|
|
360
360
|
|
|
361
361
|
it('keeps every name a topic replaced twice answers to, and the CLI\'s links to it still open', async () => {
|
|
362
|
-
scaffold({...kit(), '
|
|
362
|
+
scaffold({...kit(), 'use-a-theme-ns.doc.mjs': {...NAMESPACE, name: 'use-a-theme', title: 'Kit use-a-theme', summary: 'Kit use-a-theme.'}});
|
|
363
363
|
/** @param {string} pkg @param {string} name @param {string} replaces */
|
|
364
364
|
const replacement = (pkg, name, replaces) => {
|
|
365
365
|
const dir = path.join(tmpDir, 'node_modules', '@acme', pkg);
|
|
@@ -378,30 +378,30 @@ describe('integration docs in the docs tree', () => {
|
|
|
378
378
|
}, null, 2)};\n`,
|
|
379
379
|
);
|
|
380
380
|
};
|
|
381
|
-
replacement('two', 'acme-tokens', '
|
|
382
|
-
replacement('three', 'b-tokens', '
|
|
381
|
+
replacement('two', 'acme-tokens', 'use-a-theme');
|
|
382
|
+
replacement('three', 'b-tokens', 'use-a-theme');
|
|
383
383
|
replacement('four', 'super-tokens', 'b-tokens');
|
|
384
384
|
fs.writeFileSync(
|
|
385
385
|
path.join(tmpDir, 'astryx.config.mjs'),
|
|
386
386
|
"export default {integrations: ['@acme/kit', '@acme/two', '@acme/three', '@acme/four']};\n",
|
|
387
387
|
);
|
|
388
388
|
const listed = await docs(undefined, undefined, {cwd: tmpDir});
|
|
389
|
-
expect(listed.meta.namespaces.map(entry => entry.topic)).not.toContain('
|
|
390
|
-
for (const name of ['
|
|
389
|
+
expect(listed.meta.namespaces.map(entry => entry.topic)).not.toContain('use-a-theme');
|
|
390
|
+
for (const name of ['use-a-theme', 'acme-tokens', 'b-tokens', 'super-tokens']) {
|
|
391
391
|
expect((await docs(name, undefined, {cwd: tmpDir, index: true})).data.name).toBe('super-tokens');
|
|
392
392
|
}
|
|
393
|
-
// A walk over every topic: the CLI's own links to `
|
|
393
|
+
// A walk over every topic: the CLI's own links to `use-a-theme` still open it.
|
|
394
394
|
/** @type {string[]} */
|
|
395
395
|
const raw = [];
|
|
396
396
|
for (const entry of listed.data) {
|
|
397
397
|
const read = await docs(entry.topic, undefined, {cwd: tmpDir});
|
|
398
|
-
if (/\{@link [^}]*
|
|
398
|
+
if (/\{@link [^}]*use-a-theme\}/.test(JSON.stringify(read.data))) raw.push(entry.topic);
|
|
399
399
|
}
|
|
400
400
|
expect(raw).toEqual([]);
|
|
401
|
-
const
|
|
402
|
-
expect(JSON.stringify(
|
|
401
|
+
const theme = await docs('theme', undefined, {cwd: tmpDir});
|
|
402
|
+
expect(JSON.stringify(theme.data)).toContain('astryx docs super-tokens');
|
|
403
403
|
const check = await checkDocsTree({docsCatalog: await loadDocsCatalog(tmpDir)});
|
|
404
|
-
expect(check.message).toContain('takes the route "
|
|
404
|
+
expect(check.message).toContain('takes the route "use-a-theme", which the topic "super-tokens" also answers to');
|
|
405
405
|
expect(check.message).not.toContain('names no doc');
|
|
406
406
|
}, SLOW);
|
|
407
407
|
|
|
@@ -510,7 +510,7 @@ describe('integration docs in the docs tree', () => {
|
|
|
510
510
|
content: [
|
|
511
511
|
{
|
|
512
512
|
type: 'prose',
|
|
513
|
-
text: 'See {@link generic:integrations}, and {@link @astryxdesign/cli:
|
|
513
|
+
text: 'See {@link generic:integrations}, and {@link @astryxdesign/cli:namespace:tokens} for the tokens.',
|
|
514
514
|
},
|
|
515
515
|
],
|
|
516
516
|
},
|
|
@@ -100,7 +100,7 @@ describe('integration-contributed topics', () => {
|
|
|
100
100
|
package: '@acme/widgets',
|
|
101
101
|
});
|
|
102
102
|
// The built-in topics keep their own owner.
|
|
103
|
-
expect(listed.data.find(t => t.topic === '
|
|
103
|
+
expect(listed.data.find(t => t.topic === 'color').package).toBe('@astryxdesign/cli');
|
|
104
104
|
|
|
105
105
|
const detail = await docs('deploying', undefined, {cwd: tmpDir, full: true});
|
|
106
106
|
expect(detail.type).toBe('docs.detail');
|
|
@@ -331,7 +331,7 @@ describe('integration-contributed topics', () => {
|
|
|
331
331
|
it("falls back to the CLI's own topics when the project config is unreadable", async () => {
|
|
332
332
|
scaffold({'deploying.doc.mjs': topic()}, {config: 'export default {integrations: 42};\n'});
|
|
333
333
|
const catalog = await loadDocsCatalog(tmpDir);
|
|
334
|
-
expect(catalog.resolve('
|
|
334
|
+
expect(catalog.resolve('color')).toBeTruthy();
|
|
335
335
|
expect(catalog.resolve('deploying')).toBeUndefined();
|
|
336
336
|
}, SLOW);
|
|
337
337
|
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The design tokens are written once. Each category's table lives in its
|
|
5
|
+
* guide under the tokens namespace; a token reference to `tokens` reads that
|
|
6
|
+
* guide, so no flat copy of the tables is listed, searched, or compiled.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import fs from 'node:fs';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
import {fileURLToPath} from 'node:url';
|
|
12
|
+
import {describe, expect, it} from 'vitest';
|
|
13
|
+
import {docs} from './docs.mjs';
|
|
14
|
+
import {search} from '../search/search.mjs';
|
|
15
|
+
|
|
16
|
+
const SLOW = 60_000;
|
|
17
|
+
const DOCS_DIR = path.resolve(
|
|
18
|
+
path.dirname(fileURLToPath(import.meta.url)),
|
|
19
|
+
'../../assets/docs',
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
/** Every authored CLI doc file, flat and placed (translation overlays aside). */
|
|
23
|
+
function authoredDocFiles() {
|
|
24
|
+
return [DOCS_DIR, path.join(DOCS_DIR, 'tree')].flatMap(dir =>
|
|
25
|
+
fs
|
|
26
|
+
.readdirSync(dir)
|
|
27
|
+
.filter(file => /^[\w-]+\.doc\.mjs$/.test(file))
|
|
28
|
+
.map(file => path.join(dir, file)),
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
describe('the design tokens', () => {
|
|
33
|
+
it('are each written in exactly one doc table', async () => {
|
|
34
|
+
/** @type {Map<string, string[]>} */
|
|
35
|
+
const owners = new Map();
|
|
36
|
+
for (const file of authoredDocFiles()) {
|
|
37
|
+
const {docs: doc} = await import(file);
|
|
38
|
+
for (const section of doc.sections ?? []) {
|
|
39
|
+
for (const block of section.content ?? []) {
|
|
40
|
+
if (block?.type !== 'table') continue;
|
|
41
|
+
for (const row of block.rows) {
|
|
42
|
+
if (!/^--[a-z]/.test(row[0])) continue;
|
|
43
|
+
owners.set(row[0], [
|
|
44
|
+
...(owners.get(row[0]) ?? []),
|
|
45
|
+
path.relative(DOCS_DIR, file),
|
|
46
|
+
]);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
expect(owners.size).toBeGreaterThan(200);
|
|
52
|
+
expect([...owners].filter(([, files]) => files.length > 1)).toEqual([]);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it(
|
|
56
|
+
'are not listed or searched twice',
|
|
57
|
+
async () => {
|
|
58
|
+
const listed = await docs();
|
|
59
|
+
const names = listed.data.map(entry => entry.topic);
|
|
60
|
+
expect(names).not.toContain('token-tables');
|
|
61
|
+
expect(listed.meta.namespaces.map(entry => entry.topic)).toContain(
|
|
62
|
+
'tokens',
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const found = (await search('spacing tokens', {type: 'doc', limit: 50}))
|
|
66
|
+
.data.results;
|
|
67
|
+
const holders = found
|
|
68
|
+
.filter(
|
|
69
|
+
hit =>
|
|
70
|
+
hit.section === 'spacing-tokens' ||
|
|
71
|
+
hit.name === 'tokens/tokens-spacing',
|
|
72
|
+
)
|
|
73
|
+
.map(hit => hit.name);
|
|
74
|
+
expect(new Set(holders)).toEqual(new Set(['tokens/tokens-spacing']));
|
|
75
|
+
},
|
|
76
|
+
SLOW,
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
it(
|
|
80
|
+
'still answer a token reference to `tokens`, in every language',
|
|
81
|
+
async () => {
|
|
82
|
+
for (const options of [{}, {dense: true}, {zh: true}]) {
|
|
83
|
+
const read = await docs('color', null, options);
|
|
84
|
+
const text = JSON.stringify(read.data.sections);
|
|
85
|
+
expect(text).not.toContain('[token-ref');
|
|
86
|
+
expect(text).toContain('--color-accent');
|
|
87
|
+
}
|
|
88
|
+
const section = await docs('spacing', 'scale');
|
|
89
|
+
expect(JSON.stringify(section.data)).toContain('--spacing-4');
|
|
90
|
+
},
|
|
91
|
+
SLOW,
|
|
92
|
+
);
|
|
93
|
+
});
|
|
@@ -67,7 +67,7 @@ export const docs = {
|
|
|
67
67
|
{
|
|
68
68
|
title: 'Component Style Overrides',
|
|
69
69
|
content: [
|
|
70
|
-
{type: 'prose', text: 'The `components` field in defineTheme uses semantic component keys and style keys, not raw CSS selectors. Use `base` for all instances, `variant:value` or `stateName` for specific props/states, and let the theme pipeline choose the underlying selector. For raw external CSS escape hatches, prefer the data-attribute selector surface documented in {@link generic:styling}.'},
|
|
70
|
+
{type: 'prose', text: 'The `components` field in defineTheme uses semantic component keys and style keys, not raw CSS selectors. Use `base` for all instances, `variant:value` or `stateName` for specific props/states, and let the theme pipeline choose the underlying selector. For raw external CSS escape hatches, prefer the data-attribute selector surface documented in {@link generic:styling-advanced}.'},
|
|
71
71
|
{type: 'code', lang: 'tsx', label: 'Component overrides with standard CSS', code: "components: {\n card: {\n base: { borderRadius: '20px', padding: '24px' },\n },\n button: {\n base: {\n borderRadius: '9999px',\n textTransform: 'uppercase',\n '--button-focus-offset': '3px',\n },\n 'variant:ghost': { borderWidth: '2px', borderStyle: 'solid' },\n },\n}"},
|
|
72
72
|
{type: 'prose', text: "Run `astryx theme targets` for every themeable key in the system (`astryx theme targets <Name>` to scope it, `--json` to lint a theme against it), and `astryx component <Name>` for one component's theming targets, public CSS variables, and which standard CSS properties are supported."},
|
|
73
73
|
{type: 'list', style: 'do', items: ['Write standard CSS properties (borderRadius, padding); the pipeline expands them into internal vars.', 'Set public CSS vars directly when no standard property equivalent exists.']},
|
|
@@ -121,7 +121,7 @@ export const docs = {
|
|
|
121
121
|
]},
|
|
122
122
|
{type: 'prose', text: 'The `__built: true` flag tells Theme to skip runtime `<style>` injection; the CSS file handles it. Load the generated CSS wherever you load the module.'},
|
|
123
123
|
{type: 'code', lang: 'tsx', label: 'Using a custom built theme', code: "import {Theme} from '@astryxdesign/core';\nimport {oceanTheme} from './themes/ocean';\nimport './themes/ocean.css';\n\n<Theme theme={oceanTheme}>\n <App />\n</Theme>"},
|
|
124
|
-
{type: 'prose', text: "After upgrading Astryx, rerun `astryx theme build` for every custom prebuilt theme. Deploy the regenerated files together. The runtime intentionally trusts `__built: true` and will not repair stale CSS from an older build. The build also warns when the theme names font families it does not load. See {@link generic:
|
|
124
|
+
{type: 'prose', text: "After upgrading Astryx, rerun `astryx theme build` for every custom prebuilt theme. Deploy the regenerated files together. The runtime intentionally trusts `__built: true` and will not repair stale CSS from an older build. The build also warns when the theme names font families it does not load. See {@link generic:font-setup} for the full recipe."},
|
|
125
125
|
{type: 'prose', text: 'For the runtime vs built tradeoff, see the Runtime vs Built section of {@link generic:use-a-theme}.'},
|
|
126
126
|
],
|
|
127
127
|
},
|
|
@@ -151,7 +151,7 @@ export const docs = {
|
|
|
151
151
|
{type: 'code', lang: 'ts', label: 'CSS var references for styling-library configs', code: "import {tokenVar, tokenVars} from '@astryxdesign/core/theme/tokens';\n\nconst pandaOrEmotionTheme = {\n colors: {\n text: tokenVar('--color-text-primary'),\n surface: tokenVars['--color-background-surface'],\n },\n};"},
|
|
152
152
|
{type: 'code', lang: 'ts', label: 'Resolve token values without a hook', code: "import {resolveThemeTokens} from '@astryxdesign/core/theme/tokens';\nimport {neutralTheme} from '@astryxdesign/theme-neutral';\n\nconst lightTokens = resolveThemeTokens(neutralTheme, {mode: 'light'});\nconst chartTheme = {\n textColor: lightTokens['--color-text-primary'],\n seriesColor: lightTokens['--color-data-categorical-blue'],\n};"},
|
|
153
153
|
{type: 'prose', text: 'The `@astryxdesign/core/theme/tokens` subpath is server-safe and does not require React. The main `@astryxdesign/core/theme` barrel also re-exports these helpers for client code that already imports theme APIs.'},
|
|
154
|
-
{type: 'prose', text: 'For styling library interop patterns, see {@link
|
|
154
|
+
{type: 'prose', text: 'For styling library interop patterns, see {@link namespace:styling-libraries}.'},
|
|
155
155
|
],
|
|
156
156
|
},
|
|
157
157
|
{
|
|
@@ -159,7 +159,7 @@ export const docs = {
|
|
|
159
159
|
content: [
|
|
160
160
|
{type: 'prose', text: '`useTheme()` reads the nearest Theme and effective color mode from React context. Use it inside client components for SVG, canvas, charts, maps, and third-party configuration objects that need token values in JavaScript.'},
|
|
161
161
|
{type: 'code', lang: 'tsx', label: 'Access resolved token values in React', code: "import {useMemo} from 'react';\nimport {useTheme} from '@astryxdesign/core/theme';\n\nfunction ChartConfig() {\n const {mode, tokens} = useTheme();\n const options = useMemo(() => ({\n mode,\n textColor: tokens['--color-text-primary'],\n gridColor: tokens['--color-border'],\n seriesColor: tokens['--color-data-categorical-blue'],\n }), [mode, tokens]);\n return <Chart options={options} />;\n}"},
|
|
162
|
-
{type: 'prose', text: 'Prefer CSS variables for ordinary styling. See {@link generic:use-a-theme} for the provider setup, and {@link
|
|
162
|
+
{type: 'prose', text: 'Prefer CSS variables for ordinary styling. See {@link generic:use-a-theme} for the provider setup, and {@link namespace:tokens} for the full token reference.'},
|
|
163
163
|
],
|
|
164
164
|
},
|
|
165
165
|
],
|
|
@@ -106,7 +106,7 @@ import {themes, defaultThemeSlug} from './astryx-themes';
|
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
type: 'prose',
|
|
109
|
-
text: 'These stylesheets are cascade-layered: the reset loads in @layer reset and component styles in @layer astryx-base. If your project has existing global CSS, a legacy reset, or Tailwind, declare the layer order explicitly and assign every stylesheet to a layer deliberately: unlayered styles and later layers both override astryx-base regardless of specificity. Before building screens, read the two cascade layer sections of {@link generic:migration}.',
|
|
109
|
+
text: 'These stylesheets are cascade-layered: the reset loads in @layer reset and component styles in @layer astryx-base. If your project has existing global CSS, a legacy reset, or Tailwind, declare the layer order explicitly and assign every stylesheet to a layer deliberately: unlayered styles and later layers both override astryx-base regardless of specificity. Before building screens, read the two cascade layer sections of {@link generic:migration-setup}.',
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
112
|
type: 'prose',
|
|
@@ -143,7 +143,7 @@ export default function Page() {
|
|
|
143
143
|
content: [
|
|
144
144
|
{
|
|
145
145
|
type: 'prose',
|
|
146
|
-
text: 'Astryx components support various styling solutions, from plain CSS and `className` to Tailwind and CSS-in-JS. See {@link
|
|
146
|
+
text: 'Astryx components support various styling solutions, from plain CSS and `className` to Tailwind and CSS-in-JS. See {@link namespace:styling} for the full guide. Astryx also has a deep integration with [StyleX](https://stylexjs.com/), an atomic CSS-in-JS library: create styles with `stylex.create()` and pass them to components with the `xstyle` prop.',
|
|
147
147
|
},
|
|
148
148
|
{
|
|
149
149
|
type: 'code',
|
|
@@ -6,9 +6,9 @@ export const docsDense = {
|
|
|
6
6
|
description: 'core design principles + rules for the design system',
|
|
7
7
|
sections: [
|
|
8
8
|
{ section: 'Design Philosophy', title: 'Philosophy', content: [{ type: 'prose', text: 'consistency, adaptability, DX. core ideas:' }, { type: 'list', items: ['components over primitives', 'semantic tokens over hardcoded values', 'theme-agnostic code', 'open internals'] }] },
|
|
9
|
-
{ section: 'Rules', title: 'Rules', content: [{ type: 'prose', text: '8 rules for on-system app code.' }, { type: 'list', items: ['use components', 'frame-first layout: shell + region budgets before content ({@link namespace:layout})', 'dense data = rows (Table, List/Item) not Cards; Card = widgets/galleries/settings groups', 'StyleX or Tailwind for styling ({@link
|
|
10
|
-
{ section: 'Styling Approach', title: 'Styling', content: [{ type: 'prose', text: 'xstyle prop for component overrides. StyleX or Tailwind for layout.' }, { type: 'prose', text: 'full guide: {@link
|
|
9
|
+
{ section: 'Rules', title: 'Rules', content: [{ type: 'prose', text: '8 rules for on-system app code.' }, { type: 'list', items: ['use components', 'frame-first layout: shell + region budgets before content ({@link namespace:layout})', 'dense data = rows (Table, List/Item) not Cards; Card = widgets/galleries/settings groups', 'StyleX or Tailwind for styling ({@link namespace:styling})', 'semantic tokens only ({@link namespace:tokens})', 'CSS vars for colors', 'controlled form inputs', 'useLinkComponent() for navigation'] }] },
|
|
10
|
+
{ section: 'Styling Approach', title: 'Styling', content: [{ type: 'prose', text: 'xstyle prop for component overrides. StyleX or Tailwind for layout.' }, { type: 'prose', text: 'full guide: {@link namespace:styling}' }] },
|
|
11
11
|
{ section: 'Anti-Patterns', title: 'Anti-Patterns', content: [{ type: 'prose', text: 'what breaks theming, routing, or layout, and the fix.' }, { type: 'list', items: ['no inline styles on raw elements', 'no hardcoded colors — use tokens or Tailwind semantic classes', 'no hardcoded spacing', 'no hardcoded <a> — use useLinkComponent()', 'no Card-wrapped list items — frame first, rows for dense data ({@link namespace:layout})', 'no decorative Badge — StatusDot/Token for status', 'read docs before inventing props'] }] },
|
|
12
|
-
{ section: 'Design Tokens', title: 'Tokens', content: [{ type: 'prose', text: 'full token reference: {@link
|
|
12
|
+
{ section: 'Design Tokens', title: 'Tokens', content: [{ type: 'prose', text: 'full token reference: {@link namespace:tokens}' }] },
|
|
13
13
|
],
|
|
14
14
|
};
|
|
@@ -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
|
|
49
|
-
'Semantic tokens, not hardcoded values (see {@link
|
|
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
|
|
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
|
|
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
|
|
10
|
-
{ section: 'Styling Approach', title: '样式方法', content: [{ type: 'prose', text: '组件覆盖使用 xstyle 属性。布局使用 StyleX 或 Tailwind。' }, { type: 'prose', text: '完整指南见 {@link
|
|
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
|
|
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
|
},
|
|
@@ -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:
|
|
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
|
|
203
|
-
'{@link
|
|
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
|
|
205
|
+
'{@link namespace:migration} \u2014 cascade layer audit, Tailwind v3 coexistence, and foundation smoke test.',
|
|
206
206
|
],
|
|
207
207
|
},
|
|
208
208
|
],
|