@astryxdesign/cli 0.6.6-canary.dc3a939 → 0.6.6-canary.dee5096
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/doctor/_adapter.d.mts +7 -0
- package/api/doctor/_adapter.mjs +48 -0
- package/api/doctor/doctor.mjs +5 -3
- package/api/doctor/theme-checks.d.mts +12 -0
- package/api/doctor/theme-checks.mjs +114 -0
- package/api/doctor/theme-checks.test.mjs +142 -1
- package/assets/docs/author-a-theme.doc.mjs +3 -3
- package/assets/docs/styling-overview.doc.mjs +211 -0
- package/assets/docs/theme.doc.mjs +5 -5
- package/assets/docs/use-a-theme.doc.mjs +159 -47
- package/assets/templates/pages/table-comparison/template.doc.mjs +1 -1
- package/authoring/doctypes/template/type.ts +1 -0
- package/clients/cli/commands/docs.test.mjs +1 -1
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/package.json +9 -9
|
@@ -34,6 +34,13 @@ export function discoverDoctorUnmigratedCopies(projectDir: string): import("../.
|
|
|
34
34
|
export function findDoctorCoreDir(projectDir: string): string | null;
|
|
35
35
|
/** @param {string} projectDir @param {string} packageName */
|
|
36
36
|
export function findDoctorInstalledPackage(projectDir: string, packageName: string): string | null;
|
|
37
|
+
/**
|
|
38
|
+
* Names of the `@astryxdesign/theme-*` packages installed in the nearest
|
|
39
|
+
* `node_modules` at or above `cwd`, looking up to six levels.
|
|
40
|
+
* @param {string} cwd
|
|
41
|
+
* @returns {string[]}
|
|
42
|
+
*/
|
|
43
|
+
export function listDoctorThemePackages(cwd: string): string[];
|
|
37
44
|
/** @param {string} file */
|
|
38
45
|
export function readPackageJson(file: string): any;
|
|
39
46
|
export { resolveRecordedTheme } from "../theme/theme.mjs";
|
package/api/doctor/_adapter.mjs
CHANGED
|
@@ -132,6 +132,54 @@ export function findDoctorInstalledPackage(projectDir, packageName) {
|
|
|
132
132
|
return findInstalledPackage(projectDir, packageName);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Names of the `@astryxdesign/theme-*` packages installed in the nearest
|
|
137
|
+
* `node_modules` at or above `cwd`, looking up to six levels.
|
|
138
|
+
* @param {string} cwd
|
|
139
|
+
* @returns {string[]}
|
|
140
|
+
*/
|
|
141
|
+
export function listDoctorThemePackages(cwd) {
|
|
142
|
+
let dir = path.resolve(cwd);
|
|
143
|
+
let nodeModules = null;
|
|
144
|
+
for (let level = 0; level < 6; level++) {
|
|
145
|
+
const candidate = path.join(dir, 'node_modules');
|
|
146
|
+
if (fs.existsSync(candidate)) {
|
|
147
|
+
nodeModules = candidate;
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
const parent = path.dirname(dir);
|
|
151
|
+
if (parent === dir) break;
|
|
152
|
+
dir = parent;
|
|
153
|
+
}
|
|
154
|
+
if (!nodeModules) return [];
|
|
155
|
+
const scopeDir = path.join(nodeModules, '@astryxdesign');
|
|
156
|
+
let entries;
|
|
157
|
+
try {
|
|
158
|
+
entries = fs.readdirSync(scopeDir, {withFileTypes: true});
|
|
159
|
+
} catch {
|
|
160
|
+
return [];
|
|
161
|
+
}
|
|
162
|
+
/** @type {string[]} */
|
|
163
|
+
const names = [];
|
|
164
|
+
for (const entry of entries) {
|
|
165
|
+
if (!entry.name.startsWith('theme-')) continue;
|
|
166
|
+
// pnpm links packages into node_modules/.pnpm, and a symlink entry does
|
|
167
|
+
// not report itself as a directory, so check what it points to.
|
|
168
|
+
let isDirectory = entry.isDirectory();
|
|
169
|
+
if (!isDirectory && entry.isSymbolicLink()) {
|
|
170
|
+
try {
|
|
171
|
+
isDirectory = fs
|
|
172
|
+
.statSync(path.join(scopeDir, entry.name))
|
|
173
|
+
.isDirectory();
|
|
174
|
+
} catch {
|
|
175
|
+
isDirectory = false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (isDirectory) names.push(`@astryxdesign/${entry.name}`);
|
|
179
|
+
}
|
|
180
|
+
return names;
|
|
181
|
+
}
|
|
182
|
+
|
|
135
183
|
/** @param {string} file */
|
|
136
184
|
export function readPackageJson(file) {
|
|
137
185
|
try {
|
package/api/doctor/doctor.mjs
CHANGED
|
@@ -50,7 +50,7 @@ import {
|
|
|
50
50
|
import {typedEdges} from '../docs/node/node.mjs';
|
|
51
51
|
import {detailView, indexView} from '../../foundation/doc-compiler/lenses.mjs';
|
|
52
52
|
import {semverCompare, isValidSemver, satisfiesRange} from '../../foundation/env/semver.mjs';
|
|
53
|
-
import {checkAppThemes} from './theme-checks.mjs';
|
|
53
|
+
import {checkAppThemes, checkThemes} from './theme-checks.mjs';
|
|
54
54
|
|
|
55
55
|
/**
|
|
56
56
|
* @typedef {'pass'|'warn'|'fail'|'info'} DoctorStatus
|
|
@@ -1197,11 +1197,13 @@ export async function runChecks(options = {}) {
|
|
|
1197
1197
|
|
|
1198
1198
|
/** @type {DoctorCheck[]} */
|
|
1199
1199
|
const checks = [];
|
|
1200
|
-
// Run the
|
|
1200
|
+
// Run the theme checks and config check after the environment checks. The
|
|
1201
|
+
// released `themes` check keeps its place, ahead of the app-theme checks.
|
|
1201
1202
|
for (const fn of SYNC_CHECKS) {
|
|
1202
1203
|
checks.push(fn(ctx));
|
|
1203
1204
|
if (fn === checkVersionAlignment) {
|
|
1204
|
-
|
|
1205
|
+
const appThemeChecks = await checkAppThemes(cwd);
|
|
1206
|
+
checks.push(checkThemes(cwd, appThemeChecks), ...appThemeChecks);
|
|
1205
1207
|
checks.push(await checkConfig(ctx));
|
|
1206
1208
|
}
|
|
1207
1209
|
}
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
// @generated by scripts/sync-api-types.mjs from the JSDoc in api/**/*.mjs.
|
|
2
2
|
// DO NOT EDIT — run `pnpm sync:api-types` to regenerate.
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* The `themes` check that every released doctor report carries. Its id is
|
|
6
|
+
* stable, so it stays beside the app-theme checks. Without a generated theme
|
|
7
|
+
* module it reports what it always has: whether an `@astryxdesign/theme-*`
|
|
8
|
+
* package is installed, and whether the app's package.json names a theme in
|
|
9
|
+
* `astryx.theme`. With a generated module it reports the overall result of the
|
|
10
|
+
* app-theme checks.
|
|
11
|
+
* @param {string} cwd
|
|
12
|
+
* @param {DoctorCheck[]} appChecks - the checks {@link checkAppThemes} returned
|
|
13
|
+
* @returns {DoctorCheck}
|
|
14
|
+
*/
|
|
15
|
+
export function checkThemes(cwd: string, appChecks: DoctorCheck[]): DoctorCheck;
|
|
4
16
|
/**
|
|
5
17
|
* Run all ten app-theme checks.
|
|
6
18
|
* @param {string} cwd
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
findDoctorCoreDir,
|
|
18
18
|
findDoctorInstalledPackage,
|
|
19
19
|
isLocalThemeOwner,
|
|
20
|
+
listDoctorThemePackages,
|
|
20
21
|
listProjectSourceFiles,
|
|
21
22
|
planThemeAppWrite,
|
|
22
23
|
readPackageJson,
|
|
@@ -52,6 +53,8 @@ const CHECKS = [
|
|
|
52
53
|
['theme-global-rules', 'Cross-theme global CSS rules'],
|
|
53
54
|
];
|
|
54
55
|
|
|
56
|
+
const APP_THEME_CHECK_IDS = new Set(CHECKS.map(([id]) => id));
|
|
57
|
+
|
|
55
58
|
/**
|
|
56
59
|
* @param {string} message
|
|
57
60
|
* @param {Error|null} [moduleError]
|
|
@@ -385,6 +388,117 @@ function unmigratedCopyCheck(projectDir) {
|
|
|
385
388
|
};
|
|
386
389
|
}
|
|
387
390
|
|
|
391
|
+
/**
|
|
392
|
+
* Whether the app's package.json names a theme in `astryx.theme`.
|
|
393
|
+
* @param {string} cwd
|
|
394
|
+
*/
|
|
395
|
+
function appPackageNamesTheme(cwd) {
|
|
396
|
+
let state;
|
|
397
|
+
try {
|
|
398
|
+
state = readThemeState(cwd);
|
|
399
|
+
} catch {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
const pkg = readPackageJson(state.packageFile);
|
|
403
|
+
return Boolean(pkg?.astryx?.theme);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* The `themes` check that every released doctor report carries. Its id is
|
|
408
|
+
* stable, so it stays beside the app-theme checks. Without a generated theme
|
|
409
|
+
* module it reports what it always has: whether an `@astryxdesign/theme-*`
|
|
410
|
+
* package is installed, and whether the app's package.json names a theme in
|
|
411
|
+
* `astryx.theme`. With a generated module it reports the overall result of the
|
|
412
|
+
* app-theme checks.
|
|
413
|
+
* @param {string} cwd
|
|
414
|
+
* @param {DoctorCheck[]} appChecks - the checks {@link checkAppThemes} returned
|
|
415
|
+
* @returns {DoctorCheck}
|
|
416
|
+
*/
|
|
417
|
+
export function checkThemes(cwd, appChecks) {
|
|
418
|
+
const label = 'Theme packages';
|
|
419
|
+
const managed = appChecks.some(
|
|
420
|
+
check => APP_THEME_CHECK_IDS.has(check.id) && check.status !== 'info',
|
|
421
|
+
);
|
|
422
|
+
if (managed) {
|
|
423
|
+
// A check passes only on its own evidence, so the rollup passes only when
|
|
424
|
+
// every check it summarizes passed. An `info` result here means a check
|
|
425
|
+
// could not prove its evidence.
|
|
426
|
+
const needsWork = appChecks.filter(
|
|
427
|
+
check => check.status === 'fail' || check.status === 'warn',
|
|
428
|
+
);
|
|
429
|
+
const unproven = appChecks.filter(check => check.status === 'info');
|
|
430
|
+
if (needsWork.length > 0) {
|
|
431
|
+
const ids = needsWork.map(check => check.id).join(', ');
|
|
432
|
+
return {
|
|
433
|
+
id: 'themes',
|
|
434
|
+
label,
|
|
435
|
+
status: needsWork.some(check => check.status === 'fail')
|
|
436
|
+
? 'fail'
|
|
437
|
+
: 'warn',
|
|
438
|
+
message:
|
|
439
|
+
needsWork.length === 1
|
|
440
|
+
? `One theme check needs attention: ${ids}.`
|
|
441
|
+
: `${needsWork.length} theme checks need attention: ${ids}.`,
|
|
442
|
+
fix:
|
|
443
|
+
needsWork.length === 1
|
|
444
|
+
? `Follow the fix on the ${ids} check.`
|
|
445
|
+
: `Follow the fix on each of these checks: ${ids}.`,
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
if (unproven.length > 0) {
|
|
449
|
+
const ids = unproven.map(check => check.id).join(', ');
|
|
450
|
+
return {
|
|
451
|
+
id: 'themes',
|
|
452
|
+
label,
|
|
453
|
+
status: 'info',
|
|
454
|
+
message:
|
|
455
|
+
unproven.length === 1
|
|
456
|
+
? `One theme check could not prove its result: ${ids}.`
|
|
457
|
+
: `${unproven.length} theme checks could not prove their results: ${ids}.`,
|
|
458
|
+
fix:
|
|
459
|
+
unproven.length === 1
|
|
460
|
+
? `See the ${ids} check.`
|
|
461
|
+
: `See each of these checks: ${ids}.`,
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
return {
|
|
465
|
+
id: 'themes',
|
|
466
|
+
label,
|
|
467
|
+
status: 'pass',
|
|
468
|
+
message:
|
|
469
|
+
'App themes come from the generated theme module, and every theme check passes.',
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const run = getCliInvocation(cwd);
|
|
474
|
+
const packages = listDoctorThemePackages(cwd);
|
|
475
|
+
if (packages.length === 0) {
|
|
476
|
+
return {
|
|
477
|
+
id: 'themes',
|
|
478
|
+
label,
|
|
479
|
+
status: 'warn',
|
|
480
|
+
message: 'No @astryxdesign/theme-* packages are installed.',
|
|
481
|
+
fix: `Install a theme, e.g. \`npm install @astryxdesign/theme-neutral\`, then add it to the app with \`${run} theme add neutral --import\`.`,
|
|
482
|
+
};
|
|
483
|
+
}
|
|
484
|
+
const names = packages.join(', ');
|
|
485
|
+
if (!appPackageNamesTheme(cwd)) {
|
|
486
|
+
return {
|
|
487
|
+
id: 'themes',
|
|
488
|
+
label,
|
|
489
|
+
status: 'warn',
|
|
490
|
+
message: `Theme package(s) installed (${names}) but no theme appears wired.`,
|
|
491
|
+
fix: `Add one to the app with \`${run} theme add <slug> --import\`.`,
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
return {
|
|
495
|
+
id: 'themes',
|
|
496
|
+
label,
|
|
497
|
+
status: 'pass',
|
|
498
|
+
message: `Theme package(s) installed (${names}); wired via package.json astryx.theme.`,
|
|
499
|
+
};
|
|
500
|
+
}
|
|
501
|
+
|
|
388
502
|
/**
|
|
389
503
|
* Run all ten app-theme checks.
|
|
390
504
|
* @param {string} cwd
|
|
@@ -6,7 +6,8 @@ import {afterEach, describe, expect, it} from 'vitest';
|
|
|
6
6
|
import * as fs from 'node:fs';
|
|
7
7
|
import * as path from 'node:path';
|
|
8
8
|
import {spawnSync} from 'node:child_process';
|
|
9
|
-
import {checkAppThemes} from './theme-checks.mjs';
|
|
9
|
+
import {checkAppThemes, checkThemes} from './theme-checks.mjs';
|
|
10
|
+
import {runChecks} from './doctor.mjs';
|
|
10
11
|
import {themeAdd} from '../theme/add/add.mjs';
|
|
11
12
|
import {themeEject} from '../theme/eject/eject.mjs';
|
|
12
13
|
import {themeBuild} from '../theme/build/build.mjs';
|
|
@@ -140,6 +141,146 @@ afterEach(() => {
|
|
|
140
141
|
}
|
|
141
142
|
});
|
|
142
143
|
|
|
144
|
+
describe('the released themes check', () => {
|
|
145
|
+
/** @param {string} name */
|
|
146
|
+
function emptyApp(name) {
|
|
147
|
+
const dir = fs.mkdtempSync(
|
|
148
|
+
path.join(process.cwd(), `.astryx-doctor-${name}-`),
|
|
149
|
+
);
|
|
150
|
+
dirs.push(dir);
|
|
151
|
+
write(path.join(dir, 'package.json'), '{"name":"app","private":true}\n');
|
|
152
|
+
return dir;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** @param {string} dir @param {string} slug */
|
|
156
|
+
function installThemePackage(dir, slug) {
|
|
157
|
+
write(
|
|
158
|
+
path.join(
|
|
159
|
+
dir,
|
|
160
|
+
'node_modules/@astryxdesign',
|
|
161
|
+
`theme-${slug}`,
|
|
162
|
+
'package.json',
|
|
163
|
+
),
|
|
164
|
+
JSON.stringify({name: `@astryxdesign/theme-${slug}`, version: '1.0.0'}),
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
it('keeps its released id, label, fields, and statuses without a generated theme module', async () => {
|
|
169
|
+
const dir = emptyApp('themes-none');
|
|
170
|
+
expect(checkThemes(dir, await checkAppThemes(dir))).toEqual({
|
|
171
|
+
id: 'themes',
|
|
172
|
+
label: 'Theme packages',
|
|
173
|
+
status: 'warn',
|
|
174
|
+
message: 'No @astryxdesign/theme-* packages are installed.',
|
|
175
|
+
fix: expect.stringContaining('theme add neutral --import'),
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
installThemePackage(dir, 'neutral');
|
|
179
|
+
const unwired = checkThemes(dir, await checkAppThemes(dir));
|
|
180
|
+
expect(unwired).toEqual({
|
|
181
|
+
id: 'themes',
|
|
182
|
+
label: 'Theme packages',
|
|
183
|
+
status: 'warn',
|
|
184
|
+
message:
|
|
185
|
+
'Theme package(s) installed (@astryxdesign/theme-neutral) but no theme appears wired.',
|
|
186
|
+
fix: expect.stringContaining('theme add <slug> --import'),
|
|
187
|
+
});
|
|
188
|
+
expect(unwired.fix).not.toContain('ASTRYX_THEME');
|
|
189
|
+
|
|
190
|
+
write(
|
|
191
|
+
path.join(dir, 'package.json'),
|
|
192
|
+
JSON.stringify({
|
|
193
|
+
name: 'app',
|
|
194
|
+
private: true,
|
|
195
|
+
astryx: {theme: '@astryxdesign/theme-neutral'},
|
|
196
|
+
}),
|
|
197
|
+
);
|
|
198
|
+
expect(checkThemes(dir, await checkAppThemes(dir))).toEqual({
|
|
199
|
+
id: 'themes',
|
|
200
|
+
label: 'Theme packages',
|
|
201
|
+
status: 'pass',
|
|
202
|
+
message:
|
|
203
|
+
'Theme package(s) installed (@astryxdesign/theme-neutral); wired via package.json astryx.theme.',
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
it('reports the overall result of the app-theme checks with a generated module', async () => {
|
|
208
|
+
const healthy = await fixture();
|
|
209
|
+
expect(checkThemes(healthy.dir, await checkAppThemes(healthy.dir))).toEqual(
|
|
210
|
+
{
|
|
211
|
+
id: 'themes',
|
|
212
|
+
label: 'Theme packages',
|
|
213
|
+
status: 'pass',
|
|
214
|
+
message:
|
|
215
|
+
'App themes come from the generated theme module, and every theme check passes.',
|
|
216
|
+
},
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
// A module is loaded once per process, so the broken one is a new fixture.
|
|
220
|
+
const {dir, packageDir} = await fixture();
|
|
221
|
+
write(
|
|
222
|
+
path.join(packageDir, 'dist/ocean.js'),
|
|
223
|
+
`import '@acme/definitely-missing-dep';\nexport const oceanTheme = {name: 'ocean', tokens: {}};\n`,
|
|
224
|
+
);
|
|
225
|
+
expect(checkThemes(dir, await checkAppThemes(dir))).toEqual({
|
|
226
|
+
id: 'themes',
|
|
227
|
+
label: 'Theme packages',
|
|
228
|
+
status: 'fail',
|
|
229
|
+
message: 'One theme check needs attention: theme-owners.',
|
|
230
|
+
fix: 'Follow the fix on the theme-owners check.',
|
|
231
|
+
});
|
|
232
|
+
}, 30_000);
|
|
233
|
+
|
|
234
|
+
it('passes the module rollup only when every summarized check passed', () => {
|
|
235
|
+
/** @param {string} id @param {'pass'|'warn'|'fail'|'info'} status */
|
|
236
|
+
const result = (id, status) => ({id, label: id, status, message: id});
|
|
237
|
+
const passing = [
|
|
238
|
+
result('theme-owners', 'pass'),
|
|
239
|
+
result('theme-module', 'pass'),
|
|
240
|
+
];
|
|
241
|
+
|
|
242
|
+
expect(
|
|
243
|
+
checkThemes(process.cwd(), [
|
|
244
|
+
...passing,
|
|
245
|
+
result('theme-stylesheet-imports', 'info'),
|
|
246
|
+
]),
|
|
247
|
+
).toEqual({
|
|
248
|
+
id: 'themes',
|
|
249
|
+
label: 'Theme packages',
|
|
250
|
+
status: 'info',
|
|
251
|
+
message:
|
|
252
|
+
'One theme check could not prove its result: theme-stylesheet-imports.',
|
|
253
|
+
fix: 'See the theme-stylesheet-imports check.',
|
|
254
|
+
});
|
|
255
|
+
expect(
|
|
256
|
+
checkThemes(process.cwd(), [
|
|
257
|
+
result('theme-owners', 'fail'),
|
|
258
|
+
result('theme-module', 'pass'),
|
|
259
|
+
result('theme-fonts', 'warn'),
|
|
260
|
+
result('theme-global-rules', 'info'),
|
|
261
|
+
]),
|
|
262
|
+
).toMatchObject({
|
|
263
|
+
status: 'fail',
|
|
264
|
+
message: '2 theme checks need attention: theme-owners, theme-fonts.',
|
|
265
|
+
});
|
|
266
|
+
expect(checkThemes(process.cwd(), passing)).toMatchObject({
|
|
267
|
+
status: 'pass',
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
it('appears once in the doctor report, right after version alignment, with and without a module', async () => {
|
|
272
|
+
const {dir} = await fixture();
|
|
273
|
+
for (const cwd of [emptyApp('themes-report'), dir]) {
|
|
274
|
+
const ids = (await runChecks({cwd})).checks.map(item => item.id);
|
|
275
|
+
expect(ids.filter(id => id === 'themes')).toHaveLength(1);
|
|
276
|
+
expect(ids.indexOf('themes')).toBe(ids.indexOf('version-alignment') + 1);
|
|
277
|
+
expect(ids.indexOf('themes')).toBeLessThan(
|
|
278
|
+
ids.findIndex(id => id === 'theme-management' || id === 'theme-owners'),
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
}, 30_000);
|
|
282
|
+
});
|
|
283
|
+
|
|
143
284
|
describe('app-theme doctor checks', () => {
|
|
144
285
|
it('returns ten positive passes for a healthy package theme', async () => {
|
|
145
286
|
const {dir} = await fixture();
|
|
@@ -14,10 +14,10 @@ export const docs = {
|
|
|
14
14
|
id: 'creating-a-custom-theme',
|
|
15
15
|
title: 'Custom themes',
|
|
16
16
|
content: [
|
|
17
|
-
{type: 'prose', text: "
|
|
18
|
-
{type: 'code', lang: 'bash', label: '
|
|
17
|
+
{type: 'prose', text: "Use an installed built theme as the base for ordinary customization. Import it into your source and pass it as `extends` to `defineTheme({extends: importedTheme, ...})`. Build the result, then add the local slug. Only eject when you need to own and maintain a full source fork."},
|
|
18
|
+
{type: 'code', lang: 'bash', label: 'Add to use, eject to fork', code: 'astryx theme list\nastryx theme add stone --import\nastryx theme eject stone\nastryx theme build src/themes/stone/stoneTheme.ts\nastryx theme add stone --import'},
|
|
19
19
|
{type: 'prose', text: "For an annotated map of the whole surface (every defineTheme field, the token families, and the component override syntax, each with the CLI command that prints its reference), run `astryx theme template`. It writes `theme.template.ts` into your project to read and copy from (`astryx init --features theme` writes it as part of project setup)."},
|
|
20
|
-
{type: 'prose', text: 'To apply a theme you created, see {@link generic:use-a-theme}. To generate colors from seed values, see the Palette section below.'},
|
|
20
|
+
{type: 'prose', text: 'To apply a theme you created, see {@link generic:use-a-theme}. To generate colors from seed values, see the Palette section below. Use `theme eject` only when you want an independent source fork that no longer receives the package owner\u2019s updates.'},
|
|
21
21
|
],
|
|
22
22
|
},
|
|
23
23
|
{
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx docs styling-overview`
|
|
5
|
+
*
|
|
6
|
+
* One question: "How do I set up CSS?"
|
|
7
|
+
* Three paths, each with its exact imports.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
|
|
11
|
+
|
|
12
|
+
export const docs = {
|
|
13
|
+
name: 'styling-overview',
|
|
14
|
+
title: 'Styling overview',
|
|
15
|
+
category: 'guide',
|
|
16
|
+
description:
|
|
17
|
+
'How to set up CSS — exact imports for three paths: plain, Tailwind, and StyleX from source.',
|
|
18
|
+
keywords: [
|
|
19
|
+
'styling',
|
|
20
|
+
'CSS',
|
|
21
|
+
'setup',
|
|
22
|
+
'imports',
|
|
23
|
+
'StyleX',
|
|
24
|
+
'Tailwind',
|
|
25
|
+
'astryx.css',
|
|
26
|
+
'globals.css',
|
|
27
|
+
],
|
|
28
|
+
|
|
29
|
+
sections: [
|
|
30
|
+
{
|
|
31
|
+
id: 'pick-a-path',
|
|
32
|
+
title: 'Pick a path',
|
|
33
|
+
content: [
|
|
34
|
+
{
|
|
35
|
+
type: 'table',
|
|
36
|
+
headers: ['Path', 'Good for', 'Build step?'],
|
|
37
|
+
rows: [
|
|
38
|
+
[
|
|
39
|
+
'Plain CSS',
|
|
40
|
+
'Most apps. Style with className, xstyle, or any CSS library.',
|
|
41
|
+
'None.',
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
'Tailwind',
|
|
45
|
+
'Apps on Tailwind v4. A CSS bridge maps utility classes to design tokens.',
|
|
46
|
+
"None beyond Tailwind's own.",
|
|
47
|
+
],
|
|
48
|
+
[
|
|
49
|
+
'StyleX from source',
|
|
50
|
+
'Swizzled (ejected) components. Raw StyleX source needs a compiler plugin.',
|
|
51
|
+
'Yes \u2014 a StyleX bundler plugin.',
|
|
52
|
+
],
|
|
53
|
+
],
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
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
|
+
},
|
|
59
|
+
],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 'plain',
|
|
63
|
+
title: 'Plain CSS',
|
|
64
|
+
content: [
|
|
65
|
+
{
|
|
66
|
+
type: 'code',
|
|
67
|
+
lang: 'bash',
|
|
68
|
+
label: 'Install',
|
|
69
|
+
code: 'npm install @astryxdesign/core @stylexjs/stylex @astryxdesign/theme-neutral',
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
type: 'code',
|
|
73
|
+
lang: 'css',
|
|
74
|
+
label: 'globals.css',
|
|
75
|
+
code: `@import "@astryxdesign/core/reset.css";
|
|
76
|
+
@import "@astryxdesign/core/astryx.css";
|
|
77
|
+
@import "@astryxdesign/theme-neutral/theme.css";`,
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
type: 'prose',
|
|
81
|
+
text: "Done. Components work out of the box \u2014 style them with `className`, `xstyle`, or `style`. Swap `theme-neutral` for any theme package (`astryx theme list` shows what's available).",
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
id: 'tailwind',
|
|
87
|
+
title: 'Tailwind',
|
|
88
|
+
content: [
|
|
89
|
+
{
|
|
90
|
+
type: 'code',
|
|
91
|
+
lang: 'bash',
|
|
92
|
+
label: 'Install (add to an existing Tailwind v4 app)',
|
|
93
|
+
code: 'npm install @astryxdesign/core @stylexjs/stylex @astryxdesign/theme-neutral',
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: 'code',
|
|
97
|
+
lang: 'css',
|
|
98
|
+
label: 'globals.css',
|
|
99
|
+
code: `@layer reset, theme, base, astryx-base, astryx-theme, components, utilities;
|
|
100
|
+
|
|
101
|
+
@import "tailwindcss/theme.css" layer(theme);
|
|
102
|
+
@import "tailwindcss/preflight.css" layer(base);
|
|
103
|
+
@import "@astryxdesign/core/reset.css";
|
|
104
|
+
@import "@astryxdesign/core/astryx.css";
|
|
105
|
+
@import "@astryxdesign/theme-neutral/theme.css";
|
|
106
|
+
@import "@astryxdesign/core/tailwind-theme.css";
|
|
107
|
+
@import "tailwindcss/utilities.css" layer(utilities);`,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
type: 'prose',
|
|
111
|
+
text: 'The `@layer` declaration is critical \u2014 without it, component styles outrank Tailwind utilities and `className` overrides stop working. The bridge (`tailwind-theme.css`) maps classes like `text-primary`, `bg-surface`, and `rounded-lg` to design tokens with no JS.',
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
type: 'prose',
|
|
115
|
+
text: 'For Tailwind v3, see the layer workaround in {@link generic:migration}.',
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
id: 'stylex-from-source',
|
|
121
|
+
title: 'StyleX from source',
|
|
122
|
+
content: [
|
|
123
|
+
{
|
|
124
|
+
type: 'prose',
|
|
125
|
+
text: 'Only needed when you swizzle a component (`astryx swizzle <Component>`) or write your own StyleX. The plain path already supports `xstyle` overrides \u2014 this path is for editing component internals.',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: 'code',
|
|
129
|
+
lang: 'bash',
|
|
130
|
+
label: 'Install',
|
|
131
|
+
code: 'npm install @astryxdesign/core @stylexjs/stylex @astryxdesign/theme-neutral',
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
type: 'code',
|
|
135
|
+
lang: 'css',
|
|
136
|
+
label: 'globals.css',
|
|
137
|
+
code: `@layer reset, astryx-base, astryx-theme;
|
|
138
|
+
|
|
139
|
+
@import "@astryxdesign/core/reset.css";
|
|
140
|
+
@import "@astryxdesign/theme-neutral/theme.css";`,
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
type: 'prose',
|
|
144
|
+
text: 'No `astryx.css` \u2014 the StyleX compiler produces component styles from source. Add the plugin for your bundler:',
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
type: 'table',
|
|
148
|
+
headers: ['Bundler', 'Plugin'],
|
|
149
|
+
rows: [
|
|
150
|
+
['Webpack', '@stylexjs/webpack-plugin'],
|
|
151
|
+
['Vite / Rollup', '@stylexjs/rollup-plugin'],
|
|
152
|
+
['Babel (any)', '@stylexjs/babel-plugin + @stylexjs/postcss-plugin'],
|
|
153
|
+
['Next.js (keep next/font)', '@stylexswc/nextjs-plugin'],
|
|
154
|
+
],
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
type: 'prose',
|
|
158
|
+
text: 'If a swizzled component renders with no styles and no error, a missing compiler is almost always why. See the StyleX Build Setup section of {@link generic:styling} for bundler config examples.',
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
id: 'what-each-file-does',
|
|
164
|
+
title: 'What each import does',
|
|
165
|
+
content: [
|
|
166
|
+
{
|
|
167
|
+
type: 'table',
|
|
168
|
+
headers: ['Import', 'Layer', 'Purpose'],
|
|
169
|
+
rows: [
|
|
170
|
+
[
|
|
171
|
+
'reset.css',
|
|
172
|
+
'reset',
|
|
173
|
+
'Cross-browser reset (box-sizing, margins, color-scheme). Zero specificity via :where().',
|
|
174
|
+
],
|
|
175
|
+
[
|
|
176
|
+
'astryx.css',
|
|
177
|
+
'astryx-base',
|
|
178
|
+
'Pre-compiled component styles. Required for plain and Tailwind. Omit when compiling from source.',
|
|
179
|
+
],
|
|
180
|
+
[
|
|
181
|
+
'theme.css',
|
|
182
|
+
'astryx-theme',
|
|
183
|
+
'Design tokens (colors, spacing, radius, typography) as CSS custom properties. Swap the package for a different theme.',
|
|
184
|
+
],
|
|
185
|
+
[
|
|
186
|
+
'tailwind-theme.css',
|
|
187
|
+
'\u2014',
|
|
188
|
+
'Tailwind v4 bridge. Maps utility classes to design tokens. Pure CSS, no JS. Tailwind path only.',
|
|
189
|
+
],
|
|
190
|
+
],
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
id: 'further-reading',
|
|
196
|
+
title: 'Further reading',
|
|
197
|
+
content: [
|
|
198
|
+
{
|
|
199
|
+
type: 'list',
|
|
200
|
+
style: 'unordered',
|
|
201
|
+
items: [
|
|
202
|
+
'{@link generic:styling} \u2014 xstyle, className, data-attribute selectors, design tokens in code.',
|
|
203
|
+
'{@link generic:styling-libraries} \u2014 Tailwind bridge details, Panda, Chakra, MUI, CSS Modules, and non-CSS token resolution.',
|
|
204
|
+
'{@link generic:use-a-theme} \u2014 applying themes, dark mode, nested themes. {@link generic:author-a-theme} \u2014 defineTheme, overrides, production builds.',
|
|
205
|
+
'{@link generic:migration} \u2014 cascade layer audit, Tailwind v3 coexistence, and foundation smoke test.',
|
|
206
|
+
],
|
|
207
|
+
},
|
|
208
|
+
],
|
|
209
|
+
},
|
|
210
|
+
],
|
|
211
|
+
};
|
|
@@ -17,13 +17,13 @@ export const docs = {
|
|
|
17
17
|
content: [
|
|
18
18
|
{
|
|
19
19
|
type: 'prose',
|
|
20
|
-
text: 'Install a theme
|
|
20
|
+
text: 'Install a theme, import it with the CLI, and wire the generated module once. For the full guide — available themes, integration themes, dark mode, nested themes, and production builds — see {@link generic:use-a-theme}.',
|
|
21
21
|
},
|
|
22
22
|
{
|
|
23
23
|
type: 'code',
|
|
24
24
|
lang: 'tsx',
|
|
25
|
-
label: '
|
|
26
|
-
code: "import {Theme} from '@astryxdesign/core';\nimport {
|
|
25
|
+
label: 'Wire the generated module once',
|
|
26
|
+
code: "import {Theme} from '@astryxdesign/core';\nimport {themes, defaultThemeSlug} from './astryx-themes';\n\nfunction App() {\n return (\n <Theme theme={themes[defaultThemeSlug]}>\n <YourApp />\n </Theme>\n );\n}",
|
|
27
27
|
},
|
|
28
28
|
],
|
|
29
29
|
},
|
|
@@ -39,7 +39,7 @@ export const docs = {
|
|
|
39
39
|
type: 'code',
|
|
40
40
|
lang: 'bash',
|
|
41
41
|
label: 'Quick start',
|
|
42
|
-
code: 'astryx theme
|
|
42
|
+
code: 'astryx theme add stone --import # use an existing theme\nastryx theme eject stone # fork its source to customize\nastryx theme build src/themes/stone/stoneTheme.ts',
|
|
43
43
|
},
|
|
44
44
|
],
|
|
45
45
|
},
|
|
@@ -64,7 +64,7 @@ export const docs = {
|
|
|
64
64
|
content: [
|
|
65
65
|
{
|
|
66
66
|
type: 'prose',
|
|
67
|
-
text: 'Install an integration and Astryx discovers its themes automatically.
|
|
67
|
+
text: 'Install an integration and Astryx discovers its themes automatically. Import one with `astryx theme add <name> --import --package <integration>`. Use `theme eject` only for an independent source fork. For the full walkthrough, see {@link generic:use-a-theme}.',
|
|
68
68
|
},
|
|
69
69
|
],
|
|
70
70
|
},
|
|
@@ -6,91 +6,203 @@ export const docs = {
|
|
|
6
6
|
name: 'use-a-theme',
|
|
7
7
|
title: 'Use a theme',
|
|
8
8
|
category: 'guide',
|
|
9
|
-
keywords: ['theme', 'Theme', 'dark mode', 'light', 'nested', 'provider', 'SSR', 'built', 'runtime', 'neutralTheme', 'available themes'],
|
|
10
|
-
description:
|
|
9
|
+
keywords: ['theme', 'Theme', 'dark mode', 'light', 'nested', 'provider', 'SSR', 'built', 'runtime', 'neutralTheme', 'available themes', 'theme add', 'import', 'astryx-themes', 'eject'],
|
|
10
|
+
description:
|
|
11
|
+
'Apply a theme to your app: install, import with the CLI, wire the generated module, switch dark mode, nest themes, and choose runtime or built for production.',
|
|
12
|
+
|
|
11
13
|
sections: [
|
|
12
14
|
{
|
|
13
15
|
id: 'quick-start',
|
|
14
16
|
title: 'Wrap your app in a theme',
|
|
15
17
|
content: [
|
|
16
|
-
{
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
{
|
|
19
|
+
type: 'code',
|
|
20
|
+
lang: 'bash',
|
|
21
|
+
label: 'Install and add a theme',
|
|
22
|
+
code: 'npm install @astryxdesign/theme-neutral\nastryx theme add neutral --import',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
type: 'code',
|
|
26
|
+
lang: 'tsx',
|
|
27
|
+
label: 'Wire the generated module once',
|
|
28
|
+
code: "import {Theme} from '@astryxdesign/core';\nimport {themes, defaultThemeSlug} from './astryx-themes';\n\nfunction App() {\n return (\n <Theme theme={themes[defaultThemeSlug]}>\n <YourApp />\n </Theme>\n );\n}",
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
type: 'code',
|
|
32
|
+
lang: 'tsx',
|
|
33
|
+
label: 'Switch among added themes',
|
|
34
|
+
code: "import {useState} from 'react';\nimport {themes, type ThemeSlug} from './astryx-themes';\n\nconst [slug, setSlug] = useState<ThemeSlug>('neutral');\nconst app = <Theme theme={themes[slug]}><YourApp /></Theme>;",
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
type: 'prose',
|
|
38
|
+
text: '`theme add --import` records an installed package theme and regenerates `src/astryx-themes.ts` or `.js` with its built module, production CSS, and optional font CSS. In a project without `src`, the module is at the project root. The first imported theme becomes the default. `theme use <slug>` changes that default, and `theme remove <slug>` removes a non-default theme.',
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: 'prose',
|
|
42
|
+
text: 'Customize a package theme with `defineTheme({extends: importedTheme, ...})`, then build and add that local theme. Use `theme eject` only when you want an independent source fork that no longer receives the package owner\'s updates. For the full authoring guide, see {@link generic:author-a-theme}.',
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
title: 'Migrating Earlier Theme Copies',
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: 'prose',
|
|
51
|
+
text: 'A theme copied by the released `theme add` stays app source. The upgrade does not move, delete, or rewrite it. It only writes the missing same-stem descriptor with `maintained: false`, so the copy becomes a local theme.',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
type: 'code',
|
|
55
|
+
lang: 'bash',
|
|
56
|
+
label: 'Add descriptors to earlier copies',
|
|
57
|
+
code: 'astryx upgrade --from 0.6.4 --path . --apply',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
type: 'prose',
|
|
61
|
+
text: 'Before the upgrade runs, theme commands skip a descriptor-less copy in `src/themes`. `theme list` and doctor name it as unmigrated and show the upgrade command. A script that meant to copy source now runs `theme eject` with the same arguments. A script that meant to make the app use a theme runs `theme add --import`.',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
type: 'prose',
|
|
65
|
+
text: '`ASTRYX_THEME` is no longer read. Run `theme add <slug> --import` and `theme use <slug>` to choose the default in a generated app theme module. When that module exists, component metadata reads its recorded default theme. Without the module, the released `package.json#astryx.theme` lookup keeps its meaning.',
|
|
66
|
+
},
|
|
21
67
|
],
|
|
22
68
|
},
|
|
23
69
|
{
|
|
24
70
|
title: 'Available Themes',
|
|
25
71
|
content: [
|
|
26
|
-
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
['
|
|
33
|
-
[
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
72
|
+
{
|
|
73
|
+
type: 'prose',
|
|
74
|
+
text: 'Install the theme package you want with `npm install @astryxdesign/theme-{name}`, then import its slug with `theme add <slug> --import`. The CLI imports the package\'s built outputs for you.',
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: 'table',
|
|
78
|
+
headers: ['Theme', 'Add command', 'Description'],
|
|
79
|
+
rows: [
|
|
80
|
+
['Neutral', 'astryx theme add neutral --import', 'Muted, minimal aesthetic with Figtree typography. A good starting point.'],
|
|
81
|
+
['Butter', 'astryx theme add butter --import', 'Golden, buttery surfaces with blue accents; Sarina + Outfit type.'],
|
|
82
|
+
['Chocolate', 'astryx theme add chocolate --import', 'Warm brown tones and cozy beige; Fraunces + Albert Sans type.'],
|
|
83
|
+
['Gothic', 'astryx theme add gothic --import', 'Dark-only atmospheric theme; deep blue-gray surfaces, distressed display type.'],
|
|
84
|
+
['Matcha', 'astryx theme add matcha --import', 'Earthy greens; DM Sans + Playwrite US Trad type.'],
|
|
85
|
+
['Stone', 'astryx theme add stone --import', 'Warm stone and slate tones; Montserrat + Figtree type.'],
|
|
86
|
+
['Y2K', 'astryx theme add y2k --import', 'Playful Y2K pop; periwinkle body, holographic accents, Poppins + Crimson Text.'],
|
|
87
|
+
],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
type: 'prose',
|
|
91
|
+
text: 'Every first-party package exports its built theme at `@astryxdesign/theme-{name}/built`, production CSS at `/theme.css`, and font loading CSS at `/fonts.css`. `theme add --import` writes those imports into the generated app module.',
|
|
92
|
+
},
|
|
37
93
|
],
|
|
38
94
|
},
|
|
39
95
|
{
|
|
40
96
|
title: 'Theme Props',
|
|
41
97
|
content: [
|
|
42
|
-
{
|
|
98
|
+
{
|
|
99
|
+
type: 'prose',
|
|
100
|
+
text: "`<Theme>` takes `theme` (required), `mode` (`'system'` by default, or `'light'`/`'dark'`), and `children`. For every prop, run `astryx component Theme`.",
|
|
101
|
+
},
|
|
43
102
|
],
|
|
44
103
|
},
|
|
45
104
|
{
|
|
46
105
|
id: 'integration-themes',
|
|
47
106
|
title: 'Using a Theme from an Integration',
|
|
48
107
|
content: [
|
|
49
|
-
{
|
|
50
|
-
|
|
51
|
-
|
|
108
|
+
{
|
|
109
|
+
type: 'prose',
|
|
110
|
+
text: 'Install the integration as a direct dependency. Astryx discovers its themes and guides without an `astryx.config` entry. A theme can be added only when the installed package exports its built module and production stylesheet.',
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
type: 'code',
|
|
114
|
+
lang: 'bash',
|
|
115
|
+
label: 'Install, inspect, and add',
|
|
116
|
+
code: 'npm install @astryxdesign/core @acme/brand-integration\nastryx theme list --package @acme/brand-integration\nastryx docs brand-theme\nastryx theme add ocean --import --package @acme/brand-integration',
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
type: 'prose',
|
|
120
|
+
text: '`theme add --import` keeps the owner package in the app record and imports its built module, stylesheet, and optional font stylesheet. Package updates continue to reach the app. Run `theme eject ocean --package @acme/brand-integration` only to copy the source and descriptor into `src/themes/ocean` as an independent local fork.',
|
|
121
|
+
},
|
|
52
122
|
],
|
|
53
123
|
},
|
|
54
124
|
{
|
|
55
125
|
id: 'light-dark-mode',
|
|
56
126
|
title: 'Dark mode',
|
|
57
127
|
content: [
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
128
|
+
{
|
|
129
|
+
type: 'prose',
|
|
130
|
+
text: "Use [light, dark] tuples in token values for automatic mode switching. Use mode='system' (default) on Theme to follow OS preference.",
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
type: 'code',
|
|
134
|
+
lang: 'tsx',
|
|
135
|
+
label: 'Light/dark tuple',
|
|
136
|
+
code: "'--color-accent': ['#0064E0', '#2694FE'],\n// ^light ^dark",
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
type: 'code',
|
|
140
|
+
lang: 'tsx',
|
|
141
|
+
label: 'Toggle with a button',
|
|
142
|
+
code: "const [mode, setMode] = useState<'light' | 'dark'>('light');\n\n<Theme theme={myTheme} mode={mode}>\n <Button\n label={mode === 'light' ? 'Switch to Dark' : 'Switch to Light'}\n onClick={() => setMode(m => (m === 'light' ? 'dark' : 'light'))}\n />\n</Theme>;",
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
type: 'prose',
|
|
146
|
+
text: 'To create a theme with custom dark mode colors, see {@link generic:author-a-theme}.',
|
|
147
|
+
},
|
|
62
148
|
],
|
|
63
149
|
},
|
|
64
150
|
{
|
|
65
151
|
id: 'nesting-themes',
|
|
66
152
|
title: 'Nested themes',
|
|
67
153
|
content: [
|
|
68
|
-
{
|
|
69
|
-
|
|
154
|
+
{
|
|
155
|
+
type: 'prose',
|
|
156
|
+
text: 'Wrap different sections in separate `<Theme>` providers.',
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
type: 'code',
|
|
160
|
+
lang: 'tsx',
|
|
161
|
+
label: 'Dark sidebar with light content',
|
|
162
|
+
code: "<Theme theme={lightTheme} mode=\"light\">\n <Layout\n header={<LayoutHeader>...</LayoutHeader>}\n start={\n <Theme theme={darkTheme} mode=\"dark\">\n <LayoutPanel>{/* Dark sidebar */}</LayoutPanel>\n </Theme>\n }\n content={<LayoutContent>{/* Light content */}</LayoutContent>}\n />\n</Theme>",
|
|
163
|
+
},
|
|
70
164
|
],
|
|
71
165
|
},
|
|
72
166
|
{
|
|
73
167
|
title: 'Runtime vs Built Themes',
|
|
74
168
|
content: [
|
|
75
|
-
{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
['
|
|
82
|
-
[
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
169
|
+
{
|
|
170
|
+
type: 'prose',
|
|
171
|
+
text: 'Themes work in two modes:',
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
type: 'table',
|
|
175
|
+
headers: ['', 'Runtime (source)', 'Built'],
|
|
176
|
+
rows: [
|
|
177
|
+
['Import (published theme)', '@astryxdesign/theme-{name}', '@astryxdesign/theme-{name}/built + theme.css'],
|
|
178
|
+
['Import (custom theme)', 'defineTheme() directly', 'Built .js + .css from `astryx theme build`'],
|
|
179
|
+
['How it works', 'useInsertionEffect injects <style> at hydration', 'Pre-compiled .css file loaded with the page'],
|
|
180
|
+
['Component overrides', 'Injected client-only', 'In static CSS: present during SSR'],
|
|
181
|
+
['SSR safe', 'Tokens yes, component overrides flash on hydration', 'Fully SSR safe: no flash'],
|
|
182
|
+
['Best for', 'Dev, prototyping, client-only SPAs', 'Production, SSR apps (Next.js, Remix)'],
|
|
183
|
+
],
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
type: 'list',
|
|
187
|
+
style: 'do',
|
|
188
|
+
items: [
|
|
189
|
+
'Use `theme add --import` for production apps; it wires the built module and CSS.',
|
|
190
|
+
'Use runtime themes during development for fast iteration.',
|
|
191
|
+
'Run `astryx theme build` for custom themes to get the built artifacts.',
|
|
192
|
+
],
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
type: 'list',
|
|
196
|
+
style: 'dont',
|
|
197
|
+
items: [
|
|
198
|
+
'Use runtime themes in production SSR apps; component overrides will flash on hydration.',
|
|
199
|
+
"Import /built without the CSS file; component overrides won't apply.",
|
|
200
|
+
],
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
type: 'prose',
|
|
204
|
+
text: 'To build a custom theme for production, see the Build section of {@link generic:author-a-theme}.',
|
|
205
|
+
},
|
|
94
206
|
],
|
|
95
207
|
},
|
|
96
208
|
],
|
|
@@ -8,5 +8,5 @@ export const doc = {
|
|
|
8
8
|
description:
|
|
9
9
|
'Transposed matrix that puts candidates in the columns and criteria in grouped rows, with a pinned label column that survives horizontal scroll, columns you can swap or add, and best-in-row marks you can toggle. Compare, comparison, matrix, spec sheet, feature grid, pricing table, benchmark, frozen column, sticky column, or side-by-side.',
|
|
10
10
|
isReady: true,
|
|
11
|
-
category: 'Table -
|
|
11
|
+
category: 'Table - Comparison',
|
|
12
12
|
};
|
|
@@ -198,7 +198,7 @@ describe('blocks as text', () => {
|
|
|
198
198
|
it('prints the labels of a real section above their fences', async () => {
|
|
199
199
|
const {status, stdout} = await runCli(['docs', 'theme', 'quick-start']);
|
|
200
200
|
expect(status).toBe(0);
|
|
201
|
-
expect(stdout).toContain('
|
|
201
|
+
expect(stdout).toContain('Wire the generated module once:\n```tsx\nimport {Theme}');
|
|
202
202
|
}, SLOW);
|
|
203
203
|
});
|
|
204
204
|
|
|
@@ -16,7 +16,7 @@ export const doc = {
|
|
|
16
16
|
summary: 'Diagnose Astryx projects and integration packages',
|
|
17
17
|
description:
|
|
18
18
|
'Runs read-only project health diagnostics by default: Node version, @astryxdesign/core ' +
|
|
19
|
-
'install and version alignment, generated app themes when present, earlier copied-theme migration, config, integrations (linked without a config entry, ' +
|
|
19
|
+
'install and version alignment, theme packages, generated app themes when present, earlier copied-theme migration, config, integrations (linked without a config entry, ' +
|
|
20
20
|
'provider identity, contribution issues), agent docs, core peer dependencies, package manager, ' +
|
|
21
21
|
"and the docs the CLI reads. It writes nothing, but loading astryx.config runs that file's code. " +
|
|
22
22
|
'The `integration` subcommands provide authoring checks for one integration package.',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astryxdesign/cli",
|
|
3
|
-
"version": "0.6.6-canary.
|
|
3
|
+
"version": "0.6.6-canary.dee5096",
|
|
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",
|
|
@@ -101,10 +101,10 @@
|
|
|
101
101
|
"zod": "^4.4.3"
|
|
102
102
|
},
|
|
103
103
|
"peerDependencies": {
|
|
104
|
-
"@astryxdesign/charts": "0.6.6-canary.
|
|
105
|
-
"@astryxdesign/core": "0.6.6-canary.
|
|
106
|
-
"@astryxdesign/lab": "0.6.6-canary.
|
|
107
|
-
"@astryxdesign/theme-neutral": "0.6.6-canary.
|
|
104
|
+
"@astryxdesign/charts": "0.6.6-canary.dee5096",
|
|
105
|
+
"@astryxdesign/core": "0.6.6-canary.dee5096",
|
|
106
|
+
"@astryxdesign/lab": "0.6.6-canary.dee5096",
|
|
107
|
+
"@astryxdesign/theme-neutral": "0.6.6-canary.dee5096"
|
|
108
108
|
},
|
|
109
109
|
"peerDependenciesMeta": {
|
|
110
110
|
"@astryxdesign/charts": {
|
|
@@ -121,10 +121,10 @@
|
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
|
-
"@astryxdesign/charts": "0.6.6-canary.
|
|
125
|
-
"@astryxdesign/core": "0.6.6-canary.
|
|
126
|
-
"@astryxdesign/lab": "0.6.6-canary.
|
|
127
|
-
"@astryxdesign/theme-neutral": "0.6.6-canary.
|
|
124
|
+
"@astryxdesign/charts": "0.6.6-canary.dee5096",
|
|
125
|
+
"@astryxdesign/core": "0.6.6-canary.dee5096",
|
|
126
|
+
"@astryxdesign/lab": "0.6.6-canary.dee5096",
|
|
127
|
+
"@astryxdesign/theme-neutral": "0.6.6-canary.dee5096",
|
|
128
128
|
"@heroicons/react": "^2.2.0",
|
|
129
129
|
"@stylexjs/stylex": "^0.19.0",
|
|
130
130
|
"@types/babel__core": "^7.20.5",
|