@astryxdesign/cli 0.7.1-canary.ff40b78 → 0.7.2-canary.07f97c6
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 +35 -0
- package/api/build/_adapter.d.mts +1 -0
- package/api/build/_adapter.mjs +7 -0
- package/api/build/build.mjs +4 -1
- package/api/component/component.test.mjs +357 -184
- package/api/search/search.mjs +12 -0
- package/api/template/table-filter-view-tabs.test.mjs +45 -0
- package/api/theme/build/build.core-on-demand.test.mjs +113 -0
- package/api/theme/build/build.d.mts +13 -13
- package/api/theme/build/build.mjs +72 -37
- package/assets/docs/getting-started.doc.mjs +0 -10
- package/assets/docs/styling-overview.doc.mjs +54 -15
- package/assets/docs/tree/migration-setup.doc.mjs +31 -6
- package/assets/docs/tree/responsive.doc.mjs +37 -0
- package/assets/docs/tree/tailwind.doc.mjs +12 -0
- package/assets/docs/tree/tokens-and-setup.doc.mjs +3 -2
- package/assets/docs/tree/tokens-syntax.doc.mjs +20 -0
- package/assets/docs/tree/tokens.doc.mjs +1 -1
- package/assets/templates/blocks/components/CommandPalette/CommandPaletteAsyncSearch.tsx +6 -1
- package/assets/templates/blocks/components/Drawer/DrawerForm.doc.mjs +24 -0
- package/assets/templates/blocks/components/Drawer/DrawerForm.tsx +62 -0
- package/assets/templates/blocks/components/Drawer/DrawerScrim.doc.mjs +22 -0
- package/assets/templates/blocks/components/Drawer/DrawerScrim.tsx +68 -0
- package/assets/templates/blocks/components/Drawer/DrawerShowcase.doc.mjs +22 -0
- package/assets/templates/blocks/components/Drawer/DrawerShowcase.tsx +41 -0
- package/assets/templates/blocks/components/Drawer/DrawerStart.doc.mjs +21 -0
- package/assets/templates/blocks/components/Drawer/DrawerStart.tsx +41 -0
- package/assets/templates/blocks/components/Drawer/DrawerWidths.doc.mjs +22 -0
- package/assets/templates/blocks/components/Drawer/DrawerWidths.tsx +54 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.doc.mjs +15 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderShowcase.tsx +73 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.doc.mjs +22 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderSubtitleEndContent.tsx +49 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.doc.mjs +21 -0
- package/assets/templates/blocks/components/DrawerHeader/DrawerHeaderWithCloseButton.tsx +42 -0
- package/assets/templates/pages/detail-page/page.tsx +3 -3
- package/assets/templates/pages/table-filter/page.tsx +3 -2
- package/assets/templates/pages/table-inbox/page.tsx +10 -8
- package/assets/templates/themes/butter/butterTheme.ts +53 -11
- package/assets/templates/themes/chocolate/chocolateTheme.ts +29 -5
- package/assets/templates/themes/gothic/gothicTheme.ts +44 -9
- package/assets/templates/themes/stone/stoneTheme.ts +58 -11
- package/assets/templates/themes/y2k/y2kTheme.ts +60 -10
- package/authoring/doctypes/base/type.ts +6 -0
- package/authoring/doctypes/component/component.doc.mjs +2 -2
- package/clients/cli/commands/build-theme.mjs +32 -4
- package/clients/cli/commands/build-theme.watch.test.mjs +63 -2
- package/clients/cli/lib/component-format.mjs +5 -1
- package/foundation/discovery/component-discovery.mjs +27 -26
- package/foundation/discovery/hook-discovery.mjs +13 -12
- package/foundation/fs/listing-cache.d.mts +36 -0
- package/foundation/fs/listing-cache.mjs +95 -0
- package/foundation/fs/listing-cache.test.mjs +88 -0
- package/foundation/fs/paths.mjs +3 -2
- package/package.json +10 -10
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file The theme build imports Core when a build runs, not when the CLI starts.
|
|
5
|
+
*
|
|
6
|
+
* The CLI loads the theme build module for every command, and Core's root
|
|
7
|
+
* entry pulls in all of Core and React. So a command that builds no theme must
|
|
8
|
+
* not ask for either, or `astryx --version` pays for them whenever a Core is
|
|
9
|
+
* installed. A resolve hook in a real subprocess records every request for
|
|
10
|
+
* Core or React and the module that made it, whether or not the request
|
|
11
|
+
* resolves.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import {afterAll, beforeAll, describe, expect, it} from 'vitest';
|
|
15
|
+
import {spawnSync} from 'node:child_process';
|
|
16
|
+
import * as fs from 'node:fs';
|
|
17
|
+
import * as os from 'node:os';
|
|
18
|
+
import * as path from 'node:path';
|
|
19
|
+
import {fileURLToPath, pathToFileURL} from 'node:url';
|
|
20
|
+
|
|
21
|
+
const BIN = fileURLToPath(
|
|
22
|
+
new URL('../../../clients/cli/bin/astryx.mjs', import.meta.url),
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
/** @type {string} */
|
|
26
|
+
let dir;
|
|
27
|
+
/** @type {string} */
|
|
28
|
+
let register;
|
|
29
|
+
/** @type {string} */
|
|
30
|
+
let log;
|
|
31
|
+
|
|
32
|
+
beforeAll(() => {
|
|
33
|
+
dir = fs.mkdtempSync(path.join(os.tmpdir(), 'astryx-core-on-demand-'));
|
|
34
|
+
log = path.join(dir, 'requests.jsonl');
|
|
35
|
+
const hooks = path.join(dir, 'hooks.mjs');
|
|
36
|
+
fs.writeFileSync(
|
|
37
|
+
hooks,
|
|
38
|
+
[
|
|
39
|
+
"import {appendFileSync} from 'node:fs';",
|
|
40
|
+
`const LOG = ${JSON.stringify(log)};`,
|
|
41
|
+
'const WATCHED = /^(?:@astryxdesign\\/core|react|react-dom)(?:\\/|$)/;',
|
|
42
|
+
'export async function resolve(specifier, context, nextResolve) {',
|
|
43
|
+
' if (WATCHED.test(specifier)) {',
|
|
44
|
+
' const parent = context.parentURL ?? null;',
|
|
45
|
+
" appendFileSync(LOG, JSON.stringify({specifier, parent}) + '\\n');",
|
|
46
|
+
' }',
|
|
47
|
+
' return nextResolve(specifier, context);',
|
|
48
|
+
'}',
|
|
49
|
+
'',
|
|
50
|
+
].join('\n'),
|
|
51
|
+
);
|
|
52
|
+
register = path.join(dir, 'register.mjs');
|
|
53
|
+
fs.writeFileSync(
|
|
54
|
+
register,
|
|
55
|
+
`import {register} from 'node:module';\nregister(${JSON.stringify(pathToFileURL(hooks).href)});\n`,
|
|
56
|
+
);
|
|
57
|
+
// A plain theme object: the file itself never imports Core, so a request for
|
|
58
|
+
// Core can only come from the build.
|
|
59
|
+
fs.writeFileSync(
|
|
60
|
+
path.join(dir, 'ocean.mjs'),
|
|
61
|
+
"export default {name: 'ocean', tokens: {'--color-bg': '#0a0a0a'}};\n",
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
afterAll(() => {
|
|
66
|
+
fs.rmSync(dir, {recursive: true, force: true});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Run the CLI and return each Core or React specifier it asked for, mapped to
|
|
71
|
+
* the first module that asked.
|
|
72
|
+
* @param {string[]} args
|
|
73
|
+
* @returns {{status: number | null, requested: Record<string, string | null>}}
|
|
74
|
+
*/
|
|
75
|
+
function run(args) {
|
|
76
|
+
fs.rmSync(log, {force: true});
|
|
77
|
+
const res = spawnSync(
|
|
78
|
+
process.execPath,
|
|
79
|
+
['--import', pathToFileURL(register).href, BIN, ...args],
|
|
80
|
+
{cwd: dir, encoding: 'utf-8', timeout: 20_000},
|
|
81
|
+
);
|
|
82
|
+
/** @type {Record<string, string | null>} */
|
|
83
|
+
const requested = {};
|
|
84
|
+
const lines = fs.existsSync(log)
|
|
85
|
+
? fs.readFileSync(log, 'utf-8').split('\n').filter(Boolean)
|
|
86
|
+
: [];
|
|
87
|
+
for (const line of lines) {
|
|
88
|
+
const {specifier, parent} = JSON.parse(line);
|
|
89
|
+
if (!(specifier in requested)) requested[specifier] = parent;
|
|
90
|
+
}
|
|
91
|
+
return {status: res.status, requested};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
describe('theme build imports Core on demand', () => {
|
|
95
|
+
it('astryx --version asks for neither Core nor React', () => {
|
|
96
|
+
const {status, requested} = run(['--version']);
|
|
97
|
+
expect(status).toBe(0);
|
|
98
|
+
expect(requested).toEqual({});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('theme build imports Core from the theme build module', () => {
|
|
102
|
+
const {requested} = run([
|
|
103
|
+
'theme',
|
|
104
|
+
'build',
|
|
105
|
+
'ocean.mjs',
|
|
106
|
+
'--check',
|
|
107
|
+
'--json',
|
|
108
|
+
]);
|
|
109
|
+
expect(requested['@astryxdesign/core/theme']).toMatch(
|
|
110
|
+
/\/api\/theme\/build\/build\.mjs$/,
|
|
111
|
+
);
|
|
112
|
+
});
|
|
113
|
+
});
|
|
@@ -163,6 +163,19 @@ export function themeBuildFamily(files: string[], options: {
|
|
|
163
163
|
checked?: undefined;
|
|
164
164
|
};
|
|
165
165
|
}>;
|
|
166
|
+
/**
|
|
167
|
+
* The bindings one Core provides: the namespaces interception spreads, the
|
|
168
|
+
* functions the build calls, and why the import failed, if it did.
|
|
169
|
+
*/
|
|
170
|
+
export type CoreBindings = {
|
|
171
|
+
themeModule: any;
|
|
172
|
+
rootModule: any;
|
|
173
|
+
importError: any;
|
|
174
|
+
defineTheme: any;
|
|
175
|
+
generateThemeRulesSplit: any;
|
|
176
|
+
generateOnMediaCSS: any;
|
|
177
|
+
generateAdaptationCSS: any;
|
|
178
|
+
};
|
|
166
179
|
/**
|
|
167
180
|
* How one `prop:value` pair on a component target is classified — the single
|
|
168
181
|
* vocabulary both the root and adaptation paths reason in.
|
|
@@ -210,16 +223,3 @@ export type ThemeBuildTrailer = {
|
|
|
210
223
|
*/
|
|
211
224
|
fontNotices: string[];
|
|
212
225
|
};
|
|
213
|
-
/**
|
|
214
|
-
* The bindings one Core provides: the namespaces interception spreads, the
|
|
215
|
-
* functions the build calls, and why the import failed, if it did.
|
|
216
|
-
*/
|
|
217
|
-
export type CoreBindings = {
|
|
218
|
-
themeModule: any;
|
|
219
|
-
rootModule: any;
|
|
220
|
-
importError: any;
|
|
221
|
-
defineTheme: any;
|
|
222
|
-
generateThemeRulesSplit: any;
|
|
223
|
-
generateOnMediaCSS: any;
|
|
224
|
-
generateAdaptationCSS: any;
|
|
225
|
-
};
|
|
@@ -37,6 +37,10 @@
|
|
|
37
37
|
* general compatibility scheme for every export an arbitrary older core might
|
|
38
38
|
* lack.
|
|
39
39
|
*
|
|
40
|
+
* Core is imported on first use, never when this module loads: the CLI loads
|
|
41
|
+
* this module for every command, and Core's root entry pulls in all of Core
|
|
42
|
+
* and React.
|
|
43
|
+
*
|
|
40
44
|
* With `{check: true}`, it compiles the same outputs in memory but writes
|
|
41
45
|
* nothing: it compares each generated file against what is on disk (ignoring
|
|
42
46
|
* only the volatile `@generated` `Command:` line) and returns a
|
|
@@ -91,6 +95,8 @@ import {resolveIconImports} from './icon-imports.mjs';
|
|
|
91
95
|
// action). A built, resolvable `@astryxdesign/core` is a hard requirement.
|
|
92
96
|
// A built, resolvable `@astryxdesign/core` is a hard requirement. These are
|
|
93
97
|
// populated from a dynamic import (a runtime boundary), so `any` is intentional.
|
|
98
|
+
// That import runs the first time a build needs Core (see `loadCliCore`), not
|
|
99
|
+
// when this module loads.
|
|
94
100
|
//
|
|
95
101
|
// The CLI and core are independently versioned optional peers, so this import
|
|
96
102
|
// can succeed against a core OLDER than the CLI. Only the exports every theme
|
|
@@ -120,27 +126,6 @@ import {resolveIconImports} from './icon-imports.mjs';
|
|
|
120
126
|
*/
|
|
121
127
|
/** @type {any} */ let _coreRootModule = null;
|
|
122
128
|
/** @type {any} */ let _coreImportError = null;
|
|
123
|
-
try {
|
|
124
|
-
const coreTheme = await import('@astryxdesign/core/theme');
|
|
125
|
-
_coreThemeModule = coreTheme;
|
|
126
|
-
_defineTheme = coreTheme.defineTheme;
|
|
127
|
-
_generateThemeRulesSplit = coreTheme.generateThemeRulesSplit;
|
|
128
|
-
_generateOnMediaCSS = coreTheme.generateOnMediaCSS;
|
|
129
|
-
_generateAdaptationCSS = coreTheme.generateAdaptationCSS;
|
|
130
|
-
try {
|
|
131
|
-
_coreRootModule = await import('@astryxdesign/core');
|
|
132
|
-
} catch {
|
|
133
|
-
// A core without a usable root entry still builds themes; interception
|
|
134
|
-
// falls back to the theme namespace for the root specifier.
|
|
135
|
-
}
|
|
136
|
-
} catch (e) {
|
|
137
|
-
// Capture the reason so the theme action can surface a precise, actionable
|
|
138
|
-
// error. We don't throw here: this module is imported eagerly by the CLI
|
|
139
|
-
// entrypoint for every command, and a throw at load time would break
|
|
140
|
-
// unrelated commands (the entry wraps loads in try/catch and degrades the
|
|
141
|
-
// command to a stub). The hard failure happens when `theme build` runs.
|
|
142
|
-
_coreImportError = e;
|
|
143
|
-
}
|
|
144
129
|
|
|
145
130
|
/**
|
|
146
131
|
* The bindings one Core provides: the namespaces interception spreads, the
|
|
@@ -157,19 +142,65 @@ try {
|
|
|
157
142
|
*/
|
|
158
143
|
|
|
159
144
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
145
|
+
* Import the CLI's own Core: the `@astryxdesign/core` this module resolves.
|
|
146
|
+
* Never throws. A failed import is kept as `importError`, so the build can
|
|
147
|
+
* surface a precise, actionable error when it runs.
|
|
148
|
+
* @returns {Promise<CoreBindings>}
|
|
163
149
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
150
|
+
async function importCliCore() {
|
|
151
|
+
/** @type {CoreBindings} */
|
|
152
|
+
const core = {
|
|
153
|
+
themeModule: null,
|
|
154
|
+
rootModule: null,
|
|
155
|
+
importError: null,
|
|
156
|
+
defineTheme: null,
|
|
157
|
+
generateThemeRulesSplit: null,
|
|
158
|
+
generateOnMediaCSS: null,
|
|
159
|
+
generateAdaptationCSS: null,
|
|
160
|
+
};
|
|
161
|
+
try {
|
|
162
|
+
const coreTheme = await import('@astryxdesign/core/theme');
|
|
163
|
+
core.themeModule = coreTheme;
|
|
164
|
+
core.defineTheme = coreTheme.defineTheme;
|
|
165
|
+
core.generateThemeRulesSplit = coreTheme.generateThemeRulesSplit;
|
|
166
|
+
core.generateOnMediaCSS = coreTheme.generateOnMediaCSS;
|
|
167
|
+
core.generateAdaptationCSS = coreTheme.generateAdaptationCSS;
|
|
168
|
+
try {
|
|
169
|
+
core.rootModule = await import('@astryxdesign/core');
|
|
170
|
+
} catch {
|
|
171
|
+
// A core without a usable root entry still builds themes; interception
|
|
172
|
+
// falls back to the theme namespace for the root specifier.
|
|
173
|
+
}
|
|
174
|
+
} catch (e) {
|
|
175
|
+
// Capture the reason so the theme action can surface a precise, actionable
|
|
176
|
+
// error. The hard failure happens when `theme build` runs.
|
|
177
|
+
core.importError = e;
|
|
178
|
+
}
|
|
179
|
+
return core;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* The CLI's own Core, imported once, the first time a build needs it. The CLI
|
|
184
|
+
* loads this module for every command, and Core's root entry loads all of Core
|
|
185
|
+
* and React, so an import at module load would make every command
|
|
186
|
+
* (`--version` included) pay for that whenever a Core resolves.
|
|
187
|
+
* @type {Promise<CoreBindings> | null}
|
|
188
|
+
*/
|
|
189
|
+
let _cliCorePromise = null;
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The CLI's own Core, kept so each build can choose between it and the
|
|
193
|
+
* project's installed Core. The first call also points the build at it, so a
|
|
194
|
+
* step that runs before any build has chosen a Core reads the CLI's own.
|
|
195
|
+
* @returns {Promise<CoreBindings>}
|
|
196
|
+
*/
|
|
197
|
+
function loadCliCore() {
|
|
198
|
+
_cliCorePromise ??= importCliCore().then(core => {
|
|
199
|
+
setCore(core);
|
|
200
|
+
return core;
|
|
201
|
+
});
|
|
202
|
+
return _cliCorePromise;
|
|
203
|
+
}
|
|
173
204
|
|
|
174
205
|
/**
|
|
175
206
|
* Point the build at one Core: the module-level bindings every step reads.
|
|
@@ -248,13 +279,14 @@ function realOrSelf(file) {
|
|
|
248
279
|
* repository, a bare directory), the same Core, or one that does not load.
|
|
249
280
|
*
|
|
250
281
|
* @param {string} cwd
|
|
282
|
+
* @param {CoreBindings} cliCore - The CLI's own Core, from {@link loadCliCore}.
|
|
251
283
|
* @returns {Promise<CoreBindings | null>}
|
|
252
284
|
*/
|
|
253
|
-
async function loadProjectCore(cwd) {
|
|
285
|
+
async function loadProjectCore(cwd, cliCore) {
|
|
254
286
|
const dir = findInstalledPackage(cwd, '@astryxdesign/core');
|
|
255
287
|
const themeFile = dir ? importTarget(dir, './theme') : null;
|
|
256
288
|
if (!dir || !themeFile) return null;
|
|
257
|
-
if (
|
|
289
|
+
if (cliCore.themeModule) {
|
|
258
290
|
try {
|
|
259
291
|
const own = fileURLToPath(
|
|
260
292
|
import.meta.resolve('@astryxdesign/core/theme'),
|
|
@@ -301,9 +333,10 @@ const _projectCores = new Map();
|
|
|
301
333
|
* @param {string} cwd
|
|
302
334
|
*/
|
|
303
335
|
async function selectCore(cwd) {
|
|
336
|
+
const cliCore = await loadCliCore();
|
|
304
337
|
if (!_projectCores.has(cwd))
|
|
305
|
-
_projectCores.set(cwd, await loadProjectCore(cwd));
|
|
306
|
-
setCore(_projectCores.get(cwd) ??
|
|
338
|
+
_projectCores.set(cwd, await loadProjectCore(cwd, cliCore));
|
|
339
|
+
setCore(_projectCores.get(cwd) ?? cliCore);
|
|
307
340
|
}
|
|
308
341
|
|
|
309
342
|
/**
|
|
@@ -1694,6 +1727,8 @@ export async function validateThemePrivateInputs(
|
|
|
1694
1727
|
);
|
|
1695
1728
|
}
|
|
1696
1729
|
|
|
1730
|
+
// The CLI's own Core, unless a build in this process already chose one.
|
|
1731
|
+
await loadCliCore();
|
|
1697
1732
|
const interception = interceptCore(_coreThemeModule, _coreRootModule);
|
|
1698
1733
|
let theme;
|
|
1699
1734
|
try {
|
|
@@ -185,16 +185,6 @@ const overrides = stylex.create({
|
|
|
185
185
|
'Next.js + Tailwind bridge',
|
|
186
186
|
'[apps/example-nextjs-tailwind](https://github.com/facebook/astryx/tree/main/apps/example-nextjs-tailwind)',
|
|
187
187
|
],
|
|
188
|
-
[
|
|
189
|
-
'Next.js Source',
|
|
190
|
-
'Next.js importing from source',
|
|
191
|
-
'[apps/example-nextjs-source](https://github.com/facebook/astryx/tree/main/apps/example-nextjs-source)',
|
|
192
|
-
],
|
|
193
|
-
[
|
|
194
|
-
'Vite',
|
|
195
|
-
'Vite',
|
|
196
|
-
'[apps/example-vite](https://github.com/facebook/astryx/tree/main/apps/example-vite)',
|
|
197
|
-
],
|
|
198
188
|
[
|
|
199
189
|
'Vite + Tailwind',
|
|
200
190
|
'Vite + Tailwind bridge',
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
* @file `astryx docs styling-overview`
|
|
5
5
|
*
|
|
6
6
|
* One question: "How do I set up CSS?"
|
|
7
|
-
* Three paths, each with its exact imports.
|
|
7
|
+
* Three paths, each with its exact imports. Every path loads the prebuilt
|
|
8
|
+
* stylesheets (spec:AST-080 FR5); none compiles Astryx package source.
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
/** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
|
|
@@ -14,7 +15,7 @@ export const docs = {
|
|
|
14
15
|
title: 'Styling overview',
|
|
15
16
|
category: 'guide',
|
|
16
17
|
description:
|
|
17
|
-
'How to set up CSS — exact imports for three paths: plain, Tailwind, and StyleX
|
|
18
|
+
'How to set up CSS — exact imports for three paths: plain, Tailwind, and StyleX for your own code — plus the stylesheet each Astryx package ships.',
|
|
18
19
|
keywords: [
|
|
19
20
|
'styling',
|
|
20
21
|
'CSS',
|
|
@@ -46,15 +47,15 @@ export const docs = {
|
|
|
46
47
|
"None beyond Tailwind's own.",
|
|
47
48
|
],
|
|
48
49
|
[
|
|
49
|
-
'StyleX
|
|
50
|
-
'
|
|
51
|
-
'Yes \u2014 a StyleX
|
|
50
|
+
'StyleX for your own code',
|
|
51
|
+
'Your own `stylex.create()` styles and swizzled (ejected) components. Astryx itself stays prebuilt.',
|
|
52
|
+
'Yes \u2014 a StyleX plugin for your own code.',
|
|
52
53
|
],
|
|
53
54
|
],
|
|
54
55
|
},
|
|
55
56
|
{
|
|
56
57
|
type: 'prose',
|
|
57
|
-
text: 'All three resolve to the same design tokens and support theming and dark mode. You can mix them in one app.',
|
|
58
|
+
text: 'All three load the same prebuilt Astryx stylesheets, resolve to the same design tokens, and support theming and dark mode. None of them compiles Astryx package source. You can mix them in one app.',
|
|
58
59
|
},
|
|
59
60
|
],
|
|
60
61
|
},
|
|
@@ -117,12 +118,12 @@ export const docs = {
|
|
|
117
118
|
],
|
|
118
119
|
},
|
|
119
120
|
{
|
|
120
|
-
id: 'stylex-
|
|
121
|
-
title: 'StyleX
|
|
121
|
+
id: 'stylex-own-code',
|
|
122
|
+
title: 'StyleX for your own code',
|
|
122
123
|
content: [
|
|
123
124
|
{
|
|
124
125
|
type: 'prose',
|
|
125
|
-
text: 'Only needed when you swizzle a component (`astryx swizzle <Component>`)
|
|
126
|
+
text: 'Only needed when you write your own StyleX (`stylex.create()`) or swizzle a component (`astryx swizzle <Component>`), which copies its StyleX source into your app. The plain path already supports `xstyle` overrides \u2014 this path is for your own StyleX code. Some built-in page templates also use StyleX for layout; if you scaffold one and see "Unexpected stylex.create call at runtime", add the compiler plugin for your bundler below.',
|
|
126
127
|
},
|
|
127
128
|
{
|
|
128
129
|
type: 'code',
|
|
@@ -134,14 +135,13 @@ export const docs = {
|
|
|
134
135
|
type: 'code',
|
|
135
136
|
lang: 'css',
|
|
136
137
|
label: 'globals.css',
|
|
137
|
-
code: `@
|
|
138
|
-
|
|
139
|
-
@import "@astryxdesign/core/reset.css";
|
|
138
|
+
code: `@import "@astryxdesign/core/reset.css";
|
|
139
|
+
@import "@astryxdesign/core/astryx.css";
|
|
140
140
|
@import "@astryxdesign/theme-neutral/theme.css";`,
|
|
141
141
|
},
|
|
142
142
|
{
|
|
143
143
|
type: 'prose',
|
|
144
|
-
text: '
|
|
144
|
+
text: 'Keep `astryx.css`: Astryx component styles always come from the prebuilt stylesheets. Point the StyleX compiler at your own source only, never at `node_modules/@astryxdesign`. Add the plugin for your bundler:',
|
|
145
145
|
},
|
|
146
146
|
{
|
|
147
147
|
type: 'table',
|
|
@@ -149,7 +149,10 @@ export const docs = {
|
|
|
149
149
|
rows: [
|
|
150
150
|
['Webpack', '@stylexjs/webpack-plugin'],
|
|
151
151
|
['Vite / Rollup', '@stylexjs/rollup-plugin'],
|
|
152
|
-
[
|
|
152
|
+
[
|
|
153
|
+
'Babel (any)',
|
|
154
|
+
'@stylexjs/babel-plugin + @stylexjs/postcss-plugin',
|
|
155
|
+
],
|
|
153
156
|
['Next.js (keep next/font)', '@stylexswc/nextjs-plugin'],
|
|
154
157
|
],
|
|
155
158
|
},
|
|
@@ -159,6 +162,37 @@ export const docs = {
|
|
|
159
162
|
},
|
|
160
163
|
],
|
|
161
164
|
},
|
|
165
|
+
{
|
|
166
|
+
id: 'other-packages',
|
|
167
|
+
title: 'Other Astryx packages',
|
|
168
|
+
content: [
|
|
169
|
+
{
|
|
170
|
+
type: 'prose',
|
|
171
|
+
text: 'Every Astryx package whose components carry styles ships its own prebuilt stylesheet. Import it after `astryx.css` for each package you use. All of them place their rules in the same `astryx-base` layer, so your theme overrides win over every package.',
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
type: 'code',
|
|
175
|
+
lang: 'css',
|
|
176
|
+
label: 'globals.css',
|
|
177
|
+
code: `@import "@astryxdesign/core/reset.css";
|
|
178
|
+
@import "@astryxdesign/core/astryx.css";
|
|
179
|
+
@import "@astryxdesign/richtext/richtext.css"; /* Rich Text */
|
|
180
|
+
@import "@astryxdesign/lab/lab.css"; /* Lab */
|
|
181
|
+
@import "@astryxdesign/charts/charts.css"; /* Charts */
|
|
182
|
+
@import "@astryxdesign/theme-neutral/theme.css";`,
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
type: 'table',
|
|
186
|
+
headers: ['Package', 'Stylesheet'],
|
|
187
|
+
rows: [
|
|
188
|
+
['@astryxdesign/core', '@astryxdesign/core/astryx.css'],
|
|
189
|
+
['@astryxdesign/richtext', '@astryxdesign/richtext/richtext.css'],
|
|
190
|
+
['@astryxdesign/lab', '@astryxdesign/lab/lab.css'],
|
|
191
|
+
['@astryxdesign/charts', '@astryxdesign/charts/charts.css'],
|
|
192
|
+
],
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
},
|
|
162
196
|
{
|
|
163
197
|
id: 'what-each-file-does',
|
|
164
198
|
title: 'What each import does',
|
|
@@ -175,7 +209,12 @@ export const docs = {
|
|
|
175
209
|
[
|
|
176
210
|
'astryx.css',
|
|
177
211
|
'astryx-base',
|
|
178
|
-
'
|
|
212
|
+
'Prebuilt component styles. Required on every path.',
|
|
213
|
+
],
|
|
214
|
+
[
|
|
215
|
+
'richtext.css, lab.css, charts.css',
|
|
216
|
+
'astryx-base',
|
|
217
|
+
'Prebuilt styles for each other Astryx package you use. Load after astryx.css.',
|
|
179
218
|
],
|
|
180
219
|
[
|
|
181
220
|
'theme.css',
|
|
@@ -129,15 +129,31 @@ export function AppRoot({children}: {children: React.ReactNode}) {
|
|
|
129
129
|
},
|
|
130
130
|
{
|
|
131
131
|
type: 'prose',
|
|
132
|
-
text: '
|
|
132
|
+
text: 'A layer\'s rank is set by the first stylesheet on the page that names it, so the global CSS file (or a `layers.css` holding only the `@layer` line) must be the first import in the root layout or app entry. Import it before any module that imports Astryx or theme CSS, including the `astryx-themes` module generated by `astryx theme add` and a root component like the `AppRoot` above that imports `theme.css`. If a theme stylesheet loads first, Tailwind preflight overrides Astryx base styles and theme overrides lose.',
|
|
133
133
|
},
|
|
134
134
|
{
|
|
135
135
|
type: 'code',
|
|
136
|
-
lang: '
|
|
137
|
-
label: '
|
|
138
|
-
code:
|
|
136
|
+
lang: 'tsx',
|
|
137
|
+
label: 'Root layout or app entry',
|
|
138
|
+
code: `import './globals.css'; // first: declares the cascade-layer order
|
|
139
139
|
|
|
140
|
-
|
|
140
|
+
import {AppRoot} from './AppRoot';`,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
type: 'prose',
|
|
144
|
+
text: 'On Tailwind v3 there is no preflight.css to import, so wrap the @tailwind base directive in a named layer instead. Keep utilities unlayered so existing app utility classes still win everywhere. Put the `@layer` order line in its own `layers.css` and import it first, before `globals.css`: Next.js (webpack or Turbopack) and other bundlers that hoist CSS imports move the imported files above an inline `@layer` line, so the order would arrive too late.',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
type: 'code',
|
|
148
|
+
lang: 'css',
|
|
149
|
+
label: 'layers.css (imported first)',
|
|
150
|
+
code: `@layer reset, tw-preflight, astryx-base, astryx-theme;`,
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
type: 'code',
|
|
154
|
+
lang: 'css',
|
|
155
|
+
label: 'globals.css (Tailwind v3 coexistence)',
|
|
156
|
+
code: `@import "@astryxdesign/core/reset.css";
|
|
141
157
|
@import "@astryxdesign/core/astryx.css";
|
|
142
158
|
@import "@astryxdesign/theme-neutral/theme.css";
|
|
143
159
|
|
|
@@ -147,6 +163,15 @@ export function AppRoot({children}: {children: React.ReactNode}) {
|
|
|
147
163
|
@tailwind components;
|
|
148
164
|
@tailwind utilities; /* unlayered: legacy utility classes keep winning */`,
|
|
149
165
|
},
|
|
166
|
+
{
|
|
167
|
+
type: 'code',
|
|
168
|
+
lang: 'tsx',
|
|
169
|
+
label: 'Root layout or app entry (Tailwind v3)',
|
|
170
|
+
code: `import './layers.css'; // first: declares the cascade-layer order
|
|
171
|
+
import './globals.css';
|
|
172
|
+
|
|
173
|
+
import {AppRoot} from './AppRoot';`,
|
|
174
|
+
},
|
|
150
175
|
],
|
|
151
176
|
},
|
|
152
177
|
{
|
|
@@ -186,7 +211,7 @@ export function AppRoot({children}: {children: React.ReactNode}) {
|
|
|
186
211
|
type: 'list',
|
|
187
212
|
style: 'unordered',
|
|
188
213
|
items: [
|
|
189
|
-
'Declare the canonical @layer order once, before any @import. With webpack
|
|
214
|
+
'Declare the canonical @layer order once, before any @import. With Next.js (webpack or Turbopack) and other bundlers that hoist CSS imports, the order declaration must live in its own CSS file imported first, such as layers.css, because the bundler hoists @import content above the inline CSS that follows it.',
|
|
190
215
|
'Audit every pre-existing global or reset stylesheet and assign each one to a layer deliberately. Top-level imports without layer() stay unlayered and beat every layer; imports nested inside a layered file inherit that layer.',
|
|
191
216
|
'Remove or demote the app legacy reset. The design system ships its own :where() reset in the lowest layer, so any app reset belongs in that same reset layer and never in a layer above astryx-base.',
|
|
192
217
|
'Layer Tailwind preflight. On Tailwind v4, import preflight.css with layer(base). On Tailwind v3, wrap the @tailwind base directive in a named layer (see the snippet in Theme and CSS Setup). Unlayered preflight overrides theme CSS silently.',
|
|
@@ -21,6 +21,9 @@ export const docs = {
|
|
|
21
21
|
'Dialog',
|
|
22
22
|
'BottomSheet',
|
|
23
23
|
'contract',
|
|
24
|
+
'Grid',
|
|
25
|
+
'columns',
|
|
26
|
+
'minWidth',
|
|
24
27
|
],
|
|
25
28
|
|
|
26
29
|
sections: [
|
|
@@ -94,5 +97,39 @@ const isNarrow = useMediaQuery('(max-width: 1024px)');
|
|
|
94
97
|
},
|
|
95
98
|
],
|
|
96
99
|
},
|
|
100
|
+
{
|
|
101
|
+
id: 'columns-that-reflow',
|
|
102
|
+
title: 'Columns that reflow',
|
|
103
|
+
content: [
|
|
104
|
+
{
|
|
105
|
+
type: 'prose',
|
|
106
|
+
text: 'For columns that reflow on small screens, use `Grid columns={{minWidth, max}}`. A numeric `columns` is exactly N columns at every width and never reflows: `columns={4}` on a 390px phone renders four tracks under 100px wide, and the row overflows the page as soon as their content cannot shrink to fit. `{minWidth: 240, max: 4}` renders at most four columns, each at least 240px, and drops to one full-width column when the container is narrow; `max` is what lets that last column shrink to the container, and `gap` counts toward the room the columns need.',
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
type: 'code',
|
|
110
|
+
lang: 'tsx',
|
|
111
|
+
label: 'Reflowing stat row versus a fixed week row',
|
|
112
|
+
code: `// Reflows: 4 columns on desktop, 3 in a 768px-wide grid, 1 on a phone.
|
|
113
|
+
<Grid columns={{minWidth: 240, max: 4}} gap={3}>
|
|
114
|
+
{stats.map(stat => <StatCard key={stat.id} {...stat} />)}
|
|
115
|
+
</Grid>
|
|
116
|
+
|
|
117
|
+
// Fixed: exactly 7 columns at every width (a number never reflows).
|
|
118
|
+
<Grid columns={7} gap={1}>
|
|
119
|
+
{days.map(day => <DayCell key={day} day={day} />)}
|
|
120
|
+
</Grid>`,
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
type: 'list',
|
|
124
|
+
style: 'unordered',
|
|
125
|
+
items: [
|
|
126
|
+
'`{minWidth}` alone: as many columns as fit at the floor, no cap; a container narrower than `minWidth` overflows, so add `max` for anything that reaches a phone',
|
|
127
|
+
"`{minWidth, repeat: 'fit'}`: empty tracks collapse so present items stretch",
|
|
128
|
+
"A numeric `GridSpan` wider than the grid's current columns adds implicit columns to the whole grid; items placed before and after the span flow into them, and `columns='full'` then covers only the explicit columns. In a reflowing grid keep spans within the smallest count it can reach, or use `'full'`, which adds none",
|
|
129
|
+
'Styling that changes the room columns have to fit changes the count a reflowing shape reaches: a `columnGap` or `gap` step, inline padding on the grid, or `grid-auto-flow: column` through `xstyle`, which places items into extra implicit columns. A `className` rule replaces the computed track list only when it wins the cascade against the generated styles; prefer `xstyle` for overrides',
|
|
130
|
+
],
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
},
|
|
97
134
|
],
|
|
98
135
|
};
|
|
@@ -47,6 +47,18 @@ export const docs = {
|
|
|
47
47
|
type: 'prose',
|
|
48
48
|
text: 'Pre-declare every layer before any imports. This keeps reset lowest, Tailwind preflight above reset, component/theme styles in the middle, and Tailwind utilities last so utility classes on `className` can intentionally override component defaults.',
|
|
49
49
|
},
|
|
50
|
+
{
|
|
51
|
+
type: 'prose',
|
|
52
|
+
text: 'A layer\'s rank is set by the first stylesheet on the page that names it, so this order only holds when `globals.css` loads first. Make it the first import in the root layout or app entry, before any module that imports Astryx or theme CSS. That includes the `astryx-themes` module generated by `astryx theme add` and any root component that imports a theme\'s `theme.css`. If a theme stylesheet loads first, Tailwind preflight overrides Astryx base styles and theme overrides lose. If `globals.css` cannot come first, move the `@layer` line into its own `layers.css` and import that first instead.',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: 'code',
|
|
56
|
+
lang: 'tsx',
|
|
57
|
+
label: 'Root layout or app entry',
|
|
58
|
+
code: `import './globals.css'; // first: declares the cascade-layer order
|
|
59
|
+
|
|
60
|
+
import {themes, defaultThemeSlug} from './astryx-themes';`,
|
|
61
|
+
},
|
|
50
62
|
{
|
|
51
63
|
type: 'code',
|
|
52
64
|
lang: 'tsx',
|
|
@@ -77,7 +77,7 @@ const styles = stylex.create({
|
|
|
77
77
|
content: [
|
|
78
78
|
{
|
|
79
79
|
type: 'prose',
|
|
80
|
-
text: 'Astryx components ship pre-compiled, so consuming the published
|
|
80
|
+
text: 'Astryx components ship pre-compiled: `astryx.css` and each package\'s own stylesheet hold all of their styles, so consuming the published packages needs no StyleX setup. But `astryx swizzle <Component>` copies the raw StyleX *source* into your app, and StyleX source requires a build-time StyleX compiler to produce atomic CSS. Without one the component compiles but renders completely unstyled: no error, no warning. If a swizzled component looks unstyled, a missing StyleX compiler is almost always why. The same applies if you author your own StyleX with `stylex.create()`.',
|
|
81
81
|
},
|
|
82
82
|
{
|
|
83
83
|
type: 'table',
|
|
@@ -105,7 +105,7 @@ const styles = stylex.create({
|
|
|
105
105
|
|
|
106
106
|
export default stylexPlugin({
|
|
107
107
|
rsOptions: {
|
|
108
|
-
// Resolve
|
|
108
|
+
// Resolve the Astryx token modules that swizzled source imports.
|
|
109
109
|
aliases: {'@/*': ['./src/*']},
|
|
110
110
|
unstable_moduleResolution: {type: 'commonJS'},
|
|
111
111
|
},
|
|
@@ -120,6 +120,7 @@ export default stylexPlugin({
|
|
|
120
120
|
'Symptom of a missing compiler: swizzled component renders with no styles, but no build or runtime error.',
|
|
121
121
|
'A Babel config turns off SWC in Next.js; skip it if you need `next/font`.',
|
|
122
122
|
'Pure theming (defineTheme + astryx theme build) needs NO StyleX compiler; only swizzled/authored StyleX source does.',
|
|
123
|
+
'Keep loading `astryx.css` with a StyleX compiler in place. The compiler builds your own and swizzled source only; never add `node_modules/@astryxdesign` to its inputs.',
|
|
123
124
|
],
|
|
124
125
|
},
|
|
125
126
|
],
|
|
@@ -88,6 +88,26 @@ export const docs = {
|
|
|
88
88
|
[
|
|
89
89
|
"--color-syntax-background",
|
|
90
90
|
"var(--color-background-muted)"
|
|
91
|
+
],
|
|
92
|
+
[
|
|
93
|
+
"--color-syntax-added",
|
|
94
|
+
"color-mix(in srgb, var(--color-success-muted) 25%, transparent)"
|
|
95
|
+
],
|
|
96
|
+
[
|
|
97
|
+
"--color-syntax-removed",
|
|
98
|
+
"color-mix(in srgb, var(--color-error-muted) 25%, transparent)"
|
|
99
|
+
],
|
|
100
|
+
[
|
|
101
|
+
"--color-syntax-diff-header",
|
|
102
|
+
"var(--color-background-muted)"
|
|
103
|
+
],
|
|
104
|
+
[
|
|
105
|
+
"--color-syntax-added-marker",
|
|
106
|
+
"var(--color-text-green)"
|
|
107
|
+
],
|
|
108
|
+
[
|
|
109
|
+
"--color-syntax-removed-marker",
|
|
110
|
+
"var(--color-text-red)"
|
|
91
111
|
]
|
|
92
112
|
]
|
|
93
113
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// AUTO-GENERATED — do not edit manually.
|
|
4
4
|
// Run: node scripts/generate-token-docs.mjs
|
|
5
|
-
// Total:
|
|
5
|
+
// Total: 263 tokens across 15 categories.
|
|
6
6
|
|
|
7
7
|
/** @type {import('@astryxdesign/cli/authoring').NamespaceDoc} */
|
|
8
8
|
export const docs = {
|