@astryxdesign/cli 0.1.6-canary.1b61ba6 → 0.1.6-canary.1d64659
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/package.json +9 -13
- package/src/api/template.mjs +1 -1
- package/src/api/validate-integration.mjs +8 -0
- package/src/codemods/__tests__/registry.test.mjs +0 -1
- package/src/codemods/registry.mjs +0 -1
- package/src/config.mjs +14 -5
- package/src/integration.mjs +15 -4
- package/src/lib/component-discovery.mjs +5 -15
- package/src/lib/component-format.mjs +13 -45
- package/src/lib/component-format.test.mjs +1 -95
- package/src/lib/component-loader.mjs +2 -104
- package/src/lib/config-schema.mjs +30 -0
- package/src/lib/hook-format.mjs +3 -8
- package/src/lib/xle/registry.mjs +5 -0
- package/src/template.mjs +67 -9
- package/src/types/config.d.ts +66 -11
- package/src/types/integration.d.ts +18 -7
- package/src/types/template-api.d.ts +50 -14
- package/templates/themes/neutral/neutralTheme.ts +32 -63
- package/docs/integration-authoring.md +0 -105
- package/docs/internationalization.doc.mjs +0 -243
- package/src/api/integration-block-exports.test.mjs +0 -240
- package/src/codemods/transforms/v0.1.7/__tests__/migrate-table-tableprops-to-direct-props.test.mjs +0 -120
- package/src/codemods/transforms/v0.1.7/index.mjs +0 -19
- package/src/codemods/transforms/v0.1.7/migrate-table-tableprops-to-direct-props.mjs +0 -188
- package/src/doc.mjs +0 -27
- package/src/doc.test.mjs +0 -383
- package/src/lib/component-discovery.importpath.test.mjs +0 -59
- package/src/lib/componentDocOverlay.test.mjs +0 -111
- package/src/schemas/doc-schema.mjs +0 -226
- package/src/schemas/template-schema.mjs +0 -47
- package/src/types/doc.d.ts +0 -23
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenLiveRegion.doc.mjs +0 -14
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenLiveRegion.tsx +0 -41
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.doc.mjs +0 -13
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenShowcase.tsx +0 -78
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenStructuralHeading.doc.mjs +0 -14
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenStructuralHeading.tsx +0 -38
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.doc.mjs +0 -14
- package/templates/blocks/components/VisuallyHidden/VisuallyHiddenSupplementaryContext.tsx +0 -47
package/src/template.mjs
CHANGED
|
@@ -1,15 +1,73 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @file Static template authoring API
|
|
4
|
+
* @file Static template authoring API.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* Helpers for authoring Astryx page/block template docs. Like
|
|
7
|
+
* `createConfig`/`createIntegration`, these are tiny runtime identity helpers
|
|
8
|
+
* whose real value is the exported TypeScript surface from
|
|
9
|
+
* `@astryxdesign/cli/template`. They inject the discriminant `type` so a
|
|
10
|
+
* discovered doc always knows whether it is a page or a block. They do NOT
|
|
11
|
+
* validate — validation happens at the load boundary, where integration
|
|
12
|
+
* template discovery runs the module's default export through
|
|
13
|
+
* {@link TemplateEnvelopeSchema} (see `loadModuleWithSchema`).
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
import {z} from 'zod';
|
|
17
|
+
|
|
18
|
+
const PreviewSchema = z
|
|
19
|
+
.object({
|
|
20
|
+
image: z.string().optional(),
|
|
21
|
+
aspectRatio: z.string().optional(),
|
|
22
|
+
})
|
|
23
|
+
.strict();
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Shared authored-template shape. `type` is injected by the create* helpers,
|
|
27
|
+
* so authors never write it. Inline source/sourceFile are intentionally NOT
|
|
28
|
+
* part of v1 — a template's source is the required same-stem sibling file.
|
|
29
|
+
* Exported so integration template discovery can validate the stamped result.
|
|
30
|
+
*/
|
|
31
|
+
export const BaseTemplateSchema = z
|
|
32
|
+
.object({
|
|
33
|
+
name: z.string().min(1, 'name is required'),
|
|
34
|
+
description: z.string().min(1, 'description is required'),
|
|
35
|
+
category: z.string().optional(),
|
|
36
|
+
componentsUsed: z.array(z.string()).optional(),
|
|
37
|
+
preview: PreviewSchema.optional(),
|
|
38
|
+
})
|
|
39
|
+
.strict();
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* The metadata envelope integration template discovery validates: a stamped
|
|
43
|
+
* template doc. This is the LOAD-boundary contract — a hand-written plain
|
|
44
|
+
* object that matches this shape is accepted (discovery does not check "was it
|
|
45
|
+
* made by the factory", only the shape).
|
|
46
|
+
*/
|
|
47
|
+
export const TemplateEnvelopeSchema = BaseTemplateSchema.extend({
|
|
48
|
+
type: z.enum(['page', 'block']),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Author an Astryx page template doc. Stamp-only: returns the def with
|
|
53
|
+
* `type: 'page'` injected. Validation happens at the load boundary.
|
|
54
|
+
*
|
|
55
|
+
* @template {import('./types/template-api').AstryxPageTemplateInput} T
|
|
56
|
+
* @param {T} def
|
|
57
|
+
* @returns {T & {type: 'page'}}
|
|
58
|
+
*/
|
|
59
|
+
export function createPageTemplate(def) {
|
|
60
|
+
return /** @type {T & {type: 'page'}} */ ({...def, type: 'page'});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Author an Astryx block template doc. Stamp-only: returns the def with
|
|
65
|
+
* `type: 'block'` injected. Validation happens at the load boundary.
|
|
66
|
+
*
|
|
67
|
+
* @template {import('./types/template-api').AstryxBlockTemplateInput} T
|
|
68
|
+
* @param {T} def
|
|
69
|
+
* @returns {T & {type: 'block'}}
|
|
70
|
+
*/
|
|
71
|
+
export function createBlockTemplate(def) {
|
|
72
|
+
return /** @type {T & {type: 'block'}} */ ({...def, type: 'block'});
|
|
73
|
+
}
|
package/src/types/config.d.ts
CHANGED
|
@@ -1,15 +1,70 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* so existing `@astryxdesign/cli/config` type imports keep resolving.
|
|
4
|
+
* A command to run as part of a post-codemod hook. Returned by a hook's
|
|
5
|
+
* `buildCommand` and executed via `execFile` after codemods write files.
|
|
7
6
|
*/
|
|
8
|
-
export
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
export interface PostCodemodCommand {
|
|
8
|
+
command: string;
|
|
9
|
+
args?: string[];
|
|
10
|
+
options?: {
|
|
11
|
+
cwd?: string;
|
|
12
|
+
env?: NodeJS.ProcessEnv;
|
|
13
|
+
timeout?: number;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A post-codemod hook. `buildCommand` receives the package directory and the
|
|
19
|
+
* list of files changed by codemods, and returns the command to run (or a
|
|
20
|
+
* nullish value to skip).
|
|
21
|
+
*/
|
|
22
|
+
export type PostCodemodHook = {
|
|
23
|
+
name?: string;
|
|
24
|
+
buildCommand: (ctx: {
|
|
25
|
+
packageDir: string;
|
|
26
|
+
files: string[];
|
|
27
|
+
}) =>
|
|
28
|
+
| PostCodemodCommand
|
|
29
|
+
| null
|
|
30
|
+
| undefined
|
|
31
|
+
| Promise<PostCodemodCommand | null | undefined>;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** A component XLE layout expressions can reference by name via `{hint}`. */
|
|
35
|
+
export interface XleComponent {
|
|
36
|
+
/** Import specifier the component is imported from, e.g. '@/components/KpiCard'. */
|
|
37
|
+
from: string;
|
|
38
|
+
/** Optional human description shown in tooling. */
|
|
39
|
+
description?: string;
|
|
40
|
+
/** Import as the module's default export instead of a named export. Defaults to false. */
|
|
41
|
+
default?: boolean;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** User config exported from astryx.config.{ts,mjs,js}. */
|
|
45
|
+
export interface AstryxConfig {
|
|
46
|
+
/** Integration package names to load. */
|
|
47
|
+
integrations?: string[];
|
|
48
|
+
/** Where to file issues/feedback for this project. */
|
|
49
|
+
issuesUrl?: string;
|
|
50
|
+
/** Lifecycle hooks. */
|
|
51
|
+
hooks?: {
|
|
52
|
+
postCodemod?: PostCodemodHook[];
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* EXPERIMENTAL — shape may change and is not part of the stable config
|
|
56
|
+
* contract. Provisional home for features still being proven out.
|
|
57
|
+
*/
|
|
58
|
+
experimental?: {
|
|
59
|
+
/** Experimental XLE (layout expression) configuration. */
|
|
60
|
+
xle?: {
|
|
61
|
+
/**
|
|
62
|
+
* Register app-local components so XLE layout expressions can
|
|
63
|
+
* reference them by name via {hint}. Keyed by component name.
|
|
64
|
+
*/
|
|
65
|
+
components?: Record<string, XleComponent>;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export declare function createConfig<T extends AstryxConfig>(config: T): T;
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* validation type, not part of the authoring surface.
|
|
4
|
+
* Integration manifest exported from a conventional root manifest file
|
|
5
|
+
* (astryx.integration.{ts,mjs,js}) sibling to the integration package's
|
|
6
|
+
* package.json. Identity (name/version) comes from the package's
|
|
7
|
+
* package.json, not from the manifest.
|
|
9
8
|
*/
|
|
10
|
-
export
|
|
11
|
-
|
|
9
|
+
export interface AstryxIntegration {
|
|
10
|
+
/** Relative path to the components/docs root (resolved to absolute). */
|
|
11
|
+
components?: string;
|
|
12
|
+
/** Relative path to the templates root (resolved to absolute). */
|
|
13
|
+
templates?: string;
|
|
14
|
+
/** Relative path to the codemods root (resolved to absolute). */
|
|
15
|
+
codemods?: string;
|
|
16
|
+
/** Where to file issues/feedback for this integration. */
|
|
17
|
+
issuesUrl?: string;
|
|
18
|
+
}
|
|
12
19
|
|
|
13
20
|
/** An issue surfaced by an integration. */
|
|
14
21
|
export interface AstryxIntegrationIssue {
|
|
@@ -16,3 +23,7 @@ export interface AstryxIntegrationIssue {
|
|
|
16
23
|
severity: 'warning' | 'error';
|
|
17
24
|
message: string;
|
|
18
25
|
}
|
|
26
|
+
|
|
27
|
+
export declare function createIntegration<T extends AstryxIntegration>(
|
|
28
|
+
integration: T,
|
|
29
|
+
): T;
|
|
@@ -1,18 +1,54 @@
|
|
|
1
1
|
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Authoring surface for Astryx static templates, exported from
|
|
5
|
+
* `@astryxdesign/cli/template`.
|
|
6
|
+
*
|
|
7
|
+
* A template doc lives in a `<id>.doc.{ts,mjs,js}` file with a required
|
|
8
|
+
* same-stem sibling source file (`<id>.tsx`). The doc's `type` (page or
|
|
9
|
+
* block) — injected by the create* helpers — decides how the template is
|
|
10
|
+
* scaffolded; there is no `/pages` vs `/blocks` directory requirement.
|
|
7
11
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export
|
|
12
|
+
|
|
13
|
+
/** Optional preview metadata for a template (used by docs surfaces). */
|
|
14
|
+
export interface AstryxTemplatePreview {
|
|
15
|
+
/** Path or URL to a preview image. */
|
|
16
|
+
image?: string;
|
|
17
|
+
/** CSS aspect-ratio hint for the preview, e.g. "16 / 9". */
|
|
18
|
+
aspectRatio?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Fields common to page and block template docs (without the `type` tag). */
|
|
22
|
+
export interface AstryxTemplateInput {
|
|
23
|
+
/** Human-readable template name. Required. */
|
|
24
|
+
name: string;
|
|
25
|
+
/** One-line description of what the template provides. Required. */
|
|
26
|
+
description: string;
|
|
27
|
+
/** Optional grouping/category label. */
|
|
28
|
+
category?: string;
|
|
29
|
+
/** Component display names the template composes. */
|
|
30
|
+
componentsUsed?: string[];
|
|
31
|
+
/** Optional preview metadata. */
|
|
32
|
+
preview?: AstryxTemplatePreview;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Input accepted by {@link createPageTemplate} (no `type` field). */
|
|
36
|
+
export type AstryxPageTemplateInput = AstryxTemplateInput;
|
|
37
|
+
/** Input accepted by {@link createBlockTemplate} (no `type` field). */
|
|
38
|
+
export type AstryxBlockTemplateInput = AstryxTemplateInput;
|
|
39
|
+
|
|
40
|
+
/** A validated page template doc. */
|
|
41
|
+
export type AstryxPageTemplate = AstryxTemplateInput & {type: 'page'};
|
|
42
|
+
/** A validated block template doc. */
|
|
43
|
+
export type AstryxBlockTemplate = AstryxTemplateInput & {type: 'block'};
|
|
44
|
+
|
|
45
|
+
/** A validated template doc (page or block). */
|
|
46
|
+
export type AstryxTemplate = AstryxPageTemplate | AstryxBlockTemplate;
|
|
47
|
+
|
|
48
|
+
export declare function createPageTemplate<T extends AstryxPageTemplateInput>(
|
|
49
|
+
def: T,
|
|
50
|
+
): T & {type: 'page'};
|
|
51
|
+
|
|
52
|
+
export declare function createBlockTemplate<T extends AstryxBlockTemplateInput>(
|
|
53
|
+
def: T,
|
|
54
|
+
): T & {type: 'block'};
|
|
@@ -39,19 +39,19 @@ import {neutralIconRegistry} from './icons';
|
|
|
39
39
|
const neutralSyntax = defineSyntaxTheme({
|
|
40
40
|
name: 'xds-neutral',
|
|
41
41
|
tokens: {
|
|
42
|
-
keyword: ['#700084', '#efa8ff'],
|
|
43
|
-
string: ['#005600', '#a6d2a2'],
|
|
44
|
-
comment: ['#737373', '#a3a3a3'],
|
|
45
|
-
number: ['#6e3500', '#ffb37f'],
|
|
46
|
-
function: ['#00458c', '#a0caff'],
|
|
47
|
-
type: ['#700084', '#efa8ff'],
|
|
48
|
-
variable: ['#171717', '#e5e5e5'],
|
|
49
|
-
operator: ['#737373', '#a3a3a3'],
|
|
50
|
-
constant: ['#6e3500', '#ffb37f'],
|
|
51
|
-
tag: ['#89001a', '#ffaeaa'],
|
|
52
|
-
attribute: ['#584400', '#eec12f'],
|
|
53
|
-
property: ['#005348', '#83dac9'],
|
|
54
|
-
punctuation: ['#a3a3a3', '#525252']
|
|
42
|
+
keyword: ['#700084', '#efa8ff'], // purple T30/T80
|
|
43
|
+
string: ['#005600', '#a6d2a2'], // green (sat T30 / pastel T80)
|
|
44
|
+
comment: ['#737373', '#a3a3a3'], // neutral
|
|
45
|
+
number: ['#6e3500', '#ffb37f'], // orange
|
|
46
|
+
function: ['#00458c', '#a0caff'], // blue T30/T80 H=255
|
|
47
|
+
type: ['#700084', '#efa8ff'], // purple
|
|
48
|
+
variable: ['#171717', '#e5e5e5'], // near-black / near-white
|
|
49
|
+
operator: ['#737373', '#a3a3a3'], // neutral
|
|
50
|
+
constant: ['#6e3500', '#ffb37f'], // orange
|
|
51
|
+
tag: ['#89001a', '#ffaeaa'], // red
|
|
52
|
+
attribute: ['#584400', '#eec12f'], // yellow
|
|
53
|
+
property: ['#005348', '#83dac9'], // teal
|
|
54
|
+
punctuation: ['#a3a3a3', '#525252'],// neutral
|
|
55
55
|
background: ['#fafafa', '#0a0a0a'],
|
|
56
56
|
},
|
|
57
57
|
});
|
|
@@ -127,39 +127,39 @@ export const neutralTheme = defineTheme({
|
|
|
127
127
|
// All values use the OKLCH Neutral tonal palette (chroma=0).
|
|
128
128
|
// =========================================================================
|
|
129
129
|
'--color-background-surface': ['#ffffff', '#262626'],
|
|
130
|
-
'--color-background-body':
|
|
131
|
-
'--color-background-card':
|
|
130
|
+
'--color-background-body': ['#f1f1f1', '#1b1b1b'],
|
|
131
|
+
'--color-background-card': ['#ffffff', '#1b1b1b'],
|
|
132
132
|
'--color-background-popover': ['#ffffff', '#1b1b1b'],
|
|
133
|
-
'--color-background-muted':
|
|
133
|
+
'--color-background-muted': ['#f1f1f1', '#1b1b1b'],
|
|
134
134
|
|
|
135
135
|
// Accent + neutral surface tints (sit alongside backgrounds)
|
|
136
|
-
'--color-accent':
|
|
136
|
+
'--color-accent': ['#262626', '#ebebeb'],
|
|
137
137
|
'--color-accent-muted': ['#f1f1f1', '#262626'],
|
|
138
|
-
'--color-neutral':
|
|
138
|
+
'--color-neutral': ['#0000000F', '#FFFFFF1A'],
|
|
139
139
|
|
|
140
140
|
// Overlays (modal scrims, hover/pressed tints)
|
|
141
|
-
'--color-overlay':
|
|
142
|
-
'--color-overlay-hover':
|
|
141
|
+
'--color-overlay': ['#00000080', '#000000CC'],
|
|
142
|
+
'--color-overlay-hover': ['#0000000D', '#FFFFFF0D'],
|
|
143
143
|
'--color-overlay-pressed': ['#0000001A', '#FFFFFF1A'],
|
|
144
144
|
|
|
145
145
|
// Text
|
|
146
|
-
'--color-text-primary':
|
|
146
|
+
'--color-text-primary': ['#171717', '#fafafa'],
|
|
147
147
|
'--color-text-secondary': ['#737373', '#a3a3a3'],
|
|
148
|
-
'--color-text-disabled':
|
|
149
|
-
'--color-text-accent':
|
|
150
|
-
'--color-on-dark':
|
|
151
|
-
'--color-on-light':
|
|
148
|
+
'--color-text-disabled': ['#a3a3a3', '#525252'],
|
|
149
|
+
'--color-text-accent': ['#262626', '#ebebeb'],
|
|
150
|
+
'--color-on-dark': '#ffffff',
|
|
151
|
+
'--color-on-light': '#171717',
|
|
152
152
|
// Contrast: neutral accent is near-black (L) / near-white (D)
|
|
153
|
-
'--color-on-accent':
|
|
153
|
+
'--color-on-accent': ['#ffffff', '#171717'],
|
|
154
154
|
'--color-on-success': ['#ffffff', '#171717'],
|
|
155
|
-
'--color-on-error':
|
|
155
|
+
'--color-on-error': ['#ffffff', '#171717'],
|
|
156
156
|
'--color-on-warning': '#171717',
|
|
157
157
|
|
|
158
158
|
// Icon
|
|
159
|
-
'--color-icon-accent':
|
|
160
|
-
'--color-icon-primary':
|
|
159
|
+
'--color-icon-accent': ['#262626', '#ebebeb'],
|
|
160
|
+
'--color-icon-primary': ['#171717', '#fafafa'],
|
|
161
161
|
'--color-icon-secondary': ['#737373', '#a3a3a3'],
|
|
162
|
-
'--color-icon-disabled':
|
|
162
|
+
'--color-icon-disabled': ['#a3a3a3', '#525252'],
|
|
163
163
|
|
|
164
164
|
// Status / Sentiment — dark mode follows the issue #2150 rubric:
|
|
165
165
|
//
|
|
@@ -372,8 +372,8 @@ export const neutralTheme = defineTheme({
|
|
|
372
372
|
// =========================================================================
|
|
373
373
|
button: {
|
|
374
374
|
'variant:destructive': {
|
|
375
|
-
backgroundColor: 'var(--color-error-muted)',
|
|
376
|
-
color: 'var(--color-error)',
|
|
375
|
+
backgroundColor: 'var(--color-error-muted)', // locked pastel red bg
|
|
376
|
+
color: 'var(--color-error)', // locked T30 red — matches banner/input error text
|
|
377
377
|
},
|
|
378
378
|
},
|
|
379
379
|
|
|
@@ -482,37 +482,6 @@ export const neutralTheme = defineTheme({
|
|
|
482
482
|
},
|
|
483
483
|
},
|
|
484
484
|
|
|
485
|
-
// =========================================================================
|
|
486
|
-
// StatusDot — fill uses the SAME vivid stops as the filled semantic Badge
|
|
487
|
-
// (and ProgressBar), so a dot and its badge read as one status language.
|
|
488
|
-
//
|
|
489
|
-
// The default component maps each variant to a raw semantic token
|
|
490
|
-
// (--color-success / --color-error / --color-warning / --color-icon-
|
|
491
|
-
// secondary), which in light mode are the dark T30/T40 stops meant to
|
|
492
|
-
// sit as TEXT on a pastel surface — as a solid dot they read muddy
|
|
493
|
-
// (dark green / maroon / brown). Redirect them to the badge fills.
|
|
494
|
-
//
|
|
495
|
-
// success → badge success bg (green T45 / dark-ramp T60)
|
|
496
|
-
// warning → badge warning bg (yellow T85, same hex both modes)
|
|
497
|
-
// error → badge error bg (red T55 / dark-ramp T60)
|
|
498
|
-
// accent → badge info bg (blue T50 / dark-ramp T60) — the
|
|
499
|
-
// StatusDot "accent" is the info/attention color, so it
|
|
500
|
-
// pairs with the info badge rather than --color-accent
|
|
501
|
-
// (near-black #262626, the darkest offender).
|
|
502
|
-
//
|
|
503
|
-
// `neutral` is intentionally NOT overridden: the neutral badge bg is a
|
|
504
|
-
// near-invisible light gray (--color-background-gray #e5e5e5 / 10% white
|
|
505
|
-
// wash), fine as a large pill but unreadable as an 8px dot. It keeps the
|
|
506
|
-
// component default's visible mid-gray (--color-icon-secondary), which is
|
|
507
|
-
// not among the "too dark" cases.
|
|
508
|
-
// =========================================================================
|
|
509
|
-
statusdot: {
|
|
510
|
-
'variant:success': {backgroundColor: 'light-dark(#198100, #64af4c)'},
|
|
511
|
-
'variant:warning': {backgroundColor: '#ffce2f'},
|
|
512
|
-
'variant:error': {backgroundColor: 'light-dark(#e33f4a, #ff705d)'},
|
|
513
|
-
'variant:accent': {backgroundColor: 'light-dark(#0074e2, #6d9cfe)'},
|
|
514
|
-
},
|
|
515
|
-
|
|
516
485
|
// =========================================================================
|
|
517
486
|
// Banner — sits on a hue-tinted surface with colored text/icon:
|
|
518
487
|
// Light: pastel T90 bg (pulled from --color-{X}-muted / --color-background-blue)
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
# Authoring an Astryx Integration
|
|
2
|
-
|
|
3
|
-
> **Status:** working notes. This should eventually move to the public wiki
|
|
4
|
-
> alongside the rest of the integration-authoring guidance; it lives here for
|
|
5
|
-
> now so it ships and is versioned with the CLI.
|
|
6
|
-
|
|
7
|
-
An **Integration** is an npm package that contributes components, templates, and/or
|
|
8
|
-
codemods to a consumer's design-system workflow. Consumers install the 3rd party
|
|
9
|
-
package, add a line to their astryx.config file:
|
|
10
|
-
|
|
11
|
-
```js
|
|
12
|
-
import {createConfig} from '@astryxdesign/cli/config';
|
|
13
|
-
|
|
14
|
-
export default createConfig({
|
|
15
|
-
integrations: ['@acme/astryx-widgets'],
|
|
16
|
-
...
|
|
17
|
-
});
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
Then the integration's components and templates will be surfaced alongside Astryx
|
|
21
|
-
components in the Astryx CLI.
|
|
22
|
-
|
|
23
|
-
```sh
|
|
24
|
-
astryx component AcmeCarousel --props
|
|
25
|
-
astryx component --list --package @acme/astryx-widgets
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
## The Integration File
|
|
29
|
-
|
|
30
|
-
In order to register your package as an Astryx Integration, create an
|
|
31
|
-
`astryx.integration.{ts,mjs,js}` file as a sibling to your `package.json`. This file
|
|
32
|
-
tells Astryx where to find your components, templates, codemods, etc.
|
|
33
|
-
|
|
34
|
-
```js
|
|
35
|
-
// astryx.integration.{ts,mjs,js}
|
|
36
|
-
import {createIntegration} from '@astryxdesign/cli/integration';
|
|
37
|
-
|
|
38
|
-
export default createIntegration({
|
|
39
|
-
components: './components',
|
|
40
|
-
templates: './templates',
|
|
41
|
-
codemods: './codemods',
|
|
42
|
-
issuesUrl: 'https://github.com/acme/widgets/issues',
|
|
43
|
-
});
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Components
|
|
47
|
-
|
|
48
|
-
Your components themselves may be exported from your library as you see fit (consumers
|
|
49
|
-
will still import them from your package) but Astryx CLI will look for a .doc.{ts,mjs,js}
|
|
50
|
-
file with the same stem e.g. `AcmeCarousel.tsx` and `AcmeCarousel.doc.ts`.
|
|
51
|
-
|
|
52
|
-
```js
|
|
53
|
-
// AcmeCarousel.doc.ts
|
|
54
|
-
import {createComponentDoc} from '@astryxdesign/cli/doc';
|
|
55
|
-
|
|
56
|
-
export default createComponentDoc({
|
|
57
|
-
name: 'AcmeCarousel',
|
|
58
|
-
description: '...',
|
|
59
|
-
...
|
|
60
|
-
});
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
## Templates
|
|
64
|
-
|
|
65
|
-
Templates are typically not exported from the package directly, but instead accessed
|
|
66
|
-
via the Astryx CLI. Consumers can look through your templates and materialize them
|
|
67
|
-
into their apps.
|
|
68
|
-
|
|
69
|
-
You define a template with the `createPageTemplate` (for full pages) or `createBlockTemplate`
|
|
70
|
-
(for smaller chunks). e.g. `AcmeLandingPage.tsx`, `AcmeLandingPage.template.ts`
|
|
71
|
-
|
|
72
|
-
```js
|
|
73
|
-
// AcmeLandingPage.template.ts
|
|
74
|
-
import {createPageTemplate} from '@astryxdesign/cli/template';
|
|
75
|
-
|
|
76
|
-
export default createPageTemplate({
|
|
77
|
-
...
|
|
78
|
-
});
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Note that, since the CLI needs access to the template source code, you need to make sure
|
|
82
|
-
that it is included in your published package. This will also allow us to render previews
|
|
83
|
-
of templates in the future by bundling your template into a doc site build.
|
|
84
|
-
|
|
85
|
-
Typically, this is done via the package.json `exports` key.
|
|
86
|
-
|
|
87
|
-
```jsonc
|
|
88
|
-
{
|
|
89
|
-
"exports": {
|
|
90
|
-
// ...
|
|
91
|
-
"./templates/*.tsx": "./templates/*.tsx",
|
|
92
|
-
},
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
In order to verify that it's working, you can test importing the template component like this:
|
|
97
|
-
|
|
98
|
-
```ts
|
|
99
|
-
import('@acme/astryx-widgets/templates/AcmeLandingPage.tsx');
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Import **with the `.tsx` extension** — an extensionless specifier won't resolve
|
|
103
|
-
under `moduleResolution: bundler`. The extensionful `"./templates/*.tsx"` export
|
|
104
|
-
above is what lets that import type-check without consumers enabling
|
|
105
|
-
`allowImportingTsExtensions`.
|