@astryxdesign/cli 0.6.6-canary.fcf255b → 0.6.6-canary.ffa4f72
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/README.md +83 -83
- package/api/build/_adapter.d.mts +15 -0
- package/api/build/_adapter.mjs +22 -0
- package/api/build/build.doc.mjs +1 -1
- package/api/build/build.type.d.mts +4 -0
- package/api/build/build.type.mjs +1 -0
- package/api/build/help/help.mjs +1 -1
- package/api/build/kit/kit.mjs +12 -1
- package/api/component/component-replacement.test.mjs +12 -0
- package/api/component/component.doc.mjs +5 -2
- package/api/docs/_adapter.mjs +48 -1
- package/api/docs/compiled-topics.test.mjs +1 -1
- package/api/docs/detail/section/section.d.mts +44 -0
- package/api/docs/detail/section/section.mjs +164 -13
- package/api/docs/detail/section/section.test.mjs +4 -4
- package/api/docs/docOverlays.test.mjs +28 -17
- package/api/docs/docs.doc.mjs +3 -3
- package/api/docs/docs.mjs +11 -16
- package/api/docs/docs.test.mjs +9 -10
- package/api/docs/integration-tree.test.mjs +26 -26
- package/api/docs/integrationDocs.test.mjs +2 -2
- package/api/docs/namespace-section.test.mjs +260 -0
- package/api/docs/token-tables.test.mjs +93 -0
- package/api/doctor/_adapter.d.mts +7 -0
- package/api/doctor/_adapter.mjs +48 -0
- package/api/doctor/doctor.d.mts +6 -0
- package/api/doctor/doctor.mjs +154 -43
- package/api/doctor/doctor.test.mjs +104 -0
- package/api/doctor/theme-checks.d.mts +12 -0
- package/api/doctor/theme-checks.mjs +115 -1
- package/api/doctor/theme-checks.test.mjs +142 -1
- package/api/gap-report/gap-report.doc.mjs +2 -1
- package/api/init/run/run.mjs +1 -0
- package/api/integration/validate-integration.mjs +20 -4
- package/api/integration/validate-integration.test.mjs +73 -0
- package/api/layout/check/check.d.mts +1 -0
- package/api/layout/check/check.mjs +1 -0
- package/api/layout/expand/expand.d.mts +1 -0
- package/api/layout/expand/expand.mjs +1 -0
- package/api/layout/grammar/grammar.d.mts +1 -0
- package/api/layout/grammar/grammar.mjs +1 -0
- package/api/layout/layoutCheck.doc.mjs +1 -1
- package/api/layout/layoutExpand.doc.mjs +1 -1
- package/api/layout/layoutGrammar.doc.mjs +1 -1
- package/api/search/search.d.mts +44 -0
- package/api/search/search.domain-priority.test.mjs +261 -0
- package/api/search/search.mjs +191 -29
- package/api/swizzle/swizzle.doc.mjs +5 -2
- package/api/template/copy/copy.mjs +12 -0
- package/api/template/template.doc.mjs +1 -1
- package/api/template/template.type.d.mts +3 -0
- package/api/template/template.type.mjs +3 -0
- package/api/theme/build/build.d.mts +70 -0
- package/api/theme/build/build.mjs +205 -41
- package/api/theme/build/font-warning.d.mts +11 -0
- package/api/theme/build/font-warning.mjs +28 -3
- package/assets/docs/author-a-theme.doc.mjs +19 -14
- package/assets/docs/getting-started.doc.mjs +2 -2
- package/assets/docs/principles.doc.dense.mjs +3 -3
- package/assets/docs/principles.doc.mjs +4 -4
- package/assets/docs/principles.doc.zh.mjs +3 -3
- package/assets/docs/styling-overview.doc.mjs +211 -0
- package/assets/docs/theme.doc.dense.mjs +1 -1
- package/assets/docs/theme.doc.mjs +5 -5
- package/assets/docs/theme.doc.zh.mjs +1 -1
- package/assets/docs/tree/component-migration.doc.mjs +107 -0
- package/assets/docs/tree/css-and-stylex.doc.mjs +150 -0
- package/assets/docs/tree/font-setup.doc.mjs +122 -0
- package/assets/docs/tree/headers-and-footers.doc.mjs +0 -1
- package/assets/docs/tree/i18n-library-integration.doc.mjs +167 -0
- package/assets/docs/tree/i18n-quick-start.doc.mjs +101 -0
- package/assets/docs/{internationalization.doc.mjs → tree/i18n-rtl-and-testing.doc.mjs} +17 -223
- package/assets/docs/tree/internationalization.doc.mjs +29 -0
- package/assets/docs/tree/layout.doc.mjs +23 -0
- package/assets/docs/{migration.doc.mjs → tree/migration-setup.doc.mjs} +24 -129
- package/assets/docs/tree/migration-verification.doc.mjs +67 -0
- package/assets/docs/tree/migration.doc.mjs +28 -0
- package/assets/docs/tree/non-css-processing.doc.mjs +112 -0
- package/assets/docs/tree/other-libraries.doc.mjs +218 -0
- package/assets/docs/tree/responsive.doc.mjs +0 -4
- package/assets/docs/tree/scaffold.doc.mjs +0 -5
- package/assets/docs/tree/side-panels.doc.mjs +0 -1
- package/assets/docs/tree/structure.doc.mjs +0 -4
- package/assets/docs/tree/styling-advanced.doc.mjs +159 -0
- package/assets/docs/tree/styling-basics.doc.mjs +181 -0
- package/assets/docs/tree/styling-libraries.doc.mjs +30 -0
- package/assets/docs/tree/styling.doc.mjs +29 -0
- package/assets/docs/tree/tailwind.doc.mjs +65 -0
- package/assets/docs/tree/tokens-and-setup.doc.mjs +128 -0
- package/assets/docs/tree/tokens-border.doc.mjs +46 -0
- package/assets/docs/tree/tokens-color.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-color.doc.mjs +438 -0
- package/assets/docs/tree/tokens-color.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-data.doc.mjs +323 -0
- package/assets/docs/tree/tokens-duration.doc.mjs +78 -0
- package/assets/docs/tree/tokens-ease.doc.mjs +46 -0
- package/assets/docs/tree/tokens-focus.doc.mjs +57 -0
- package/assets/docs/tree/tokens-font-weight.doc.mjs +58 -0
- package/assets/docs/tree/tokens-radius.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-radius.doc.mjs +70 -0
- package/assets/docs/tree/tokens-radius.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-shadow.doc.mjs +74 -0
- package/assets/docs/tree/tokens-shadow.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-size.doc.mjs +54 -0
- package/assets/docs/tree/tokens-size.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-spacing.doc.mjs +102 -0
- package/assets/docs/tree/tokens-spacing.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens-syntax.doc.mjs +98 -0
- package/assets/docs/tree/tokens-text-size.doc.mjs +90 -0
- package/assets/docs/tree/tokens-type-scale.doc.mjs +210 -0
- package/assets/docs/tree/tokens-typography.doc.mjs +54 -0
- package/assets/docs/tree/tokens-usage.doc.dense.mjs +10 -0
- package/assets/docs/tree/tokens-usage.doc.mjs +36 -0
- package/assets/docs/tree/tokens-usage.doc.zh.mjs +10 -0
- package/assets/docs/tree/tokens.doc.mjs +28 -0
- package/assets/docs/tree/type-scale.doc.mjs +147 -0
- package/assets/docs/tree/typography-best-practices.doc.mjs +55 -0
- package/assets/docs/tree/typography.doc.mjs +29 -0
- package/assets/docs/use-a-theme.doc.mjs +162 -47
- package/assets/templates/pages/incident-console/page.tsx +1 -1
- package/assets/templates/pages/table-comparison/template.doc.mjs +1 -1
- package/assets/theme.template.ts +4 -3
- package/authoring/doctypes/template/type.ts +1 -0
- package/clients/cli/commands/blog.mjs +3 -3
- package/clients/cli/commands/build-theme.adaptations.test.mjs +1 -1
- package/clients/cli/commands/build-theme.ascii-output.test.mjs +11 -1
- package/clients/cli/commands/build-theme.batch-report.test.mjs +335 -0
- package/clients/cli/commands/build-theme.font-warning.test.mjs +36 -7
- package/clients/cli/commands/build-theme.import-path.test.mjs +3 -3
- package/clients/cli/commands/build-theme.mjs +68 -18
- package/clients/cli/commands/build-theme.watch.test.mjs +33 -0
- package/clients/cli/commands/build.mjs +1 -0
- package/clients/cli/commands/component/index.mjs +4 -1
- package/clients/cli/commands/component-replacement.text.test.mjs +45 -0
- package/clients/cli/commands/docs.doc.mjs +2 -1
- package/clients/cli/commands/docs.test.mjs +16 -13
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
- package/clients/cli/commands/doctor.doc.mjs +1 -1
- package/clients/cli/commands/doctor.test.mjs +50 -1
- package/clients/cli/commands/import-hint-correctness.test.mjs +23 -0
- package/clients/cli/commands/layout-check.doc.mjs +1 -0
- package/clients/cli/commands/layout-expand.doc.mjs +1 -0
- package/clients/cli/commands/layout-grammar.doc.mjs +1 -0
- package/clients/cli/commands/layout.deprecation-lifecycle.test.mjs +140 -0
- package/clients/cli/commands/layout.doc.mjs +1 -0
- package/clients/cli/commands/layout.mjs +6 -11
- package/clients/cli/commands/search.test.mjs +6 -2
- package/clients/cli/commands/swizzle.routing.test.mjs +2 -1
- package/clients/cli/commands/template.mjs +4 -3
- package/clients/cli/commands/theme-add-lifecycle.test.mjs +9 -6
- package/clients/cli/commands/theme-build.doc.mjs +3 -1
- package/clients/cli/commands/upgrade.config-ordering.test.mjs +2 -1
- package/clients/cli/index.mjs +1 -1
- package/clients/cli/lib/component-format.mjs +13 -3
- package/clients/cli/lib/component-format.test.mjs +1 -1
- package/clients/cli/lib/define-command.mjs +4 -0
- package/foundation/agent-docs/agent-docs.mjs +18 -2
- package/foundation/agent-docs/agent-docs.test.mjs +18 -0
- package/foundation/config/project.test.mjs +1 -1
- package/foundation/discovery/docs-discovery.test.mjs +1 -1
- package/foundation/discovery/template-needs.d.mts +31 -0
- package/foundation/discovery/template-needs.mjs +156 -0
- package/foundation/discovery/template-needs.test.mjs +203 -0
- package/foundation/doc-compiler/bundle.mjs +52 -1
- package/foundation/doc-compiler/split-topic-keywords.test.mjs +73 -0
- package/foundation/doc-compiler/tree.d.mts +10 -0
- package/foundation/doc-compiler/tree.mjs +22 -0
- package/foundation/doc-compiler/tree.test.mjs +3 -2
- package/foundation/env/package-manager.d.mts +31 -8
- package/foundation/env/package-manager.mjs +120 -13
- package/foundation/env/package-manager.test.mjs +174 -1
- package/foundation/integrations/validate-contributions.d.mts +16 -0
- package/foundation/integrations/validate-contributions.mjs +56 -8
- package/foundation/response/response-types.doc.mjs +4 -4
- package/package.json +9 -9
- package/assets/docs/styling-libraries.doc.mjs +0 -469
- package/assets/docs/styling.doc.mjs +0 -412
- package/assets/docs/tokens.doc.dense.mjs +0 -15
- package/assets/docs/tokens.doc.mjs +0 -1491
- package/assets/docs/tokens.doc.zh.mjs +0 -15
- package/assets/docs/typography.doc.mjs +0 -286
|
@@ -71,6 +71,46 @@ export function validateComponentOverridesAgainstRegistry(themeDef: {
|
|
|
71
71
|
propsByKey: Record<string, string[]>;
|
|
72
72
|
deprecatedByKey: Record<string, string>;
|
|
73
73
|
}): string[];
|
|
74
|
+
/**
|
|
75
|
+
* Print the install snippet and font guidance once for a batch: the first
|
|
76
|
+
* theme as the full example, one import line per built theme, and one font
|
|
77
|
+
* recipe naming every family the themes do not load.
|
|
78
|
+
* @param {ThemeBuildTrailer[]} trailers
|
|
79
|
+
*/
|
|
80
|
+
export function printBatchTrailer(trailers: ThemeBuildTrailer[]): void;
|
|
81
|
+
/**
|
|
82
|
+
* Print what a short report keeps after its one line per theme: one line
|
|
83
|
+
* naming the fonts the themes do not load, and, when the caller chose no
|
|
84
|
+
* detail level, where the install example and font recipe are.
|
|
85
|
+
* @param {ThemeBuildTrailer[]} trailers
|
|
86
|
+
* @param {{hint?: boolean}} [options]
|
|
87
|
+
*/
|
|
88
|
+
export function printCompactTrailer(trailers: ThemeBuildTrailer[], { hint }?: {
|
|
89
|
+
hint?: boolean;
|
|
90
|
+
}): void;
|
|
91
|
+
/**
|
|
92
|
+
* Build one theme for a batch or compact CLI report. Same build, outputs, and
|
|
93
|
+
* receipt as {@link themeBuild}; the install snippet and font guidance come
|
|
94
|
+
* back as `trailer` instead of being printed, and `compact` leaves out the
|
|
95
|
+
* per-file progress lines. CLI-internal: not exported from the API entry.
|
|
96
|
+
* @param {string} file
|
|
97
|
+
* @param {{out?: string, check?: boolean, iconsSpecifier?: string}} [options]
|
|
98
|
+
* @param {{cwd?: string}} [ctx]
|
|
99
|
+
* @param {{compact?: boolean}} [report]
|
|
100
|
+
* @returns {Promise<{receipt: import('../theme.type.mjs').ThemeBuildResponse | import('../theme.type.mjs').ThemeBuildCheckResponse | null, trailer: ThemeBuildTrailer | null}>}
|
|
101
|
+
*/
|
|
102
|
+
export function themeBuildForReport(file: string, options?: {
|
|
103
|
+
out?: string;
|
|
104
|
+
check?: boolean;
|
|
105
|
+
iconsSpecifier?: string;
|
|
106
|
+
}, ctx?: {
|
|
107
|
+
cwd?: string;
|
|
108
|
+
}, { compact }?: {
|
|
109
|
+
compact?: boolean;
|
|
110
|
+
}): Promise<{
|
|
111
|
+
receipt: import("../theme.type.mjs").ThemeBuildResponse | import("../theme.type.mjs").ThemeBuildCheckResponse | null;
|
|
112
|
+
trailer: ThemeBuildTrailer | null;
|
|
113
|
+
}>;
|
|
74
114
|
/** @param {string} file @param {{out?: string, check?: boolean, iconsSpecifier?: string}} [options] @param {{cwd?: string}} [ctx] @returns {Promise<import('../theme.type.mjs').ThemeBuildResponse | import('../theme.type.mjs').ThemeBuildCheckResponse | null>} */
|
|
75
115
|
export function themeBuild(file: string, options?: {
|
|
76
116
|
out?: string;
|
|
@@ -140,6 +180,36 @@ export function themeBuildFamily(files: string[], options: {
|
|
|
140
180
|
* validateAdaptationEnrollment)
|
|
141
181
|
*/
|
|
142
182
|
export type ComponentValueClass = "builtin" | "enrollment" | "unresolved";
|
|
183
|
+
/**
|
|
184
|
+
* What a standalone build prints after its [ok] lines, kept as data so a
|
|
185
|
+
* batch can print it once for every theme.
|
|
186
|
+
*/
|
|
187
|
+
export type ThemeBuildTrailer = {
|
|
188
|
+
/**
|
|
189
|
+
* The theme's name.
|
|
190
|
+
*/
|
|
191
|
+
themeName: string;
|
|
192
|
+
/**
|
|
193
|
+
* The built module's theme export.
|
|
194
|
+
*/
|
|
195
|
+
exportName: string;
|
|
196
|
+
/**
|
|
197
|
+
* Import specifier of the built JS module.
|
|
198
|
+
*/
|
|
199
|
+
jsImport: string;
|
|
200
|
+
/**
|
|
201
|
+
* Import specifier of the built CSS.
|
|
202
|
+
*/
|
|
203
|
+
cssImport: string;
|
|
204
|
+
/**
|
|
205
|
+
* Font families the theme names but does not load.
|
|
206
|
+
*/
|
|
207
|
+
unloadedFonts: string[];
|
|
208
|
+
/**
|
|
209
|
+
* One notice per unloaded font family.
|
|
210
|
+
*/
|
|
211
|
+
fontNotices: string[];
|
|
212
|
+
};
|
|
143
213
|
/**
|
|
144
214
|
* The bindings one Core provides: the namespaces interception spreads, the
|
|
145
215
|
* functions the build calls, and why the import failed, if it did.
|
|
@@ -74,7 +74,11 @@ import {
|
|
|
74
74
|
collectThemingTargets,
|
|
75
75
|
targetValidationRegistry,
|
|
76
76
|
} from '../../../foundation/discovery/theming-targets.mjs';
|
|
77
|
-
import {
|
|
77
|
+
import {
|
|
78
|
+
collectUnloadedFonts,
|
|
79
|
+
formatBatchFontLoadingHelp,
|
|
80
|
+
formatFontLoadingHelp,
|
|
81
|
+
} from './font-warning.mjs';
|
|
78
82
|
import {interceptCore} from './core-interception.mjs';
|
|
79
83
|
import {generateFamilyCSS, resolveThemeFamily} from './family.mjs';
|
|
80
84
|
import {resolveIconImports} from './icon-imports.mjs';
|
|
@@ -2339,6 +2343,7 @@ async function themeBuildInternal(
|
|
|
2339
2343
|
file,
|
|
2340
2344
|
options = {},
|
|
2341
2345
|
{cwd = process.cwd()} = {},
|
|
2346
|
+
/** @type {{compact?: boolean, trailers?: ThemeBuildTrailer[]}} */ report = {},
|
|
2342
2347
|
) {
|
|
2343
2348
|
const filePath = path.resolve(cwd, file);
|
|
2344
2349
|
|
|
@@ -2350,7 +2355,11 @@ async function themeBuildInternal(
|
|
|
2350
2355
|
);
|
|
2351
2356
|
}
|
|
2352
2357
|
|
|
2353
|
-
|
|
2358
|
+
if (!report.compact) {
|
|
2359
|
+
logger.log(`\nBuilding theme from ${path.relative(cwd, filePath)}...`);
|
|
2360
|
+
}
|
|
2361
|
+
// A compact report has no per-theme heading, so each warning names its file.
|
|
2362
|
+
const source = report.compact ? `${path.relative(cwd, filePath)}: ` : '';
|
|
2354
2363
|
|
|
2355
2364
|
await selectCore(cwd);
|
|
2356
2365
|
|
|
@@ -2469,18 +2478,18 @@ async function themeBuildInternal(
|
|
|
2469
2478
|
const noticeMessages = [];
|
|
2470
2479
|
for (const w of warnings) {
|
|
2471
2480
|
warningMessages.push(w);
|
|
2472
|
-
logger.warn(` [warn] ${w}`);
|
|
2481
|
+
logger.warn(` [warn] ${source}${w}`);
|
|
2473
2482
|
}
|
|
2474
2483
|
|
|
2475
2484
|
// Validate no private vars are set directly
|
|
2476
2485
|
const privateVarErrors = validatePrivateVars(themeDef);
|
|
2477
2486
|
for (const e of privateVarErrors) {
|
|
2478
2487
|
warningMessages.push(e);
|
|
2479
|
-
logger.error(` [error] ${e}`);
|
|
2488
|
+
logger.error(` [error] ${source}${e}`);
|
|
2480
2489
|
}
|
|
2481
2490
|
if (privateVarErrors.length > 0) {
|
|
2482
2491
|
logger.error(
|
|
2483
|
-
`\n ${privateVarErrors.length} private var error(s). Use standard CSS properties instead.`,
|
|
2492
|
+
`\n ${source}${privateVarErrors.length} private var error(s). Use standard CSS properties instead.`,
|
|
2484
2493
|
);
|
|
2485
2494
|
}
|
|
2486
2495
|
|
|
@@ -2719,7 +2728,7 @@ async function themeBuildInternal(
|
|
|
2719
2728
|
for (const message of droppedDeclarations) {
|
|
2720
2729
|
const w = `Declaration ${message}. The generated CSS omits it; fix the value in the theme source.`;
|
|
2721
2730
|
warningMessages.push(w);
|
|
2722
|
-
logger.warn(` [warn] ${w}`);
|
|
2731
|
+
logger.warn(` [warn] ${source}${w}`);
|
|
2723
2732
|
}
|
|
2724
2733
|
const unemittedHeadingTypes = headingTypesWithoutEmittedRule(
|
|
2725
2734
|
customHeadingTypes(themeDef),
|
|
@@ -2741,7 +2750,7 @@ async function themeBuildInternal(
|
|
|
2741
2750
|
);
|
|
2742
2751
|
}
|
|
2743
2752
|
if (cssParts.length === 0) {
|
|
2744
|
-
logger.log(
|
|
2753
|
+
logger.log(`${source}No overrides found; nothing to build.`);
|
|
2745
2754
|
return null;
|
|
2746
2755
|
}
|
|
2747
2756
|
// The data-token defaults are theme-independent and go in @layer
|
|
@@ -2933,19 +2942,21 @@ async function themeBuildInternal(
|
|
|
2933
2942
|
|
|
2934
2943
|
writeBuildOutputs(writes);
|
|
2935
2944
|
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
` ${tokenCount} token overrides, ${componentCount} component overrides`,
|
|
2940
|
-
);
|
|
2941
|
-
logger.log(` ${size} KB`);
|
|
2942
|
-
logger.log(`[ok] ${path.relative(cwd, jsPath)}`);
|
|
2943
|
-
logger.log(`[ok] ${path.relative(cwd, dtsPath)}`);
|
|
2944
|
-
if (variantDtsPath && variantDecl) {
|
|
2945
|
-
const augCount = (variantDecl.match(/': true;/g) || []).length;
|
|
2945
|
+
if (!report.compact) {
|
|
2946
|
+
logger.log(`\n[ok] ${path.relative(cwd, outPath)}`);
|
|
2947
|
+
logger.log(`[ok] ${path.relative(cwd, cssDtsPath)}`);
|
|
2946
2948
|
logger.log(
|
|
2947
|
-
`
|
|
2949
|
+
` ${tokenCount} token overrides, ${componentCount} component overrides`,
|
|
2948
2950
|
);
|
|
2951
|
+
logger.log(` ${size} KB`);
|
|
2952
|
+
logger.log(`[ok] ${path.relative(cwd, jsPath)}`);
|
|
2953
|
+
logger.log(`[ok] ${path.relative(cwd, dtsPath)}`);
|
|
2954
|
+
if (variantDtsPath && variantDecl) {
|
|
2955
|
+
const augCount = (variantDecl.match(/': true;/g) || []).length;
|
|
2956
|
+
logger.log(
|
|
2957
|
+
`[ok] ${path.relative(cwd, variantDtsPath)} (${augCount} type augmentations)`,
|
|
2958
|
+
);
|
|
2959
|
+
}
|
|
2949
2960
|
}
|
|
2950
2961
|
|
|
2951
2962
|
const relOutDir = path.relative(cwd, outDir) || '.';
|
|
@@ -2953,25 +2964,6 @@ async function themeBuildInternal(
|
|
|
2953
2964
|
const jsImport = importSpecifier(relOutDir, baseName);
|
|
2954
2965
|
const cssImport = importSpecifier(relOutDir, cssBase) + '.css';
|
|
2955
2966
|
const exportName = `${toIdentifier(baseName)}Theme`;
|
|
2956
|
-
logger.log(`
|
|
2957
|
-
Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
|
|
2958
|
-
|
|
2959
|
-
import { ${exportName} } from '${jsImport}';
|
|
2960
|
-
import '${cssImport}';
|
|
2961
|
-
|
|
2962
|
-
<Theme theme={${exportName}}>
|
|
2963
|
-
<App />
|
|
2964
|
-
</Theme>
|
|
2965
|
-
|
|
2966
|
-
Or with a <link> tag:
|
|
2967
|
-
|
|
2968
|
-
import { ${exportName} } from '${jsImport}';
|
|
2969
|
-
|
|
2970
|
-
<link rel="stylesheet" href="${cssImport}" />
|
|
2971
|
-
<Theme theme={${exportName}}>
|
|
2972
|
-
<App />
|
|
2973
|
-
</Theme>
|
|
2974
|
-
`);
|
|
2975
2967
|
|
|
2976
2968
|
// Fonts the theme names but nothing loads (#5015). Resolved tokens and
|
|
2977
2969
|
// component overrides carry the final font-family values on both load
|
|
@@ -2985,15 +2977,27 @@ Or with a <link> tag:
|
|
|
2985
2977
|
// permanently in violation of its own "compiles with no warnings" guard).
|
|
2986
2978
|
// Adaptation rules are resolved theme writes in their own right, so a family
|
|
2987
2979
|
// named only inside one needs the same notice as one named at the root.
|
|
2980
|
+
/** @type {string[]} */
|
|
2981
|
+
const fontNotices = [];
|
|
2988
2982
|
for (const family of unloadedFonts) {
|
|
2989
2983
|
const msg = `Font "${family}" is named by this theme but not loaded; add a <link> or @font-face in your app (recipe: astryx docs typography)`;
|
|
2990
2984
|
noticeMessages.push(msg);
|
|
2991
|
-
|
|
2992
|
-
}
|
|
2993
|
-
if (unloadedFonts.length > 0) {
|
|
2994
|
-
logger.log(formatFontLoadingHelp(themeDef.name, unloadedFonts));
|
|
2985
|
+
fontNotices.push(msg);
|
|
2995
2986
|
}
|
|
2996
2987
|
|
|
2988
|
+
/** @type {ThemeBuildTrailer} */
|
|
2989
|
+
const trailer = {
|
|
2990
|
+
themeName: themeDef.name,
|
|
2991
|
+
exportName,
|
|
2992
|
+
jsImport,
|
|
2993
|
+
cssImport,
|
|
2994
|
+
unloadedFonts,
|
|
2995
|
+
fontNotices,
|
|
2996
|
+
};
|
|
2997
|
+
// A batch or compact report prints this once for the whole run instead.
|
|
2998
|
+
if (report.trailers) report.trailers.push(trailer);
|
|
2999
|
+
else printBuildTrailer(trailer);
|
|
3000
|
+
|
|
2997
3001
|
return {
|
|
2998
3002
|
type: 'theme.build',
|
|
2999
3003
|
data: {
|
|
@@ -3016,6 +3020,166 @@ Or with a <link> tag:
|
|
|
3016
3020
|
};
|
|
3017
3021
|
}
|
|
3018
3022
|
|
|
3023
|
+
/**
|
|
3024
|
+
* What a standalone build prints after its [ok] lines, kept as data so a
|
|
3025
|
+
* batch can print it once for every theme.
|
|
3026
|
+
* @typedef {object} ThemeBuildTrailer
|
|
3027
|
+
* @property {string} themeName The theme's name.
|
|
3028
|
+
* @property {string} exportName The built module's theme export.
|
|
3029
|
+
* @property {string} jsImport Import specifier of the built JS module.
|
|
3030
|
+
* @property {string} cssImport Import specifier of the built CSS.
|
|
3031
|
+
* @property {string[]} unloadedFonts Font families the theme names but does not load.
|
|
3032
|
+
* @property {string[]} fontNotices One notice per unloaded font family.
|
|
3033
|
+
*/
|
|
3034
|
+
|
|
3035
|
+
/**
|
|
3036
|
+
* Print a standalone build's install snippet and font guidance.
|
|
3037
|
+
* @param {ThemeBuildTrailer} trailer
|
|
3038
|
+
*/
|
|
3039
|
+
function printBuildTrailer(trailer) {
|
|
3040
|
+
logger.log(`
|
|
3041
|
+
Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
|
|
3042
|
+
|
|
3043
|
+
import { Theme } from '@astryxdesign/core';
|
|
3044
|
+
import { ${trailer.exportName} } from '${trailer.jsImport}';
|
|
3045
|
+
import '${trailer.cssImport}';
|
|
3046
|
+
|
|
3047
|
+
<Theme theme={${trailer.exportName}}>
|
|
3048
|
+
<App />
|
|
3049
|
+
</Theme>
|
|
3050
|
+
|
|
3051
|
+
Or with a <link> tag:
|
|
3052
|
+
|
|
3053
|
+
import { Theme } from '@astryxdesign/core';
|
|
3054
|
+
import { ${trailer.exportName} } from '${trailer.jsImport}';
|
|
3055
|
+
|
|
3056
|
+
<link rel="stylesheet" href="${trailer.cssImport}" />
|
|
3057
|
+
<Theme theme={${trailer.exportName}}>
|
|
3058
|
+
<App />
|
|
3059
|
+
</Theme>
|
|
3060
|
+
`);
|
|
3061
|
+
for (const msg of trailer.fontNotices) logger.log(` note: ${msg}`);
|
|
3062
|
+
if (trailer.unloadedFonts.length > 0) {
|
|
3063
|
+
logger.log(formatFontLoadingHelp(trailer.themeName, trailer.unloadedFonts));
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
|
|
3067
|
+
/**
|
|
3068
|
+
* Print the install snippet and font guidance once for a batch: the first
|
|
3069
|
+
* theme as the full example, one import line per built theme, and one font
|
|
3070
|
+
* recipe naming every family the themes do not load.
|
|
3071
|
+
* @param {ThemeBuildTrailer[]} trailers
|
|
3072
|
+
*/
|
|
3073
|
+
export function printBatchTrailer(trailers) {
|
|
3074
|
+
if (trailers.length === 0) return;
|
|
3075
|
+
const [first] = trailers;
|
|
3076
|
+
logger.log(`
|
|
3077
|
+
Install in your app (paths are relative to a file in src/; adjust if yours lives elsewhere):
|
|
3078
|
+
|
|
3079
|
+
import { Theme } from '@astryxdesign/core';
|
|
3080
|
+
import { ${first.exportName} } from '${first.jsImport}';
|
|
3081
|
+
import '${first.cssImport}';
|
|
3082
|
+
|
|
3083
|
+
<Theme theme={${first.exportName}}>
|
|
3084
|
+
<App />
|
|
3085
|
+
</Theme>
|
|
3086
|
+
|
|
3087
|
+
Or with a <link> tag:
|
|
3088
|
+
|
|
3089
|
+
import { Theme } from '@astryxdesign/core';
|
|
3090
|
+
import { ${first.exportName} } from '${first.jsImport}';
|
|
3091
|
+
|
|
3092
|
+
<link rel="stylesheet" href="${first.cssImport}" />
|
|
3093
|
+
<Theme theme={${first.exportName}}>
|
|
3094
|
+
<App />
|
|
3095
|
+
</Theme>
|
|
3096
|
+
`);
|
|
3097
|
+
if (trailers.length > 1) {
|
|
3098
|
+
logger.log('Each built theme imports the same way:');
|
|
3099
|
+
for (const trailer of trailers) {
|
|
3100
|
+
logger.log(
|
|
3101
|
+
` import { ${trailer.exportName} } from '${trailer.jsImport}'; import '${trailer.cssImport}';`,
|
|
3102
|
+
);
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
const fonts = groupUnloadedFonts(trailers);
|
|
3106
|
+
if (fonts.length > 0) logger.log(formatBatchFontLoadingHelp(fonts));
|
|
3107
|
+
}
|
|
3108
|
+
|
|
3109
|
+
/**
|
|
3110
|
+
* Print what a short report keeps after its one line per theme: one line
|
|
3111
|
+
* naming the fonts the themes do not load, and, when the caller chose no
|
|
3112
|
+
* detail level, where the install example and font recipe are.
|
|
3113
|
+
* @param {ThemeBuildTrailer[]} trailers
|
|
3114
|
+
* @param {{hint?: boolean}} [options]
|
|
3115
|
+
*/
|
|
3116
|
+
export function printCompactTrailer(trailers, {hint = false} = {}) {
|
|
3117
|
+
if (trailers.length === 0) return;
|
|
3118
|
+
const fonts = groupUnloadedFonts(trailers);
|
|
3119
|
+
if (fonts.length > 0) {
|
|
3120
|
+
const named = fonts
|
|
3121
|
+
.map(({family, themes}) =>
|
|
3122
|
+
trailers.length > 1
|
|
3123
|
+
? `"${family}" (${themes.join(', ')})`
|
|
3124
|
+
: `"${family}"`,
|
|
3125
|
+
)
|
|
3126
|
+
.join(', ');
|
|
3127
|
+
logger.log(
|
|
3128
|
+
`[note] Fonts named but not loaded: ${named}. Load them in your app (recipe: astryx docs typography).`,
|
|
3129
|
+
);
|
|
3130
|
+
}
|
|
3131
|
+
if (hint) {
|
|
3132
|
+
logger.log(
|
|
3133
|
+
'Run with --detail full for the install example and font recipe.',
|
|
3134
|
+
);
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
|
|
3138
|
+
/**
|
|
3139
|
+
* Each font family the themes name but do not load, with the themes that
|
|
3140
|
+
* name it, in first-seen order.
|
|
3141
|
+
* @param {ThemeBuildTrailer[]} trailers
|
|
3142
|
+
* @returns {Array<{family: string, themes: string[]}>}
|
|
3143
|
+
*/
|
|
3144
|
+
function groupUnloadedFonts(trailers) {
|
|
3145
|
+
/** @type {Map<string, {family: string, themes: string[]}>} */
|
|
3146
|
+
const byFamily = new Map();
|
|
3147
|
+
for (const trailer of trailers) {
|
|
3148
|
+
for (const family of trailer.unloadedFonts) {
|
|
3149
|
+
const key = family.toLowerCase();
|
|
3150
|
+
const entry = byFamily.get(key) ?? {family, themes: []};
|
|
3151
|
+
entry.themes.push(trailer.themeName);
|
|
3152
|
+
byFamily.set(key, entry);
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
return [...byFamily.values()];
|
|
3156
|
+
}
|
|
3157
|
+
|
|
3158
|
+
/**
|
|
3159
|
+
* Build one theme for a batch or compact CLI report. Same build, outputs, and
|
|
3160
|
+
* receipt as {@link themeBuild}; the install snippet and font guidance come
|
|
3161
|
+
* back as `trailer` instead of being printed, and `compact` leaves out the
|
|
3162
|
+
* per-file progress lines. CLI-internal: not exported from the API entry.
|
|
3163
|
+
* @param {string} file
|
|
3164
|
+
* @param {{out?: string, check?: boolean, iconsSpecifier?: string}} [options]
|
|
3165
|
+
* @param {{cwd?: string}} [ctx]
|
|
3166
|
+
* @param {{compact?: boolean}} [report]
|
|
3167
|
+
* @returns {Promise<{receipt: import('../theme.type.mjs').ThemeBuildResponse | import('../theme.type.mjs').ThemeBuildCheckResponse | null, trailer: ThemeBuildTrailer | null}>}
|
|
3168
|
+
*/
|
|
3169
|
+
export async function themeBuildForReport(
|
|
3170
|
+
file,
|
|
3171
|
+
options = {},
|
|
3172
|
+
ctx = {},
|
|
3173
|
+
{compact = false} = {},
|
|
3174
|
+
) {
|
|
3175
|
+
/** @type {ThemeBuildTrailer[]} */
|
|
3176
|
+
const trailers = [];
|
|
3177
|
+
const receipt = /** @type {any} */ (
|
|
3178
|
+
await themeBuildInternal(file, options, ctx, {compact, trailers})
|
|
3179
|
+
);
|
|
3180
|
+
return {receipt, trailer: trailers[0] ?? null};
|
|
3181
|
+
}
|
|
3182
|
+
|
|
3019
3183
|
/** @param {string} file @param {{out?: string, check?: boolean, iconsSpecifier?: string}} [options] @param {{cwd?: string}} [ctx] @returns {Promise<import('../theme.type.mjs').ThemeBuildResponse | import('../theme.type.mjs').ThemeBuildCheckResponse | null>} */
|
|
3020
3184
|
export async function themeBuild(file, options = {}, ctx = {}) {
|
|
3021
3185
|
return /** @type {any} */ (themeBuildInternal(file, options, ctx));
|
|
@@ -38,3 +38,14 @@ export function collectUnloadedFonts(resolvedTheme: {
|
|
|
38
38
|
* @returns {string}
|
|
39
39
|
*/
|
|
40
40
|
export function formatFontLoadingHelp(themeName: string, families: string[]): string;
|
|
41
|
+
/**
|
|
42
|
+
* The same fix once for a batch build: each family the built themes name but
|
|
43
|
+
* do not load, with the themes that name it, then one recipe for all of them.
|
|
44
|
+
*
|
|
45
|
+
* @param {Array<{family: string, themes: string[]}>} entries
|
|
46
|
+
* @returns {string}
|
|
47
|
+
*/
|
|
48
|
+
export function formatBatchFontLoadingHelp(entries: Array<{
|
|
49
|
+
family: string;
|
|
50
|
+
themes: string[];
|
|
51
|
+
}>): string;
|
|
@@ -202,6 +202,33 @@ export function collectUnloadedFonts(resolvedTheme) {
|
|
|
202
202
|
*/
|
|
203
203
|
export function formatFontLoadingHelp(themeName, families) {
|
|
204
204
|
const named = families.map(f => `"${f}"`).join(', ');
|
|
205
|
+
return `
|
|
206
|
+
[note] Theme "${themeName}" names fonts it does not load: ${named}
|
|
207
|
+
${fontLoadingRecipe(families)}`;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* The same fix once for a batch build: each family the built themes name but
|
|
212
|
+
* do not load, with the themes that name it, then one recipe for all of them.
|
|
213
|
+
*
|
|
214
|
+
* @param {Array<{family: string, themes: string[]}>} entries
|
|
215
|
+
* @returns {string}
|
|
216
|
+
*/
|
|
217
|
+
export function formatBatchFontLoadingHelp(entries) {
|
|
218
|
+
const named = entries
|
|
219
|
+
.map(({family, themes}) => ` "${family}" (${themes.join(', ')})`)
|
|
220
|
+
.join('\n');
|
|
221
|
+
return `
|
|
222
|
+
[note] The built themes name fonts they do not load:
|
|
223
|
+
${named}
|
|
224
|
+
${fontLoadingRecipe(entries.map(entry => entry.family))}`;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* @param {string[]} families
|
|
229
|
+
* @returns {string}
|
|
230
|
+
*/
|
|
231
|
+
function fontLoadingRecipe(families) {
|
|
205
232
|
const cssHref =
|
|
206
233
|
'https://fonts.googleapis.com/css2?' +
|
|
207
234
|
families
|
|
@@ -210,9 +237,7 @@ export function formatFontLoadingHelp(themeName, families) {
|
|
|
210
237
|
'&display=swap';
|
|
211
238
|
const first = families[0];
|
|
212
239
|
const slug = first.toLowerCase().replace(/ /g, '-');
|
|
213
|
-
return `
|
|
214
|
-
[note] Theme "${themeName}" names fonts it does not load: ${named}
|
|
215
|
-
The built CSS only sets font-family; load these in your app, or every
|
|
240
|
+
return ` The built CSS only sets font-family; load these in your app, or every
|
|
216
241
|
browser quietly falls back.
|
|
217
242
|
|
|
218
243
|
Google Fonts (add :wght@... axes as your theme's weights require):
|
|
@@ -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
|
{
|
|
@@ -34,7 +34,7 @@ export const docs = {
|
|
|
34
34
|
{
|
|
35
35
|
title: 'defineTheme',
|
|
36
36
|
content: [
|
|
37
|
-
{type: 'prose', text: "defineTheme creates a theme from token overrides and optional scale configs. Scale configs generate tokens from parameters. Explicit token overrides always take precedence over scale-generated values, token by token. localTokens accepts any valid CSS custom-property name; prefixes do not establish ownership. One caveat for the accent: overriding --color-accent in tokens re-points the reference tokens (--color-accent-muted, --color-text-accent, --color-icon-accent) but NOT --color-on-accent, which stays baked from the color.accent seed. To give each scheme its own accent with a consistent derived palette, pass a [light, dark] tuple to color.accent instead of overriding the token."},
|
|
37
|
+
{type: 'prose', text: "defineTheme creates a theme from token overrides and optional scale configs. Only override tokens that differ from defaults; omitted tokens use the design system defaults. Scale configs generate tokens from parameters. Explicit token overrides always take precedence over scale-generated values, token by token. localTokens accepts any valid CSS custom-property name; prefixes do not establish ownership. One caveat for the accent: overriding --color-accent in tokens re-points the reference tokens (--color-accent-muted, --color-text-accent, --color-icon-accent) but NOT --color-on-accent, which stays baked from the color.accent seed. To give each scheme its own accent with a consistent derived palette, pass a [light, dark] tuple to color.accent instead of overriding the token."},
|
|
38
38
|
{type: 'code', lang: 'tsx', label: 'defineTheme with scale configs', code: "import {defineTheme} from '@astryxdesign/core/theme';\n\nconst myTheme = defineTheme({\n name: 'my-theme',\n // accent: single hex, or [light, dark] tuple to seed each scheme separately\n color: { accent: ['#7B61FF', '#9B85FF'], neutralStyle: 'cool' },\n typography: {\n scale: { base: 14, ratio: 1.2 },\n body: { family: 'Inter', fallbacks: '-apple-system, sans-serif' },\n },\n radius: { base: 4, multiplier: 1 },\n motion: { fast: 175, medium: 410, ratio: 0.75 },\n tokens: {\n // Explicit overrides take precedence over scale-generated values\n '--color-background-body': ['#FFFFFF', '#0A0A0A'],\n },\n});"},
|
|
39
39
|
{type: 'table', headers: ['Config', 'Generates', 'Parameters'], rows: [
|
|
40
40
|
['color', '--color-accent, --color-background-*, --color-text-*, --color-border, etc.', 'accent? (hex or [light, dark] tuple; omit for neutral-only), neutralStyle? (warm|cool|neutral), contrast? (standard|high)'],
|
|
@@ -60,18 +60,18 @@ export const docs = {
|
|
|
60
60
|
['typography, motion, radius, color', 'Child config replaces base entirely (these are scale inputs, not additive).'],
|
|
61
61
|
['adaptations', 'Width-breakpoint overrides merge by fixed name. Inherited ordered rules keep their relative order; child rules append and re-resolve against the child root axes.'],
|
|
62
62
|
]},
|
|
63
|
-
{type: 'prose', text: "Inheritance is resolved when the theme is defined, so an extended theme is flat: `astryx theme build` emits one self-contained stylesheet holding everything the child inherited, and the base theme's CSS does not need to be loaded next to it."},
|
|
63
|
+
{type: 'prose', text: "Inheritance is resolved when the theme is defined, so an extended theme is flat: `astryx theme build` emits one self-contained stylesheet holding everything the child inherited, and the base theme's CSS does not need to be loaded next to it. A base that is not a theme (most often an import that missed) throws when `defineTheme` runs, rather than producing a theme that silently inherits nothing."},
|
|
64
64
|
{type: 'prose', text: 'For the integration-specific guidance on mapping a palette to tokens when extending, see `astryx docs cli/integrations/building-blocks/themes/define-the-theme`.'},
|
|
65
65
|
],
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
title: 'Component Style Overrides',
|
|
69
69
|
content: [
|
|
70
|
-
{type: 'prose', text: 'The `components` field in defineTheme uses semantic component keys and style keys, not raw CSS selectors. Use `base` for all instances, `variant:value` or `stateName` for specific props/states, and let the theme pipeline choose the underlying selector. For raw external CSS escape hatches, prefer the data-attribute selector surface documented in {@link generic:styling}.'},
|
|
70
|
+
{type: 'prose', text: 'The `components` field in defineTheme uses semantic component keys and style keys, not raw CSS selectors. Use `base` for all instances, `variant:value` or `stateName` for specific props/states, and let the theme pipeline choose the underlying selector. For raw external CSS escape hatches, prefer the data-attribute selector surface documented in {@link generic:styling-advanced}.'},
|
|
71
71
|
{type: 'code', lang: 'tsx', label: 'Component overrides with standard CSS', code: "components: {\n card: {\n base: { borderRadius: '20px', padding: '24px' },\n },\n button: {\n base: {\n borderRadius: '9999px',\n textTransform: 'uppercase',\n '--button-focus-offset': '3px',\n },\n 'variant:ghost': { borderWidth: '2px', borderStyle: 'solid' },\n },\n}"},
|
|
72
72
|
{type: 'prose', text: "Run `astryx theme targets` for every themeable key in the system (`astryx theme targets <Name>` to scope it, `--json` to lint a theme against it), and `astryx component <Name>` for one component's theming targets, public CSS variables, and which standard CSS properties are supported."},
|
|
73
73
|
{type: 'list', style: 'do', items: ['Write standard CSS properties (borderRadius, padding); the pipeline expands them into internal vars.', 'Set public CSS vars directly when no standard property equivalent exists.']},
|
|
74
|
-
{type: 'list', style: 'dont', items: ['Set private CSS vars (prefixed --_) directly. Use standard CSS properties instead. `astryx theme build` will error.']},
|
|
74
|
+
{type: 'list', style: 'dont', items: ['Set private CSS vars (prefixed --_) directly. Use standard CSS properties instead. `astryx theme build` will error.', 'Set a public CSS var the component does not define. It compiles to CSS that never applies, and the build does not warn. Take the names from `astryx component <Name>`.']},
|
|
75
75
|
],
|
|
76
76
|
},
|
|
77
77
|
{
|
|
@@ -94,7 +94,7 @@ export const docs = {
|
|
|
94
94
|
['contrast', 'more | less | no-preference'],
|
|
95
95
|
['motion', 'reduce | no-preference'],
|
|
96
96
|
]},
|
|
97
|
-
{type: 'prose', text: "`widthBreakpoints` are fixed named start points. Defaults are 640 / 768 / 1024 / 1280 / 1536 CSS pixels. `from` includes its point; `below` excludes it."},
|
|
97
|
+
{type: 'prose', text: "`widthBreakpoints` are fixed named start points. Defaults are 640 / 768 / 1024 / 1280 / 1536 CSS pixels. `from` includes its point; `below` excludes it. Breakpoint configuration alone emits no CSS."},
|
|
98
98
|
],
|
|
99
99
|
},
|
|
100
100
|
{
|
|
@@ -103,6 +103,7 @@ export const docs = {
|
|
|
103
103
|
content: [
|
|
104
104
|
{type: 'prose', text: "Precedence follows rule order. Root theme values apply first, then every matching rule in declaration order. A later rule may deliberately restore a root value. `onDark` and `onLight` media-surface overrides apply after adaptations and win on the same leaf."},
|
|
105
105
|
{type: 'prose', text: "`extends` preserves the base rule order and appends child rules. Inherited conditions use the child's effective breakpoint map. An empty child rule is a no-op, not a removal operator."},
|
|
106
|
+
{type: 'prose', text: "A rule may replace a theme-local token only when the exact name is already enrolled by root `localTokens` or an enrolled base. Component writes in a rule are validated exactly like root `components`: same targets, axes, and value domains. The one addition is that a rule may not be the only place a custom value is enrolled: a value that is valid only because a theme enrolls it generates unconditional type augmentation, so declare it on the root theme first and let rules restyle it. Built-in values need no root declaration. When rules can match together, their ordered portable and local token writes are validated as one effective graph; any reachable cycle fails before CSS is emitted."},
|
|
106
107
|
{type: 'prose', text: 'Adaptations compile to CSS media queries with no resize listener or styling rerender. Runtime and `astryx theme build` use the same compiler, but only a built theme is present at first paint in an SSR app.'},
|
|
107
108
|
],
|
|
108
109
|
},
|
|
@@ -118,8 +119,9 @@ export const docs = {
|
|
|
118
119
|
['ocean.d.ts', 'TypeScript declarations for the theme and icon registry exports'],
|
|
119
120
|
['ocean.variants.d.ts', "(Optional) Module augmentations for custom component prop values"],
|
|
120
121
|
]},
|
|
121
|
-
{type: '
|
|
122
|
-
{type: '
|
|
122
|
+
{type: 'prose', text: 'The `__built: true` flag tells Theme to skip runtime `<style>` injection; the CSS file handles it. Load the generated CSS wherever you load the module.'},
|
|
123
|
+
{type: 'code', lang: 'tsx', label: 'Using a custom built theme', code: "import {Theme} from '@astryxdesign/core';\nimport {oceanTheme} from './themes/ocean';\nimport './themes/ocean.css';\n\n<Theme theme={oceanTheme}>\n <App />\n</Theme>"},
|
|
124
|
+
{type: 'prose', text: "After upgrading Astryx, rerun `astryx theme build` for every custom prebuilt theme. Deploy the regenerated files together. The runtime intentionally trusts `__built: true` and will not repair stale CSS from an older build. The build also warns when the theme names font families it does not load. See {@link generic:font-setup} for the full recipe."},
|
|
123
125
|
{type: 'prose', text: 'For the runtime vs built tradeoff, see the Runtime vs Built section of {@link generic:use-a-theme}.'},
|
|
124
126
|
],
|
|
125
127
|
},
|
|
@@ -129,13 +131,15 @@ export const docs = {
|
|
|
129
131
|
content: [
|
|
130
132
|
{type: 'prose', text: "`theme build` emits an icon import when it detects a named import used by the theme's `icons:` field. It does not compile that registry module. Move the registry to a separate module and use a named import."},
|
|
131
133
|
{type: 'code', lang: 'bash', label: 'Compiling the icon registry sidecar', code: "# Emit the built theme\nastryx theme build ./src/themes/ocean.ts -o dist/theme.css --icons-specifier ./icons.mjs\n\n# Compile the icon registry alongside it\nesbuild src/themes/icons.tsx --bundle --format=esm --outfile=dist/icons.mjs \\\n --external:react --external:lucide-react --jsx=automatic"},
|
|
134
|
+
{type: 'prose', text: 'In the example above, the generated theme imports `./icons.mjs` from `dist`. If the second command is skipped, `theme build` can still succeed, but loading or bundling the generated module fails because `dist/icons.mjs` is missing. `--icons-specifier` changes the emitted import; it does not create or verify the target file. Match the specifier to a module that resolves from the generated JS file.'},
|
|
135
|
+
{type: 'prose', text: 'Without `--icons-specifier`, the detected source import specifier is emitted unchanged. In the default flow without `--out`, a bundler can resolve an extensionless `./icons` to the neighboring `icons.tsx` source, but Node ESM does not perform that lookup and reports `ERR_MODULE_NOT_FOUND`. Moving the output with `--out` also changes where relative imports resolve from.'},
|
|
132
136
|
{type: 'prose', text: 'Keep `react` and the icon library external so the registry does not bundle its own copies of those dependencies.'},
|
|
133
137
|
],
|
|
134
138
|
},
|
|
135
139
|
{
|
|
136
140
|
title: 'Building a Theme Family',
|
|
137
141
|
content: [
|
|
138
|
-
{type: 'prose', text: 'Use family mode when an app switches among one base theme and its selected descendants. The build writes one keyed CSS file containing every member, plus one keyed JavaScript module and one declaration file.'},
|
|
142
|
+
{type: 'prose', text: 'Use family mode when an app switches among one base theme and its selected descendants. The build writes one keyed CSS file containing every member, plus one keyed JavaScript module and one declaration file, beside the root source.'},
|
|
139
143
|
{type: 'code', lang: 'bash', label: 'Build one family', code: "astryx theme build --family \\\n ./src/themes/ocean.mjs \\\n ./src/themes/ocean-calm.mjs \\\n ./src/themes/ocean-calm-deep.mjs \\\n --family-key ocean-family"},
|
|
140
144
|
{type: 'prose', text: 'The family stylesheet eagerly downloads every selected member so first paint is complete. Switching members changes only the theme identity; it does not add, remove, or reorder stylesheets.'},
|
|
141
145
|
],
|
|
@@ -143,10 +147,11 @@ export const docs = {
|
|
|
143
147
|
{
|
|
144
148
|
title: 'Token Utilities',
|
|
145
149
|
content: [
|
|
146
|
-
{type: 'prose', text: 'Use `tokenVar()` when a non-StyleX styling library wants a CSS variable reference, and `resolveThemeTokens()` when JavaScript needs token values for a specific theme and mode without React context.'},
|
|
150
|
+
{type: 'prose', text: 'Use `tokenVar()` when a non-StyleX styling library wants a CSS variable reference, and `resolveThemeTokens()` when JavaScript needs token values for a specific theme and mode without React context. Themes are registered by name when created with `defineTheme()`; call `registerTheme(theme)` for prebuilt or object-literal themes that need name-based SSR lookup.'},
|
|
147
151
|
{type: 'code', lang: 'ts', label: 'CSS var references for styling-library configs', code: "import {tokenVar, tokenVars} from '@astryxdesign/core/theme/tokens';\n\nconst pandaOrEmotionTheme = {\n colors: {\n text: tokenVar('--color-text-primary'),\n surface: tokenVars['--color-background-surface'],\n },\n};"},
|
|
148
152
|
{type: 'code', lang: 'ts', label: 'Resolve token values without a hook', code: "import {resolveThemeTokens} from '@astryxdesign/core/theme/tokens';\nimport {neutralTheme} from '@astryxdesign/theme-neutral';\n\nconst lightTokens = resolveThemeTokens(neutralTheme, {mode: 'light'});\nconst chartTheme = {\n textColor: lightTokens['--color-text-primary'],\n seriesColor: lightTokens['--color-data-categorical-blue'],\n};"},
|
|
149
|
-
{type: 'prose', text: '
|
|
153
|
+
{type: 'prose', text: 'The `@astryxdesign/core/theme/tokens` subpath is server-safe and does not require React. The main `@astryxdesign/core/theme` barrel also re-exports these helpers for client code that already imports theme APIs.'},
|
|
154
|
+
{type: 'prose', text: 'For styling library interop patterns, see {@link namespace:styling-libraries}.'},
|
|
150
155
|
],
|
|
151
156
|
},
|
|
152
157
|
{
|
|
@@ -154,7 +159,7 @@ export const docs = {
|
|
|
154
159
|
content: [
|
|
155
160
|
{type: 'prose', text: '`useTheme()` reads the nearest Theme and effective color mode from React context. Use it inside client components for SVG, canvas, charts, maps, and third-party configuration objects that need token values in JavaScript.'},
|
|
156
161
|
{type: 'code', lang: 'tsx', label: 'Access resolved token values in React', code: "import {useMemo} from 'react';\nimport {useTheme} from '@astryxdesign/core/theme';\n\nfunction ChartConfig() {\n const {mode, tokens} = useTheme();\n const options = useMemo(() => ({\n mode,\n textColor: tokens['--color-text-primary'],\n gridColor: tokens['--color-border'],\n seriesColor: tokens['--color-data-categorical-blue'],\n }), [mode, tokens]);\n return <Chart options={options} />;\n}"},
|
|
157
|
-
{type: 'prose', text: 'Prefer CSS variables for ordinary styling. See {@link generic:use-a-theme} for the provider setup, and {@link
|
|
162
|
+
{type: 'prose', text: 'Prefer CSS variables for ordinary styling. See {@link generic:use-a-theme} for the provider setup, and {@link namespace:tokens} for the full token reference.'},
|
|
158
163
|
],
|
|
159
164
|
},
|
|
160
165
|
],
|
|
@@ -106,7 +106,7 @@ import {themes, defaultThemeSlug} from './astryx-themes';
|
|
|
106
106
|
},
|
|
107
107
|
{
|
|
108
108
|
type: 'prose',
|
|
109
|
-
text: 'These stylesheets are cascade-layered: the reset loads in @layer reset and component styles in @layer astryx-base. If your project has existing global CSS, a legacy reset, or Tailwind, declare the layer order explicitly and assign every stylesheet to a layer deliberately: unlayered styles and later layers both override astryx-base regardless of specificity. Before building screens, read the two cascade layer sections of {@link generic:migration}.',
|
|
109
|
+
text: 'These stylesheets are cascade-layered: the reset loads in @layer reset and component styles in @layer astryx-base. If your project has existing global CSS, a legacy reset, or Tailwind, declare the layer order explicitly and assign every stylesheet to a layer deliberately: unlayered styles and later layers both override astryx-base regardless of specificity. Before building screens, read the two cascade layer sections of {@link generic:migration-setup}.',
|
|
110
110
|
},
|
|
111
111
|
{
|
|
112
112
|
type: 'prose',
|
|
@@ -143,7 +143,7 @@ export default function Page() {
|
|
|
143
143
|
content: [
|
|
144
144
|
{
|
|
145
145
|
type: 'prose',
|
|
146
|
-
text: 'Astryx components support various styling solutions, from plain CSS and `className` to Tailwind and CSS-in-JS. See {@link
|
|
146
|
+
text: 'Astryx components support various styling solutions, from plain CSS and `className` to Tailwind and CSS-in-JS. See {@link namespace:styling} for the full guide. Astryx also has a deep integration with [StyleX](https://stylexjs.com/), an atomic CSS-in-JS library: create styles with `stylex.create()` and pass them to components with the `xstyle` prop.',
|
|
147
147
|
},
|
|
148
148
|
{
|
|
149
149
|
type: 'code',
|
|
@@ -6,9 +6,9 @@ export const docsDense = {
|
|
|
6
6
|
description: 'core design principles + rules for the design system',
|
|
7
7
|
sections: [
|
|
8
8
|
{ section: 'Design Philosophy', title: 'Philosophy', content: [{ type: 'prose', text: 'consistency, adaptability, DX. core ideas:' }, { type: 'list', items: ['components over primitives', 'semantic tokens over hardcoded values', 'theme-agnostic code', 'open internals'] }] },
|
|
9
|
-
{ section: 'Rules', title: 'Rules', content: [{ type: 'prose', text: '8 rules for on-system app code.' }, { type: 'list', items: ['use components', 'frame-first layout: shell + region budgets before content ({@link namespace:layout})', 'dense data = rows (Table, List/Item) not Cards; Card = widgets/galleries/settings groups', 'StyleX or Tailwind for styling ({@link
|
|
10
|
-
{ section: 'Styling Approach', title: 'Styling', content: [{ type: 'prose', text: 'xstyle prop for component overrides. StyleX or Tailwind for layout.' }, { type: 'prose', text: 'full guide: {@link
|
|
9
|
+
{ section: 'Rules', title: 'Rules', content: [{ type: 'prose', text: '8 rules for on-system app code.' }, { type: 'list', items: ['use components', 'frame-first layout: shell + region budgets before content ({@link namespace:layout})', 'dense data = rows (Table, List/Item) not Cards; Card = widgets/galleries/settings groups', 'StyleX or Tailwind for styling ({@link namespace:styling})', 'semantic tokens only ({@link namespace:tokens})', 'CSS vars for colors', 'controlled form inputs', 'useLinkComponent() for navigation'] }] },
|
|
10
|
+
{ section: 'Styling Approach', title: 'Styling', content: [{ type: 'prose', text: 'xstyle prop for component overrides. StyleX or Tailwind for layout.' }, { type: 'prose', text: 'full guide: {@link namespace:styling}' }] },
|
|
11
11
|
{ section: 'Anti-Patterns', title: 'Anti-Patterns', content: [{ type: 'prose', text: 'what breaks theming, routing, or layout, and the fix.' }, { type: 'list', items: ['no inline styles on raw elements', 'no hardcoded colors — use tokens or Tailwind semantic classes', 'no hardcoded spacing', 'no hardcoded <a> — use useLinkComponent()', 'no Card-wrapped list items — frame first, rows for dense data ({@link namespace:layout})', 'no decorative Badge — StatusDot/Token for status', 'read docs before inventing props'] }] },
|
|
12
|
-
{ section: 'Design Tokens', title: 'Tokens', content: [{ type: 'prose', text: 'full token reference: {@link
|
|
12
|
+
{ section: 'Design Tokens', title: 'Tokens', content: [{ type: 'prose', text: 'full token reference: {@link namespace:tokens}' }] },
|
|
13
13
|
],
|
|
14
14
|
};
|