@astryxdesign/cli 0.7.5-canary.04434e7 → 0.7.5-canary.06ff669
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/CHANGELOG.md +3 -3
- package/README.md +1 -1
- package/api/hook/detail/detail.test.mjs +11 -0
- package/api/swizzle/copy/copy.mjs +1 -1
- package/api/template/tokenizer-showcase.test.mjs +47 -0
- package/api/theme/build/build.adaptation-enrollment.test.mjs +4 -0
- package/api/theme/build/build.icon-entry-variants.test.mjs +134 -0
- package/api/theme/build/build.icon-function-entries.test.mjs +499 -0
- package/api/theme/build/build.icon-variants.test.mjs +105 -0
- package/api/theme/build/build.mjs +371 -113
- package/api/theme/build/build.project-core.test.mjs +63 -8
- package/api/theme/build/build.test.mjs +77 -0
- package/api/theme/build/icon-imports.d.mts +12 -2
- package/api/theme/build/icon-imports.mjs +36 -11
- package/api/upgrade/_adapter.d.mts +47 -2
- package/api/upgrade/_adapter.mjs +58 -2
- package/api/upgrade/run/failure-receipt.test.mjs +57 -0
- package/api/upgrade/run/outcomes.test.mjs +646 -0
- package/api/upgrade/run/run.d.mts +36 -0
- package/api/upgrade/run/run.mjs +509 -45
- package/api/upgrade/upgrade.doc.mjs +2 -2
- package/api/upgrade/upgrade.type.d.mts +24 -0
- package/api/upgrade/upgrade.type.mjs +15 -3
- package/assets/codemods/__tests__/runner.unparseable.test.mjs +457 -0
- package/assets/codemods/integration-runner.mjs +7 -1
- package/assets/codemods/integration-runner.protection.test.mjs +53 -0
- package/assets/codemods/outcome.mjs +79 -0
- package/assets/codemods/outcome.test.mjs +40 -0
- package/assets/codemods/parse.mjs +94 -0
- package/assets/codemods/run-codemod.mjs +92 -2
- package/assets/codemods/runner.mjs +38 -5
- package/assets/codemods/transforms/next/__tests__/migrate-codeblock-tokenizer-to-language.test.mjs +130 -0
- package/assets/codemods/transforms/next/index.mjs +11 -1
- package/assets/codemods/transforms/next/migrate-codeblock-tokenizer-to-language.mjs +315 -0
- package/assets/codemods/transforms/v0.1.2/rename-text-color-active-to-accent.mjs +1 -1
- package/assets/codemods/transforms/v0.1.3/__tests__/migrate-layout-components-to-experimental.test.mjs +216 -2
- package/assets/codemods/transforms/v0.1.3/migrate-layout-components-to-experimental.mjs +88 -6
- package/assets/codemods/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +1 -1
- package/assets/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +1 -1
- package/assets/codemods/transforms/v0.1.8/rename-avatar-size-scale.mjs +1 -1
- package/assets/codemods/transforms/v0.2.0/remove-tablist-orientation.mjs +1 -1
- package/assets/codemods/transforms/v0.2.1/migrate-dialog-position-to-logical.mjs +1 -1
- package/assets/codemods/transforms/v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs +4 -3
- package/assets/codemods/transforms/v0.7.0/__tests__/validate-data-token-ownership.test.mjs +24 -4
- package/assets/codemods/transforms/v0.7.0/migrate-deprecated-theme-surface.mjs +44 -10
- package/assets/codemods/transforms/v0.7.0/validate-data-token-ownership.mjs +6 -3
- package/assets/docs/README.md +13 -13
- package/assets/docs/author-a-theme.doc.mjs +5 -1
- package/assets/docs/getting-started.doc.mjs +5 -5
- package/assets/docs/icons.doc.mjs +82 -1
- package/assets/docs/motion.doc.mjs +1 -1
- package/assets/docs/theme.doc.dense.mjs +8 -0
- package/assets/docs/theme.doc.mjs +16 -0
- package/assets/docs/theme.doc.zh.mjs +11 -0
- package/assets/docs/tree/i18n-library-integration.doc.mjs +1 -1
- package/assets/docs/tree/template-styles.doc.mjs +1 -1
- package/assets/docs/tree/tokens-color.doc.mjs +145 -1
- package/assets/docs/tree/tokens-ease.doc.mjs +4 -0
- package/assets/docs/tree/tokens.doc.mjs +1 -1
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.doc.mjs +6 -4
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherReviewFlow.tsx +61 -55
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.doc.mjs +6 -4
- package/assets/templates/blocks/components/BottomSheet/BottomSheetSwitcherShowcase.tsx +68 -37
- package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.doc.mjs +1 -1
- package/assets/templates/blocks/components/CodeBlock/CodeBlockBashCommand.tsx +10 -2
- package/assets/templates/blocks/components/Thumbnail/ThumbnailDisabled.doc.mjs +1 -1
- package/assets/templates/blocks/components/Tokenizer/TokenizerShowcase.tsx +13 -6
- package/assets/templates/pages/dashboard-alert-rail/page.tsx +3 -3
- package/assets/templates/pages/library/page.tsx +1 -2
- package/assets/templates/pages/table-comparison/page.tsx +12 -3
- package/assets/templates/themes/butter/butterPaletteRefs.generated.ts +3 -2
- package/assets/templates/themes/butter/butterTheme.ts +47 -44
- package/assets/templates/themes/chocolate/chocolateTheme.ts +15 -2
- package/assets/templates/themes/gothic/gothicTheme.ts +21 -16
- package/assets/templates/themes/matcha/matchaPaletteRefs.generated.ts +1 -1
- package/assets/templates/themes/matcha/matchaTheme.ts +15 -2
- package/assets/templates/themes/neutral/neutralPaletteRefs.generated.ts +4 -4
- package/assets/templates/themes/neutral/neutralTheme.ts +24 -119
- package/assets/templates/themes/stone/stoneTheme.ts +46 -21
- package/assets/templates/themes/y2k/y2kTheme.ts +20 -16
- package/assets/theme.template.ts +19 -6
- package/authoring/codemod/type.ts +10 -0
- package/authoring/config/config.doc.mjs +1 -1
- package/clients/cli/commands/build-theme.adaptations.test.mjs +110 -0
- package/clients/cli/commands/build-theme.outside-project.test.mjs +140 -0
- package/clients/cli/commands/swizzle.routing.test.mjs +1 -1
- package/clients/cli/commands/upgrade.doc.mjs +30 -2
- package/clients/cli/commands/upgrade.file-protection.test.mjs +146 -0
- package/clients/cli/commands/upgrade.outcomes.test.mjs +350 -0
- package/foundation/agent-docs/agent-docs.mjs +1 -0
- package/foundation/agent-docs/agent-docs.test.mjs +5 -0
- package/foundation/config/project.d.mts +1 -1
- package/foundation/config/project.mjs +1 -1
- package/foundation/debug/redact.test.mjs +1 -1
- package/foundation/doc-compiler/doc-loads.test.mjs +2 -6
- package/foundation/env/package-manager.test.mjs +14 -1
- package/foundation/response/response-types.doc.mjs +1 -1
- package/package.json +13 -12
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Codemod: Migrate Table tableProps to direct root props
|
|
5
|
-
* @see https://github.com/
|
|
5
|
+
* @see https://github.com/meta/astryx/issues/3679
|
|
6
6
|
*
|
|
7
7
|
* `tableProps` (typed HTMLAttributes<HTMLTableElement>, nesting HTML
|
|
8
8
|
* attributes one level deep) is deprecated. As of v0.1.7, <Table> honors
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Codemod: Rename Avatar named sizes to Icon's abbreviated scale
|
|
5
|
-
* @see https://github.com/
|
|
5
|
+
* @see https://github.com/meta/astryx/issues/2672
|
|
6
6
|
*
|
|
7
7
|
* This transform is deliberately limited to static literals written directly
|
|
8
8
|
* in the `size` prop of an imported Avatar or AvatarGroup JSX element. It does
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Codemod: Remove TabList orientation prop
|
|
5
|
-
* @see https://github.com/
|
|
5
|
+
* @see https://github.com/meta/astryx/issues/4231
|
|
6
6
|
*
|
|
7
7
|
* As of v0.2.0, TabList no longer accepts an `orientation` prop. The prop
|
|
8
8
|
* was misleading: it only drove the keyboard-hint badge, not a real vertical
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @file Codemod: Migrate Dialog position left/right -> start/end
|
|
5
|
-
* @see https://github.com/
|
|
5
|
+
* @see https://github.com/meta/astryx/pull/4568
|
|
6
6
|
*
|
|
7
7
|
* The Dialog `position` prop's physical `left`/`right` offsets are deprecated
|
|
8
8
|
* in favor of the logical `start`/`end` offsets. `start`/`end` map to
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
import path from 'node:path';
|
|
16
16
|
import postcss from 'postcss';
|
|
17
17
|
import selectorParser from 'postcss-selector-parser';
|
|
18
|
+
import {parseCss, processSelector} from '../../parse.mjs';
|
|
18
19
|
import {
|
|
19
20
|
V054_THEME_SELECTOR_DYNAMIC_AXES,
|
|
20
21
|
V054_THEME_SELECTOR_TARGETS,
|
|
@@ -555,7 +556,7 @@ function migrateSelectorTextWithContext(
|
|
|
555
556
|
) {
|
|
556
557
|
/** @type {TargetContext} */
|
|
557
558
|
let context = {guaranteed: [], possible: []};
|
|
558
|
-
const text =
|
|
559
|
+
const text = processSelector(selector, selectors => {
|
|
559
560
|
/** @type {TargetContext[]} */
|
|
560
561
|
const branchContexts = [];
|
|
561
562
|
selectors.each(selectorNode => {
|
|
@@ -593,7 +594,7 @@ function migrateSelectorTextWithContext(
|
|
|
593
594
|
});
|
|
594
595
|
});
|
|
595
596
|
context = combineSelectorListContexts(branchContexts);
|
|
596
|
-
})
|
|
597
|
+
});
|
|
597
598
|
return {text, context};
|
|
598
599
|
}
|
|
599
600
|
|
|
@@ -677,7 +678,7 @@ export function migrateAstryxThemeSelectors(source, from = 'styles.css', data) {
|
|
|
677
678
|
|
|
678
679
|
/** @param {string} source @param {string} from @returns {string} */
|
|
679
680
|
function migrateWithActiveTables(source, from) {
|
|
680
|
-
const root =
|
|
681
|
+
const root = parseCss(source, {from});
|
|
681
682
|
const existingComments = new Set();
|
|
682
683
|
root.walkComments(comment => {
|
|
683
684
|
existingComments.add(comment.text.trim());
|
|
@@ -5,6 +5,7 @@ import * as os from 'node:os';
|
|
|
5
5
|
import * as path from 'node:path';
|
|
6
6
|
import {afterAll, describe, expect, it} from 'vitest';
|
|
7
7
|
import transform, {meta} from '../validate-data-token-ownership.mjs';
|
|
8
|
+
import {codemodOutcome} from '../../../outcome.mjs';
|
|
8
9
|
import {upgrade} from '../../../../../api/upgrade/upgrade.mjs';
|
|
9
10
|
|
|
10
11
|
const SLOW = 30_000;
|
|
@@ -76,10 +77,20 @@ describe('validate-data-token-ownership', () => {
|
|
|
76
77
|
expect(meta.fileExtensions).toEqual(['.css']);
|
|
77
78
|
});
|
|
78
79
|
|
|
79
|
-
it('
|
|
80
|
+
it('reports stale generated theme CSS with root data defaults as a regeneration', () => {
|
|
80
81
|
expect(() => transform({source: STALE_THEME, path: 'theme.css'})).toThrow(
|
|
81
82
|
/Rebuild it with `astryx theme build`/,
|
|
82
83
|
);
|
|
84
|
+
let thrown;
|
|
85
|
+
try {
|
|
86
|
+
transform({source: STALE_THEME, path: 'theme.css'});
|
|
87
|
+
} catch (err) {
|
|
88
|
+
thrown = err;
|
|
89
|
+
}
|
|
90
|
+
expect(codemodOutcome(thrown)).toMatchObject({
|
|
91
|
+
kind: 'regenerate',
|
|
92
|
+
commands: ['astryx theme build'],
|
|
93
|
+
});
|
|
83
94
|
});
|
|
84
95
|
|
|
85
96
|
it('passes raw data-token uses with or without a fallback', () => {
|
|
@@ -136,11 +147,20 @@ describe('validate-data-token-ownership', () => {
|
|
|
136
147
|
);
|
|
137
148
|
|
|
138
149
|
it(
|
|
139
|
-
'
|
|
150
|
+
'leaves `astryx upgrade --apply` incomplete on stale generated theme CSS, naming the rebuild',
|
|
140
151
|
async () => {
|
|
141
152
|
const root = project({...PREBUILT, 'src/theme.css': STALE_THEME});
|
|
142
|
-
await
|
|
143
|
-
|
|
153
|
+
const res = await runUpgrade(root);
|
|
154
|
+
expect(res.data).toMatchObject({
|
|
155
|
+
complete: false,
|
|
156
|
+
errorCode: 'ERR_CODEMOD_PROTECTED',
|
|
157
|
+
errors: [],
|
|
158
|
+
regenerate: [
|
|
159
|
+
expect.objectContaining({
|
|
160
|
+
file: 'src/theme.css',
|
|
161
|
+
commands: ['astryx theme build'],
|
|
162
|
+
}),
|
|
163
|
+
],
|
|
144
164
|
});
|
|
145
165
|
},
|
|
146
166
|
SLOW,
|
|
@@ -27,6 +27,12 @@ import {
|
|
|
27
27
|
importedComponents,
|
|
28
28
|
resolveImportedComponent,
|
|
29
29
|
} from '../../transform-prop.mjs';
|
|
30
|
+
import {
|
|
31
|
+
isCodemodParseError,
|
|
32
|
+
markParseError,
|
|
33
|
+
parseCss,
|
|
34
|
+
processSelector,
|
|
35
|
+
} from '../../parse.mjs';
|
|
30
36
|
import {migrateAstryxThemeSelectors} from '../v0.6.0/migrate-astryx-theme-selectors-to-data-attrs.mjs';
|
|
31
37
|
import {
|
|
32
38
|
V06_THEME_SELECTOR_DYNAMIC_AXES,
|
|
@@ -204,7 +210,7 @@ function ownerScope(owner) {
|
|
|
204
210
|
function unclassifiedBareClasses(selectorText) {
|
|
205
211
|
/** @type {Set<string>} */
|
|
206
212
|
const found = new Set();
|
|
207
|
-
|
|
213
|
+
processSelector(selectorText, selectors => {
|
|
208
214
|
selectors.walk((/** @type {any} */ node) => {
|
|
209
215
|
if (node.type !== 'selector') return;
|
|
210
216
|
/** @type {any[][]} */
|
|
@@ -232,19 +238,23 @@ function unclassifiedBareClasses(selectorText) {
|
|
|
232
238
|
}
|
|
233
239
|
}
|
|
234
240
|
});
|
|
235
|
-
})
|
|
241
|
+
});
|
|
236
242
|
return [...found].sort();
|
|
237
243
|
}
|
|
238
244
|
|
|
239
|
-
/** @param {string} selector */
|
|
245
|
+
/** @param {string | import('postcss').Rule} selector selector text, or the rule that holds it */
|
|
240
246
|
function finishSelectorText(selector) {
|
|
241
|
-
return
|
|
247
|
+
return processSelector(selector, selectors => {
|
|
242
248
|
selectors.each(finishSelectorMigration);
|
|
243
|
-
})
|
|
249
|
+
});
|
|
244
250
|
}
|
|
245
251
|
|
|
246
|
-
/**
|
|
247
|
-
|
|
252
|
+
/**
|
|
253
|
+
* Migrate each parenthesized selector group of an `@scope` prelude.
|
|
254
|
+
* @param {string} params
|
|
255
|
+
* @param {(selector: string, start: number) => string} [finish] migrates one group; `start` is its offset in `params`
|
|
256
|
+
*/
|
|
257
|
+
function finishScopeParams(params, finish = finishSelectorText) {
|
|
248
258
|
let result = '';
|
|
249
259
|
let last = 0;
|
|
250
260
|
let depth = 0;
|
|
@@ -281,7 +291,7 @@ function finishScopeParams(params) {
|
|
|
281
291
|
if (char === ')' && depth > 0) {
|
|
282
292
|
depth--;
|
|
283
293
|
if (depth === 0 && groupStart >= 0) {
|
|
284
|
-
result +=
|
|
294
|
+
result += finish(params.slice(groupStart, index), groupStart);
|
|
285
295
|
result += ')';
|
|
286
296
|
last = index + 1;
|
|
287
297
|
groupStart = -1;
|
|
@@ -293,15 +303,39 @@ function finishScopeParams(params) {
|
|
|
293
303
|
|
|
294
304
|
/** @param {string} source @param {string} from */
|
|
295
305
|
function migrateCss(source, from) {
|
|
306
|
+
// Parse every selector of the stylesheet as written first, so one the
|
|
307
|
+
// selector parser rejects is reported at its line and column in the file,
|
|
308
|
+
// not in the migrated text below.
|
|
309
|
+
const original = parseCss(source, {from});
|
|
310
|
+
original.walkRules(rule => {
|
|
311
|
+
processSelector(rule, () => {});
|
|
312
|
+
});
|
|
313
|
+
original.walkAtRules('scope', atRule => {
|
|
314
|
+
const offset =
|
|
315
|
+
`@${atRule.name}`.length + (atRule.raws.afterName ?? '').length;
|
|
316
|
+
finishScopeParams(atRule.params, (selector, start) => {
|
|
317
|
+
try {
|
|
318
|
+
processSelector(selector, () => {});
|
|
319
|
+
} catch (err) {
|
|
320
|
+
if (!isCodemodParseError(err)) throw err;
|
|
321
|
+
throw markParseError(
|
|
322
|
+
atRule.error(/** @type {Error} */ (err).message, {
|
|
323
|
+
index: offset + start,
|
|
324
|
+
}),
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
return selector;
|
|
328
|
+
});
|
|
329
|
+
});
|
|
296
330
|
const migrated = migrateAstryxThemeSelectors(source, from, SELECTOR_DATA);
|
|
297
|
-
const root =
|
|
331
|
+
const root = parseCss(migrated, {from});
|
|
298
332
|
/** @type {Set<string>} */
|
|
299
333
|
const existingComments = new Set();
|
|
300
334
|
root.walkComments(comment => {
|
|
301
335
|
existingComments.add(comment.text.trim());
|
|
302
336
|
});
|
|
303
337
|
root.walkRules(rule => {
|
|
304
|
-
rule.selector = finishSelectorText(rule
|
|
338
|
+
rule.selector = finishSelectorText(rule);
|
|
305
339
|
const tokens = unclassifiedBareClasses(rule.selector);
|
|
306
340
|
if (tokens.length === 0) return;
|
|
307
341
|
const list = tokens.map(token => `.${token}`).join(', ');
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* @file Reject stale generated theme CSS that still owns data-token defaults.
|
|
5
5
|
*
|
|
6
6
|
* @input Generated theme CSS
|
|
7
|
-
* @output No rewritten source;
|
|
8
|
-
*
|
|
7
|
+
* @output No rewritten source; a regeneration report (`RegenerationRequired`,
|
|
8
|
+
* with `astryx theme build`) for a generated theme stylesheet that still
|
|
9
|
+
* declares data-color defaults at `:root`
|
|
9
10
|
* @position Next-release upgrade validation for spec:AST-066 FR19
|
|
10
11
|
*
|
|
11
12
|
* Raw `var(--color-data-*)` uses are not checked: prebuilt
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
*/
|
|
16
17
|
|
|
17
18
|
import * as path from 'node:path';
|
|
19
|
+
import {RegenerationRequired} from '../../outcome.mjs';
|
|
18
20
|
|
|
19
21
|
export const meta = {
|
|
20
22
|
title: 'Validate data-token ownership',
|
|
@@ -36,8 +38,9 @@ export default function validateDataTokenOwnership(file) {
|
|
|
36
38
|
file.source.includes(GENERATED_THEME_HEADER) &&
|
|
37
39
|
ROOT_DATA_DECLARATION.test(file.source)
|
|
38
40
|
) {
|
|
39
|
-
throw new
|
|
41
|
+
throw new RegenerationRequired(
|
|
40
42
|
'This generated theme CSS still emits canonical data defaults at :root. Rebuild it with `astryx theme build`; defaults come from @astryxdesign/core/astryx.css in prebuilt mode, and in a source build from the @astryxdesign/build PostCSS integration or dataVars imports.',
|
|
43
|
+
{commands: ['astryx theme build']},
|
|
41
44
|
);
|
|
42
45
|
}
|
|
43
46
|
return undefined;
|
package/assets/docs/README.md
CHANGED
|
@@ -32,22 +32,22 @@ A public authoring-quality rubric is also caller-facing when it helps someone ev
|
|
|
32
32
|
|
|
33
33
|
## Where the rest goes
|
|
34
34
|
|
|
35
|
-
The material is usually good; the finding is placement, not quality. It goes in the [wiki](https://github.com/
|
|
35
|
+
The material is usually good; the finding is placement, not quality. It goes in the [wiki](https://github.com/meta/astryx/wiki) — **as a section on the page that already covers it, not a new page.** The wiki is at nearly 60 pages, several of them overlapping, because every stray section got its own.
|
|
36
36
|
|
|
37
37
|
| what you wrote | where it goes |
|
|
38
38
|
| --------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
39
|
-
| how a component is graded — checks, scoring | [Component-Audit-Rubric](https://github.com/
|
|
40
|
-
| lab → core promotion, what a component must satisfy | [Component-Lifecycle](https://github.com/
|
|
41
|
-
| how to build a new component | [Component-Authoring-Guide](https://github.com/
|
|
42
|
-
| what a component must be hardened against | [Component-Hardening-Protocol](https://github.com/
|
|
43
|
-
| a11y requirements as checks we run | [Accessibility-Checklist](https://github.com/
|
|
44
|
-
| how the system is put together | [System-Architecture](https://github.com/
|
|
45
|
-
| API naming and shape decisions | [API-Conventions](https://github.com/
|
|
46
|
-
| contributor workflow, PR process | [Contributing](https://github.com/
|
|
47
|
-
| release mechanics | [Release-Process](https://github.com/
|
|
48
|
-
| what a nightly agent role does | the Night-Watch pages, from [Night-Watch-Overview](https://github.com/
|
|
49
|
-
|
|
50
|
-
**Fits no row?** It is still not caller-facing. Default it to [Contributing](https://github.com/
|
|
39
|
+
| how a component is graded — checks, scoring | [Component-Audit-Rubric](https://github.com/meta/astryx/wiki/Component-Audit-Rubric) |
|
|
40
|
+
| lab → core promotion, what a component must satisfy | [Component-Lifecycle](https://github.com/meta/astryx/wiki/Component-Lifecycle) |
|
|
41
|
+
| how to build a new component | [Component-Authoring-Guide](https://github.com/meta/astryx/wiki/Component-Authoring-Guide), [Creating-New-Components](https://github.com/meta/astryx/wiki/Creating-New-Components) |
|
|
42
|
+
| what a component must be hardened against | [Component-Hardening-Protocol](https://github.com/meta/astryx/wiki/Component-Hardening-Protocol), [Hardening-Audit-Guide](https://github.com/meta/astryx/wiki/Hardening-Audit-Guide) |
|
|
43
|
+
| a11y requirements as checks we run | [Accessibility-Checklist](https://github.com/meta/astryx/wiki/Accessibility-Checklist) |
|
|
44
|
+
| how the system is put together | [System-Architecture](https://github.com/meta/astryx/wiki/System-Architecture), [Theming-Infrastructure](https://github.com/meta/astryx/wiki/Theming-Infrastructure) |
|
|
45
|
+
| API naming and shape decisions | [API-Conventions](https://github.com/meta/astryx/wiki/API-Conventions), [API-Arbitration](https://github.com/meta/astryx/wiki/API-Arbitration) |
|
|
46
|
+
| contributor workflow, PR process | [Contributing](https://github.com/meta/astryx/wiki/Contributing), [Contributing-with-AI-Assistants](https://github.com/meta/astryx/wiki/Contributing-with-AI-Assistants) |
|
|
47
|
+
| release mechanics | [Release-Process](https://github.com/meta/astryx/wiki/Release-Process) |
|
|
48
|
+
| what a nightly agent role does | the Night-Watch pages, from [Night-Watch-Overview](https://github.com/meta/astryx/wiki/Night-Watch-Overview) |
|
|
49
|
+
|
|
50
|
+
**Fits no row?** It is still not caller-facing. Default it to [Contributing](https://github.com/meta/astryx/wiki/Contributing), or `CONTRIBUTING.md` when it is a step someone follows with the repo cloned. Never default it back to this directory.
|
|
51
51
|
|
|
52
52
|
Worked example: a responsive-and-interaction readiness rubric is grading criteria → **Component-Audit-Rubric**, or **Component-Lifecycle** if it is a promotion gate.
|
|
53
53
|
|
|
@@ -55,9 +55,11 @@ export const docs = {
|
|
|
55
55
|
['tokens', 'Base tokens are copied first, then child tokens override on top.'],
|
|
56
56
|
['components', 'Deep-merged: child component rules override matching keys from the base.'],
|
|
57
57
|
['icons', 'Shallow-merged: child icons override matching names from the base.'],
|
|
58
|
+
['iconVariants', 'Replaced, never merged: a child that sets iconVariants replaces the base list; a child that omits it inherits the list.'],
|
|
58
59
|
['indicators', 'Shallow-merged: child indicators override matching names from the base.'],
|
|
59
60
|
['onDark, onLight', "Deep-merged per surface: the base's resolved surface first, then the child's overrides."],
|
|
60
|
-
['
|
|
61
|
+
['motion', "Field by field: the child's `fast`, `medium` and `ratio` regenerate the fast and medium duration tokens; `slow` and `easing` left unset keep the base theme's tokens, so an inherited slow band stays at the base's ratio."],
|
|
62
|
+
['typography, radius, color', 'Child config replaces base entirely (these are scale inputs, not additive).'],
|
|
61
63
|
['adaptations', 'Width-breakpoint overrides merge by fixed name. Inherited ordered rules keep their relative order; child rules append and re-resolve against the child root axes.'],
|
|
62
64
|
]},
|
|
63
65
|
{type: 'prose', text: "Inheritance is resolved when the theme is defined, so an extended theme is flat: `{@command theme build}` emits one self-contained stylesheet holding everything the child inherited, and the base theme's CSS does not need to be loaded next to it. A base that is not a theme (most often an import that missed) throws when `defineTheme` runs, rather than producing a theme that silently inherits nothing."},
|
|
@@ -134,6 +136,8 @@ export const docs = {
|
|
|
134
136
|
{type: 'prose', text: 'In the example above, the generated theme imports `./icons.mjs` from `dist`. If the second command is skipped, `theme build` can still succeed, but loading or bundling the generated module fails because `dist/icons.mjs` is missing. `--icons-specifier` changes the emitted import; it does not create or verify the target file. Match the specifier to a module that resolves from the generated JS file.'},
|
|
135
137
|
{type: 'prose', text: 'Without `--icons-specifier`, the detected source import specifier is emitted unchanged. In the default flow without `--out`, a bundler can resolve an extensionless `./icons` to the neighboring `icons.tsx` source, but Node ESM does not perform that lookup and reports `ERR_MODULE_NOT_FOUND`. Moving the output with `--out` also changes where relative imports resolve from.'},
|
|
136
138
|
{type: 'prose', text: 'Keep `react` and the icon library external so the registry does not bundle its own copies of those dependencies.'},
|
|
139
|
+
{type: 'prose', text: "A registry entry can be a function of `{size, variant}`. The built theme keeps the function, so `Icon` asks it for the size and variant it renders, as the runtime theme does, including for entries inherited from a built or package theme. The built theme's `icons` field and the registry its module re-exports are React nodes, with each function read at size `md`. A function written in the theme file itself cannot be carried, so the build fails; move it into the registry module."},
|
|
140
|
+
{type: 'prose', text: "A theme that lists `iconVariants` also writes an `IconVariantMap` augmentation into `<theme>.variants.d.ts`, so `Icon`'s `variant` accepts those names wherever the theme's types load. Its declaration carries the list too, so a theme that extends the built theme types `variant` in its icon entries by that list."},
|
|
137
141
|
],
|
|
138
142
|
},
|
|
139
143
|
{
|
|
@@ -193,22 +193,22 @@ const overrides = stylex.create({
|
|
|
193
193
|
[
|
|
194
194
|
'Next.js',
|
|
195
195
|
'Next.js + theme CSS',
|
|
196
|
-
'[apps/example-nextjs](https://github.com/
|
|
196
|
+
'[apps/example-nextjs](https://github.com/meta/astryx/tree/main/apps/example-nextjs)',
|
|
197
197
|
],
|
|
198
198
|
[
|
|
199
199
|
'Next.js + StyleX',
|
|
200
200
|
'Next.js + StyleX for custom styles',
|
|
201
|
-
'[apps/example-nextjs-stylex](https://github.com/
|
|
201
|
+
'[apps/example-nextjs-stylex](https://github.com/meta/astryx/tree/main/apps/example-nextjs-stylex)',
|
|
202
202
|
],
|
|
203
203
|
[
|
|
204
204
|
'Next.js + Tailwind',
|
|
205
205
|
'Next.js + Tailwind bridge',
|
|
206
|
-
'[apps/example-nextjs-tailwind](https://github.com/
|
|
206
|
+
'[apps/example-nextjs-tailwind](https://github.com/meta/astryx/tree/main/apps/example-nextjs-tailwind)',
|
|
207
207
|
],
|
|
208
208
|
[
|
|
209
209
|
'Vite + Tailwind',
|
|
210
210
|
'Vite + Tailwind bridge',
|
|
211
|
-
'[apps/example-vite-tailwind](https://github.com/
|
|
211
|
+
'[apps/example-vite-tailwind](https://github.com/meta/astryx/tree/main/apps/example-vite-tailwind)',
|
|
212
212
|
],
|
|
213
213
|
],
|
|
214
214
|
},
|
|
@@ -216,7 +216,7 @@ const overrides = stylex.create({
|
|
|
216
216
|
type: 'code',
|
|
217
217
|
lang: 'bash',
|
|
218
218
|
label: 'Clone and run an example',
|
|
219
|
-
code: `git clone https://github.com/
|
|
219
|
+
code: `git clone https://github.com/meta/astryx.git
|
|
220
220
|
cd astryx/apps/example-nextjs
|
|
221
221
|
{@pm install}
|
|
222
222
|
{@pm run dev}`,
|
|
@@ -101,11 +101,92 @@ export const brandTheme = defineTheme({
|
|
|
101
101
|
},
|
|
102
102
|
});`,
|
|
103
103
|
},
|
|
104
|
+
{
|
|
105
|
+
type: 'prose',
|
|
106
|
+
text: "An entry can also be a function of the request, so the theme maps Icon's size to its icon library's own props or artwork. `Icon` calls it with `{size, variant}`, where `size` is the size it renders at (`xsm`, `sm`, `md`, or `lg`: an explicit `size`, else the owning component's default, else `md`). Reads that return one node — `getIcon()`, `useIcon()`, `getIconRegistry()`, and the theme's `icons` field — call it with `{size: 'md'}`. The same entry shape works in `registerIcons()`.",
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
type: 'code',
|
|
110
|
+
lang: 'tsx',
|
|
111
|
+
label: 'A size-aware icon entry',
|
|
112
|
+
code: `import {defineTheme} from '@astryxdesign/core/theme';
|
|
113
|
+
import {Info} from 'lucide-react';
|
|
114
|
+
|
|
115
|
+
export const brandTheme = defineTheme({
|
|
116
|
+
name: 'brand',
|
|
117
|
+
icons: {
|
|
118
|
+
// A heavier stroke keeps the small size legible.
|
|
119
|
+
info: ({size}) => <Info strokeWidth={size === 'sm' || size === 'xsm' ? 2.5 : 2} />,
|
|
120
|
+
},
|
|
121
|
+
});`,
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
type: 'prose',
|
|
125
|
+
text: 'Keep the function pure and synchronous: it computes its result from the request only, with no hooks, DOM or SVG measurement, browser globals, network access, mutable module state, or side effects. Its result is final. Returning `null` draws no glyph instead of falling back to a registered or built-in icon, while a `null` or `undefined` node entry still falls back. A child theme that sets an entry for a key replaces the inherited entry for that key.',
|
|
126
|
+
},
|
|
104
127
|
],
|
|
105
128
|
},
|
|
106
129
|
{
|
|
107
|
-
title: '
|
|
130
|
+
title: 'Icon Variants',
|
|
108
131
|
category: 'foundations',
|
|
132
|
+
content: [
|
|
133
|
+
{
|
|
134
|
+
type: 'prose',
|
|
135
|
+
text: "A theme lists the icon variant names it supports once, with `iconVariants` in `defineTheme()`. The list belongs to the whole theme, never to one icon, and Astryx defines no names of its own. Inside `defineTheme`, an entry function receives `variant` typed as the listed names, or `undefined`, so a misspelled name is a type error. An entry that receives `undefined` draws its normal artwork.",
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
type: 'code',
|
|
139
|
+
lang: 'tsx',
|
|
140
|
+
label: 'Listing variants and mapping them to artwork',
|
|
141
|
+
code: `import {defineTheme} from '@astryxdesign/core/theme';
|
|
142
|
+
import {InfoFilledIcon, InfoIcon} from './brand-icons';
|
|
143
|
+
|
|
144
|
+
export const brandTheme = defineTheme({
|
|
145
|
+
name: 'brand',
|
|
146
|
+
iconVariants: ['outline', 'filled'],
|
|
147
|
+
icons: {
|
|
148
|
+
info: ({size, variant}) =>
|
|
149
|
+
variant === 'filled' ? <InfoFilledIcon /> : <InfoIcon bold={size === 'sm'} />,
|
|
150
|
+
},
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
brandTheme.iconVariants; // ['outline', 'filled']`,
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
type: 'prose',
|
|
157
|
+
text: 'A theme that `extends` another inherits its list unless it sets its own; a list it sets replaces the inherited one instead of merging with it.',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
type: 'prose',
|
|
161
|
+
text: "Request a variant with `Icon`'s `variant` prop. The entry receives it only when the active theme lists it; an entry the theme inherited also needs the theme that defined it to list it. Otherwise the entry receives `undefined` and draws its normal artwork, so an unlisted variant never breaks rendering. A `registerIcons()` entry receives the variants the active theme lists, and a node entry draws the same node for every variant. An icon component passed directly to `Icon` never receives `variant`, and `variant` is never written to the DOM: it selects artwork, so there is no theming selector for it.",
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
type: 'code',
|
|
165
|
+
lang: 'tsx',
|
|
166
|
+
label: 'Requesting a variant',
|
|
167
|
+
code: `<Icon icon="info" variant="filled" /> // brandTheme: the filled artwork
|
|
168
|
+
<Icon icon="info" /> // the normal artwork`,
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
type: 'prose',
|
|
172
|
+
text: 'An application declares the variant names it uses by augmenting `IconVariantMap` from `@astryxdesign/core/Icon`. `IconVariant` is those names, and an entry passed to `registerIcons()` receives `variant` typed as `IconVariant`. `astryx theme build` writes this augmentation for a built theme\'s list.',
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
type: 'code',
|
|
176
|
+
lang: 'ts',
|
|
177
|
+
label: 'Declaring the variant names an application uses',
|
|
178
|
+
code: `declare module '@astryxdesign/core/Icon' {
|
|
179
|
+
interface IconVariantMap {
|
|
180
|
+
outline: true;
|
|
181
|
+
filled: true;
|
|
182
|
+
}
|
|
183
|
+
}`,
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
title: 'Component and Library Icons',
|
|
189
|
+
category: 'foundations',
|
|
109
190
|
content: [
|
|
110
191
|
{
|
|
111
192
|
type: 'prose',
|
|
@@ -50,7 +50,7 @@ export const docs = {
|
|
|
50
50
|
content: [
|
|
51
51
|
{
|
|
52
52
|
type: 'prose',
|
|
53
|
-
text: '
|
|
53
|
+
text: 'Two easing curves. `--ease-standard` decelerates, for things arriving and state changes. `--ease-exit` accelerates, for things leaving: it moves off from rest and leaves fast, so the travel stays visible for the whole duration.',
|
|
54
54
|
},
|
|
55
55
|
{
|
|
56
56
|
type: 'token-ref',
|
|
@@ -21,6 +21,14 @@ export const docsDense = {
|
|
|
21
21
|
{type: 'prose', text: "new palette: `astryx theme palette generate palette.config.json --out palette.generated.ts` → review + commit module and receipt → `import {palette} from './palette.generated';` → map semantic tokens to stable stops such as `palette.neutral.light[100]` / `palette.neutral.dark[15]`. regeneration updates mapped roles; generation does not rewrite the theme."},
|
|
22
22
|
],
|
|
23
23
|
},
|
|
24
|
+
{
|
|
25
|
+
section: 'Icon sizes',
|
|
26
|
+
title: 'Icon sizes',
|
|
27
|
+
content: [
|
|
28
|
+
{type: 'prose', text: "theme sets each Icon size's glyph dimension: `width` + `height` on `components.icon['size:sm']` (or xsm/md/lg); semantic names + SVG components alike. px or rem only: a semantic icon takes its font size from the dimension, so em also grows its box. unstyled: xsm/sm/md/lg = 12/16/20/24px at 16px root, scale w/ root font size (rem keeps it). size names are fixed."},
|
|
29
|
+
null,
|
|
30
|
+
],
|
|
31
|
+
},
|
|
24
32
|
{
|
|
25
33
|
section: 'Dark mode',
|
|
26
34
|
title: 'Dark mode',
|
|
@@ -53,6 +53,22 @@ export const docs = {
|
|
|
53
53
|
},
|
|
54
54
|
],
|
|
55
55
|
},
|
|
56
|
+
{
|
|
57
|
+
id: 'icon-sizes',
|
|
58
|
+
title: 'Icon sizes',
|
|
59
|
+
content: [
|
|
60
|
+
{
|
|
61
|
+
type: 'prose',
|
|
62
|
+
text: "A theme sets the dimension of each Icon size in its stylesheet: `width` and `height` on `components.icon['size:sm']` (or `xsm`, `md`, `lg`) resize that size's glyph, for semantic icon names and SVG components passed to `Icon` alike. Give the dimension in `px` or `rem`: a semantic icon takes its font size from it, so an `em` value would also grow its box. A size the theme leaves alone stays 12, 16, 20, or 24px at a 16px root (`xsm`, `sm`, `md`, `lg`) and scales with the root font size; `rem` keeps that scaling. The four size names are fixed.",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: 'code',
|
|
66
|
+
lang: 'tsx',
|
|
67
|
+
label: 'Set Icon size dimensions',
|
|
68
|
+
code: "const brandTheme = defineTheme({\n name: 'brand',\n components: {\n icon: {\n 'size:sm': {width: '1.125rem', height: '1.125rem'},\n 'size:lg': {width: '1.75rem', height: '1.75rem'},\n },\n },\n});",
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
56
72
|
{
|
|
57
73
|
id: 'light-dark-mode',
|
|
58
74
|
title: 'Dark mode',
|
|
@@ -25,6 +25,17 @@ export const docsZh = {
|
|
|
25
25
|
},
|
|
26
26
|
],
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
section: 'Icon sizes',
|
|
30
|
+
title: '图标尺寸',
|
|
31
|
+
content: [
|
|
32
|
+
{
|
|
33
|
+
type: 'prose',
|
|
34
|
+
text: "主题在样式表中设置每个 Icon 尺寸的大小:在 `components.icon['size:sm']`(或 `xsm`、`md`、`lg`)上设置 `width` 和 `height`,即可调整该尺寸的图标,语义图标名称和直接传给 `Icon` 的 SVG 组件都适用。请使用 `px` 或 `rem` 设置尺寸:语义图标会据此设置自身的字号,因此 `em` 值也会放大它的外框。主题未设置的尺寸在 16px 根字号下保持 12、16、20 或 24px(`xsm`、`sm`、`md`、`lg`),并随根字号缩放;`rem` 可保留这种缩放。四个尺寸名称是固定的。",
|
|
35
|
+
},
|
|
36
|
+
null,
|
|
37
|
+
],
|
|
38
|
+
},
|
|
28
39
|
{
|
|
29
40
|
section: 'Dark mode',
|
|
30
41
|
title: '深色模式',
|
|
@@ -111,7 +111,7 @@ export default function App() {
|
|
|
111
111
|
},
|
|
112
112
|
{
|
|
113
113
|
type: 'prose',
|
|
114
|
-
text: "Single-catalog usage (where an external i18n runtime like react-intl or i18next resolves both your app strings AND astryx's strings through one provider) is on the roadmap via a `Translator` adapter. Track [
|
|
114
|
+
text: "Single-catalog usage (where an external i18n runtime like react-intl or i18next resolves both your app strings AND astryx's strings through one provider) is on the roadmap via a `Translator` adapter. Track [meta/astryx#4029](https://github.com/meta/astryx/issues/4029). For now, run the two providers side by side as shown above.",
|
|
115
115
|
},
|
|
116
116
|
],
|
|
117
117
|
},
|