@astryxdesign/cli 0.6.6-canary.fb78fa1 → 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/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/doctor.d.mts +6 -0
- package/api/doctor/doctor.mjs +149 -40
- package/api/doctor/doctor.test.mjs +104 -0
- package/api/gap-report/gap-report.doc.mjs +2 -1
- package/api/integration/validate-integration.mjs +20 -4
- package/api/integration/validate-integration.test.mjs +73 -0
- package/api/search/search.d.mts +3 -2
- package/api/search/search.domain-priority.test.mjs +35 -21
- package/api/search/search.mjs +30 -9
- package/api/swizzle/swizzle.doc.mjs +5 -2
- package/assets/docs/author-a-theme.doc.mjs +4 -4
- 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 +5 -5
- 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 +3 -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/theme.template.ts +4 -3
- 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 +13 -11
- package/clients/cli/commands/doctor-integration-components.doc.mjs +1 -1
- package/clients/cli/commands/doctor.test.mjs +33 -0
- package/clients/cli/lib/component-format.mjs +13 -3
- package/foundation/agent-docs/agent-docs.mjs +14 -1
- package/foundation/config/project.test.mjs +1 -1
- package/foundation/discovery/docs-discovery.test.mjs +1 -1
- 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 +3 -0
- package/foundation/env/package-manager.mjs +71 -3
- package/foundation/env/package-manager.test.mjs +82 -1
- package/foundation/integrations/validate-contributions.d.mts +16 -0
- package/foundation/integrations/validate-contributions.mjs +56 -8
- 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
package/api/search/search.mjs
CHANGED
|
@@ -494,8 +494,9 @@ const STRONG_TOKEN_SCORE = 70;
|
|
|
494
494
|
* {@link STRONG_TOKEN_SCORE} or above, or when it matches every word.
|
|
495
495
|
*
|
|
496
496
|
* A doc has priority when the reader asked for that doc:
|
|
497
|
-
* - 2: the whole query
|
|
498
|
-
*
|
|
497
|
+
* - 2: the whole query is the topic's name, its last route segment, or its
|
|
498
|
+
* own title, as words and whatever the plural (`font setup` is
|
|
499
|
+
* typography/font-setup, `side panel` is "Side panels");
|
|
499
500
|
* - 1: a word of the query is the topic's name (`illustration` in a longer
|
|
500
501
|
* question is the illustrations guide);
|
|
501
502
|
* - 1: the query holds one of the doc's titles whole (`resizable side panels`
|
|
@@ -525,13 +526,15 @@ export function domainPriority(term, tokens, candidate, hit) {
|
|
|
525
526
|
const words = [term, ...tokens];
|
|
526
527
|
if (candidate.domain === 'doc') {
|
|
527
528
|
const topic = String(candidate._topic ?? candidate.name).toLowerCase();
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
529
|
+
// The whole query, read as words, is the topic's route, its last
|
|
530
|
+
// segment, or its own title, whatever the plural: `side panel` is
|
|
531
|
+
// layout/side-panels, and `header and footer` is "Headers and footers".
|
|
532
|
+
// A section's title is a heading inside a topic, not the topic's name.
|
|
533
|
+
const named = [topic, topic.slice(topic.lastIndexOf('/') + 1)];
|
|
534
|
+
if (candidate._section == null && candidate.titles?.[0]) {
|
|
535
|
+
named.push(candidate.titles[0]);
|
|
536
|
+
}
|
|
537
|
+
if (named.some(n => samePhrase(term, n))) {
|
|
535
538
|
return 2;
|
|
536
539
|
}
|
|
537
540
|
if (
|
|
@@ -602,6 +605,24 @@ function samePhraseWord(a, b) {
|
|
|
602
605
|
);
|
|
603
606
|
}
|
|
604
607
|
|
|
608
|
+
/**
|
|
609
|
+
* Whether two phrases are the same words, in order, ignoring case,
|
|
610
|
+
* punctuation, and a plural on any word: `side panel` is "Side panels", and
|
|
611
|
+
* `headers and footers` is `header-and-footer`.
|
|
612
|
+
* @param {string} a
|
|
613
|
+
* @param {string} b
|
|
614
|
+
* @returns {boolean}
|
|
615
|
+
*/
|
|
616
|
+
function samePhrase(a, b) {
|
|
617
|
+
const x = phraseWords(a);
|
|
618
|
+
const y = phraseWords(b);
|
|
619
|
+
return (
|
|
620
|
+
x.length > 0 &&
|
|
621
|
+
x.length === y.length &&
|
|
622
|
+
x.every((w, k) => samePhraseWord(w, y[k]) || sameWord(w, y[k]))
|
|
623
|
+
);
|
|
624
|
+
}
|
|
625
|
+
|
|
605
626
|
/**
|
|
606
627
|
* Whether `plural` is the plural of `word`: `integrations` of `integration`,
|
|
607
628
|
* `boxes` of `box`. `es` only follows s, x, z, ch, or sh, so `notes` is not a
|
|
@@ -19,7 +19,10 @@ export const doc = {
|
|
|
19
19
|
'It copies from the locally resolved @astryxdesign/core (or the owning integration) ' +
|
|
20
20
|
'package source, rewriting imports that escape the component directory to the owner ' +
|
|
21
21
|
"package's subpaths and flagging whether any copied file uses StyleX. With no name " +
|
|
22
|
-
'(or list) it returns the swizzlable component names instead.'
|
|
22
|
+
'(or list) it returns the swizzlable component names instead. An integration ' +
|
|
23
|
+
'component that replaces a Core component is what that Core name copies; ' +
|
|
24
|
+
"options.package '@astryxdesign/core' copies the original. The list names Core " +
|
|
25
|
+
'components, including one an integration component replaces.',
|
|
23
26
|
importPath: '@astryxdesign/cli/api',
|
|
24
27
|
signature:
|
|
25
28
|
'swizzle(component?: string, options?: SwizzleOptions): Promise<SwizzleListResponse | SwizzleCopyResponse>',
|
|
@@ -48,7 +51,7 @@ export const doc = {
|
|
|
48
51
|
name: 'options.package',
|
|
49
52
|
type: 'string',
|
|
50
53
|
description:
|
|
51
|
-
|
|
54
|
+
"Owning package to copy from when the name is provided by more than one. Use '@astryxdesign/core' to copy an original replaced by an integration component.",
|
|
52
55
|
},
|
|
53
56
|
{
|
|
54
57
|
name: 'options.list',
|
|
@@ -67,7 +67,7 @@ export const docs = {
|
|
|
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.']},
|
|
@@ -121,7 +121,7 @@ export const docs = {
|
|
|
121
121
|
]},
|
|
122
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
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:
|
|
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."},
|
|
125
125
|
{type: 'prose', text: 'For the runtime vs built tradeoff, see the Runtime vs Built section of {@link generic:use-a-theme}.'},
|
|
126
126
|
],
|
|
127
127
|
},
|
|
@@ -151,7 +151,7 @@ export const docs = {
|
|
|
151
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};"},
|
|
152
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};"},
|
|
153
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
|
|
154
|
+
{type: 'prose', text: 'For styling library interop patterns, see {@link namespace:styling-libraries}.'},
|
|
155
155
|
],
|
|
156
156
|
},
|
|
157
157
|
{
|
|
@@ -159,7 +159,7 @@ export const docs = {
|
|
|
159
159
|
content: [
|
|
160
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.'},
|
|
161
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}"},
|
|
162
|
-
{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.'},
|
|
163
163
|
],
|
|
164
164
|
},
|
|
165
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
|
};
|
|
@@ -45,8 +45,8 @@ export const docs = {
|
|
|
45
45
|
'Use components for everything they cover',
|
|
46
46
|
'Page layout is frame-first: pick the shell and budget regions before writing content (see {@link namespace:layout})',
|
|
47
47
|
'Dense data renders as rows (Table, List/Item), edge-to-edge with dividers; Card is for widgets, galleries, and settings groups',
|
|
48
|
-
'StyleX or Tailwind for custom styling; both are first-class (see {@link
|
|
49
|
-
'Semantic tokens, not hardcoded values (see {@link
|
|
48
|
+
'StyleX or Tailwind for custom styling; both are first-class (see {@link namespace:styling})',
|
|
49
|
+
'Semantic tokens, not hardcoded values (see {@link namespace:tokens})',
|
|
50
50
|
'CSS custom properties for colors, not hex values',
|
|
51
51
|
'Form inputs are controlled (value + onChange)',
|
|
52
52
|
'Use useLinkComponent() for navigation so consumers can plug in their framework router via LinkProvider',
|
|
@@ -64,7 +64,7 @@ export const docs = {
|
|
|
64
64
|
},
|
|
65
65
|
{
|
|
66
66
|
type: 'prose',
|
|
67
|
-
text: 'See {@link
|
|
67
|
+
text: 'See {@link namespace:styling} for the complete guide with examples.',
|
|
68
68
|
},
|
|
69
69
|
],
|
|
70
70
|
},
|
|
@@ -97,7 +97,7 @@ export const docs = {
|
|
|
97
97
|
content: [
|
|
98
98
|
{
|
|
99
99
|
type: 'prose',
|
|
100
|
-
text: 'The design system provides semantic design tokens for spacing, color, radius, shadow, typography, and size. Tokens adapt to the active theme and color mode. Run {@link
|
|
100
|
+
text: 'The design system provides semantic design tokens for spacing, color, radius, shadow, typography, and size. Tokens adapt to the active theme and color mode. Run {@link namespace:tokens} for the full reference with all values.',
|
|
101
101
|
},
|
|
102
102
|
],
|
|
103
103
|
},
|
|
@@ -6,9 +6,9 @@ export const docsZh = {
|
|
|
6
6
|
description: 'Astryx 核心设计原则和规则。',
|
|
7
7
|
sections: [
|
|
8
8
|
{ section: 'Design Philosophy', title: '设计哲学', content: [{ type: 'prose', text: '一个注重一致性、适应性和开发者体验的设计系统。核心理念:' }, { type: 'list', items: ['组件优于原始元素 — 优先使用 Astryx 组件', '语义化令牌优于硬编码值', '主题无关的代码 — 深色模式自动生效', '开放的内部机制 — 所有基础组件均可导出和组合'] }] },
|
|
9
|
-
{ section: 'Rules', title: '规则', content: [{ type: 'prose', text: '让应用代码保持在设计系统之内的八条规则。' }, { type: 'list', items: ['所有支持的场景都使用 Astryx 组件', '布局采用框架优先:先选定外壳并规划区域尺寸,再编写内容(见 {@link namespace:layout})', '密集数据使用行(Table、List/Item)通栏渲染;Card 用于小部件、画廊和设置分组', '使用 StyleX 或 Tailwind 进行样式设置(见 {@link
|
|
10
|
-
{ section: 'Styling Approach', title: '样式方法', content: [{ type: 'prose', text: '组件覆盖使用 xstyle 属性。布局使用 StyleX 或 Tailwind。' }, { type: 'prose', text: '完整指南见 {@link
|
|
9
|
+
{ section: 'Rules', title: '规则', content: [{ type: 'prose', text: '让应用代码保持在设计系统之内的八条规则。' }, { type: 'list', items: ['所有支持的场景都使用 Astryx 组件', '布局采用框架优先:先选定外壳并规划区域尺寸,再编写内容(见 {@link namespace:layout})', '密集数据使用行(Table、List/Item)通栏渲染;Card 用于小部件、画廊和设置分组', '使用 StyleX 或 Tailwind 进行样式设置(见 {@link namespace:styling})', '使用语义化令牌,不使用硬编码值(见 {@link namespace:tokens})', '使用 CSS 变量设置颜色,不使用十六进制值', '表单输入为受控组件(value + onChange)', '使用 useLinkComponent() 进行导航'] }] },
|
|
10
|
+
{ section: 'Styling Approach', title: '样式方法', content: [{ type: 'prose', text: '组件覆盖使用 xstyle 属性。布局使用 StyleX 或 Tailwind。' }, { type: 'prose', text: '完整指南见 {@link namespace:styling}。' }] },
|
|
11
11
|
{ section: 'Anti-Patterns', title: '反模式', content: [{ type: 'prose', text: '会破坏主题、路由或布局的写法,以及应改用的做法。' }, { type: 'list', items: ['不要在原始元素上使用内联样式', '不要硬编码颜色 — 使用令牌或 Tailwind 语义类', '不要硬编码间距', '不要硬编码 <a> 元素 — 使用 useLinkComponent()', '不要把每个列表项都包在 Card 里 — 先定框架,密集数据用行渲染(见 {@link namespace:layout})', '不要把 Badge 当装饰 — 状态请使用 StatusDot 或 Token', '不要自创属性。先阅读组件文档'] }] },
|
|
12
|
-
{ section: 'Design Tokens', title: '设计令牌', content: [{ type: 'prose', text: '完整令牌参考见 {@link
|
|
12
|
+
{ section: 'Design Tokens', title: '设计令牌', content: [{ type: 'prose', text: '完整令牌参考见 {@link namespace:tokens}。' }] },
|
|
13
13
|
],
|
|
14
14
|
};
|
|
@@ -112,7 +112,7 @@ export const docs = {
|
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
114
|
type: 'prose',
|
|
115
|
-
text: 'For Tailwind v3, see the layer workaround in {@link generic:migration}.',
|
|
115
|
+
text: 'For Tailwind v3, see the layer workaround in {@link generic:migration-setup}.',
|
|
116
116
|
},
|
|
117
117
|
],
|
|
118
118
|
},
|
|
@@ -155,7 +155,7 @@ export const docs = {
|
|
|
155
155
|
},
|
|
156
156
|
{
|
|
157
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:
|
|
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:tokens-and-setup} for bundler config examples.',
|
|
159
159
|
},
|
|
160
160
|
],
|
|
161
161
|
},
|
|
@@ -199,10 +199,10 @@ export const docs = {
|
|
|
199
199
|
type: 'list',
|
|
200
200
|
style: 'unordered',
|
|
201
201
|
items: [
|
|
202
|
-
'{@link
|
|
203
|
-
'{@link
|
|
202
|
+
'{@link namespace:styling} \u2014 xstyle, className, data-attribute selectors, design tokens in code.',
|
|
203
|
+
'{@link namespace:styling-libraries} \u2014 Tailwind bridge details, Panda, Chakra, MUI, CSS Modules, and non-CSS token resolution.',
|
|
204
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
|
|
205
|
+
'{@link namespace:migration} \u2014 cascade layer audit, Tailwind v3 coexistence, and foundation smoke test.',
|
|
206
206
|
],
|
|
207
207
|
},
|
|
208
208
|
],
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx docs migration/component-migration`: migrate the app frame,
|
|
5
|
+
* map shadcn/Radix primitives, and wire up command palette, settings, and
|
|
6
|
+
* theme controls.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
|
|
10
|
+
|
|
11
|
+
export const docs = {
|
|
12
|
+
type: 'generic',
|
|
13
|
+
name: 'component-migration',
|
|
14
|
+
title: 'Component Migration',
|
|
15
|
+
placement: {parent: 'namespace:migration', slot: 'guides', order: 20},
|
|
16
|
+
category: 'guide',
|
|
17
|
+
description:
|
|
18
|
+
'Move the app frame first, map shadcn and Radix primitives to components, and wire up command palette, settings, and theme controls.',
|
|
19
|
+
keywords: [
|
|
20
|
+
'Button',
|
|
21
|
+
'TextInput',
|
|
22
|
+
'CommandPalette',
|
|
23
|
+
],
|
|
24
|
+
|
|
25
|
+
sections: [
|
|
26
|
+
{
|
|
27
|
+
title: 'Move the App Frame First',
|
|
28
|
+
content: [
|
|
29
|
+
{
|
|
30
|
+
type: 'prose',
|
|
31
|
+
text: 'Start with AppShell so page migration happens inside the final navigation, spacing, surface, and responsive frame. This also exposes theme and color issues early because every route shares the same shell.',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
type: 'table',
|
|
35
|
+
headers: ['Legacy surface', 'Component', 'Notes'],
|
|
36
|
+
rows: [
|
|
37
|
+
['Header', 'TopNav', 'Use for product identity, global actions, account entry, and command/search trigger.'],
|
|
38
|
+
['Sidebar', 'SideNav', 'Use sections and nested nav items for route groups. Keep selection state driven by the router.'],
|
|
39
|
+
['Main page wrapper', 'AppShell + Layout', 'Let the shell own persistent structure; let route components own page content.'],
|
|
40
|
+
['Mobile drawer nav', 'MobileNav or AppShell mobile behavior', 'Verify focus, close behavior, and route changes on narrow viewports.'],
|
|
41
|
+
['Settings menu', 'Popover + Layout + Switch', 'Use as the home for theme mode and app preferences.'],
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
title: 'Map shadcn and Radix Primitives',
|
|
48
|
+
content: [
|
|
49
|
+
{
|
|
50
|
+
type: 'prose',
|
|
51
|
+
text: 'Do not wrap old shadcn components in design system styles. Replace the primitive with the component that owns the behavior, accessibility, state classes, and token usage.',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
type: 'table',
|
|
55
|
+
headers: ['Existing primitive', 'Component', 'Migration note'],
|
|
56
|
+
rows: [
|
|
57
|
+
['button / shadcn Button', 'Button or IconButton', 'Use Button for labeled commands and IconButton for icon-only toolbar actions.'],
|
|
58
|
+
['input', 'TextInput', 'Keep validation state in status props rather than ad hoc border classes.'],
|
|
59
|
+
['textarea', 'TextArea', 'Use when multiline editing is the primary action.'],
|
|
60
|
+
['switch', 'Switch', 'Use for persisted boolean settings, including theme mode when represented as a binary choice.'],
|
|
61
|
+
['checkbox', 'CheckboxInput or CheckboxList', 'Use list variants for grouped selection.'],
|
|
62
|
+
['radio group', 'RadioList', 'Use when one option must be selected from a visible set.'],
|
|
63
|
+
['select / combobox', 'Selector or Typeahead', 'Use Selector for bounded options and Typeahead for searchable async options.'],
|
|
64
|
+
['tabs used as page nav', 'TabList', 'Use route state or current page state as the source of truth.'],
|
|
65
|
+
['command dialog', 'CommandPalette', 'Keep app-specific search sources outside the shell and feed searchable items.'],
|
|
66
|
+
['dropdown action menu', 'DropdownMenu or MoreMenu', 'Use MoreMenu for compact overflow actions.'],
|
|
67
|
+
['alert / callout', 'Banner or Toast', 'Use Banner for page or section messages and Toast for transient feedback.'],
|
|
68
|
+
['dialog', 'Dialog or AlertDialog', 'Use AlertDialog for destructive confirmation and Dialog for task flows.'],
|
|
69
|
+
['card-like list row', 'ListItem', 'Prefer ListItem for selectable rows instead of styling Button as a row.'],
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
id: 'command-palette',
|
|
76
|
+
title: 'Command Palette, Settings, and Theme',
|
|
77
|
+
content: [
|
|
78
|
+
{
|
|
79
|
+
type: 'prose',
|
|
80
|
+
text: 'Move global search to CommandPalette once the shell exists. Treat the palette as a view over app commands: routes, contextual actions, create actions, filters, recent items, and entity results. Keep data normalization in app code so search sources always return arrays of searchable items.',
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'prose',
|
|
84
|
+
text: 'Put light and dark mode controls in the settings popover or account menu. The switch or selector should update the mode passed to Theme, not toggle isolated body classes.',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
type: 'code',
|
|
88
|
+
lang: 'tsx',
|
|
89
|
+
label: 'Settings popover theme control',
|
|
90
|
+
code: `function ThemeModeSwitch() {
|
|
91
|
+
const {mode, setMode} = useSettings();
|
|
92
|
+
const isDark = mode === 'dark';
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<Switch
|
|
96
|
+
label="Dark mode"
|
|
97
|
+
description="Use the dark color theme"
|
|
98
|
+
value={isDark}
|
|
99
|
+
onChange={next => setMode(next ? 'dark' : 'light')}
|
|
100
|
+
/>
|
|
101
|
+
);
|
|
102
|
+
}`,
|
|
103
|
+
},
|
|
104
|
+
],
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx docs styling-libraries/css-and-stylex`: core integration
|
|
5
|
+
* principle, plain CSS / CSS Modules, and StyleX typed-token imports.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
|
|
9
|
+
|
|
10
|
+
export const docs = {
|
|
11
|
+
type: 'generic',
|
|
12
|
+
name: 'css-and-stylex',
|
|
13
|
+
title: 'CSS & StyleX',
|
|
14
|
+
placement: {parent: 'namespace:styling-libraries', slot: 'guides', order: 10},
|
|
15
|
+
category: 'guide',
|
|
16
|
+
description:
|
|
17
|
+
'Core integration principle, plain CSS / CSS Modules, and StyleX typed-token imports.',
|
|
18
|
+
|
|
19
|
+
sections: [
|
|
20
|
+
{
|
|
21
|
+
title: 'Core Principle',
|
|
22
|
+
content: [
|
|
23
|
+
{
|
|
24
|
+
type: 'prose',
|
|
25
|
+
text: 'Keep the system as the source of truth for theme values. Components read design tokens from CSS custom properties such as `--color-text-primary`, `--color-background-surface`, `--spacing-4`, and `--radius-container`. Other styling libraries should map their own semantic tokens, utility names, or theme objects to those system CSS variables whenever possible.',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: 'prose',
|
|
29
|
+
text: 'Use CSS variables for ordinary DOM styling because they inherit through the tree, follow `data-theme` color mode, respect nested `data-astryx-theme` scopes, and update when themes switch. Use token resolver APIs only for non-CSS consumers such as SVG attribute values, canvas, chart configuration, color calculations, or static config generation.',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
type: 'prose',
|
|
33
|
+
text: 'For available token names and values, run {@link namespace:tokens}. Focused references are also available with {@link generic:color}, {@link generic:spacing}, {@link generic:shape}, {@link namespace:typography}, {@link generic:elevation}, and {@link generic:motion}.',
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
title: 'Choose an Integration Path',
|
|
39
|
+
content: [
|
|
40
|
+
{
|
|
41
|
+
type: 'prose',
|
|
42
|
+
text: 'Choose the narrowest integration path that fits the styling library. Most DOM styling should stay on the CSS-variable path; JavaScript token resolution is for APIs that cannot consume CSS custom properties.',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
type: 'table',
|
|
46
|
+
headers: ['Path', 'Use when', 'Value shape'],
|
|
47
|
+
rows: [
|
|
48
|
+
[
|
|
49
|
+
'CSS variable aliases',
|
|
50
|
+
'The library ultimately writes CSS and accepts string values',
|
|
51
|
+
'`var(--color-text-primary)`',
|
|
52
|
+
],
|
|
53
|
+
[
|
|
54
|
+
'StyleX token imports',
|
|
55
|
+
'You are writing StyleX styles in application code',
|
|
56
|
+
"`colorVars['--color-text-primary']`",
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
'Tailwind bridge',
|
|
60
|
+
'You want utility classes backed by active system tokens',
|
|
61
|
+
'`@astryxdesign/core/tailwind-theme.css`',
|
|
62
|
+
],
|
|
63
|
+
[
|
|
64
|
+
'Design token resolver APIs',
|
|
65
|
+
'JavaScript needs token values for charts, canvas, SVG, or config objects',
|
|
66
|
+
"`resolveThemeToken(theme, '--color-data-categorical-blue', {mode})`",
|
|
67
|
+
],
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
title: 'Best Practices',
|
|
74
|
+
content: [
|
|
75
|
+
{
|
|
76
|
+
type: 'list',
|
|
77
|
+
style: 'do',
|
|
78
|
+
items: [
|
|
79
|
+
'Map by semantic intent: text, surface, border, accent, status, radius, spacing, typography.',
|
|
80
|
+
'Let the system own color mode. The root Theme syncs `data-theme="light|dark"` and `data-astryx-theme` to `<html>` for portals and first-level theme scope.',
|
|
81
|
+
'Prefer CSS variables for runtime theme switching and nested themes.',
|
|
82
|
+
],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
type: 'list',
|
|
86
|
+
style: 'dont',
|
|
87
|
+
items: [
|
|
88
|
+
'Copy raw hex/px values into a second theme object when a `var(...)` reference would work.',
|
|
89
|
+
'Run a second unsynchronized dark-mode provider that disagrees with Theme.',
|
|
90
|
+
'Make another library\'s CSS variables the source of truth for the system. Some consumers need token values outside the DOM.',
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
],
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
title: 'Plain CSS and CSS Modules',
|
|
97
|
+
content: [
|
|
98
|
+
{
|
|
99
|
+
type: 'prose',
|
|
100
|
+
text: 'The simplest integration is direct CSS variable usage. CSS Modules scope class names, but system token variables are global/inherited values supplied by package CSS and the active theme.',
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
type: 'code',
|
|
104
|
+
lang: 'css',
|
|
105
|
+
label: 'Card.module.css',
|
|
106
|
+
code: `.card {
|
|
107
|
+
background: var(--color-background-surface);
|
|
108
|
+
color: var(--color-text-primary);
|
|
109
|
+
border: 1px solid var(--color-border);
|
|
110
|
+
border-radius: var(--radius-container);
|
|
111
|
+
padding: var(--spacing-4);
|
|
112
|
+
}`,
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
type: 'prose',
|
|
116
|
+
text: 'Sass variables are compile-time only. They are useful for generating static CSS, but they do not update when the system switches theme or color mode. Use native CSS custom properties for themeable values.',
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
title: 'StyleX',
|
|
122
|
+
content: [
|
|
123
|
+
{
|
|
124
|
+
type: 'prose',
|
|
125
|
+
text: 'For StyleX styles, prefer the typed token exports from `@astryxdesign/core/theme/tokens.stylex`. They provide autocomplete and catch token-name typos while still resolving through the same system CSS variables at runtime.',
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
type: 'code',
|
|
129
|
+
lang: 'tsx',
|
|
130
|
+
label: 'Typed token imports',
|
|
131
|
+
code: `import * as stylex from '@stylexjs/stylex';
|
|
132
|
+
import {colorVars, spacingVars, radiusVars} from '@astryxdesign/core/theme/tokens.stylex';
|
|
133
|
+
|
|
134
|
+
const styles = stylex.create({
|
|
135
|
+
panel: {
|
|
136
|
+
backgroundColor: colorVars['--color-background-surface'],
|
|
137
|
+
color: colorVars['--color-text-primary'],
|
|
138
|
+
padding: spacingVars['--spacing-4'],
|
|
139
|
+
borderRadius: radiusVars['--radius-container'],
|
|
140
|
+
},
|
|
141
|
+
});`,
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
type: 'prose',
|
|
145
|
+
text: 'Use `xstyle` for component overrides and `stylex.props()` for your own DOM nodes. Use `className` when integrating a non-StyleX styling library.',
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @file `astryx docs typography/font-setup`: font families, custom fonts,
|
|
5
|
+
* font sizes, and font weights.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** @type {import('@astryxdesign/cli/authoring').ReferenceDoc} */
|
|
9
|
+
|
|
10
|
+
export const docs = {
|
|
11
|
+
type: 'generic',
|
|
12
|
+
name: 'font-setup',
|
|
13
|
+
title: 'Font Setup',
|
|
14
|
+
placement: {parent: 'namespace:typography', slot: 'guides', order: 10},
|
|
15
|
+
category: 'foundations',
|
|
16
|
+
description:
|
|
17
|
+
'Font families, custom font loading, geometric font sizes, and semantic font weights.',
|
|
18
|
+
keywords: [
|
|
19
|
+
'font family',
|
|
20
|
+
'custom fonts',
|
|
21
|
+
'webfont',
|
|
22
|
+
'Google Fonts',
|
|
23
|
+
'font-face',
|
|
24
|
+
'font size',
|
|
25
|
+
'font weight',
|
|
26
|
+
'geometric scale',
|
|
27
|
+
],
|
|
28
|
+
|
|
29
|
+
sections: [
|
|
30
|
+
{
|
|
31
|
+
title: 'Overview',
|
|
32
|
+
content: [
|
|
33
|
+
{
|
|
34
|
+
type: 'prose',
|
|
35
|
+
text: 'Typography is built on a geometric type scale: base size × ratio^step, with 14px and 1.2 as defaults. Every text style is a semantic token that composes font size, weight, and line-height, so components express intent (heading, body, label) rather than raw values.',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
type: 'prose',
|
|
39
|
+
text: 'Two layers work together: raw size tokens (--font-size-xs ... --font-size-5xl) form the geometric scale, and semantic type scale tokens (--text-heading-1-size, --text-body-leading, etc.) reference them by var(). Themes override the entire scale by adjusting base and ratio in defineTheme; all semantic tokens recompute automatically.',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
title: 'Font Families',
|
|
45
|
+
content: [
|
|
46
|
+
{
|
|
47
|
+
type: 'prose',
|
|
48
|
+
text: 'Three font roles: body (UI text), heading (titles and headings), and code (monospace). By default, body and heading share the same system font stack; code uses a monospace stack. Custom themes can assign different families per role; heading inherits from body when not explicitly set.',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: 'token-ref',
|
|
52
|
+
topic: 'tokens',
|
|
53
|
+
section: 'Font Family Tokens',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
id: 'loading-custom-fonts',
|
|
59
|
+
title: 'Custom fonts',
|
|
60
|
+
content: [
|
|
61
|
+
{
|
|
62
|
+
type: 'prose',
|
|
63
|
+
text: 'Astryx never loads font files. defineTheme and the built CSS only set font-family: naming a webfont (Fraunces, JetBrains Mono, and so on) makes every browser look for it, and quietly fall back when the app has not loaded it. `astryx theme build` warns when a theme names families that are neither CSS generics nor common system fonts and prints the snippet to add; loading the font is always the app\'s job.',
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
type: 'code',
|
|
67
|
+
lang: 'html',
|
|
68
|
+
label: 'Google Fonts: add to your document <head>',
|
|
69
|
+
code: `<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
70
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
71
|
+
<link
|
|
72
|
+
rel="stylesheet"
|
|
73
|
+
href="https://fonts.googleapis.com/css2?family=Fraunces:wght@400;600;700&family=JetBrains+Mono&display=swap"
|
|
74
|
+
/>`,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: 'code',
|
|
78
|
+
lang: 'css',
|
|
79
|
+
label: 'Self-hosted: one @font-face per family and weight',
|
|
80
|
+
code: `@font-face {
|
|
81
|
+
font-family: 'Fraunces';
|
|
82
|
+
src: url('/fonts/fraunces.woff2') format('woff2');
|
|
83
|
+
font-weight: 400 700; /* variable-font range, or one weight per file */
|
|
84
|
+
font-display: swap; /* fallback text stays visible while the font loads */
|
|
85
|
+
}`,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
type: 'prose',
|
|
89
|
+
text: "Always pair a webfont with a real fallback stack (metric-similar system fonts plus a generic) so text stays readable before the font loads and wherever it never does: defineTheme({typography: {heading: {family: 'Fraunces', fallbacks: 'Georgia, serif'}}}).",
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
title: 'Font Sizes',
|
|
95
|
+
content: [
|
|
96
|
+
{
|
|
97
|
+
type: 'prose',
|
|
98
|
+
text: 'Geometric scale: round(base × ratio^step), expressed in rem. The default scale is 14px × 1.2, producing 12 steps from 4xs (6px) to 5xl (42px). Adjusting base and ratio in defineTheme regenerates every size token while preserving proportional relationships.',
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
type: 'token-ref',
|
|
102
|
+
topic: 'tokens',
|
|
103
|
+
section: 'Font Size Tokens',
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
title: 'Font Weights',
|
|
109
|
+
content: [
|
|
110
|
+
{
|
|
111
|
+
type: 'prose',
|
|
112
|
+
text: 'Four semantic weights: normal (400, body/code), medium (500, labels/data), semibold (600, headings/titles), bold (700, strong emphasis). Type scale tokens reference these by var() so themes can remap numeric values.',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
type: 'token-ref',
|
|
116
|
+
topic: 'tokens',
|
|
117
|
+
section: 'Font Weight Tokens',
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
};
|