@astryxdesign/cli 0.1.4-canary.d5cbae3 → 0.1.4-canary.d7c9a39
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/docs/styling.doc.mjs +6 -6
- package/docs/working-with-ai.doc.mjs +1 -1
- package/package.json +10 -10
- package/src/codemods/__tests__/registry.test.mjs +1 -0
- package/src/codemods/registry.mjs +1 -0
- package/src/codemods/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs +93 -0
- package/src/codemods/transforms/v0.1.5/index.mjs +19 -0
- package/src/codemods/transforms/v0.1.5/rename-switch-label-spacing-default-to-hug.mjs +140 -0
- package/src/commands/build-theme.color-scheme.test.mjs +153 -0
- package/src/commands/build-theme.mjs +8 -1
- package/src/commands/build-theme.variants.test.mjs +7 -18
- package/templates/blocks/components/Collapsible/CollapsibleWithoutCard.tsx +25 -23
- package/templates/pages/classic-gallery/page.tsx +1 -1
- package/templates/pages/dashboard/page.tsx +1 -1
- package/templates/pages/documentation/page.tsx +1 -1
- package/templates/pages/incident-console/template.doc.mjs +1 -1
- package/templates/pages/messaging-shell/template.doc.mjs +1 -1
- package/templates/pages/mixed-gallery/page.tsx +1 -1
- package/templates/pages/payment-form/page.tsx +2 -6
- package/templates/pages/product-detail/page.tsx +3 -11
- package/templates/pages/product-gallery/page.tsx +1 -1
- package/templates/pages/settings/page.tsx +1 -1
- package/templates/pages/side-gallery/page.tsx +1 -1
- package/templates/pages/table-page/page.tsx +1 -1
- package/templates/pages/table-page-chart/page.tsx +1 -1
- package/templates/pages/table-page-heatmap-status/page.tsx +1 -1
- package/templates/pages/table-page-shoe-store-heatmap/page.tsx +1 -1
package/docs/styling.doc.mjs
CHANGED
|
@@ -344,7 +344,7 @@ const styles = stylex.create({
|
|
|
344
344
|
content: [
|
|
345
345
|
{
|
|
346
346
|
type: 'prose',
|
|
347
|
-
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
|
|
347
|
+
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()`.',
|
|
348
348
|
},
|
|
349
349
|
{
|
|
350
350
|
type: 'table',
|
|
@@ -353,12 +353,12 @@ const styles = stylex.create({
|
|
|
353
353
|
['Webpack', '@stylexjs/webpack-plugin'],
|
|
354
354
|
['Vite / Rollup', '@stylexjs/rollup-plugin (or a community Vite plugin)'],
|
|
355
355
|
['Babel (any bundler)', '@stylexjs/babel-plugin + @stylexjs/postcss-plugin'],
|
|
356
|
-
['Next.js (App Router, SWC)', 'An SWC-based transform
|
|
356
|
+
['Next.js (App Router, SWC)', 'An SWC-based transform; see the Next.js note below'],
|
|
357
357
|
],
|
|
358
358
|
},
|
|
359
359
|
{
|
|
360
360
|
type: 'prose',
|
|
361
|
-
text: 'Next.js (App Router) is the sharp edge. StyleX\
|
|
361
|
+
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, which in turn breaks SWC-dependent features like `next/font`. So the "obvious" Babel setup is actively incompatible with a standard Next 15 App Router app.',
|
|
362
362
|
},
|
|
363
363
|
{
|
|
364
364
|
type: 'prose',
|
|
@@ -367,7 +367,7 @@ const styles = stylex.create({
|
|
|
367
367
|
{
|
|
368
368
|
type: 'code',
|
|
369
369
|
lang: 'js',
|
|
370
|
-
label: 'next.config.mjs
|
|
370
|
+
label: 'next.config.mjs: SWC-based StyleX transform (keeps next/font working)',
|
|
371
371
|
code: `import stylexPlugin from '@stylexswc/nextjs-plugin';
|
|
372
372
|
|
|
373
373
|
export default stylexPlugin({
|
|
@@ -385,8 +385,8 @@ export default stylexPlugin({
|
|
|
385
385
|
style: 'unordered',
|
|
386
386
|
items: [
|
|
387
387
|
'Symptom of a missing compiler: swizzled component renders with no styles, but no build or runtime error.',
|
|
388
|
-
'Do NOT add @stylexjs/babel-plugin to a Next.js App Router app
|
|
389
|
-
'Pure theming (defineTheme + astryx theme build) needs NO StyleX compiler
|
|
388
|
+
'Do NOT add @stylexjs/babel-plugin to a Next.js App Router app; it disables SWC and breaks next/font.',
|
|
389
|
+
'Pure theming (defineTheme + astryx theme build) needs NO StyleX compiler; only swizzled/authored StyleX source does.',
|
|
390
390
|
],
|
|
391
391
|
},
|
|
392
392
|
],
|
|
@@ -125,7 +125,7 @@ If you don't know all three, run \`npx astryx init --features agents\` to genera
|
|
|
125
125
|
lang: 'json',
|
|
126
126
|
label: 'package.json',
|
|
127
127
|
code: `"scripts": {
|
|
128
|
-
"
|
|
128
|
+
"astryx": "node node_modules/@astryxdesign/cli/bin/astryx.mjs"
|
|
129
129
|
}`,
|
|
130
130
|
},
|
|
131
131
|
{
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.1.4-canary.
|
|
3
|
+
"version": "0.1.4-canary.d7c9a39",
|
|
4
4
|
"displayName": "CLI",
|
|
5
5
|
"description": "Scaffold projects, browse templates, generate themes, and get agent-ready docs from the command line.",
|
|
6
6
|
"author": "Meta Open Source",
|
|
@@ -68,17 +68,17 @@
|
|
|
68
68
|
"CHANGELOG.md"
|
|
69
69
|
],
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@clack/prompts": "^1.
|
|
71
|
+
"@clack/prompts": "^1.7.0",
|
|
72
72
|
"commander": "^12.1.0",
|
|
73
73
|
"jiti": "^2.7.0",
|
|
74
74
|
"jscodeshift": "^17.3.0",
|
|
75
75
|
"zod": "^4.4.3"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
|
-
"@astryxdesign/charts": "0.1.4-canary.
|
|
79
|
-
"@astryxdesign/core": "0.1.4-canary.
|
|
80
|
-
"@astryxdesign/lab": "0.1.4-canary.
|
|
81
|
-
"@astryxdesign/theme-neutral": "0.1.4-canary.
|
|
78
|
+
"@astryxdesign/charts": "0.1.4-canary.d7c9a39",
|
|
79
|
+
"@astryxdesign/core": "0.1.4-canary.d7c9a39",
|
|
80
|
+
"@astryxdesign/lab": "0.1.4-canary.d7c9a39",
|
|
81
|
+
"@astryxdesign/theme-neutral": "0.1.4-canary.d7c9a39",
|
|
82
82
|
"gpt-tokenizer": "^3.4.0"
|
|
83
83
|
},
|
|
84
84
|
"peerDependenciesMeta": {
|
|
@@ -96,10 +96,10 @@
|
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
"devDependencies": {
|
|
99
|
-
"@astryxdesign/charts": "0.1.4-canary.
|
|
100
|
-
"@astryxdesign/core": "0.1.4-canary.
|
|
101
|
-
"@astryxdesign/lab": "0.1.4-canary.
|
|
102
|
-
"@astryxdesign/theme-neutral": "0.1.4-canary.
|
|
99
|
+
"@astryxdesign/charts": "0.1.4-canary.d7c9a39",
|
|
100
|
+
"@astryxdesign/core": "0.1.4-canary.d7c9a39",
|
|
101
|
+
"@astryxdesign/lab": "0.1.4-canary.d7c9a39",
|
|
102
|
+
"@astryxdesign/theme-neutral": "0.1.4-canary.d7c9a39",
|
|
103
103
|
"gpt-tokenizer": "^3.4.0"
|
|
104
104
|
},
|
|
105
105
|
"scripts": {
|
|
@@ -20,6 +20,7 @@ const registry = new Map([
|
|
|
20
20
|
['0.1.0', () => import('./transforms/v0.1.0/index.mjs')],
|
|
21
21
|
['0.1.2', () => import('./transforms/v0.1.2/index.mjs')],
|
|
22
22
|
['0.1.3', () => import('./transforms/v0.1.3/index.mjs')],
|
|
23
|
+
['0.1.5', () => import('./transforms/v0.1.5/index.mjs')],
|
|
23
24
|
]);
|
|
24
25
|
|
|
25
26
|
// Re-export from the shared utility so registry callers and other consumers
|
package/src/codemods/transforms/v0.1.5/__tests__/rename-switch-label-spacing-default-to-hug.test.mjs
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
import {describe, it, expect} from 'vitest';
|
|
4
|
+
|
|
5
|
+
async function applyTransform(source) {
|
|
6
|
+
const {default: transform} =
|
|
7
|
+
await import('../rename-switch-label-spacing-default-to-hug.mjs');
|
|
8
|
+
const jscodeshift = (await import('jscodeshift')).default;
|
|
9
|
+
const j = jscodeshift.withParser('tsx');
|
|
10
|
+
const api = {jscodeshift: j, stats: () => {}, report: () => {}};
|
|
11
|
+
const file = {source, path: 'test.tsx'};
|
|
12
|
+
const result = transform(file, api);
|
|
13
|
+
return result ?? source;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
describe('rename-switch-label-spacing-default-to-hug', () => {
|
|
17
|
+
it('renames Switch labelSpacing="default" to labelSpacing="hug"', async () => {
|
|
18
|
+
const input = `<Switch label="Notify" value={on} labelSpacing="default" />`;
|
|
19
|
+
const output = await applyTransform(input);
|
|
20
|
+
expect(output).toContain("'hug'");
|
|
21
|
+
expect(output).not.toContain('default');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("renames expression-container labelSpacing={'default'}", async () => {
|
|
25
|
+
const input = `<Switch label="Notify" value={on} labelSpacing={'default'} />`;
|
|
26
|
+
const output = await applyTransform(input);
|
|
27
|
+
expect(output).toContain("'hug'");
|
|
28
|
+
expect(output).not.toContain("'default'");
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('renames default inside a ternary labelSpacing expression', async () => {
|
|
32
|
+
const input = `<Switch label="Notify" value={on} labelSpacing={isRow ? 'spread' : 'default'} />`;
|
|
33
|
+
const output = await applyTransform(input);
|
|
34
|
+
expect(output).toContain("'hug'");
|
|
35
|
+
expect(output).toContain("'spread'");
|
|
36
|
+
expect(output).not.toContain("'default'");
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('does not change labelSpacing="spread"', async () => {
|
|
40
|
+
const input = `<Switch label="Notify" value={on} labelSpacing="spread" />`;
|
|
41
|
+
const output = await applyTransform(input);
|
|
42
|
+
expect(output).toBe(input);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('does not touch labelSpacing="default" on non-Switch components', async () => {
|
|
46
|
+
const input = `<LegacyToggle labelSpacing="default" />`;
|
|
47
|
+
const output = await applyTransform(input);
|
|
48
|
+
expect(output).toBe(input);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('does not touch other props with a "default" value on Switch', async () => {
|
|
52
|
+
const input = `<Switch label="Notify" value={on} data-variant="default" />`;
|
|
53
|
+
const output = await applyTransform(input);
|
|
54
|
+
expect(output).toBe(input);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('does not touch unrelated "default" string literals', async () => {
|
|
58
|
+
const input = `const theme = {mode: 'default', label: 'Default Mode'};`;
|
|
59
|
+
const output = await applyTransform(input);
|
|
60
|
+
expect(output).toBe(input);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('renames object labelSpacing prop in files importing Switch', async () => {
|
|
64
|
+
const input = `import {Switch} from '@astryxdesign/core/Switch';
|
|
65
|
+
const cfg = {labelSpacing: 'default'};`;
|
|
66
|
+
const output = await applyTransform(input);
|
|
67
|
+
expect(output).toContain("labelSpacing: 'hug'");
|
|
68
|
+
expect(output).not.toContain("'default'");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("renames labelSpacing: 'default' as const in files importing Switch", async () => {
|
|
72
|
+
const input = `import {Switch} from '@astryxdesign/core/Switch';
|
|
73
|
+
const ROWS = [{labelSpacing: 'default' as const, label: 'Adjacent'}];`;
|
|
74
|
+
const output = await applyTransform(input);
|
|
75
|
+
expect(output).toContain("'hug' as const");
|
|
76
|
+
expect(output).not.toContain("'default'");
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('does not rename object labelSpacing prop when Switch is not imported', async () => {
|
|
80
|
+
const input = `const cfg = {labelSpacing: 'default'};`;
|
|
81
|
+
const output = await applyTransform(input);
|
|
82
|
+
expect(output).toBe(input);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('renames Storybook argTypes options in files importing Switch', async () => {
|
|
86
|
+
const input = `import {Switch} from '@astryxdesign/core/Switch';
|
|
87
|
+
const meta = {argTypes: {labelSpacing: {control: 'select', options: ['default', 'spread']}}};`;
|
|
88
|
+
const output = await applyTransform(input);
|
|
89
|
+
expect(output).toContain("'hug'");
|
|
90
|
+
expect(output).toContain("'spread'");
|
|
91
|
+
expect(output).not.toContain("'default'");
|
|
92
|
+
});
|
|
93
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file v0.1.5 transform manifest
|
|
5
|
+
*
|
|
6
|
+
* Lists all codemods for the v0.1.5 release in the order they should run.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import renameSwitchLabelSpacingDefaultToHug, {
|
|
10
|
+
meta as renameSwitchLabelSpacingDefaultToHugMeta,
|
|
11
|
+
} from './rename-switch-label-spacing-default-to-hug.mjs';
|
|
12
|
+
|
|
13
|
+
export default [
|
|
14
|
+
{
|
|
15
|
+
name: 'rename-switch-label-spacing-default-to-hug',
|
|
16
|
+
transform: renameSwitchLabelSpacingDefaultToHug,
|
|
17
|
+
meta: renameSwitchLabelSpacingDefaultToHugMeta,
|
|
18
|
+
},
|
|
19
|
+
];
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Codemod: Rename Switch labelSpacing "default" to "hug"
|
|
5
|
+
* @see https://github.com/facebook/astryx/issues/2889
|
|
6
|
+
*
|
|
7
|
+
* The `labelSpacing="default"` value is renamed to `labelSpacing="hug"` so
|
|
8
|
+
* the name describes the behavior (label and switch hug each other), matching
|
|
9
|
+
* the behavioral register of the sibling `spread` value and the existing
|
|
10
|
+
* `hug`/`fill` layout vocabulary on TabList and SegmentedControl. The old
|
|
11
|
+
* `default` value keeps working as a deprecated alias, so this codemod is a
|
|
12
|
+
* cleanup, not a build fix.
|
|
13
|
+
*
|
|
14
|
+
* Transforms (scoped to Switch):
|
|
15
|
+
* - <Switch labelSpacing="default" /> → <Switch labelSpacing="hug" />
|
|
16
|
+
* - <Switch labelSpacing={'default'} /> → <Switch labelSpacing={'hug'} />
|
|
17
|
+
* - <Switch labelSpacing={cond ? 'default' : x}> → <Switch labelSpacing={cond ? 'hug' : x}>
|
|
18
|
+
* - Storybook argTypes: labelSpacing: { options: [..., 'default', ...] }
|
|
19
|
+
* → replaces 'default' with 'hug' (files importing Switch)
|
|
20
|
+
* - Object properties: { labelSpacing: 'default' } / { labelSpacing: 'default' as const }
|
|
21
|
+
* → { labelSpacing: 'hug' } (files importing Switch)
|
|
22
|
+
*
|
|
23
|
+
* The transform deliberately does NOT touch bare `'default'` strings that are
|
|
24
|
+
* not a `labelSpacing` value (an extremely common string otherwise), so it is
|
|
25
|
+
* safe to run across an entire codebase.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
export const meta = {
|
|
29
|
+
title: 'Rename Switch labelSpacing "default" to "hug"',
|
|
30
|
+
description:
|
|
31
|
+
'Renames the `labelSpacing="default"` value to `labelSpacing="hug"` on ' +
|
|
32
|
+
'Switch. The old value keeps working as a deprecated alias. Also updates ' +
|
|
33
|
+
'Storybook labelSpacing argTypes options and object-literal `labelSpacing` ' +
|
|
34
|
+
'props in files that import Switch.',
|
|
35
|
+
pr: '#2889',
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const OLD_VALUE = 'default';
|
|
39
|
+
const NEW_VALUE = 'hug';
|
|
40
|
+
|
|
41
|
+
/** Prop whose value is being renamed. */
|
|
42
|
+
const TARGET_PROP = 'labelSpacing';
|
|
43
|
+
|
|
44
|
+
/** Components whose `labelSpacing` prop accepts a SwitchLabelSpacing value. */
|
|
45
|
+
const TARGET_COMPONENTS = new Set(['Switch']);
|
|
46
|
+
|
|
47
|
+
export default function transformer(file, api) {
|
|
48
|
+
const j = api.jscodeshift;
|
|
49
|
+
const root = j(file.source);
|
|
50
|
+
let hasChanges = false;
|
|
51
|
+
|
|
52
|
+
/** Rewrite a string-literal node when it equals the old value. */
|
|
53
|
+
function renameStringLiteral(node) {
|
|
54
|
+
if (!node) return false;
|
|
55
|
+
if (
|
|
56
|
+
(node.type === 'StringLiteral' || node.type === 'Literal') &&
|
|
57
|
+
node.value === OLD_VALUE
|
|
58
|
+
) {
|
|
59
|
+
node.value = NEW_VALUE;
|
|
60
|
+
if (node.raw) node.raw = `'${NEW_VALUE}'`;
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Recursively rewrite the old value inside ternary/logical expressions. */
|
|
67
|
+
function renameInExpression(node) {
|
|
68
|
+
if (!node) return false;
|
|
69
|
+
let changed = false;
|
|
70
|
+
if (node.type === 'StringLiteral' || node.type === 'Literal') {
|
|
71
|
+
changed = renameStringLiteral(node) || changed;
|
|
72
|
+
} else if (node.type === 'ConditionalExpression') {
|
|
73
|
+
changed = renameInExpression(node.consequent) || changed;
|
|
74
|
+
changed = renameInExpression(node.alternate) || changed;
|
|
75
|
+
} else if (node.type === 'LogicalExpression') {
|
|
76
|
+
changed = renameInExpression(node.left) || changed;
|
|
77
|
+
changed = renameInExpression(node.right) || changed;
|
|
78
|
+
} else if (node.type === 'TSAsExpression') {
|
|
79
|
+
// `'default' as const` → rewrite the inner expression
|
|
80
|
+
changed = renameInExpression(node.expression) || changed;
|
|
81
|
+
}
|
|
82
|
+
return changed;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// --- 1. JSX attribute: labelSpacing="default" / labelSpacing={'default'} on Switch ---
|
|
86
|
+
root.find(j.JSXOpeningElement).forEach(path => {
|
|
87
|
+
const name = path.node.name;
|
|
88
|
+
const componentName = name.type === 'JSXIdentifier' ? name.name : null;
|
|
89
|
+
if (!componentName || !TARGET_COMPONENTS.has(componentName)) return;
|
|
90
|
+
|
|
91
|
+
path.node.attributes.forEach(attr => {
|
|
92
|
+
if (attr.type !== 'JSXAttribute') return;
|
|
93
|
+
if (!attr.name || attr.name.name !== TARGET_PROP) return;
|
|
94
|
+
|
|
95
|
+
const value = attr.value;
|
|
96
|
+
if (!value) return;
|
|
97
|
+
|
|
98
|
+
if (value.type === 'StringLiteral' || value.type === 'Literal') {
|
|
99
|
+
if (renameStringLiteral(value)) hasChanges = true;
|
|
100
|
+
} else if (value.type === 'JSXExpressionContainer') {
|
|
101
|
+
if (renameInExpression(value.expression)) hasChanges = true;
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// Object-property / argTypes transforms only run in files that use a target
|
|
107
|
+
// component — keeps unrelated `{ labelSpacing: 'default' }` strings safe.
|
|
108
|
+
const importsTarget =
|
|
109
|
+
root
|
|
110
|
+
.find(j.ImportSpecifier)
|
|
111
|
+
.filter(p => TARGET_COMPONENTS.has(p.node.imported?.name))
|
|
112
|
+
.size() > 0;
|
|
113
|
+
|
|
114
|
+
if (importsTarget) {
|
|
115
|
+
const PropertyType = j.ObjectProperty ?? j.Property;
|
|
116
|
+
|
|
117
|
+
// --- 2. Object property: { labelSpacing: 'default' } / 'default' as const ---
|
|
118
|
+
root.find(PropertyType, {key: {name: TARGET_PROP}}).forEach(path => {
|
|
119
|
+
if (renameInExpression(path.node.value)) hasChanges = true;
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
// --- 3. Storybook argTypes: labelSpacing: { options: [..., 'default', ...] } ---
|
|
123
|
+
root.find(PropertyType, {key: {name: TARGET_PROP}}).forEach(path => {
|
|
124
|
+
const value = path.node.value;
|
|
125
|
+
if (!value || value.type !== 'ObjectExpression') return;
|
|
126
|
+
|
|
127
|
+
const optionsProp = value.properties.find(
|
|
128
|
+
p => p.key && (p.key.name === 'options' || p.key.value === 'options'),
|
|
129
|
+
);
|
|
130
|
+
if (optionsProp && optionsProp.value.type === 'ArrayExpression') {
|
|
131
|
+
optionsProp.value.elements.forEach(el => {
|
|
132
|
+
if (renameStringLiteral(el)) hasChanges = true;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (!hasChanges) return undefined;
|
|
139
|
+
return root.toSource({quote: 'single'});
|
|
140
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file Regression test for the `color-scheme` declaration `astryx theme build`
|
|
5
|
+
* emits alongside `light-dark()` token output (see #3658).
|
|
6
|
+
*
|
|
7
|
+
* `astryx theme build` injects a `color-scheme` declaration into
|
|
8
|
+
* `@layer astryx-theme` whenever the generated CSS contains `light-dark()`,
|
|
9
|
+
* so LightningCSS/browsers can resolve it. That declaration must mirror
|
|
10
|
+
* reset.css's own `html[data-theme]` -> `color-scheme` mapping (a bare
|
|
11
|
+
* `:root { color-scheme: light dark; }` alone permanently pins the page to
|
|
12
|
+
* "light dark", defeating `<Theme mode="light|dark">` forcing regardless of
|
|
13
|
+
* `@layer astryx-theme` being declared after `@layer reset` in layer order):
|
|
14
|
+
*
|
|
15
|
+
* :root { color-scheme: light dark; }
|
|
16
|
+
* html[data-theme="light"] { color-scheme: light; }
|
|
17
|
+
* html[data-theme="dark"] { color-scheme: dark; }
|
|
18
|
+
*
|
|
19
|
+
* Themes that never use `light-dark()` have no `color-scheme` ambiguity to
|
|
20
|
+
* resolve, so none of the three rules should be emitted for them.
|
|
21
|
+
*
|
|
22
|
+
* Building `astryx theme build` requires a compiled @astryxdesign/core (there is no in-CLI
|
|
23
|
+
* fallback generator), so this suite builds core once in beforeAll via the
|
|
24
|
+
* shared ensureCoreBuilt() helper — which serializes concurrent Vitest workers
|
|
25
|
+
* behind a lock — to stay self-sufficient regardless of CI job ordering.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
import {describe, it, expect, beforeAll, beforeEach, afterEach} from 'vitest';
|
|
29
|
+
import {execFileSync} from 'node:child_process';
|
|
30
|
+
import * as fs from 'node:fs';
|
|
31
|
+
import * as path from 'node:path';
|
|
32
|
+
import * as os from 'node:os';
|
|
33
|
+
import {fileURLToPath} from 'node:url';
|
|
34
|
+
import {ensureCoreBuilt} from './ensure-core-built.mjs';
|
|
35
|
+
|
|
36
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
37
|
+
const CLI_BIN = path.resolve(__dirname, '../../bin/astryx.mjs');
|
|
38
|
+
|
|
39
|
+
const COLOR_SCHEME_ROOT_DECL = ':root { color-scheme: light dark; }';
|
|
40
|
+
const COLOR_SCHEME_LIGHT_DECL = 'html[data-theme="light"] { color-scheme: light; }';
|
|
41
|
+
const COLOR_SCHEME_DARK_DECL = 'html[data-theme="dark"] { color-scheme: dark; }';
|
|
42
|
+
|
|
43
|
+
function runCli(args, cwd) {
|
|
44
|
+
try {
|
|
45
|
+
const out = execFileSync('node', [CLI_BIN, ...args], {
|
|
46
|
+
cwd,
|
|
47
|
+
encoding: 'utf-8',
|
|
48
|
+
stdio: ['ignore', 'pipe', 'pipe'],
|
|
49
|
+
env: {...process.env, FORCE_COLOR: '0'},
|
|
50
|
+
});
|
|
51
|
+
return {code: 0, stdout: out, stderr: ''};
|
|
52
|
+
} catch (e) {
|
|
53
|
+
return {
|
|
54
|
+
code: e.status ?? 1,
|
|
55
|
+
stdout: e.stdout?.toString() ?? '',
|
|
56
|
+
stderr: e.stderr?.toString() ?? '',
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function writeTheme(dir, name, tokens) {
|
|
62
|
+
fs.mkdirSync(dir, {recursive: true});
|
|
63
|
+
// The CLI writes <basename>.css next to the source file, so use the
|
|
64
|
+
// theme name as the filename for unambiguous fixtures.
|
|
65
|
+
const file = path.join(dir, `${name}.mjs`);
|
|
66
|
+
fs.writeFileSync(
|
|
67
|
+
file,
|
|
68
|
+
`export default { name: ${JSON.stringify(name)}, tokens: ${JSON.stringify(tokens)} };\n`,
|
|
69
|
+
);
|
|
70
|
+
return file;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// `astryx theme build` imports the compiled @astryxdesign/core/theme entry. Build core
|
|
74
|
+
// once if it isn't already present so the suite works in any CI job.
|
|
75
|
+
beforeAll(() => {
|
|
76
|
+
ensureCoreBuilt();
|
|
77
|
+
}, 200_000);
|
|
78
|
+
|
|
79
|
+
let tmpDir;
|
|
80
|
+
beforeEach(() => {
|
|
81
|
+
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-build-theme-color-scheme-'));
|
|
82
|
+
});
|
|
83
|
+
afterEach(() => {
|
|
84
|
+
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
describe('theme build color-scheme output', () => {
|
|
88
|
+
it('emits the mode-aware color-scheme rules in @layer astryx-theme for a light-dark() theme', () => {
|
|
89
|
+
const project = path.join(tmpDir, 'project');
|
|
90
|
+
const themesDir = path.join(project, 'themes');
|
|
91
|
+
// A raw light-dark() token value is what triggers the color-scheme
|
|
92
|
+
// injection in build-theme.mjs (it checks the generated CSS for the
|
|
93
|
+
// literal substring). `defineTheme.test.ts` already covers the separate
|
|
94
|
+
// [light, dark] tuple -> light-dark() conversion; this fixture writes
|
|
95
|
+
// the string directly so this test stays focused on the CLI's own
|
|
96
|
+
// color-scheme decision, not on that conversion.
|
|
97
|
+
const themeFile = writeTheme(themesDir, 'with-light-dark', {
|
|
98
|
+
'--color-accent': 'light-dark(#0077B6, #48CAE4)',
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const result = runCli(
|
|
102
|
+
['theme', 'build', path.relative(project, themeFile)],
|
|
103
|
+
project,
|
|
104
|
+
);
|
|
105
|
+
|
|
106
|
+
expect(result.code).toBe(0);
|
|
107
|
+
|
|
108
|
+
const cssPath = path.join(themesDir, 'with-light-dark.css');
|
|
109
|
+
expect(fs.existsSync(cssPath)).toBe(true);
|
|
110
|
+
const css = fs.readFileSync(cssPath, 'utf-8');
|
|
111
|
+
|
|
112
|
+
expect(css).toContain('light-dark(#0077B6, #48CAE4)');
|
|
113
|
+
|
|
114
|
+
// All 3 rules must be present...
|
|
115
|
+
expect(css).toContain(COLOR_SCHEME_ROOT_DECL);
|
|
116
|
+
expect(css).toContain(COLOR_SCHEME_LIGHT_DECL);
|
|
117
|
+
expect(css).toContain(COLOR_SCHEME_DARK_DECL);
|
|
118
|
+
|
|
119
|
+
// ...and specifically inside @layer astryx-theme, not @layer reset (the
|
|
120
|
+
// declaration must sit alongside the light-dark() token/component output
|
|
121
|
+
// it resolves, not the zero-specificity prose defaults).
|
|
122
|
+
const themeLayerStart = css.indexOf('@layer astryx-theme');
|
|
123
|
+
expect(themeLayerStart).toBeGreaterThanOrEqual(0);
|
|
124
|
+
const themeLayerBody = css.slice(themeLayerStart);
|
|
125
|
+
expect(themeLayerBody).toContain(COLOR_SCHEME_ROOT_DECL);
|
|
126
|
+
expect(themeLayerBody).toContain(COLOR_SCHEME_LIGHT_DECL);
|
|
127
|
+
expect(themeLayerBody).toContain(COLOR_SCHEME_DARK_DECL);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('omits all color-scheme rules for a theme with no light-dark() tokens', () => {
|
|
131
|
+
const project = path.join(tmpDir, 'project');
|
|
132
|
+
const themesDir = path.join(project, 'themes');
|
|
133
|
+
const themeFile = writeTheme(themesDir, 'no-light-dark', {
|
|
134
|
+
'--color-accent': '#0077B6',
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const result = runCli(
|
|
138
|
+
['theme', 'build', path.relative(project, themeFile)],
|
|
139
|
+
project,
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
expect(result.code).toBe(0);
|
|
143
|
+
|
|
144
|
+
const cssPath = path.join(themesDir, 'no-light-dark.css');
|
|
145
|
+
expect(fs.existsSync(cssPath)).toBe(true);
|
|
146
|
+
const css = fs.readFileSync(cssPath, 'utf-8');
|
|
147
|
+
|
|
148
|
+
expect(css).not.toContain('light-dark(');
|
|
149
|
+
expect(css).not.toContain(COLOR_SCHEME_ROOT_DECL);
|
|
150
|
+
expect(css).not.toContain(COLOR_SCHEME_LIGHT_DECL);
|
|
151
|
+
expect(css).not.toContain(COLOR_SCHEME_DARK_DECL);
|
|
152
|
+
});
|
|
153
|
+
});
|
|
@@ -939,8 +939,15 @@ export function registerTheme(program) {
|
|
|
939
939
|
if (component.length > 0) {
|
|
940
940
|
const componentInner = component.join('\n\n');
|
|
941
941
|
const componentScope = `@scope (${scopeSelector}) to (${scopeTo}) {\n${componentInner}\n}`;
|
|
942
|
+
// light-dark() needs a color-scheme declaration in this bundle, but a
|
|
943
|
+
// bare `:root { color-scheme: light dark }` outranks reset.css's
|
|
944
|
+
// `html[data-theme]` mapping (astryx-theme layer comes after reset),
|
|
945
|
+
// silently defeating `<Theme mode>` forcing on <html>. Mirror the
|
|
946
|
+
// attribute-keyed mapping so the declaration follows the active mode.
|
|
942
947
|
const colorSchemeDecl = componentScope.includes('light-dark(')
|
|
943
|
-
? ' :root { color-scheme: light dark; }\n
|
|
948
|
+
? ' :root { color-scheme: light dark; }\n' +
|
|
949
|
+
' html[data-theme="light"] { color-scheme: light; }\n' +
|
|
950
|
+
' html[data-theme="dark"] { color-scheme: dark; }\n\n'
|
|
944
951
|
: '';
|
|
945
952
|
cssParts.push(
|
|
946
953
|
`@layer astryx-theme {\n${colorSchemeDecl}${componentScope}\n}`,
|
|
@@ -28,20 +28,10 @@ import * as fs from 'node:fs';
|
|
|
28
28
|
import * as path from 'node:path';
|
|
29
29
|
import * as os from 'node:os';
|
|
30
30
|
import {fileURLToPath} from 'node:url';
|
|
31
|
+
import {ensureCoreBuilt} from './ensure-core-built.mjs';
|
|
31
32
|
|
|
32
33
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
33
34
|
const CLI_BIN = path.resolve(__dirname, '../../bin/astryx.mjs');
|
|
34
|
-
const REPO_ROOT = path.resolve(__dirname, '../../../..');
|
|
35
|
-
const CORE_THEME_ENTRY = path.join(
|
|
36
|
-
REPO_ROOT,
|
|
37
|
-
'packages/core/dist/theme/index.js',
|
|
38
|
-
);
|
|
39
|
-
// The fix reads core's shipped component declarations to decide whether an
|
|
40
|
-
// interface is augmentable; those .d.ts files come from the same core build.
|
|
41
|
-
const CORE_BUTTON_DTS = path.join(
|
|
42
|
-
REPO_ROOT,
|
|
43
|
-
'packages/core/dist/Button/index.d.ts',
|
|
44
|
-
);
|
|
45
35
|
|
|
46
36
|
function runCli(args, cwd) {
|
|
47
37
|
try {
|
|
@@ -68,14 +58,13 @@ function writeTheme(dir, contents) {
|
|
|
68
58
|
return file;
|
|
69
59
|
}
|
|
70
60
|
|
|
61
|
+
// Build core through the shared lock helper — this suite previously ran its
|
|
62
|
+
// own unguarded `if (!exists) pnpm -F core build`, and when Vitest scheduled
|
|
63
|
+
// it alongside the other build-theme suites on a fresh checkout, the
|
|
64
|
+
// concurrent builds collided on packages/core/dist (core's build starts by
|
|
65
|
+
// wiping dist), nondeterministically breaking whichever suite was mid-read.
|
|
71
66
|
beforeAll(() => {
|
|
72
|
-
|
|
73
|
-
execFileSync('pnpm', ['-F', '@astryxdesign/core', 'build'], {
|
|
74
|
-
cwd: REPO_ROOT,
|
|
75
|
-
stdio: 'pipe',
|
|
76
|
-
timeout: 180_000,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
67
|
+
ensureCoreBuilt();
|
|
79
68
|
}, 200_000);
|
|
80
69
|
|
|
81
70
|
let tmpDir;
|
|
@@ -2,34 +2,36 @@
|
|
|
2
2
|
|
|
3
3
|
'use client';
|
|
4
4
|
|
|
5
|
-
import {Collapsible} from '@astryxdesign/core/Collapsible';
|
|
5
|
+
import {Collapsible, CollapsibleGroup} from '@astryxdesign/core/Collapsible';
|
|
6
6
|
import {Divider} from '@astryxdesign/core/Divider';
|
|
7
7
|
import {Text} from '@astryxdesign/core/Text';
|
|
8
8
|
import {VStack} from '@astryxdesign/core/Layout';
|
|
9
9
|
|
|
10
10
|
export default function CollapsibleWithoutCard() {
|
|
11
11
|
return (
|
|
12
|
-
<
|
|
13
|
-
<
|
|
14
|
-
<
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
12
|
+
<CollapsibleGroup type="single" defaultValue="deployment">
|
|
13
|
+
<VStack gap={3} style={{width: '100%', maxWidth: 400}}>
|
|
14
|
+
<Collapsible trigger="Deployment Details" value="deployment">
|
|
15
|
+
<Text type="body">
|
|
16
|
+
Last deployed on April 18, 2026 at 3:42 PM by Sarah Chen. Build
|
|
17
|
+
duration was 2m 14s with zero warnings.
|
|
18
|
+
</Text>
|
|
19
|
+
</Collapsible>
|
|
20
|
+
<Divider />
|
|
21
|
+
<Collapsible trigger="Environment Variables" value="environment">
|
|
22
|
+
<Text type="body">
|
|
23
|
+
12 variables configured. Last updated March 30, 2026. All secrets
|
|
24
|
+
are encrypted at rest with AES-256.
|
|
25
|
+
</Text>
|
|
26
|
+
</Collapsible>
|
|
27
|
+
<Divider />
|
|
28
|
+
<Collapsible trigger="Build Logs" value="logs">
|
|
29
|
+
<Text type="body">
|
|
30
|
+
Build completed successfully. 847 modules compiled, 0 errors, 0
|
|
31
|
+
warnings. Bundle size: 142 KB gzipped.
|
|
32
|
+
</Text>
|
|
33
|
+
</Collapsible>
|
|
34
|
+
</VStack>
|
|
35
|
+
</CollapsibleGroup>
|
|
34
36
|
);
|
|
35
37
|
}
|
|
@@ -6,7 +6,7 @@ export const doc = {
|
|
|
6
6
|
name: 'Incident Console',
|
|
7
7
|
displayName: 'Incident Console',
|
|
8
8
|
description:
|
|
9
|
-
'On-call incident response console: grouped dense incident rows with severity dots, PowerSearch filtering, status segmented control, and a resizable inspector panel with metadata and timeline. Frame-first tracker archetype
|
|
9
|
+
'On-call incident response console: grouped dense incident rows with severity dots, PowerSearch filtering, status segmented control, and a resizable inspector panel with metadata and timeline. Frame-first tracker archetype: rows, not cards.',
|
|
10
10
|
isReady: false,
|
|
11
11
|
category: 'Tools - Incident Console',
|
|
12
12
|
};
|
|
@@ -6,7 +6,7 @@ export const doc = {
|
|
|
6
6
|
name: 'Messaging Shell',
|
|
7
7
|
displayName: 'Messaging Shell',
|
|
8
8
|
description:
|
|
9
|
-
'Slack-style messaging shell with a four-column frame (workspace rail, channel sidebar, message stream, thread panel) built on the Chat component family
|
|
9
|
+
'Slack-style messaging shell with a four-column frame (workspace rail, channel sidebar, message stream, thread panel) built on the Chat component family: dense rows, zero cards.',
|
|
10
10
|
isReady: false,
|
|
11
11
|
category: 'Shell - Messaging',
|
|
12
12
|
};
|
|
@@ -153,10 +153,6 @@ const fmt = (n: number) => `$${n.toFixed(2)}`;
|
|
|
153
153
|
// :root by `@astryxdesign/core/astryx.css`). No StyleX compiler required.
|
|
154
154
|
|
|
155
155
|
const fullWidth: CSSProperties = {width: '100%'};
|
|
156
|
-
// LayoutContent clips overflow by default, which traps position:sticky
|
|
157
|
-
// children (the sticky order summary). With height="auto" the page scrolls
|
|
158
|
-
// at the window, so let overflow be visible here so sticky can pin.
|
|
159
|
-
const visibleOverflow: CSSProperties = {overflow: 'visible'};
|
|
160
156
|
// Form column flex-basis so the two checkout columns share width evenly.
|
|
161
157
|
const formColBasis: CSSProperties = {flexBasis: 0};
|
|
162
158
|
// Space the Order Summary content below its collapsible trigger title.
|
|
@@ -266,9 +262,9 @@ export default function PaymentFormPage() {
|
|
|
266
262
|
|
|
267
263
|
return (
|
|
268
264
|
<Layout
|
|
269
|
-
height="
|
|
265
|
+
height="fill"
|
|
270
266
|
content={
|
|
271
|
-
<LayoutContent padding={0}
|
|
267
|
+
<LayoutContent padding={0}>
|
|
272
268
|
<Center axis="horizontal">
|
|
273
269
|
<Section
|
|
274
270
|
variant="transparent"
|
|
@@ -3,12 +3,7 @@
|
|
|
3
3
|
'use client';
|
|
4
4
|
|
|
5
5
|
import {useState} from 'react';
|
|
6
|
-
import {
|
|
7
|
-
VStack,
|
|
8
|
-
HStack,
|
|
9
|
-
Layout,
|
|
10
|
-
LayoutContent,
|
|
11
|
-
} from '@astryxdesign/core/Layout';
|
|
6
|
+
import {VStack, HStack, Layout, LayoutContent} from '@astryxdesign/core/Layout';
|
|
12
7
|
import {Center} from '@astryxdesign/core/Center';
|
|
13
8
|
import {Grid} from '@astryxdesign/core/Grid';
|
|
14
9
|
import {Text, Heading} from '@astryxdesign/core/Text';
|
|
@@ -203,10 +198,7 @@ function ProductInfo() {
|
|
|
203
198
|
<VStack gap={2}>
|
|
204
199
|
<Text type="label">Finish</Text>
|
|
205
200
|
<VStack hAlign="start">
|
|
206
|
-
<SegmentedControl
|
|
207
|
-
value={finish}
|
|
208
|
-
onChange={setFinish}
|
|
209
|
-
label="Finish">
|
|
201
|
+
<SegmentedControl value={finish} onChange={setFinish} label="Finish">
|
|
210
202
|
{FINISHES.map(f => (
|
|
211
203
|
<SegmentedControlItem
|
|
212
204
|
key={f.value}
|
|
@@ -286,7 +278,7 @@ export default function ProductDetailTemplate() {
|
|
|
286
278
|
|
|
287
279
|
return (
|
|
288
280
|
<Layout
|
|
289
|
-
height="
|
|
281
|
+
height="fill"
|
|
290
282
|
contentWidth={1200}
|
|
291
283
|
content={
|
|
292
284
|
<LayoutContent padding={6}>
|