@taprootio/site-authoring 0.56.0 → 0.60.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -12
- package/package.json +2 -2
- package/src/api.js +16 -0
- package/src/block-flow.js +4 -2
- package/src/changelog.json +99 -0
- package/src/chrome-additions.js +106 -0
- package/src/chrome-features.js +43 -10
- package/src/chrome-input.js +137 -30
- package/src/chrome-report.js +4 -2
- package/src/cli.js +56 -17
- package/src/content/button-styles.js +27 -0
- package/src/content/components.js +76 -10
- package/src/content/free-form-section-registry.json +9 -0
- package/src/content/free-form-sections.js +55 -16
- package/src/content/markdown.js +133 -56
- package/src/content/media-presentation.js +37 -0
- package/src/content/tiptap-prosemirror.ts +26 -10
- package/src/credentials.js +2 -1
- package/src/delivery-check.js +10 -2
- package/src/font-catalog.js +9 -6
- package/src/footer-content.js +1 -1
- package/src/footer-contract.js +3 -0
- package/src/footer-draft-hash.js +1 -0
- package/src/heading-outline.js +94 -6
- package/src/image-description-contract.js +5 -3
- package/src/image-description-write.js +26 -0
- package/src/index.js +1 -0
- package/src/output.js +2 -1
- package/src/page-structure-checks.js +14 -25
- package/src/placed-image-ids.js +42 -17
- package/src/presentation-reference.js +63 -18
- package/src/problems.js +147 -4
- package/src/reference-help.js +102 -57
- package/src/site-check-findings.js +2 -3
- package/src/site-check-rules.json +0 -1
- package/src/site-health-findings.js +7 -9
- package/src/site-health-image-checks.js +4 -1
- package/src/site-health-precheck.js +23 -6
- package/src/site-navigation-groups.js +16 -0
- package/src/status-warning-paints.js +175 -0
- package/src/template-token-reach.json +13 -18
- package/src/theme-proposals.js +143 -55
- package/src/theme-resolve.js +14 -1
- package/src/theme-validation.js +70 -38
- package/src/token-reach.js +20 -0
- package/src/typed-page-reference.js +10 -3
- package/src/typed-pages.js +7 -7
- package/src/verbs/changelog.js +23 -2
- package/src/verbs/delivery-check.js +43 -9
- package/src/verbs/media-images.js +4 -4
- package/src/verbs/pages-push.js +38 -32
- package/src/verbs/plan.js +28 -20
- package/src/verbs/pull.js +179 -24
- package/src/verbs/theme-push.js +59 -15
- package/src/verbs/theme-resolve.js +109 -11
- package/src/verbs/validate.js +97 -16
- package/src/workspace-check.js +4 -4
- package/src/workspace-context-usage.js +180 -0
- package/src/workspace.js +12 -0
- package/test/fixtures/default-site-theme.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { listSiteImagesByIds
|
|
1
|
+
import { listSiteImagesByIds } from "./api.js";
|
|
2
|
+
import { writeImageDescription } from "./image-description-write.js";
|
|
2
3
|
import {
|
|
3
4
|
LIMITS,
|
|
4
5
|
REFUSAL_CAPABILITY_MISSING,
|
|
@@ -8,7 +9,7 @@ import {
|
|
|
8
9
|
REFUSAL_THROTTLED,
|
|
9
10
|
} from "./constants.js";
|
|
10
11
|
import { outcomeUnknown, SiteAuthoringError } from "./errors.js";
|
|
11
|
-
import { placedImageIds } from "./placed-image-ids.js";
|
|
12
|
+
import { decorationOnlyImageIds, placedImageIds } from "./placed-image-ids.js";
|
|
12
13
|
import { boundedByBytes } from "./session.js";
|
|
13
14
|
import {
|
|
14
15
|
IMAGE_CHECK_READ_FAILED,
|
|
@@ -51,16 +52,32 @@ const REASONS = Object.freeze({
|
|
|
51
52
|
export function placedImageIdsForPages(pages) {
|
|
52
53
|
return pages.map((page) => {
|
|
53
54
|
let imageIds = [];
|
|
55
|
+
let decorationOnly = [];
|
|
54
56
|
try {
|
|
55
57
|
const template = documentTemplate(page.document);
|
|
56
|
-
|
|
58
|
+
const data = wireTemplate(page.document)[PAGE_TEMPLATES[template].dataKey];
|
|
59
|
+
imageIds = [...placedImageIds(template, data)];
|
|
60
|
+
decorationOnly = decorationOnlyImageIds(template, data);
|
|
57
61
|
// The cover is a field beside the body, so the walk does not see it; the freezer adds it the same way.
|
|
62
|
+
// An image that is also the cover is placed as content, so it still needs a description.
|
|
58
63
|
const cover = page.document.coverImageId;
|
|
59
|
-
if (typeof cover === "string" && cover !== "")
|
|
64
|
+
if (typeof cover === "string" && cover !== "") {
|
|
65
|
+
const coverId = cover.toLowerCase();
|
|
66
|
+
imageIds.push(coverId);
|
|
67
|
+
decorationOnly = decorationOnly.filter((imageId) => imageId !== coverId);
|
|
68
|
+
}
|
|
60
69
|
} catch {
|
|
61
70
|
imageIds = [];
|
|
71
|
+
decorationOnly = [];
|
|
62
72
|
}
|
|
63
|
-
return {
|
|
73
|
+
return {
|
|
74
|
+
key: page.file,
|
|
75
|
+
path: displayPagePath(page.pagePath),
|
|
76
|
+
title: page.title,
|
|
77
|
+
imageIds,
|
|
78
|
+
decorationOnlyImageIds: decorationOnly,
|
|
79
|
+
document: page.document,
|
|
80
|
+
};
|
|
64
81
|
});
|
|
65
82
|
}
|
|
66
83
|
|
|
@@ -288,7 +305,7 @@ export async function describeMissingImages({ client, siteId, state, plan }) {
|
|
|
288
305
|
continue;
|
|
289
306
|
}
|
|
290
307
|
try {
|
|
291
|
-
const written = await
|
|
308
|
+
const written = await writeImageDescription(client, siteId, item.imageId, {
|
|
292
309
|
defaultDescription: item.description,
|
|
293
310
|
expectedRevision: item.expectedRevision,
|
|
294
311
|
onlyIfMissing: true,
|
|
@@ -15,6 +15,22 @@ export function canStyleNavigationAsButton(kind, hasChildren, kinds = SITE_NAVIG
|
|
|
15
15
|
export function canPlaceNavigationAtHeaderEnd(kind, depth, hasChildren, kinds = SITE_NAVIGATION_KINDS) {
|
|
16
16
|
return depth === 1 && canStyleNavigationAsButton(kind, hasChildren, kinds);
|
|
17
17
|
}
|
|
18
|
+
/** A page link takes its page's path; an unresolved page gets "" and renders without a link. */
|
|
19
|
+
export function resolveNavigationUrl(item, urlsByResourceId, kinds) {
|
|
20
|
+
if (item.kind === kinds.externalUrl)
|
|
21
|
+
return item.externalUrl ?? "";
|
|
22
|
+
if (item.kind === kinds.page)
|
|
23
|
+
return urlsByResourceId.get(item.resourceId ?? "") ?? "";
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
26
|
+
/** Attach a url to every item. Generator rendering and the CLI's chrome check both call this. */
|
|
27
|
+
export function resolveNavigationItems(items, urlsByResourceId, kinds) {
|
|
28
|
+
return (items ?? []).map((item) => ({
|
|
29
|
+
...item,
|
|
30
|
+
url: resolveNavigationUrl(item, urlsByResourceId, kinds),
|
|
31
|
+
children: resolveNavigationItems(item.children, urlsByResourceId, kinds),
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
18
34
|
/** Rendering treatment after the navigation tree has been prepared. */
|
|
19
35
|
export function describeHeaderNavigationItem(item, kinds, buttonAppearance) {
|
|
20
36
|
const group = item.kind === kinds.groupHeader || (item.children?.length ?? 0) > 0;
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { sanitizeDiagnostic } from "./errors.js";
|
|
2
|
+
import { getPaintingComponents } from "./token-reach.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Which components render the status colors a warning names (TR01412).
|
|
6
|
+
*
|
|
7
|
+
* Espalier's status-color warnings say two families are hard to tell apart; they
|
|
8
|
+
* do not say whether anything in the author's site paints either one. These
|
|
9
|
+
* records name the components that do, read from the token manifest through
|
|
10
|
+
* the same catalog `help tokens` uses.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const STATUS_FAMILIES = Object.freeze(["danger", "success", "warning", "info"]);
|
|
14
|
+
const MAXIMUM_RECORDS = 12;
|
|
15
|
+
// Everything before these words is the list of names the warning is about.
|
|
16
|
+
const NAMES_END = / (?:are hard to distinguish|cannot be separated|may not separate)/u;
|
|
17
|
+
const ACTION_ALIAS = /actionBackground is sourced from the "([a-z]+)" status family/u;
|
|
18
|
+
|
|
19
|
+
/** The status families a warning names, whatever the warning's remedy says. */
|
|
20
|
+
function familiesIn(warning) {
|
|
21
|
+
const alias = ACTION_ALIAS.exec(warning);
|
|
22
|
+
if (alias !== null) return STATUS_FAMILIES.filter((family) => family === alias[1]);
|
|
23
|
+
const start = warning.indexOf("Status colors ");
|
|
24
|
+
if (start === -1) return [];
|
|
25
|
+
const listed = warning.slice(start + "Status colors ".length).split(NAMES_END)[0];
|
|
26
|
+
const names = new Set([...listed.matchAll(/"([a-z]+)"/gu)].map((match) => match[1]));
|
|
27
|
+
return STATUS_FAMILIES.filter((family) => names.has(family));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const CONTEXT_SCOPE = /^(?:light|dark): contexts\.([^:]+): /u;
|
|
31
|
+
export const UNUSED_CONTEXT_NOTE = "no use found in this workspace";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The warnings whose record groups fit the bound, each with its families. A warning keeps all of its records or
|
|
35
|
+
* none: once a group would pass the bound, it and every later one are left out.
|
|
36
|
+
*/
|
|
37
|
+
function retainedGroups(warnings) {
|
|
38
|
+
const retained = [];
|
|
39
|
+
let count = 0;
|
|
40
|
+
for (const warning of new Set(warnings ?? [])) {
|
|
41
|
+
const families = familiesIn(warning);
|
|
42
|
+
if (count + families.length > MAXIMUM_RECORDS) break;
|
|
43
|
+
count += families.length;
|
|
44
|
+
retained.push({ warning, families });
|
|
45
|
+
}
|
|
46
|
+
return retained;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Whether a warning the report keeps is a status-color warning for a named context, the only kind a usage read can
|
|
51
|
+
* annotate. A warning the bound drops never triggers the read.
|
|
52
|
+
*/
|
|
53
|
+
export function hasContextScopedStatusWarning(warnings) {
|
|
54
|
+
return retainedGroups(warnings).some(({ warning, families }) => families.length > 0 && CONTEXT_SCOPE.test(warning));
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The context names the context-scoped status warnings mention, the only ones a usage count needs to keep. */
|
|
58
|
+
export function contextScopedNames(warnings) {
|
|
59
|
+
const names = new Set();
|
|
60
|
+
for (const { warning, families } of retainedGroups(warnings)) {
|
|
61
|
+
const name = families.length > 0 ? CONTEXT_SCOPE.exec(warning)?.[1] : undefined;
|
|
62
|
+
if (name !== undefined) names.add(name);
|
|
63
|
+
}
|
|
64
|
+
return names;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* What a context-scoped warning's record says about use; nothing without workspace evidence (TR01419). With
|
|
69
|
+
* `listed`, the first record of the warning also lists the sections and calls to action behind the counts (TR01426).
|
|
70
|
+
*/
|
|
71
|
+
function usageFields(warning, usage, listed) {
|
|
72
|
+
const name = usage === undefined ? undefined : CONTEXT_SCOPE.exec(warning)?.[1];
|
|
73
|
+
if (name === undefined) return {};
|
|
74
|
+
const used = usage.get(name);
|
|
75
|
+
if (used === undefined) return { usedBy: null, usedByNote: UNUSED_CONTEXT_NOTE };
|
|
76
|
+
const { usedIn, ...counts } = used;
|
|
77
|
+
return { usedBy: counts, ...(listed && usedIn !== undefined ? { usedIn } : {}) };
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const USE_KIND_LABEL = Object.freeze({ section: "section", cta: "call to action" });
|
|
81
|
+
|
|
82
|
+
/** The text line saying what uses the warning's context, or none. */
|
|
83
|
+
function usageLine(record) {
|
|
84
|
+
if (record.usedBy === undefined) return [];
|
|
85
|
+
if (record.usedBy === null) return [` Used by: ${record.usedByNote}`];
|
|
86
|
+
const { header, footer, sections, ctas } = record.usedBy;
|
|
87
|
+
const parts = [header ? "header" : "", footer ? "footer" : "", sections > 0 ? `${sections} section(s)` : "", ctas > 0 ? `${ctas} call(s) to action` : ""];
|
|
88
|
+
const { items = [], total = 0 } = record.usedIn ?? {};
|
|
89
|
+
const where = items.map(({ file, kind, position }) => `${file} ${USE_KIND_LABEL[kind] ?? kind} ${position}`);
|
|
90
|
+
if (total > items.length) where.push(`and ${total - items.length} more`);
|
|
91
|
+
return [` Used by: ${parts.filter(Boolean).join(", ")}${where.length > 0 ? `: ${where.join(", ")}` : ""}`];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Where the text view finds the `usedIn` lists a JSON result shed to fit its bound. A symbol key is not
|
|
96
|
+
* serialized, so the JSON stays as fitted while the default text output still names the pages.
|
|
97
|
+
*/
|
|
98
|
+
export const TEXT_USED_IN = Symbol("theme-resolve.textUsedIn");
|
|
99
|
+
|
|
100
|
+
/** The records with the text view's `usedIn` lists put back where the JSON dropped them. */
|
|
101
|
+
export function withTextUsedIn(records, lists) {
|
|
102
|
+
if (records === undefined || lists === undefined) return records;
|
|
103
|
+
const seen = new Set();
|
|
104
|
+
return records.map((record) => {
|
|
105
|
+
if (seen.has(record.warning)) return record;
|
|
106
|
+
seen.add(record.warning);
|
|
107
|
+
return record.usedIn === undefined && lists.has(record.warning) ? { ...record, usedIn: lists.get(record.warning) } : record;
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** The records' `usedIn` lists by warning, which sit on each warning's first record. */
|
|
112
|
+
export function usedInOf(records) {
|
|
113
|
+
return new Map((records ?? []).filter((record) => record.usedIn !== undefined).map((record) => [record.warning, record.usedIn]));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/** The records without their `usedIn` lists, the shape every existing fitting stage sizes. */
|
|
117
|
+
export function withoutUsedIn(records) {
|
|
118
|
+
return records?.map(({ usedIn: _listed, ...record }) => record);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** The one text line naming the pages a context-scoped count left out, or none. */
|
|
122
|
+
export function notCountedLine(skipped) {
|
|
123
|
+
if (skipped === undefined) return [];
|
|
124
|
+
const files = skipped.items.map(({ file, code }) => `${sanitizeDiagnostic(file, "")} (${code})`);
|
|
125
|
+
if (skipped.total > skipped.items.length) files.push(`and ${skipped.total - skipped.items.length} more`);
|
|
126
|
+
return [`Not counted: ${skipped.total} page source(s) skipped: ${files.join(", ")}`];
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** The one text line saying the page inventory could not be read, so no usage was counted. */
|
|
130
|
+
export function usageUnavailableLine(unavailable) {
|
|
131
|
+
if (unavailable === undefined) return [];
|
|
132
|
+
return [`Usage not counted: the page inventory could not be read (${unavailable.code}${unavailable.field === undefined ? "" : `, ${unavailable.field}`}).`];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* One record per status family each status-color warning names. A warning keeps all of its records or none:
|
|
137
|
+
* once a warning's group would pass the bound, it and every later one are left out (see omittedStatusWarnings).
|
|
138
|
+
* With `usage` (see buildContextUsage), records for a context also say what uses that context.
|
|
139
|
+
*/
|
|
140
|
+
export function statusWarningPaints(warnings, { paintsFor = getPaintingComponents, usage, usedIn = true } = {}) {
|
|
141
|
+
return retainedGroups(warnings).flatMap(({ warning, families }) =>
|
|
142
|
+
families.map((family, index) => ({
|
|
143
|
+
warning,
|
|
144
|
+
family,
|
|
145
|
+
paints: paintsFor(family),
|
|
146
|
+
...usageFields(warning, usage, usedIn && index === 0),
|
|
147
|
+
}))
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** How many status warnings have no records, so a reader knows the paint information is incomplete. */
|
|
152
|
+
export function omittedStatusWarnings(warnings, records) {
|
|
153
|
+
const covered = new Set(records.map(({ warning }) => warning));
|
|
154
|
+
return new Set((warnings ?? []).filter((warning) => familiesIn(warning).length > 0 && !covered.has(warning))).size;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** The result fields for the records: the list, and how many warnings it could not hold. */
|
|
158
|
+
export function statusPaintFields(warnings, records) {
|
|
159
|
+
const omitted = omittedStatusWarnings(warnings, records);
|
|
160
|
+
return {
|
|
161
|
+
...(records.length === 0 ? {} : { statusWarningPaints: records }),
|
|
162
|
+
...(omitted === 0 ? {} : { statusWarningPaintsOmitted: omitted }),
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** The text line under a warning for each family it names. */
|
|
167
|
+
export function statusPaintLines(records, warning) {
|
|
168
|
+
const own = (records ?? []).filter((record) => record.warning === warning);
|
|
169
|
+
const lines = own.map(({ family, paints }) =>
|
|
170
|
+
` Paints (${family}): ${paints.length === 0 ? "no component paint row in this Espalier release" : paints.join(", ")}`
|
|
171
|
+
);
|
|
172
|
+
// Every record of a warning shares its context, so one line covers them.
|
|
173
|
+
if (own.length > 0) lines.push(...usageLine(own[0]));
|
|
174
|
+
return lines.length > 0 || familiesIn(warning).length === 0 ? lines : [" Paints: not listed; too many status warnings"];
|
|
175
|
+
}
|
|
@@ -17,33 +17,28 @@
|
|
|
17
17
|
{"token": "--esp-color-shadow", "file": "generator/client/pages/card-grid/taproot-card-grid.ts", "markup": ":host", "part": "--taproot-cg-card-shadow", "label": "card grid shadow fallback", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
18
18
|
{"token": "--esp-color-layer-1", "file": "generator/client/pages/card-grid/taproot-card-grid.ts", "markup": "::slotted(.card-item)", "part": "background", "label": "card item fill", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
19
19
|
{"token": "--esp-color-border", "file": "generator/client/pages/card-grid/taproot-card-grid.ts", "markup": "::slotted(.card-item)", "part": "border", "label": "card item border", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
20
|
-
{"token": "--esp-color-layer-2", "file": "generator/client/pages/card-grid/taproot-card-grid.ts", "markup": ":host(:
|
|
20
|
+
{"token": "--esp-color-layer-2", "file": "generator/client/pages/card-grid/taproot-card-grid.ts", "markup": ":host(:is(:not([interaction]), [interaction=\"lift\"])) ::slotted(a.card-item:is(:hover, :focus-visible))", "part": "background", "label": "card item hover fill", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
21
|
+
{"token": "--esp-color-shadow", "file": "generator/client/pages/card-grid/taproot-card-grid.ts", "markup": ":host([interaction=\"press\"]) ::slotted(.card-item)", "part": "box-shadow via --esp-shadow-2", "label": "pressable card resting shadow", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
22
|
+
{"token": "--esp-color-shadow", "file": "generator/client/pages/card-grid/taproot-card-grid.ts", "markup": ":host([interaction=\"press\"]) ::slotted(.card-item)", "part": "box-shadow", "label": "pressable card resting shadow fallback", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
23
|
+
{"token": "--esp-color-layer-2", "file": "generator/client/pages/card-grid/taproot-card-grid.ts", "markup": ":host([interaction=\"press\"]) ::slotted(a.card-item:is(:hover, :focus-visible))", "part": "background", "label": "pressable card hover fill", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
24
|
+
{"token": "--esp-color-shadow", "file": "generator/client/pages/card-grid/taproot-card-grid.ts", "markup": ":host([interaction=\"press\"]) ::slotted(a.card-item:is(:hover, :focus-visible))", "part": "box-shadow via --esp-shadow-1", "label": "pressable card hover shadow", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
25
|
+
{"token": "--esp-color-shadow", "file": "generator/client/pages/card-grid/taproot-card-grid.ts", "markup": ":host([interaction=\"press\"]) ::slotted(a.card-item:is(:hover, :focus-visible))", "part": "box-shadow", "label": "pressable card hover shadow fallback", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
21
26
|
{"token": "--esp-color-link", "file": "generator/client/pages/card-grid/taproot-card-grid.ts", "markup": "::slotted(a.card-item:focus-visible)", "part": "outline", "label": "card item focus ring", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
22
27
|
{"token": "--esp-color-layer-2", "file": "generator/client/pages/card-grid/taproot-card-grid.ts", "markup": ":host(:not([interaction=\"none\"])) ::slotted(a.card-item:focus-visible)", "part": "background", "label": "card item fill", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
23
28
|
{"token": "intent:danger", "file": "generator/client/pages/cta/taproot-cta.ts", "markup": "esp-button[class=\"cta__button\"]", "part": "intent", "label": "destructive call-to-action button", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
29
|
+
{"token": "--esp-color-background", "file": "generator/client/pages/cta/taproot-cta.ts", "markup": ":host([context]:not([context=\"\"])) .cta", "part": "background", "label": "cta panel fill from its context", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
24
30
|
{"token": "--esp-color-border", "file": "generator/client/pages/cta/taproot-cta.ts", "markup": ".cta--bordered", "part": "border", "label": "cta bordered border", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
25
|
-
{"token": "--esp-color-headings", "file": "generator/
|
|
26
|
-
{"token": "--esp-color-text", "file": "generator/
|
|
31
|
+
{"token": "--esp-color-headings", "file": "generator/src/hero-cta-markup.ts", "markup": "taproot-cta > [slot=\"heading\"]", "part": "color", "label": "cta heading ink", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
32
|
+
{"token": "--esp-color-text", "file": "generator/src/hero-cta-markup.ts", "markup": "taproot-cta > [slot=\"description\"]", "part": "color", "label": "cta description ink", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
27
33
|
{"token": "--esp-color-headings", "file": "generator/client/pages/feature-grid/taproot-feature-grid.ts", "markup": ":host", "part": "--taproot-fg-icon-color", "label": "feature icon ink", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
28
34
|
{"token": "--esp-color-border", "file": "generator/client/pages/feature-grid/taproot-feature-grid.ts", "markup": "::slotted(.feature-item)", "part": "border", "label": "feature item border", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
29
35
|
{"token": "--esp-color-headings", "file": "generator/client/pages/feature-grid/taproot-feature-grid.ts", "markup": "taproot-feature-grid .feature-item > .feature-item__icon:not([banner])", "part": "color", "label": "feature item icon ink", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
30
36
|
{"token": "--esp-color-headings", "file": "generator/client/pages/feature-grid/taproot-feature-grid.ts", "markup": "taproot-feature-grid .feature-item__title", "part": "color", "label": "feature item title ink", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
31
37
|
{"token": "--esp-color-link", "file": "generator/client/pages/feature-grid/taproot-feature-grid.ts", "markup": "taproot-feature-grid a.feature-item:focus-visible", "part": "outline", "label": "feature item focus ring", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
32
|
-
{"token": "--esp-color-type-overline", "file": "generator/
|
|
33
|
-
{"token": "--esp-color-headings", "file": "generator/
|
|
34
|
-
{"token": "--esp-color-headings", "file": "generator/
|
|
35
|
-
{"token": "--esp-color-type-lead", "file": "generator/
|
|
36
|
-
{"token": "--esp-color-action-background", "file": "generator/client/pages/hero/taproot-hero.ts", "markup": ".hero__action--primary", "part": "border-color", "label": "hero action primary border", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
37
|
-
{"token": "--esp-color-action-background", "file": "generator/client/pages/hero/taproot-hero.ts", "markup": ".hero__action--primary", "part": "background", "label": "hero action primary fill", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
38
|
-
{"token": "--esp-color-action-text", "file": "generator/client/pages/hero/taproot-hero.ts", "markup": ".hero__action--primary", "part": "color", "label": "hero action primary ink", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
39
|
-
{"token": "--esp-color-link", "file": "generator/client/pages/hero/taproot-hero.ts", "markup": ".hero__action--secondary", "part": "border-color", "label": "hero action secondary border", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
40
|
-
{"token": "--esp-color-link", "file": "generator/client/pages/hero/taproot-hero.ts", "markup": ".hero__action--secondary", "part": "color", "label": "hero action secondary ink", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
41
|
-
{"token": "--esp-color-action-background", "file": "generator/client/pages/hero/taproot-hero.ts", "markup": ".hero__action--primary:hover", "part": "background", "label": "hero action primary hover fill", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
42
|
-
{"token": "--esp-color-shadow", "file": "generator/client/pages/hero/taproot-hero.ts", "markup": ".hero__action--primary:hover", "part": "box-shadow via --esp-shadow-1", "label": "hero action primary hover shadow", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
43
|
-
{"token": "--esp-color-action-text", "file": "generator/client/pages/hero/taproot-hero.ts", "markup": ".hero__action--primary:hover", "part": "color", "label": "hero action primary hover ink", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
44
|
-
{"token": "--esp-color-link-hover-bg", "file": "generator/client/pages/hero/taproot-hero.ts", "markup": ".hero__action--secondary:hover", "part": "background", "label": "hero action secondary hover fill", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
45
|
-
{"token": "--esp-color-link-hover", "file": "generator/client/pages/hero/taproot-hero.ts", "markup": ".hero__action--secondary:hover", "part": "color", "label": "hero action secondary hover ink", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
46
|
-
{"token": "--esp-color-link", "file": "generator/client/pages/hero/taproot-hero.ts", "markup": ".hero__action:focus-visible", "part": "outline", "label": "hero action focus ring", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
38
|
+
{"token": "--esp-color-type-overline", "file": "generator/src/hero-cta-markup.ts", "markup": "taproot-hero > [slot=\"overline\"]", "part": "color via --esp-type-overline-color", "label": "hero overline ink", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
39
|
+
{"token": "--esp-color-headings", "file": "generator/src/hero-cta-markup.ts", "markup": "taproot-hero > [slot=\"title\"]", "part": "color", "label": "hero title ink", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
40
|
+
{"token": "--esp-color-headings", "file": "generator/src/hero-cta-markup.ts", "markup": "taproot-hero[title-size=\"display\"] > [slot=\"title\"]", "part": "color via --esp-type-display-color", "label": "hero display title ink", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
41
|
+
{"token": "--esp-color-type-lead", "file": "generator/src/hero-cta-markup.ts", "markup": "taproot-hero > [slot=\"lead\"]", "part": "color via --esp-type-lead-color", "label": "hero lead ink", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
47
42
|
{"token": "--esp-color-link", "file": "generator/client/pages/image-row/taproot-image-row.ts", "markup": "taproot-image-row > a.image-row__item:focus-visible", "part": "outline", "label": "image row item focus ring", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
48
43
|
{"token": "--esp-color-text", "file": "generator/client/pages/latest-posts/taproot-latest-posts.ts", "markup": "taproot-latest-posts :is(a.post-card.post-card, a.post-card__link)", "part": "color", "label": "latest posts card link ink", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
|
49
44
|
{"token": "--esp-color-layer-2", "file": "generator/client/pages/latest-posts/taproot-latest-posts.ts", "markup": "taproot-latest-posts :is(a.post-card.post-card:hover, article.post-card:has(> a.post-card__link:hover))", "part": "background", "label": "latest posts hover fill", "topics": ["free-form", "article", "album", "recipe", "place-review", "legal", "generated"]},
|
package/src/theme-proposals.js
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
import { computeThemeProperties } from "@taprootio/espalier/shared/theme-properties";
|
|
12
12
|
|
|
13
13
|
import { loadEspalierShared } from "./espalier-shared.js";
|
|
14
|
+
import { authoredMappingTokens } from "./theme-validation.js";
|
|
14
15
|
import { SiteAuthoringError } from "./errors.js";
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -64,22 +65,113 @@ function lintTokenKeys(suite, root) {
|
|
|
64
65
|
// Status colors
|
|
65
66
|
// ---------------------------------------------------------------------------
|
|
66
67
|
|
|
68
|
+
// Espalier 7.7.0 drops its "via intents" clause from a context collision that involves the action
|
|
69
|
+
// color, so the clause is optional and only a context-action collision may go without it.
|
|
67
70
|
const STATUS_COLLISION =
|
|
68
|
-
/^(light|dark): (?:contexts\.[^:]
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
+
/^(light|dark): (?:contexts\.([^:]+): )?Status colors "([a-z]+)" and "([a-z]+)" (?:.*retune (?:one of them|both|"([a-z]+)") via intents)?/u;
|
|
72
|
+
// When two statuses collide, the first family listed that can move moves, so danger moves last.
|
|
73
|
+
const STATUS_FAMILY_ORDER = ["info", "success", "warning", "danger"];
|
|
74
|
+
// A status keeps its hue family: red, orange, gold, green and blue stay recognizable inside this bound.
|
|
75
|
+
const MAXIMUM_STATUS_HUE_SHIFT = 16;
|
|
76
|
+
const STATUS_HUE_SHIFTS = [0, 4, -4, 8, -8, 12, -12, MAXIMUM_STATUS_HUE_SHIFT, -MAXIMUM_STATUS_HUE_SHIFT];
|
|
77
|
+
const STATUS_CHROMA_SHIFTS = [0, 0.03, -0.03, 0.06, -0.06];
|
|
78
|
+
const STATUS_LIGHTNESS_SHIFTS = [0, 0.06, -0.06];
|
|
79
|
+
// Espalier's INTENT_DISTANCE_THRESHOLD: statuses closer than this, as rendered, collide.
|
|
80
|
+
const STATUS_DISTANCE_THRESHOLD = 0.045;
|
|
71
81
|
|
|
72
82
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
* since the audit re-renders status colors at the action's lightness. Values
|
|
76
|
-
* already proposed for other families in this scheme are applied with it, so
|
|
77
|
-
* taking every proposal together cannot recreate a collision.
|
|
83
|
+
* What the audit sees of one status base color: re-rendered at the action
|
|
84
|
+
* stop's lightness and clamped to the action chroma band.
|
|
78
85
|
*/
|
|
79
|
-
function
|
|
86
|
+
function renderedStatus(engine, base, stop, band) {
|
|
87
|
+
return engine.gamutMapToSRGB(engine.deriveSemantic(base, stop, band.min, band.max));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** The status families and action source the audit compares, resolved the way it resolves them. */
|
|
91
|
+
async function statusRendering(theme, scheme, context, engine) {
|
|
92
|
+
const [core, variants] = await Promise.all([loadEspalierShared("theme-core.js"), loadEspalierShared("variant-engine.js")]);
|
|
93
|
+
const merged = mergeTheme(DEFAULTS[scheme], theme);
|
|
94
|
+
const effective = context === undefined ? merged : core.resolveContextTheme(merged, context) ?? merged;
|
|
95
|
+
const seed = engine.parseCssColor(effective.seedColor);
|
|
96
|
+
if (seed === null || seed === undefined) return undefined;
|
|
97
|
+
const bases = variants.computeVariants(seed, effective);
|
|
98
|
+
const mapping = effective.semanticMappings.actionBackground;
|
|
99
|
+
const action = variants.resolveMappingSource(mapping.source, bases, effective.anchors);
|
|
100
|
+
const stop = core.resolveLightnessReference(effective.lightness, effective.tones, mapping.lightness);
|
|
101
|
+
const band = effective.chroma.actionBackground;
|
|
102
|
+
const base = (name) => (name === "action" ? action : bases[name]);
|
|
103
|
+
return { base, render: (color) => renderedStatus(engine, color, stop, band) };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Where the action color of a context's surface is set, in Espalier's precedence: the context's own
|
|
108
|
+
* actionBackground pin, then an explicit root pin the context inherits, then the context's action role.
|
|
109
|
+
*/
|
|
110
|
+
function contextActionSource(theme, scheme, context) {
|
|
111
|
+
const surface = theme.contexts?.[context];
|
|
112
|
+
const root = `${scheme}Theme`;
|
|
113
|
+
if (surface?.semanticMappings?.actionBackground !== undefined) {
|
|
114
|
+
return `${root}.contexts.${context}.semanticMappings.actionBackground`;
|
|
115
|
+
}
|
|
116
|
+
const rootPinned = authoredMappingTokens(theme).has("actionBackground");
|
|
117
|
+
if (rootPinned) return `${root}.semanticMappings.actionBackground (the context inherits this pin)`;
|
|
118
|
+
if (surface?.action !== undefined) return `${root}.contexts.${context}.action`;
|
|
119
|
+
return `${root}.roles.action (the context inherits it)`;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Candidates for one family: hue within the family's bound, chroma and
|
|
124
|
+
* lightness shifts, each rendered the way the audit renders it. A candidate
|
|
125
|
+
* that renders like one already listed, or like the current color, is dropped.
|
|
126
|
+
* Nearest first by rendered ΔE-OK from the current color.
|
|
127
|
+
*/
|
|
128
|
+
function statusCandidates(engine, rendering, family, counterpart) {
|
|
129
|
+
const base = rendering.base(family);
|
|
130
|
+
if (base === null || base === undefined) return [];
|
|
131
|
+
const current = rendering.render(base);
|
|
132
|
+
const against = counterpart === undefined ? undefined : rendering.render(counterpart);
|
|
133
|
+
const seen = new Set([engine.serializeOklch(current)]);
|
|
134
|
+
const candidates = [];
|
|
135
|
+
for (const hue of STATUS_HUE_SHIFTS) {
|
|
136
|
+
for (const chroma of STATUS_CHROMA_SHIFTS) {
|
|
137
|
+
for (const lightness of STATUS_LIGHTNESS_SHIFTS) {
|
|
138
|
+
const color = engine.gamutMapToSRGB({
|
|
139
|
+
l: Math.min(0.95, Math.max(0.05, base.l + lightness)),
|
|
140
|
+
c: Math.max(0, base.c + chroma),
|
|
141
|
+
h: (base.h + hue + 360) % 360,
|
|
142
|
+
});
|
|
143
|
+
const shown = rendering.render(color);
|
|
144
|
+
const key = engine.serializeOklch(shown);
|
|
145
|
+
if (seen.has(key)) continue;
|
|
146
|
+
seen.add(key);
|
|
147
|
+
// A color that renders within the threshold of its counterpart cannot clear the warning.
|
|
148
|
+
if (against !== undefined && engine.deltaEOK(shown, against) < STATUS_DISTANCE_THRESHOLD) continue;
|
|
149
|
+
candidates.push({ family, color, distance: engine.deltaEOK(current, shown) });
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
return candidates.sort((left, right) => left.distance - right.distance);
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* An `intents` color for one of the families a collision names. Each family
|
|
158
|
+
* keeps its hue within MAXIMUM_STATUS_HUE_SHIFT and moves the least that the
|
|
159
|
+
* audit's own rendering lets clear the collision; danger moves only when no
|
|
160
|
+
* other family can. Values already proposed for other families in this scheme
|
|
161
|
+
* are applied with it, so taking every proposal together cannot recreate a
|
|
162
|
+
* collision. A collision with a context's action color gets advice, never a
|
|
163
|
+
* root change, because intents are set once per scheme.
|
|
164
|
+
*/
|
|
165
|
+
async function proposeStatusIntent(warning, themes, baseline, accepted, engine, budget) {
|
|
80
166
|
const match = STATUS_COLLISION.exec(warning);
|
|
81
167
|
if (match === null) return undefined;
|
|
82
|
-
const [, scheme, first, second, named] = match;
|
|
168
|
+
const [matched, scheme, context, first, second, named] = match;
|
|
169
|
+
const contextAction = context !== undefined && (first === "action" || second === "action");
|
|
170
|
+
if (!contextAction && !matched.includes("via intents")) return undefined;
|
|
171
|
+
if (contextAction) {
|
|
172
|
+
return `Intents do not set this surface: its action color does. Retune ${contextActionSource(themes[scheme], scheme, context)}, `
|
|
173
|
+
+ "or leave the warning if this context renders no status UI.";
|
|
174
|
+
}
|
|
83
175
|
const theme = { ...themes[scheme], intents: { ...themes[scheme].intents, ...accepted[scheme] } };
|
|
84
176
|
const statusBefore = new Set(baseline.filter((entry) => entry.includes("Status colors")));
|
|
85
177
|
// The values already proposed may clear this collision on their own; a
|
|
@@ -90,50 +182,45 @@ function proposeStatusIntent(warning, themes, baseline, accepted, engine, budget
|
|
|
90
182
|
const result = validateThemePair(...encodePair(...withScheme(themes, scheme, theme)));
|
|
91
183
|
if (result.valid && !result.warnings.includes(warning)) return "Cleared by the intents proposed above.";
|
|
92
184
|
}
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
const
|
|
185
|
+
const rendering = await statusRendering(theme, scheme, context, engine);
|
|
186
|
+
if (rendering === undefined) return undefined;
|
|
187
|
+
const pair = [first, second];
|
|
188
|
+
const movable = (named === undefined ? pair : [named]).filter((family) => !(family in accepted[scheme]));
|
|
189
|
+
const families = [...movable].sort((left, right) => STATUS_FAMILY_ORDER.indexOf(left) - STATUS_FAMILY_ORDER.indexOf(right));
|
|
190
|
+
if (families.length === 0) return undefined;
|
|
191
|
+
const perFamily = Math.max(1, Math.floor(MAXIMUM_CANDIDATES / families.length));
|
|
192
|
+
const proposedFamilies = Object.keys(accepted[scheme]);
|
|
193
|
+
let exhausted = false;
|
|
97
194
|
for (const family of families) {
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
195
|
+
const counterpart = rendering.base(pair.find((name) => name !== family) ?? "");
|
|
196
|
+
for (const { color } of statusCandidates(engine, rendering, family, counterpart).slice(0, perFamily)) {
|
|
197
|
+
if (budget.remaining <= 0) {
|
|
198
|
+
exhausted = true;
|
|
199
|
+
break;
|
|
200
|
+
}
|
|
201
|
+
budget.remaining -= 1;
|
|
202
|
+
const value = engine.serializeOklch(color);
|
|
203
|
+
const patched = { ...theme, intents: { ...theme.intents, [family]: value } };
|
|
204
|
+
const result = validateThemePair(...encodePair(...withScheme(themes, scheme, patched)));
|
|
205
|
+
if (!result.valid || result.warnings.includes(warning)) continue;
|
|
206
|
+
if (result.warnings.some((entry) => entry.includes("Status colors") && !statusBefore.has(entry))) continue;
|
|
207
|
+
// Nor may it collide with a family already given a proposal, even where
|
|
208
|
+
// that collision was there before.
|
|
209
|
+
if (
|
|
210
|
+
result.warnings.some((entry) =>
|
|
211
|
+
entry.startsWith(`${scheme}: `) && entry.includes("Status colors") && entry.includes(`"${family}"`)
|
|
212
|
+
&& proposedFamilies.some((other) => entry.includes(`"${other}"`))
|
|
213
|
+
)
|
|
214
|
+
) continue;
|
|
215
|
+
const together = proposedFamilies.length > 0 ? ", with the intents proposed above" : "";
|
|
216
|
+
const everyZone = context === undefined ? "" : " An intents change applies to every zone, not only this context.";
|
|
217
|
+
accepted[scheme][family] = value;
|
|
218
|
+
return `Nearest passing value: ${scheme}Theme.intents.${family} = "${value}"${together}.${everyZone}`;
|
|
112
219
|
}
|
|
113
220
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
budget.remaining -= 1;
|
|
118
|
-
const value = engine.serializeOklch(color);
|
|
119
|
-
const patched = { ...theme, intents: { ...theme.intents, [family]: value } };
|
|
120
|
-
const result = validateThemePair(...encodePair(...withScheme(themes, scheme, patched)));
|
|
121
|
-
if (!result.valid || result.warnings.includes(warning)) continue;
|
|
122
|
-
if (result.warnings.some((entry) => entry.includes("Status colors") && !statusBefore.has(entry))) continue;
|
|
123
|
-
// Nor may it collide with a family already given a proposal, even where
|
|
124
|
-
// that collision was there before.
|
|
125
|
-
const proposedFamilies = Object.keys(accepted[scheme]);
|
|
126
|
-
if (
|
|
127
|
-
result.warnings.some((entry) =>
|
|
128
|
-
entry.startsWith(`${scheme}: `) && entry.includes("Status colors") && entry.includes(`"${family}"`)
|
|
129
|
-
&& proposedFamilies.some((other) => entry.includes(`"${other}"`))
|
|
130
|
-
)
|
|
131
|
-
) continue;
|
|
132
|
-
const together = Object.keys(accepted[scheme]).length > 0 ? ", with the intents proposed above" : "";
|
|
133
|
-
accepted[scheme][family] = value;
|
|
134
|
-
return `Nearest passing value: ${scheme}Theme.intents.${family} = "${value}"${together}.`;
|
|
135
|
-
}
|
|
136
|
-
return undefined;
|
|
221
|
+
if (exhausted) return undefined;
|
|
222
|
+
return `No intents change keeps ${families.join(" or ")} within ${MAXIMUM_STATUS_HUE_SHIFT}° of its hue and clears this. `
|
|
223
|
+
+ "Move the action lightness stop, widen the actionBackground chroma band, or retune the other family.";
|
|
137
224
|
}
|
|
138
225
|
|
|
139
226
|
// ---------------------------------------------------------------------------
|
|
@@ -270,15 +357,16 @@ export async function proposePassingValues({ lightTheme, darkTheme, warnings, li
|
|
|
270
357
|
for (const key of proposal.clearedKeys) clearedByProposals.add(key);
|
|
271
358
|
}
|
|
272
359
|
const accepted = { light: {}, dark: {} };
|
|
273
|
-
const proposedWarnings =
|
|
360
|
+
const proposedWarnings = [];
|
|
361
|
+
for (const warning of warnings) {
|
|
274
362
|
let proposal;
|
|
275
363
|
try {
|
|
276
|
-
proposal = proposeStatusIntent(warning, themes, warnings, accepted, engine, budget);
|
|
364
|
+
proposal = await proposeStatusIntent(warning, themes, warnings, accepted, engine, budget);
|
|
277
365
|
} catch {
|
|
278
366
|
proposal = undefined;
|
|
279
367
|
}
|
|
280
|
-
|
|
281
|
-
}
|
|
368
|
+
proposedWarnings.push(proposal === undefined ? warning : `${warning} ${proposal}`);
|
|
369
|
+
}
|
|
282
370
|
return {
|
|
283
371
|
warnings: proposedWarnings,
|
|
284
372
|
lints: lints.map((item) => (proposals.has(item) ? `${item.text} ${proposals.get(item)}` : item.text)),
|
package/src/theme-resolve.js
CHANGED
|
@@ -12,10 +12,11 @@ import {
|
|
|
12
12
|
wcagRatio,
|
|
13
13
|
} from "@taprootio/espalier/shared/theme";
|
|
14
14
|
|
|
15
|
-
import { CHROME_NAVIGATION_UNAVAILABLE_MESSAGE } from "./chrome-input.js";
|
|
15
|
+
import { CHROME_NAVIGATION_UNAVAILABLE_MESSAGE, describeSkippedLinks } from "./chrome-input.js";
|
|
16
16
|
import { CHROME_UNAVAILABLE_MESSAGE, decodeChromePair, floorTo } from "./chrome-output.js";
|
|
17
17
|
import { SiteAuthoringError } from "./errors.js";
|
|
18
18
|
import { loadEspalierShared } from "./espalier-shared.js";
|
|
19
|
+
import { notCountedLine, statusPaintLines, TEXT_USED_IN, withTextUsedIn } from "./status-warning-paints.js";
|
|
19
20
|
import { pinnedTheme } from "./theme-proposals.js";
|
|
20
21
|
import { validateAndEncodeThemePair } from "./theme-validation.js";
|
|
21
22
|
import { formatTokenPaints, getTokenDerivation } from "./token-reach.js";
|
|
@@ -465,8 +466,20 @@ export function formatThemeResolve(result) {
|
|
|
465
466
|
]));
|
|
466
467
|
}
|
|
467
468
|
}
|
|
469
|
+
if (result.statusWarningPaints !== undefined || result.statusWarningPaintsOmitted !== undefined) {
|
|
470
|
+
lines.push("", "Status color warnings");
|
|
471
|
+
const records = withTextUsedIn(result.statusWarningPaints, result[TEXT_USED_IN]);
|
|
472
|
+
for (const warning of new Set((records ?? []).map((record) => record.warning))) {
|
|
473
|
+
lines.push(` ${warning}`, ...statusPaintLines(records, warning).map((line) => ` ${line}`));
|
|
474
|
+
}
|
|
475
|
+
if (result.statusWarningPaintsOmitted !== undefined) {
|
|
476
|
+
lines.push(` ${result.statusWarningPaintsOmitted} more status warning(s) have no paint information; run with --json for the count.`);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
if (result.contextUsageSkipped !== undefined) lines.push("", ...notCountedLine(result.contextUsageSkipped));
|
|
468
480
|
if (result.chromeUnavailable) lines.push("", CHROME_UNAVAILABLE_MESSAGE);
|
|
469
481
|
if (result.chromeNavigationUnavailable) lines.push("", CHROME_NAVIGATION_UNAVAILABLE_MESSAGE);
|
|
482
|
+
if (result.skippedNavigationLinks !== undefined) lines.push("", describeSkippedLinks(result.skippedNavigationLinks));
|
|
470
483
|
const { belowAa, pairs } = result.contrast;
|
|
471
484
|
const measured = result.chromeUnavailable ? " measured" : "";
|
|
472
485
|
const codes = [...new Set(result.flags.items.map((flag) => flag.code))];
|