@reqvire-org/ads 0.5.3 → 0.5.5
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/dist/ads-errors.mjs +105 -8
- package/dist/analysis/client-directive.mjs +26 -0
- package/dist/analysis/externals.mjs +47 -0
- package/dist/analysis/module-graph.mjs +6 -0
- package/dist/analysis/owner-analysis-key.mjs +1 -1
- package/dist/analysis/owner-choices.mjs +14 -2
- package/dist/analysis/owner-composition.mjs +32 -4
- package/dist/analysis/owner-source.mjs +121 -17
- package/dist/border-paint.mjs +34 -0
- package/dist/check.mjs +2 -0
- package/dist/composed-contrast.mjs +34 -12
- package/dist/construction-output.mjs +58 -31
- package/dist/construction-spec.d.mts +111 -15
- package/dist/construction-spec.mjs +129 -20
- package/dist/corner-overpaint.mjs +3 -1
- package/dist/design-foundation.mjs +18 -4
- package/dist/emit/owner-emission-cache.mjs +1 -1
- package/dist/end-alignment.mjs +69 -0
- package/dist/external-macro.d.mts +20 -0
- package/dist/external-macro.mjs +12 -0
- package/dist/finding-rules.mjs +3 -0
- package/dist/forced-colors.mjs +81 -0
- package/dist/frame-regions.mjs +2 -2
- package/dist/guard/externals.mjs +64 -0
- package/dist/guard/run.mjs +9 -5
- package/dist/inventories.mjs +1 -1
- package/dist/lowering-layer.mjs +38 -4
- package/dist/lowering-overlaps.mjs +13 -1
- package/dist/lowering-properties.mjs +4 -0
- package/dist/lowering-region-layout.mjs +22 -3
- package/dist/lowering-session.mjs +1 -1
- package/dist/lowering-transitions.mjs +1 -0
- package/dist/mcp/preview-http.bundle.js +2 -2
- package/dist/mcp/preview-widget.bundle.js +12 -12
- package/dist/measured-geometry.mjs +8 -2
- package/dist/owner-analysis-check.mjs +190 -11
- package/dist/owner-errors.mjs +3 -0
- package/dist/owner-lowering.mjs +3 -2
- package/dist/ownership-model.mjs +14 -5
- package/dist/platform-features.mjs +7 -0
- package/dist/preview-bun.mjs +15 -2
- package/dist/profile-macro.d.mts +18 -0
- package/dist/recipe-macro.d.mts +107 -9
- package/dist/recipe-model.mjs +22 -8
- package/dist/region-lowering.mjs +204 -49
- package/dist/render-audit/axe-run.page.mjs +40 -1
- package/dist/render-audit/forced-states.page.mjs +37 -0
- package/dist/render-audit/layout-overflow.page.mjs +52 -2
- package/dist/render-audit/non-text-contrast.page.mjs +14 -10
- package/dist/render-audit/worker.mjs +38 -0
- package/dist/render-audit.mjs +42 -5
- package/dist/role-vocabulary.d.mts +5 -2
- package/dist/role-vocabulary.mjs +6 -3
- package/dist/scenario-kit.d.mts +2 -2
- package/dist/showcase/assets-view.mjs +12 -47
- package/dist/showcase/client.bundle.js +50 -50
- package/dist/showcase/http-client.bundle.js +18 -18
- package/dist/showcase/token-sample.mjs +2 -2
- package/dist/showcase/ui/ui.css +1 -1
- package/dist/showcase/ui/ui.js +13 -13
- package/dist/skills/ads-designer/references/accessibility.md +21 -1
- package/dist/skills/ads-designer/references/branding.md +4 -0
- package/dist/skills/ads-designer/references/design-data.md +6 -0
- package/dist/skills/ads-designer/references/layers.md +5 -0
- package/dist/skills/ads-designer/references/layout.md +8 -1
- package/dist/skills/ads-designer/references/recipes.md +52 -2
- package/dist/skills/ads-designer/references/runtimes.md +4 -0
- package/dist/skills/ads-designer/references/scenarios.md +2 -0
- package/dist/skills/ads-import/references/design-data.md +6 -0
- package/dist/skills/ads-import/references/layers.md +5 -0
- package/dist/skills/ads-import/references/layout.md +8 -1
- package/dist/skills/ads-import/references/recipes.md +52 -2
- package/dist/skills/ads-import/references/runtimes.md +4 -0
- package/dist/skills/ads-import/references/scenarios.md +2 -0
- package/dist/skills/ads-migrate/SKILL.md +2 -0
- package/dist/skills/ads-migrate/references/0.5.3-to-0.5.4.md +42 -0
- package/dist/skills/ads-migrate/references/0.5.4-to-0.5.5.md +61 -0
- package/dist/skills/ads-port/references/design-data.md +6 -0
- package/dist/skills/ads-port/references/layers.md +5 -0
- package/dist/skills/ads-port/references/layout.md +8 -1
- package/dist/skills/ads-port/references/recipes.md +52 -2
- package/dist/skills/ads-port/references/runtimes.md +4 -0
- package/dist/skills/ads-port/references/scenarios.md +2 -0
- package/dist/spatial-model.mjs +37 -10
- package/dist/system-colors.d.mts +9 -0
- package/dist/system-colors.mjs +1 -0
- package/dist/target-size.mjs +14 -1
- package/dist/tsconfig.declarations.json +1 -0
- package/docs/ADS.md +23 -1
- package/docs/ASSETS.md +21 -0
- package/docs/CACHING.md +1 -1
- package/docs/CHANGELOG.md +220 -21
- package/docs/GUIDE.md +31 -20
- package/docs/LANGUAGE.md +146 -11
- package/docs/MOTION.md +11 -1
- package/docs/PROFILE-KINDS.md +60 -9
- package/docs/RULES.md +21 -8
- package/package.json +5 -1
|
@@ -121,17 +121,21 @@ export function nonTextContrast({ nodeLimit, scope, declared: declarations = []
|
|
|
121
121
|
}
|
|
122
122
|
const icon = (busy || !text(element)) && [...element.querySelectorAll("svg")].find((svg) => svg.checkVisibility({ checkOpacity: !0, checkVisibilityCSS: !0 }));
|
|
123
123
|
if (icon) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
124
|
+
let best = null;
|
|
125
|
+
for (const shape of icon.querySelectorAll("path, circle, rect, ellipse, line, polyline, polygon, use, text")) {
|
|
126
|
+
const paint = getComputedStyle(shape);
|
|
127
|
+
for (const value of [paint.stroke, paint.fill]) {
|
|
128
|
+
if (value === "none" || value.startsWith("url(") || rgba(value)[3] <= 0)
|
|
129
|
+
continue;
|
|
130
|
+
const color = rgba(value).slice();
|
|
131
|
+
color[3] *= opacity(shape, element) / Number(style.opacity);
|
|
132
|
+
const back = background(shape.parentElement) ?? own, measured = ratio(color, back);
|
|
133
|
+
if (best === null || measured > best.measured)
|
|
134
|
+
best = { measured, color, back };
|
|
135
|
+
}
|
|
134
136
|
}
|
|
137
|
+
if (best !== null && best.measured + 0.000000001 < 3)
|
|
138
|
+
report("icon", best.measured, over(best.color, best.back), best.back);
|
|
135
139
|
}
|
|
136
140
|
}
|
|
137
141
|
return { issues, counts, ...declaredHits.length ? { declared: declaredHits } : {} };
|
|
@@ -9,6 +9,7 @@ import { layoutOverflow } from "./layout-overflow.page.mjs";
|
|
|
9
9
|
import { layoutShift } from "./layout-shift.page.mjs";
|
|
10
10
|
import { imageShape } from "./image-shape.page.mjs";
|
|
11
11
|
import { cornerOverpaint } from "./corner-overpaint.page.mjs";
|
|
12
|
+
import { forcedStates } from "./forced-states.page.mjs";
|
|
12
13
|
import { overflowOnly, overridePasses, viewportPasses } from "./text-scale.mjs";
|
|
13
14
|
import { auditRenderStates, listTargets } from "./render-states.mjs";
|
|
14
15
|
import { brandReady, hasAxe, hasMainLandmark, markRenderAudit, setScenarioState, themeReady } from "./worker.page.mjs";
|
|
@@ -109,6 +110,38 @@ try {
|
|
|
109
110
|
};
|
|
110
111
|
}
|
|
111
112
|
}
|
|
113
|
+
async function environmentPass(app, environment) {
|
|
114
|
+
if (browser === void 0)
|
|
115
|
+
throw Error("The audit browser is not running.");
|
|
116
|
+
const own = await browser.newContext({
|
|
117
|
+
viewport: request.viewport,
|
|
118
|
+
deviceScaleFactor: 1,
|
|
119
|
+
colorScheme: app.scheme,
|
|
120
|
+
bypassCSP: !0,
|
|
121
|
+
reducedMotion: "reduce",
|
|
122
|
+
...environment === "forced-colors" ? { forcedColors: "active" } : { hasTouch: !0 }
|
|
123
|
+
});
|
|
124
|
+
try {
|
|
125
|
+
await own.addInitScript(markRenderAudit);
|
|
126
|
+
const page = await own.newPage();
|
|
127
|
+
if (app.state !== void 0)
|
|
128
|
+
await page.addInitScript(setScenarioState, app.state);
|
|
129
|
+
const url = new URL(app.url);
|
|
130
|
+
url.searchParams.set("environment", environment);
|
|
131
|
+
const opened = await openPreviewScenario(page, url.href, app.scenario, { timeout });
|
|
132
|
+
await opened.waitForFunction(themeReady, app.theme, { timeout });
|
|
133
|
+
if (app.brand)
|
|
134
|
+
await opened.waitForFunction(brandReady, app.brand, { timeout });
|
|
135
|
+
await page.mouse.move(request.viewport.width - 1, request.viewport.height - 1);
|
|
136
|
+
await opened.evaluate(firstRender);
|
|
137
|
+
if (!await opened.evaluate(hasAxe))
|
|
138
|
+
await opened.addScriptTag({ content: axe });
|
|
139
|
+
const found = await opened.evaluate(axeRun, { tags: request.tags, nodeLimit: request.nodeLimit }), forced = environment === "forced-colors" ? (await opened.evaluate(forcedStates, { nodeLimit: request.nodeLimit })).issues : void 0;
|
|
140
|
+
return { environment, ...found, ...forced === void 0 ? {} : { forced } };
|
|
141
|
+
} finally {
|
|
142
|
+
await own.close().catch(() => {});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
112
145
|
async function audit(app, partial, index) {
|
|
113
146
|
const page = await context.newPage();
|
|
114
147
|
if (app.state !== void 0)
|
|
@@ -187,6 +220,11 @@ try {
|
|
|
187
220
|
if (app.text) {
|
|
188
221
|
textScale.push(...await viewportPasses(page, frame, { nodeLimit: request.nodeLimit, widths: request.textWidths, height: request.viewport.height, rest }));
|
|
189
222
|
result.textScale = textScale;
|
|
223
|
+
const environments = [];
|
|
224
|
+
for (const environment of request.environments ?? [])
|
|
225
|
+
environments.push(await environmentPass(app, environment));
|
|
226
|
+
if (environments.length > 0)
|
|
227
|
+
result.environments = environments;
|
|
190
228
|
}
|
|
191
229
|
const assigned = await turns[index] ?? { triggers: [], controls: [] };
|
|
192
230
|
await auditRenderStates({ page, frame, result, request, phoneWidth: request.overflowWidths[0], assigned });
|
package/dist/render-audit.mjs
CHANGED
|
@@ -21,7 +21,34 @@ const shiftLimit = 0.1;
|
|
|
21
21
|
export const auditTags = Object.freeze(["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"]);
|
|
22
22
|
const viewport = { width: 1280, height: 800 };
|
|
23
23
|
export const overflowWidths = Object.freeze([390, 768, 1280]), auditedKinds = Object.freeze(["components", "patterns"]), containerWidth = 240, containerKinds = Object.freeze(["components", "patterns"]), auditAttempts = 3;
|
|
24
|
-
const limits = { scenarios: 500, nodes: 5, findings: 2000, reportBytes: 8388608, overlays: 3, controls: 6, contentQuietMs: 500, contentLimitMs: 5000 }
|
|
24
|
+
const limits = { scenarios: 500, nodes: 5, findings: 2000, reportBytes: 8388608, overlays: 3, controls: 6, contentQuietMs: 500, contentLimitMs: 5000 };
|
|
25
|
+
export const AUDIT_ENVIRONMENTS = ["forced-colors", "coarse-pointer"];
|
|
26
|
+
const ENVIRONMENT_LABELS = { "forced-colors": "in forced colours", "coarse-pointer": "with a coarse pointer" };
|
|
27
|
+
export const FORCED_RENDER_RULE = "a11y-forced-colors-render";
|
|
28
|
+
export function environmentFindings(runs, scenarios) {
|
|
29
|
+
const files = fileMap(scenarios), findings = [];
|
|
30
|
+
for (const run of runs)
|
|
31
|
+
for (const pass of run.environments ?? []) {
|
|
32
|
+
const label = ENVIRONMENT_LABELS[pass.environment], known = new Set((run.violations ?? []).map((violation) => JSON.stringify([violation.id, violation.nodes.map((node) => node.selector).sort()]))), added = pass.violations.filter((violation) => !known.has(JSON.stringify([violation.id, violation.nodes.map((node) => node.selector).sort()])));
|
|
33
|
+
for (const finding of auditFindings([{ scenario: run.scenario, theme: run.theme, ...run.brand ? { brand: run.brand } : {}, violations: added }], scenarios))
|
|
34
|
+
findings.push({ ...finding, environment: pass.environment, message: `${finding.message.replace(` in ${run.scenario} `, ` in ${run.scenario} ${label} `)}` });
|
|
35
|
+
for (const issue of pass.forced ?? [])
|
|
36
|
+
findings.push({
|
|
37
|
+
rule: FORCED_RENDER_RULE,
|
|
38
|
+
severity: findingSeverity(FORCED_RENDER_RULE),
|
|
39
|
+
file: files.get(run.scenario) ?? run.scenario,
|
|
40
|
+
line: 1,
|
|
41
|
+
column: 1,
|
|
42
|
+
scenario: run.scenario,
|
|
43
|
+
themes: [run.theme],
|
|
44
|
+
environment: pass.environment,
|
|
45
|
+
guidanceUri: "ads://guides/accessibility",
|
|
46
|
+
message: `In forced colours, ${issue.selector} (${issue.attribute}) in ${run.scenario} looks like ${issue.sibling} without it: the state cannot be seen. Declare \`forcedColors\` on the state's surface, or show the state by a border, a mark or text.`
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return findings.slice(0, limits.findings);
|
|
50
|
+
}
|
|
51
|
+
const fileMap = (scenarios) => new Map(scenarios.map((scenario) => [scenario.id, scenario.file])), addOnce = (list, value) => {
|
|
25
52
|
if (value !== void 0 && !list.includes(value))
|
|
26
53
|
list.push(value);
|
|
27
54
|
}, where = (themes, brands) => `[${themes.join(", ")}${brands.length ? `; ${brands.join(", ")}` : ""}]`;
|
|
@@ -233,11 +260,19 @@ const skipReasons = {
|
|
|
233
260
|
fix: "Make the element fluid (%, fr, min(100%, ...)), wrap it, or put it in an overflow-x: auto scroller."
|
|
234
261
|
},
|
|
235
262
|
clipped: {
|
|
236
|
-
what: "text or a
|
|
263
|
+
what: "text, a control, or a box's painted edge (a card's border and corners) is cut off by overflow hidden or clip (cropped images, artwork and decorative layers do not count)",
|
|
237
264
|
fix: "Make the content fit, truncate it with text-overflow: ellipsis, or use overflow-x: auto if it should scroll."
|
|
238
265
|
},
|
|
266
|
+
"collapsed-scroller": {
|
|
267
|
+
what: "a scroll area that holds content is collapsed to nothing: everything in it is out of sight",
|
|
268
|
+
fix: 'Give the scroll area a size: let it fill a parent that has a height (extent: "fill" in a stack given a height), or a minimum block size; check its parents for a height of 0.'
|
|
269
|
+
},
|
|
270
|
+
"broken-word": {
|
|
271
|
+
what: "a word is broken across lines: its box is narrower than the word (a field squeezed beside its tools)",
|
|
272
|
+
fix: "Give the box a minimum inline size that holds its longest word (min-inline-size in rem or ch), or let what sits beside it wrap to its own row below a width condition."
|
|
273
|
+
},
|
|
239
274
|
"block-clipped": {
|
|
240
|
-
what: "text or a
|
|
275
|
+
what: "text, a control or a box's painted edge is cut off by overflow hidden or clip on the block axis",
|
|
241
276
|
fix: "Let the box grow with its text: drop the fixed block size or use min-block-size, or scroll it with overflow-y: auto."
|
|
242
277
|
},
|
|
243
278
|
spilled: {
|
|
@@ -274,7 +309,7 @@ function groupLayout(entries) {
|
|
|
274
309
|
}
|
|
275
310
|
return [...groups.values()].slice(0, limits.findings);
|
|
276
311
|
}
|
|
277
|
-
const layoutElements = ({ nodes, nodeCount }) => [...nodes.values()].slice(0, 3).map((node) => `${node.selector} (${node.overflow}px at ${node.width}px${node.cut ? `, cutting ${node.cut.content === "text" ? "text" : "a control"} at ${node.cut.selector}` : ""})`).join(", ") + (nodeCount > 3 ? ` and ${nodeCount - 3} more` : "");
|
|
312
|
+
const layoutElements = ({ nodes, nodeCount }) => [...nodes.values()].slice(0, 3).map((node) => `${node.selector} (${node.overflow}px at ${node.width}px${node.cut ? `, cutting ${node.cut.content === "text" ? "text" : node.cut.content === "box" ? "a box's edge" : "a control"} at ${node.cut.selector}` : ""})`).join(", ") + (nodeCount > 3 ? ` and ${nodeCount - 3} more` : "");
|
|
278
313
|
export function layoutOverflowFindings(runs, scenarios) {
|
|
279
314
|
const files = fileMap(scenarios), entries = runs.flatMap((run) => (run.layout ?? []).map(({ width, container = !1, issues = [], counts = {} }) => ({
|
|
280
315
|
run,
|
|
@@ -612,7 +647,8 @@ async function runAuditWorker({
|
|
|
612
647
|
declared,
|
|
613
648
|
derived,
|
|
614
649
|
conditionWidths: boundWidths(derived.flatMap((construction) => construction.bounds ?? []), overflowWidths),
|
|
615
|
-
evidence
|
|
650
|
+
evidence,
|
|
651
|
+
environments: AUDIT_ENVIRONMENTS
|
|
616
652
|
}));
|
|
617
653
|
const timeoutMs = Math.min(1800000, settings.timeoutMs + apps.length * Math.min(settings.timeoutMs, 15000));
|
|
618
654
|
let cause;
|
|
@@ -809,6 +845,7 @@ export async function runRenderAudit(directory, { scenarios: selected, themes: s
|
|
|
809
845
|
...selected === void 0 || selected.length === 0 ? unrenderedConstructionFindings(runs, derived, path.relative(root, options.dsRoot) || ".") : [],
|
|
810
846
|
...derivedStateFindings(runs, scenarios, path.relative(root, options.dsRoot) || "."),
|
|
811
847
|
...findingsByState(runs, (some) => auditFindings(some, scenarios)),
|
|
848
|
+
...findingsByState(runs, (some) => environmentFindings(some, scenarios)),
|
|
812
849
|
...findingsByState(runs, (some) => nonTextContrastFindings(some, scenarios)),
|
|
813
850
|
...findingsByState(runs, (some) => declaredBoundaryFindings(some, scenarios, root)),
|
|
814
851
|
...findingsByState(runs, (some) => layoutOverflowFindings(some, scenarios)),
|
|
@@ -141,6 +141,7 @@ declare const tokenRolesByKind: {
|
|
|
141
141
|
background: string[];
|
|
142
142
|
color: string[];
|
|
143
143
|
"border-color": string[];
|
|
144
|
+
"text-decoration-color": string[];
|
|
144
145
|
"box-shadow": string[];
|
|
145
146
|
"background-image": string[];
|
|
146
147
|
opacity: string[];
|
|
@@ -163,6 +164,8 @@ declare const tokenRolesByKind: {
|
|
|
163
164
|
"meta-gap": string[];
|
|
164
165
|
"section-gap": string[];
|
|
165
166
|
indent: string[];
|
|
167
|
+
"space-before": string[];
|
|
168
|
+
"space-after": string[];
|
|
166
169
|
overlap: string[];
|
|
167
170
|
"anchor-gap": string[];
|
|
168
171
|
"outset-block": string[];
|
|
@@ -227,11 +230,11 @@ export declare const TEXT_TRANSFORM = "text-transform";
|
|
|
227
230
|
export declare const TEXT_TRANSFORMS: readonly ["uppercase", "lowercase", "capitalize"];
|
|
228
231
|
/** A frame profile's policy field: the line its border is drawn with. `solid` without it. */
|
|
229
232
|
export declare const BORDER_STYLE = "border-style";
|
|
230
|
-
export declare const BORDER_STYLES: readonly ["solid", "dashed", "dotted"];
|
|
233
|
+
export declare const BORDER_STYLES: readonly ["solid", "dashed", "dotted", "forced-only"];
|
|
231
234
|
export declare const profilePolicyFields: {
|
|
232
235
|
readonly text: readonly ["text-transform"];
|
|
233
236
|
readonly frame: readonly ["border-style"];
|
|
234
|
-
readonly visual: readonly ["fit", "preserve-ratio", "anchor"];
|
|
237
|
+
readonly visual: readonly ["fit", "preserve-ratio", "anchor", "size-axis"];
|
|
235
238
|
readonly motion: readonly ["reduced"];
|
|
236
239
|
readonly sequence: readonly ["reduced", "repeat"];
|
|
237
240
|
readonly spatial: readonly ["ratios"];
|
package/dist/role-vocabulary.mjs
CHANGED
|
@@ -164,6 +164,7 @@ const tokenRolesByKind = {
|
|
|
164
164
|
background: ["paint"],
|
|
165
165
|
color: ["paint"],
|
|
166
166
|
"border-color": ["paint"],
|
|
167
|
+
"text-decoration-color": ["paint"],
|
|
167
168
|
"box-shadow": ["shadow"],
|
|
168
169
|
"background-image": ["gradient"],
|
|
169
170
|
opacity: ["opacity"],
|
|
@@ -186,6 +187,8 @@ const tokenRolesByKind = {
|
|
|
186
187
|
"meta-gap": ["content-gap", "spacing"],
|
|
187
188
|
"section-gap": ["content-gap", "spacing"],
|
|
188
189
|
indent: ["content-gap", "spacing"],
|
|
190
|
+
"space-before": ["content-gap", "spacing"],
|
|
191
|
+
"space-after": ["content-gap", "spacing"],
|
|
189
192
|
overlap: ["overlap", "content-gap", "spacing"],
|
|
190
193
|
"anchor-gap": ["layout-size", "content-gap", "spacing"],
|
|
191
194
|
"outset-block": ["content-gap", "spacing", "box-share"],
|
|
@@ -227,12 +230,12 @@ export const profileTokenRoles = tokenRolesByKind, spatialClauseTokenRoles = {
|
|
|
227
230
|
"fixed-start": ["layout-size"],
|
|
228
231
|
"fixed-end": ["layout-size"]
|
|
229
232
|
},
|
|
230
|
-
"ads-gutter": { start: ["spacing", "grid-gutter"], end: ["spacing", "grid-gutter"] },
|
|
233
|
+
"ads-gutter": { start: ["spacing", "grid-gutter"], end: ["spacing", "grid-gutter"], gap: ["spacing", "grid-gutter", "content-gap"] },
|
|
231
234
|
"ads-condition": { below: ["layout-size"] }
|
|
232
|
-
}, SURFACE_STATE = "state", INACTIVE_STATE = "inactive", TEXT_TRANSFORM = "text-transform", TEXT_TRANSFORMS = ["uppercase", "lowercase", "capitalize"], BORDER_STYLE = "border-style", BORDER_STYLES = ["solid", "dashed", "dotted"], profilePolicyFields = {
|
|
235
|
+
}, SURFACE_STATE = "state", INACTIVE_STATE = "inactive", TEXT_TRANSFORM = "text-transform", TEXT_TRANSFORMS = ["uppercase", "lowercase", "capitalize"], BORDER_STYLE = "border-style", BORDER_STYLES = ["solid", "dashed", "dotted", "forced-only"], profilePolicyFields = {
|
|
233
236
|
text: [TEXT_TRANSFORM],
|
|
234
237
|
frame: [BORDER_STYLE],
|
|
235
|
-
visual: ["fit", "preserve-ratio", "anchor"],
|
|
238
|
+
visual: ["fit", "preserve-ratio", "anchor", "size-axis"],
|
|
236
239
|
motion: ["reduced"],
|
|
237
240
|
sequence: ["reduced", "repeat"],
|
|
238
241
|
spatial: ["ratios"],
|
package/dist/scenario-kit.d.mts
CHANGED
|
@@ -39,8 +39,8 @@ export interface Scenario<State extends object = object> {
|
|
|
39
39
|
readonly captureTargets?: Readonly<Record<string, string>>;
|
|
40
40
|
}
|
|
41
41
|
export interface ContainerProps {
|
|
42
|
-
/** The parent's width: the line (default), a 280px pane, a 360px column or a 720px page. */
|
|
43
|
-
readonly inline?: "fill" | "pane" | "column" | "page";
|
|
42
|
+
/** The parent's width: the line (default), a 280px pane, a 360px column, a 390px phone or a 720px page. */
|
|
43
|
+
readonly inline?: "fill" | "pane" | "column" | "phone" | "page";
|
|
44
44
|
/** The parent's height: its content's (default), 160px, 320px or 560px. */
|
|
45
45
|
readonly block?: "content" | "short" | "medium" | "tall";
|
|
46
46
|
/** What the parent stands for, in its caption. */
|
|
@@ -43,7 +43,7 @@ export function assetNote(asset, px) {
|
|
|
43
43
|
opticalCentre(asset) === "Middle" ? "" : `centre ${opticalCentre(asset)}`
|
|
44
44
|
].filter(Boolean).join(" \xB7 ");
|
|
45
45
|
}
|
|
46
|
-
const
|
|
46
|
+
const TILE_INLINE = 150;
|
|
47
47
|
export function assetSummary(facts) {
|
|
48
48
|
const counted = (group) => ["foreground", "slots", "intrinsic"].map((paint) => [facts.assets.filter((asset) => asset.group === group && asset.paint === paint).length, paint]).filter(([count]) => count > 0).map(([count, paint]) => `${count} ${paint}`).join(", ");
|
|
49
49
|
return [
|
|
@@ -121,9 +121,9 @@ export function mountAssets(container, facts) {
|
|
|
121
121
|
...(facts?.groups ?? []).map((group) => ({ id: groupChoice(group.group), label: `${groupTitle(group.group)} ${group.count}` })),
|
|
122
122
|
...facts?.sets.length ? [{ id: SETS, label: `Glyph sets ${facts.sets.length}` }] : []
|
|
123
123
|
], listed = html.dataset.adsChoices === "host";
|
|
124
|
-
let choice = listed ? SUMMARY : choices[0]?.id ?? "", hosted = listed
|
|
124
|
+
let choice = listed ? SUMMARY : choices[0]?.id ?? "", hosted = listed;
|
|
125
125
|
const render = () => {
|
|
126
|
-
const theme = html.dataset.theme, scheme = view?.getComputedStyle(html).colorScheme.includes("dark") ? "dark" : "light", members = choice === SETS || choice === SUMMARY ? [] : assets.filter((asset) => groupChoice(asset.group) === choice), folder = choice.startsWith("group:") ? groupTitle(choice.slice(6) || null) : null, sizes = [...new Map((facts?.sizes ?? []).map((token) => [Math.round(pixels(token) * 100) / 100, token]))].filter(([px]) => px > 0 && px <= 64).sort(([a], [b]) => a - b).map(([px, token]) => ({ token, px })),
|
|
126
|
+
const theme = html.dataset.theme, scheme = view?.getComputedStyle(html).colorScheme.includes("dark") ? "dark" : "light", members = choice === SETS || choice === SUMMARY ? [] : assets.filter((asset) => groupChoice(asset.group) === choice), folder = choice.startsWith("group:") ? groupTitle(choice.slice(6) || null) : null, sizes = [...new Map((facts?.sizes ?? []).map((token) => [Math.round(pixels(token) * 100) / 100, token]))].filter(([px]) => px > 0 && px <= 64).sort(([a], [b]) => a - b).map(([px, token]) => ({ token, px })), everySize = folder !== null;
|
|
127
127
|
renderCardPage(page, {
|
|
128
128
|
title: folder !== null && hosted ? `${folder} artwork` : choice === SETS && hosted ? "Glyph sets" : "Artwork",
|
|
129
129
|
description: folder !== null && hosted ? `${members.length} ${members.length === 1 ? "asset" : "assets"} declared under assets/${folder === "Top level" ? "" : `${folder}/`}, drawn in this frame's theme${theme ? ` (${theme})` : ""}.` : choice === SETS && hosted ? `${facts?.sets.length ?? 0} glyph ${facts?.sets.length === 1 ? "set" : "sets"}: the glyphs an owner may choose from data, by name.` : assets.length ? `${assets.length} assets in ${facts?.groups.length ?? 0} groups${facts?.sets.length ? `, ${facts.sets.length} glyph ${facts.sets.length === 1 ? "set" : "sets"}` : ""}. Every drawing is a declared asset of the design system.` : facts === null || facts === void 0 ? "This revision's preview tree has no artwork facts: emit it again." : "This revision declares no asset.",
|
|
@@ -138,27 +138,6 @@ export function mountAssets(container, facts) {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
} : {},
|
|
141
|
-
...folder !== null && members.length > 0 ? {
|
|
142
|
-
settings: {
|
|
143
|
-
controls: [
|
|
144
|
-
{ prop: VIEW, options: [COMPACT, ALL_SIZES], chosen: mode, as: "buttons" },
|
|
145
|
-
...everySize || size === void 0 ? [] : [{ prop: SIZE, options: sizes.map((item) => String(item.px)), chosen: String(size.px), as: "buttons" }],
|
|
146
|
-
...everySize ? [] : [{ prop: GUIDES, options: [NO_GUIDES, GRID, GRID_CENTRE], chosen: guides, as: "buttons" }],
|
|
147
|
-
...everySize ? [] : [{ prop: PLACE, options: [ALONE, BESIDE_TEXT], chosen: place, as: "buttons" }]
|
|
148
|
-
],
|
|
149
|
-
onControl: (prop, option) => {
|
|
150
|
-
if (prop === VIEW)
|
|
151
|
-
mode = option;
|
|
152
|
-
else if (prop === SIZE)
|
|
153
|
-
chosenSize = option;
|
|
154
|
-
else if (prop === GUIDES)
|
|
155
|
-
guides = option;
|
|
156
|
-
else if (prop === PLACE)
|
|
157
|
-
place = option;
|
|
158
|
-
render();
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
} : {},
|
|
162
141
|
sections: facts === null || facts === void 0 || everySize ? [] : assetSections(facts, choice, pixels)
|
|
163
142
|
});
|
|
164
143
|
const element = (asset, drawing, height) => {
|
|
@@ -182,7 +161,8 @@ export function mountAssets(container, facts) {
|
|
|
182
161
|
aliases: [...asset.aliases],
|
|
183
162
|
findings: [],
|
|
184
163
|
grid: drawing === void 0 ? null : { x: drawing.box[0], y: drawing.box[1], width: drawing.box[2], height: drawing.box[3] },
|
|
185
|
-
drawing: (height) => element(asset, drawing, height)
|
|
164
|
+
drawing: (height) => element(asset, asset.drawings.find((own) => own.size !== null && sizes.some((item) => item.token === own.size && item.px === height)) ?? drawing, height),
|
|
165
|
+
note: assetNote(asset, pixels)
|
|
186
166
|
};
|
|
187
167
|
}),
|
|
188
168
|
sizes,
|
|
@@ -192,8 +172,8 @@ export function mountAssets(container, facts) {
|
|
|
192
172
|
findings: []
|
|
193
173
|
};
|
|
194
174
|
renderArtworkCatalogue(catalogue, { data });
|
|
195
|
-
for (const
|
|
196
|
-
|
|
175
|
+
for (const staged of catalogue.querySelectorAll(".catalogue-set, .catalogue-mag, .catalogue-sizes"))
|
|
176
|
+
staged.dataset.adsStageInset = "8";
|
|
197
177
|
} else
|
|
198
178
|
unmount(catalogue);
|
|
199
179
|
for (const slot of page.querySelectorAll('[data-slot="stage"][data-key]')) {
|
|
@@ -202,37 +182,22 @@ export function mountAssets(container, facts) {
|
|
|
202
182
|
unmount(slot);
|
|
203
183
|
continue;
|
|
204
184
|
}
|
|
205
|
-
const
|
|
185
|
+
const drawing = drawingFor(asset, theme, scheme);
|
|
206
186
|
if (drawing === void 0) {
|
|
207
187
|
unmount(slot);
|
|
208
188
|
continue;
|
|
209
189
|
}
|
|
210
|
-
const wanted =
|
|
190
|
+
const wanted = drawing.box[3] <= 32 ? drawing.box[3] * 2 : 48, width = wanted * drawing.box[2] / drawing.box[3], scale = width > TILE_INLINE ? TILE_INLINE / width : 1, [inline, block] = [+(width * scale).toFixed(2), +(wanted * scale).toFixed(2)], drawn = element(asset, drawing, block);
|
|
211
191
|
if (drawn === null) {
|
|
212
192
|
renderArtworkSample(slot, { failed: !0, problem: "Not drawn: its SVG is not safe to show" });
|
|
213
193
|
continue;
|
|
214
194
|
}
|
|
215
|
-
const guided = folder !== null && guides !== NO_GUIDES;
|
|
216
195
|
unmount(slot);
|
|
217
196
|
slot.replaceChildren();
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
frame?.style.setProperty("inline-size", `${inline}px`);
|
|
222
|
-
frame?.style.setProperty("block-size", `${block}px`);
|
|
223
|
-
drawn.setAttribute("width", frame === null ? String(inline) : "100%");
|
|
224
|
-
drawn.setAttribute("height", frame === null ? String(block) : "100%");
|
|
197
|
+
renderArtworkSample(slot, {});
|
|
198
|
+
drawn.setAttribute("width", String(inline));
|
|
199
|
+
drawn.setAttribute("height", String(block));
|
|
225
200
|
slot.querySelector('[data-slot="drawing"]')?.replaceChildren(drawn);
|
|
226
|
-
if (sized !== void 0)
|
|
227
|
-
slot.dataset.adsOwnDrawing = size?.token ?? "";
|
|
228
|
-
else
|
|
229
|
-
delete slot.dataset.adsOwnDrawing;
|
|
230
|
-
const fitted = slot.closest(".ux-sample-card")?.querySelector(".ux-sample-card-note") ?? null;
|
|
231
|
-
if (fitted !== null && folder !== null) {
|
|
232
|
-
const said = " \xB7 shown at ", text = fitted.firstChild, plain = (text?.nodeValue ?? "").split(said)[0] ?? "";
|
|
233
|
-
if (text !== null)
|
|
234
|
-
text.nodeValue = scale < 1 ? `${plain}${said}${Math.round(block)}px to fit, not ${wanted}px` : plain;
|
|
235
|
-
}
|
|
236
201
|
}
|
|
237
202
|
}, choose = (id) => {
|
|
238
203
|
if (!choices.some((item) => item.id === id))
|