@taprootio/site-authoring 0.38.1 → 0.39.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 +44 -1
- package/examples/riverbend-wellness/settings/site-publishing-preferences.json +29 -4
- package/package.json +2 -2
- package/src/atomic-file.js +2 -1
- package/src/changelog.json +19 -0
- package/src/display-scale.js +17 -0
- package/src/footer-alignment.js +97 -0
- package/src/footer-brand-inputs.js +26 -0
- package/src/footer-branding.js +38 -0
- package/src/footer-contract.js +118 -4
- package/src/footer-draft-hash.js +19 -1
- package/src/footer-fit-widths.js +10 -0
- package/src/footer-fit.js +328 -0
- package/src/footer-font-metrics.js +8345 -0
- package/src/header-presentation.js +4 -15
- package/src/presentation-reference.js +68 -3
- package/src/reference-help.js +1 -1
- package/src/site-check-findings.js +42 -10
- package/src/site-check-rules.json +3 -2
- package/src/verbs/footer-push.js +11 -0
- package/src/verbs/validate.js +17 -11
package/README.md
CHANGED
|
@@ -129,7 +129,7 @@ easy to confuse:
|
|
|
129
129
|
| --- | --- | --- |
|
|
130
130
|
| Brand & style > Page style > Background image | `lightTheme` / `darkTheme` `pageBackgroundImage` (with `pageBackgroundImageOpacity`) | One layer across the page box behind the content; the opaque header and footer cover it, so it shows behind the main content. |
|
|
131
131
|
| Brand & style > Page canvas > Canvas image | `lightCanvasImageId` / `darkCanvasImageId` in `taproot-styles.json` (with the two `...CanvasImageOpacity` fields) | Only the empty side margins of a page. Not on a standard site today, whose margins are 0 px wide. |
|
|
132
|
-
| Brand & style > Brand > Logo | `lightLogoId` / `darkLogoId` | The header brand
|
|
132
|
+
| Brand & style > Brand > Logo | `lightLogoId` / `darkLogoId` | The header brand and the enabled footer's inherited logo. Each footer scheme may override it with `logoId`. |
|
|
133
133
|
| Brand & style > Brand > Favicon | `brand.json` `faviconId` | The icon set in every page's head and `/favicon.ico`. |
|
|
134
134
|
|
|
135
135
|
Both background layers tile at the image's natural pixel size from the top-left;
|
|
@@ -147,6 +147,49 @@ Warnings never refuse: `linkWarnings` names a link whose address is only
|
|
|
147
147
|
`http(s)://` plus its own text (`content.link_autolinked`, left by older editor
|
|
148
148
|
autolinking), and `pages push` reports the same for the pages it sends.
|
|
149
149
|
|
|
150
|
+
Footer regions have individual widths: `brandSpan` is 1–3, a link column's
|
|
151
|
+
`span` and `asideSpan` are 1–2, and `brandSize` is `standard` or `large`.
|
|
152
|
+
Omitted spans are 1; omitted or empty size is `standard`. `brandSize` changes
|
|
153
|
+
only brand text. `logoScale` independently sets logo size as a string from
|
|
154
|
+
`"1.0"` through `"5.0"` in 0.1 steps. Empty and `"1"` normalize to `"1.0"`;
|
|
155
|
+
whitespace, exponents, numeric JSON values and extra decimal places are refused.
|
|
156
|
+
Old absent or null scales migrate to `"1.5"` for Large text and `"1.0"`
|
|
157
|
+
otherwise; pull and footer push write the explicit value, so later text-size
|
|
158
|
+
edits do not change the logo. Each scheme's `logoId` accepts a site-owned PNG
|
|
159
|
+
or WebP; empty inherits that scheme's site logo independently. `logoUrl` is
|
|
160
|
+
read-only metadata and stays out of workspace requests. There is no total
|
|
161
|
+
track limit. Set `logoBox` to `natural` to fit constrained artwork dimensions;
|
|
162
|
+
`fixed` keeps the scaled image height, including spare space. Missing, null or
|
|
163
|
+
empty means `fixed`. Positioning the brand at Top moves spare space below the
|
|
164
|
+
artwork; natural mode removes the unused envelope without cropping alpha padding.
|
|
165
|
+
|
|
166
|
+
`alignment` sets whole-footer defaults. `brandAlignment`, `asideAlignment` and
|
|
167
|
+
each link column's `alignment` override individual regions. Each is a sparse
|
|
168
|
+
object with optional `wide`, `wrapped` (Brand row) and `stacked` layouts, whose
|
|
169
|
+
`horizontal` and `vertical` choices are `start`, `center` or `end`. Logical
|
|
170
|
+
start/end follow writing direction. `textAlign` also accepts `auto` and `justify`.
|
|
171
|
+
`bottomAlignment` uses the same layouts with only `horizontal` and `textAlign`.
|
|
172
|
+
For each axis, the active layout tries the region then whole-footer choice,
|
|
173
|
+
then repeats toward wider layouts. Empty or omitted axes inherit; null or empty
|
|
174
|
+
profiles disappear on pull. Explicit `start` stays authored intent. Text `auto`
|
|
175
|
+
follows current horizontal placement and resets inherited justification.
|
|
176
|
+
Justification affects prose with a normal last line; headings, brand text,
|
|
177
|
+
menus and CTA labels follow horizontal placement. Save only authored choices,
|
|
178
|
+
for example `"alignment": { "stacked": { "horizontal": "center" } }`.
|
|
179
|
+
|
|
180
|
+
`validate` and `footer push` estimate `footer.word_breaks` at five widths:
|
|
181
|
+
Desktop, Small desktop, Tablet, Phone and Small phone (320px). They show at most
|
|
182
|
+
12 footer warnings, with the true count and any remainder. Generated default-font
|
|
183
|
+
metrics, type scale and gaps are assumed; custom fonts or scale may differ.
|
|
184
|
+
Supported whitespace, hyphen and zero-width breaks are estimated, with bounded
|
|
185
|
+
contextual shaping; fragments containing Han, Kana or Thai are skipped.
|
|
186
|
+
Unknown logo proportions
|
|
187
|
+
use the 4:1 maximum, so a narrow logo can produce extra brand warnings.
|
|
188
|
+
Warnings allow the push. Managed Docs workspaces get the same check; deployment
|
|
189
|
+
checks cover standard and profile sites. Footer overrides count as logos even without
|
|
190
|
+
a site logo. After upgrading to this v7 footer hash
|
|
191
|
+
contract, pull again before pushing.
|
|
192
|
+
|
|
150
193
|
`validate` also runs the site checks that need nothing but the workspace, from
|
|
151
194
|
the same rule catalogue the editor and the site-health page read. `findings`
|
|
152
195
|
lists each one as a rule id (`link.page_missing`, a link to a page the workspace
|
|
@@ -37,7 +37,8 @@
|
|
|
37
37
|
"backgroundPresentation": "FOOTER_BACKGROUND_PRESENTATION_COVER",
|
|
38
38
|
"backgroundFade": "FOOTER_FADE_MODE_NONE",
|
|
39
39
|
"backgroundRepeatHeightPx": 160,
|
|
40
|
-
"additionalTopPaddingRem": 1
|
|
40
|
+
"additionalTopPaddingRem": 1,
|
|
41
|
+
"logoId": "a0000000-0000-4000-8000-0000000000a0"
|
|
41
42
|
},
|
|
42
43
|
"dark": {
|
|
43
44
|
"backgroundColor": "--esp-color-layer-1",
|
|
@@ -50,7 +51,8 @@
|
|
|
50
51
|
"backgroundPresentation": "FOOTER_BACKGROUND_PRESENTATION_COVER",
|
|
51
52
|
"backgroundFade": "FOOTER_FADE_MODE_NONE",
|
|
52
53
|
"backgroundRepeatHeightPx": 160,
|
|
53
|
-
"additionalTopPaddingRem": 1
|
|
54
|
+
"additionalTopPaddingRem": 1,
|
|
55
|
+
"logoId": ""
|
|
54
56
|
},
|
|
55
57
|
"linkColumns": [
|
|
56
58
|
{
|
|
@@ -72,7 +74,11 @@
|
|
|
72
74
|
}
|
|
73
75
|
]
|
|
74
76
|
}
|
|
75
|
-
]
|
|
77
|
+
],
|
|
78
|
+
"span": 1,
|
|
79
|
+
"alignment": {
|
|
80
|
+
"stacked": { "horizontal": "start", "textAlign": "start" }
|
|
81
|
+
}
|
|
76
82
|
}
|
|
77
83
|
],
|
|
78
84
|
"asideHeadingContent": {
|
|
@@ -109,7 +115,26 @@
|
|
|
109
115
|
}
|
|
110
116
|
]
|
|
111
117
|
},
|
|
112
|
-
"featureImage": null
|
|
118
|
+
"featureImage": null,
|
|
119
|
+
"brandSpan": 1,
|
|
120
|
+
"asideSpan": 1,
|
|
121
|
+
"brandSize": "standard",
|
|
122
|
+
"logoScale": "1.0",
|
|
123
|
+
"logoBox": "natural",
|
|
124
|
+
"alignment": {
|
|
125
|
+
"stacked": { "horizontal": "center" }
|
|
126
|
+
},
|
|
127
|
+
"brandAlignment": {
|
|
128
|
+
"wide": { "vertical": "start" },
|
|
129
|
+
"wrapped": { "horizontal": "center" }
|
|
130
|
+
},
|
|
131
|
+
"asideAlignment": {
|
|
132
|
+
"wide": { "textAlign": "justify" },
|
|
133
|
+
"stacked": { "textAlign": "auto" }
|
|
134
|
+
},
|
|
135
|
+
"bottomAlignment": {
|
|
136
|
+
"stacked": { "textAlign": "auto" }
|
|
137
|
+
}
|
|
113
138
|
}
|
|
114
139
|
}
|
|
115
140
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taprootio/site-authoring",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.39.0",
|
|
4
4
|
"description": "Taproot site authoring CLI: sign in once in the browser, then pull, validate, push, preview, approve, and deploy a site from the terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "ISC",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"README.md"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@taprootio/espalier": "
|
|
31
|
+
"@taprootio/espalier": "7.1.0",
|
|
32
32
|
"mediabunny": "1.61.1"
|
|
33
33
|
},
|
|
34
34
|
"scripts": {
|
package/src/atomic-file.js
CHANGED
|
@@ -90,7 +90,8 @@ export async function atomicWriteFile(filePath, contents, {
|
|
|
90
90
|
throw failures.notRegular();
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
// A valid destination filename can already use the filesystem's full limit.
|
|
94
|
+
const temporaryPath = path.join(directory, `.taproot-site-${randomUUID()}.tmp`);
|
|
94
95
|
let handle;
|
|
95
96
|
let renamed = false;
|
|
96
97
|
try {
|
package/src/changelog.json
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"entries": [
|
|
3
|
+
{
|
|
4
|
+
"version": "0.39.0",
|
|
5
|
+
"note": "Set footer widths, responsive alignment and artwork space, choose independent logos and scale, and check whether words fit before saving.",
|
|
6
|
+
"behavior": [
|
|
7
|
+
"The bundled Espalier is 7.1.0, with independent footer logos, logo-only scaling and responsive footer alignment.",
|
|
8
|
+
"Footer settings accept brandSpan (1–3), asideSpan (1–2), brandSize (standard or large) for text, and span (1–2) on each link column. Omitted spans are 1 and an omitted or empty brandSize is standard. There is no total track limit.",
|
|
9
|
+
"logoScale independently sizes the footer logo from \"1.0\" through \"5.0\" in 0.1 steps. It must be a string; empty and \"1\" normalize to \"1.0\". Old absent or null values migrate to \"1.5\" for large text, otherwise \"1.0\"; pull and footer push materialize the scale, so later text-size edits keep the logo size.",
|
|
10
|
+
"Each footer scheme accepts a site-owned PNG/WebP logoId. Empty independently inherits that scheme's site logo. logoUrl is read-only metadata, excluded from requests and concurrency hashing. Footer push owns logo ids and scale; theme push still owns only the ten footer colors and preserves all other footer content.",
|
|
11
|
+
"Sparse alignment, brandAlignment, asideAlignment and column alignment profiles accept wide, wrapped (Brand row) and stacked horizontal/vertical/textAlign choices. bottomAlignment omits vertical. Empty axes inherit; start/center/end retain intent. Text also accepts auto to follow horizontal placement and justify for prose only. The active layout tries the region then footer default before searching wider layouts; invalid, padded, non-string and wrong-axis choices are refused.",
|
|
12
|
+
"logoBox natural fits constrained artwork dimensions and its reservation without cropping transparent padding. Fixed preserves scaled height, including spare image-box space; omitted, null or empty means fixed. Footer push owns every profile and logoBox. Theme push preserves them, explicit auto and all logo content, and refuses unsaved local content under the unchanged footer-content-v2 baseline.",
|
|
13
|
+
"validate and footer push report footer.word_breaks warnings at five widths, including Small phone (320px) and settings-only managed Docs workspaces. At most 12 footer findings are shown, with their true count; warnings never block a push. Generated default-font metrics and bounded break opportunities guide the estimate; custom fonts or scale may differ, and Han, Kana or Thai fragments are skipped. Logo proportions are unknown to the CLI, so a narrow logo can lead to extra brand warnings. Deployment checks cover standard and profile sites.",
|
|
14
|
+
"The footer concurrency hash is now footer-draft-v7, including logoBox and sparse profiles without expanding inherited choices. Upgrade to the latest CLI and pull again before pushing an existing workspace.",
|
|
15
|
+
"Pull can write a page whose source filename reaches the filesystem's filename limit; atomic temporary names no longer grow with the page slug.",
|
|
16
|
+
"The help reference version is 60."
|
|
17
|
+
],
|
|
18
|
+
"help": [
|
|
19
|
+
"footer"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
3
22
|
{
|
|
4
23
|
"version": "0.38.1",
|
|
5
24
|
"note": "Uses Espalier 6.15.1, whose header controls stay in place during pointer activation.",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Generated from shared/display-scale.ts by scripts/sync-field-validation.mjs. Do not edit.
|
|
2
|
+
export const DISPLAY_SCALE_LIMITS = Object.freeze({ minimum: 1, maximum: 5, step: 0.1 });
|
|
3
|
+
const NORMAL_SCALE = Object.freeze({ tenths: 10, scale: 1, canonical: "1.0" });
|
|
4
|
+
const DISPLAY_SCALE = /^(?:[1-4](?:\.[0-9])?|5(?:\.0)?)$/u;
|
|
5
|
+
/** Parse authored tenths without floating-point remainder or whitespace normalization. */
|
|
6
|
+
export function parseDisplayScale(value) {
|
|
7
|
+
if (value === undefined || value === "")
|
|
8
|
+
return NORMAL_SCALE;
|
|
9
|
+
if (typeof value !== "string" || DISPLAY_SCALE.exec(value)?.[0] !== value)
|
|
10
|
+
return null;
|
|
11
|
+
const whole = value.charCodeAt(0) - 48;
|
|
12
|
+
const fraction = value.length === 3 ? value.charCodeAt(2) - 48 : 0;
|
|
13
|
+
const tenths = whole * 10 + fraction;
|
|
14
|
+
return tenths === 10
|
|
15
|
+
? NORMAL_SCALE
|
|
16
|
+
: Object.freeze({ tenths, scale: tenths / 10, canonical: `${whole}.${fraction}` });
|
|
17
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Generated from shared/footer-alignment.ts by scripts/sync-field-validation.mjs. Do not edit.
|
|
2
|
+
export const FOOTER_ALIGNMENT_LAYOUTS = Object.freeze(["wide", "wrapped", "stacked"]);
|
|
3
|
+
export const FOOTER_POSITION_VALUES = Object.freeze(["start", "center", "end"]);
|
|
4
|
+
export const FOOTER_TEXT_ALIGN_VALUES = Object.freeze(["auto", "start", "center", "end", "justify"]);
|
|
5
|
+
const ALIGNMENT_AXES = Object.freeze([
|
|
6
|
+
{ key: "horizontal", attribute: "inline-align", values: FOOTER_POSITION_VALUES },
|
|
7
|
+
{ key: "vertical", attribute: "block-align", values: FOOTER_POSITION_VALUES },
|
|
8
|
+
{ key: "textAlign", attribute: "text-align", values: FOOTER_TEXT_ALIGN_VALUES },
|
|
9
|
+
]);
|
|
10
|
+
const PROFILE_PREFIXES = Object.freeze([
|
|
11
|
+
{ key: "alignment", prefix: "", inlineOnly: false },
|
|
12
|
+
{ key: "brandAlignment", prefix: "brand-", inlineOnly: false },
|
|
13
|
+
{ key: "asideAlignment", prefix: "aside-", inlineOnly: false },
|
|
14
|
+
{ key: "bottomAlignment", prefix: "bottom-", inlineOnly: true },
|
|
15
|
+
]);
|
|
16
|
+
function record(value) {
|
|
17
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
18
|
+
? value
|
|
19
|
+
: {};
|
|
20
|
+
}
|
|
21
|
+
function axes(inlineOnly) {
|
|
22
|
+
return ALIGNMENT_AXES.filter(axis => !inlineOnly || axis.key !== "vertical");
|
|
23
|
+
}
|
|
24
|
+
function attributeName(prefix, attribute, layout) {
|
|
25
|
+
return `${prefix}${attribute}${layout === "wide" ? "" : `-${layout}`}`;
|
|
26
|
+
}
|
|
27
|
+
/** The mapper and adapters share ownership of exactly these input attributes. */
|
|
28
|
+
export const FOOTER_ALIGNMENT_ATTRIBUTE_NAMES = Object.freeze([
|
|
29
|
+
...PROFILE_PREFIXES.flatMap(profile => FOOTER_ALIGNMENT_LAYOUTS.flatMap(layout => axes(profile.inlineOnly).map(axis => attributeName(profile.prefix, axis.attribute, layout)))),
|
|
30
|
+
"brand-logo-sizing",
|
|
31
|
+
]);
|
|
32
|
+
function normalizeProfile(value, inlineOnly) {
|
|
33
|
+
const input = record(value);
|
|
34
|
+
const profile = {};
|
|
35
|
+
for (const layout of FOOTER_ALIGNMENT_LAYOUTS) {
|
|
36
|
+
const inputAlignment = record(input[layout]);
|
|
37
|
+
const alignment = {};
|
|
38
|
+
for (const axis of axes(inlineOnly)) {
|
|
39
|
+
const choice = inputAlignment[axis.key];
|
|
40
|
+
if (typeof choice === "string" && axis.values.includes(choice)) {
|
|
41
|
+
Object.assign(alignment, { [axis.key]: choice });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (Object.keys(alignment).length > 0)
|
|
45
|
+
profile[layout] = alignment;
|
|
46
|
+
}
|
|
47
|
+
return Object.keys(profile).length > 0 ? profile : undefined;
|
|
48
|
+
}
|
|
49
|
+
/** Invalid stored choices disappear; saved intent is never expanded through inheritance. */
|
|
50
|
+
export function normalizeFooterResponsiveAlignment(value) {
|
|
51
|
+
return normalizeProfile(value, false);
|
|
52
|
+
}
|
|
53
|
+
export function normalizeFooterResponsiveInlineAlignment(value) {
|
|
54
|
+
return normalizeProfile(value, true);
|
|
55
|
+
}
|
|
56
|
+
export function normalizeFooterLogoBox(value) {
|
|
57
|
+
return value === "natural" ? "natural" : "fixed";
|
|
58
|
+
}
|
|
59
|
+
/** The draft hash encodes empty axes as empty strings, in layout then axis order. */
|
|
60
|
+
export function footerAlignmentProfileValues(value, inlineOnly = false) {
|
|
61
|
+
const profile = normalizeProfile(value, inlineOnly);
|
|
62
|
+
return FOOTER_ALIGNMENT_LAYOUTS.flatMap(layout => axes(inlineOnly).map(axis => profile?.[layout]?.[axis.key] ?? ""));
|
|
63
|
+
}
|
|
64
|
+
function profileAttributes(value, prefix, inlineOnly) {
|
|
65
|
+
const profile = normalizeProfile(value, inlineOnly);
|
|
66
|
+
const attributes = {};
|
|
67
|
+
for (const layout of FOOTER_ALIGNMENT_LAYOUTS) {
|
|
68
|
+
for (const axis of axes(inlineOnly)) {
|
|
69
|
+
const choice = profile?.[layout]?.[axis.key];
|
|
70
|
+
if (choice !== undefined)
|
|
71
|
+
attributes[attributeName(prefix, axis.attribute, layout)] = choice;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return attributes;
|
|
75
|
+
}
|
|
76
|
+
export function footerAlignmentAttributes(value) {
|
|
77
|
+
const settings = record(value);
|
|
78
|
+
const attributes = {};
|
|
79
|
+
for (const profile of PROFILE_PREFIXES) {
|
|
80
|
+
Object.assign(attributes, profileAttributes(settings[profile.key], profile.prefix, profile.inlineOnly));
|
|
81
|
+
}
|
|
82
|
+
if (normalizeFooterLogoBox(settings.logoBox) === "natural")
|
|
83
|
+
attributes["brand-logo-sizing"] = "natural";
|
|
84
|
+
return attributes;
|
|
85
|
+
}
|
|
86
|
+
export function footerColumnAlignmentAttributes(value) {
|
|
87
|
+
return profileAttributes(record(value).alignment, "", false);
|
|
88
|
+
}
|
|
89
|
+
/** Caller-content alignment CSS is needed only when a profile carries authored intent. */
|
|
90
|
+
export function hasFooterAlignment(value) {
|
|
91
|
+
const settings = record(value);
|
|
92
|
+
if (PROFILE_PREFIXES.some(profile => normalizeProfile(settings[profile.key], profile.inlineOnly) !== undefined)) {
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
return Array.isArray(settings.linkColumns)
|
|
96
|
+
&& settings.linkColumns.some(column => normalizeFooterResponsiveAlignment(record(column).alignment) !== undefined);
|
|
97
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { APPEARANCE_FILES } from "./appearance-contract.js";
|
|
2
|
+
import { isCanonicalUuid } from "./errors.js";
|
|
3
|
+
import { SETTINGS_TYPE_SITE_HEADER, SETTINGS_TYPE_TAPROOT_STYLES } from "./settings-catalog.js";
|
|
4
|
+
import { readWorkspaceJson, WORKSPACE_LIMITS } from "./workspace.js";
|
|
5
|
+
|
|
6
|
+
async function optionalSettings(workspaceDir, settingsType) {
|
|
7
|
+
try {
|
|
8
|
+
const document = await readWorkspaceJson(workspaceDir, APPEARANCE_FILES[settingsType], WORKSPACE_LIMITS.settingsBytes);
|
|
9
|
+
return document?.settings;
|
|
10
|
+
} catch {
|
|
11
|
+
return undefined;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Optional files are independent: losing the header must not discard a known logo, or the reverse. */
|
|
16
|
+
export async function readFooterBrandInputs(workspaceDir, footerSettings) {
|
|
17
|
+
const [header, styles] = await Promise.all([
|
|
18
|
+
optionalSettings(workspaceDir, SETTINGS_TYPE_SITE_HEADER),
|
|
19
|
+
optionalSettings(workspaceDir, SETTINGS_TYPE_TAPROOT_STYLES),
|
|
20
|
+
]);
|
|
21
|
+
return {
|
|
22
|
+
brandText: typeof header?.brandText === "string" ? header.brandText : "",
|
|
23
|
+
hasLogo: [styles?.lightLogoId, styles?.darkLogoId, footerSettings?.light?.logoId, footerSettings?.dark?.logoId]
|
|
24
|
+
.some(isCanonicalUuid),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Generated from shared/footer-branding.ts by scripts/sync-field-validation.mjs. Do not edit.
|
|
2
|
+
import { DISPLAY_SCALE_LIMITS, parseDisplayScale } from "./display-scale.js";
|
|
3
|
+
import { resolveHeaderLogoPairs } from "./header-presentation.js";
|
|
4
|
+
export const FOOTER_LOGO_SCALE_LIMITS = DISPLAY_SCALE_LIMITS;
|
|
5
|
+
export const FOOTER_LOGO_BOX = Object.freeze({ heightRem: 3, maxWidthRem: 12 });
|
|
6
|
+
/** TR01365's unpublished Large setting scaled both logo and text before separation. */
|
|
7
|
+
export function parseFooterLogoScale(value, brandSize) {
|
|
8
|
+
return parseDisplayScale(value === undefined || value === null ? (brandSize === "large" ? "1.5" : "1.0") : value);
|
|
9
|
+
}
|
|
10
|
+
/** Invalid stored data renders normally; writes use the strict parser. */
|
|
11
|
+
export function resolveFooterLogoScale(value, brandSize) {
|
|
12
|
+
return parseFooterLogoScale(value, brandSize) ?? parseDisplayScale("");
|
|
13
|
+
}
|
|
14
|
+
export function footerBrandSizeStyles(size, logoScale) {
|
|
15
|
+
const scale = resolveFooterLogoScale(logoScale, size).scale;
|
|
16
|
+
const declarations = {};
|
|
17
|
+
if (scale !== 1) {
|
|
18
|
+
const rem = (normal) => `${Number((normal * scale).toFixed(1))}rem`;
|
|
19
|
+
declarations["--esp-footer-brand-logo-size"] = rem(FOOTER_LOGO_BOX.heightRem);
|
|
20
|
+
declarations["--esp-footer-brand-logo-max-width"] = rem(FOOTER_LOGO_BOX.maxWidthRem);
|
|
21
|
+
declarations["--esp-footer-brand-logo-size-compact"] = rem(FOOTER_LOGO_BOX.heightRem);
|
|
22
|
+
declarations["--esp-footer-brand-logo-max-width-compact"] = rem(FOOTER_LOGO_BOX.maxWidthRem);
|
|
23
|
+
}
|
|
24
|
+
if (size === "large") {
|
|
25
|
+
declarations["--esp-footer-brand-text-size"] = "var(--esp-type-big)";
|
|
26
|
+
declarations["--esp-footer-brand-text-size-compact"] = "var(--esp-type-large)";
|
|
27
|
+
}
|
|
28
|
+
return Object.entries(declarations).map(([key, value]) => `${key}: ${value};`).join(" ");
|
|
29
|
+
}
|
|
30
|
+
/** An unset footer scheme inherits its site scheme, never the other footer override. */
|
|
31
|
+
export function resolveFooterLogoPairs(input) {
|
|
32
|
+
const site = resolveHeaderLogoPairs(input);
|
|
33
|
+
const override = (id, url = "", aspectRatio = "", inherited) => id ? { url, aspectRatio: url ? aspectRatio : "" } : inherited;
|
|
34
|
+
return {
|
|
35
|
+
light: override(input.lightFooterLogoId, input.lightFooterLogoUrl, input.lightFooterLogoAspectRatio, site.light),
|
|
36
|
+
dark: override(input.darkFooterLogoId, input.darkFooterLogoUrl, input.darkFooterLogoAspectRatio, site.dark),
|
|
37
|
+
};
|
|
38
|
+
}
|
package/src/footer-contract.js
CHANGED
|
@@ -4,12 +4,24 @@ import {
|
|
|
4
4
|
isContactOrWebUrl,
|
|
5
5
|
} from "./contact-url.js";
|
|
6
6
|
import { hasControlCharacter, isCanonicalUuid, SiteAuthoringError } from "./errors.js";
|
|
7
|
+
import { parseFooterLogoScale, resolveFooterLogoScale } from "./footer-branding.js";
|
|
8
|
+
import {
|
|
9
|
+
FOOTER_ALIGNMENT_LAYOUTS,
|
|
10
|
+
FOOTER_POSITION_VALUES,
|
|
11
|
+
FOOTER_TEXT_ALIGN_VALUES,
|
|
12
|
+
normalizeFooterLogoBox,
|
|
13
|
+
normalizeFooterResponsiveAlignment,
|
|
14
|
+
normalizeFooterResponsiveInlineAlignment,
|
|
15
|
+
} from "./footer-alignment.js";
|
|
7
16
|
import { isSocialLinkUrl, SOCIAL_LINK_URL_MAX_LENGTH, trimSocialLinkInput } from "./social-link-url.js";
|
|
8
17
|
import socialPlatforms from "./social-platforms.json" with { type: "json" };
|
|
9
18
|
import { FOOTER_COLOR_TOKENS, requireAppearanceColor } from "./theme-validation.js";
|
|
10
19
|
|
|
11
20
|
export const FOOTER_LIMITS = Object.freeze({
|
|
12
21
|
linkColumns: 6,
|
|
22
|
+
brandSpanMax: 3,
|
|
23
|
+
asideSpanMax: 2,
|
|
24
|
+
columnSpanMax: 2,
|
|
13
25
|
linkGroups: 12,
|
|
14
26
|
groupsPerColumn: 6,
|
|
15
27
|
linksPerGroup: 12,
|
|
@@ -42,7 +54,7 @@ export const FOOTER_FADE_MODES = Object.freeze([
|
|
|
42
54
|
]);
|
|
43
55
|
|
|
44
56
|
// One ordered inventory drives the local closed-object checks, the request
|
|
45
|
-
// mapper (validation returns this exact shape), and reference help. The
|
|
57
|
+
// mapper (validation returns this exact shape), and reference help. The
|
|
46
58
|
// response-only delivery fields remain in the inventory as read-only so a
|
|
47
59
|
// future proto edit cannot quietly become authorable.
|
|
48
60
|
export const FOOTER_FIELD_INVENTORY = Object.freeze({
|
|
@@ -60,8 +72,21 @@ export const FOOTER_FIELD_INVENTORY = Object.freeze({
|
|
|
60
72
|
"featureImage",
|
|
61
73
|
"showBrandText",
|
|
62
74
|
"socialLinks",
|
|
75
|
+
"brandSpan",
|
|
76
|
+
"asideSpan",
|
|
77
|
+
"brandSize",
|
|
78
|
+
"logoScale",
|
|
79
|
+
"alignment",
|
|
80
|
+
"brandAlignment",
|
|
81
|
+
"asideAlignment",
|
|
82
|
+
"bottomAlignment",
|
|
83
|
+
"logoBox",
|
|
63
84
|
]),
|
|
64
|
-
FooterLinkColumn: Object.freeze(["id", "groups"]),
|
|
85
|
+
FooterLinkColumn: Object.freeze(["id", "groups", "span", "alignment"]),
|
|
86
|
+
FooterAlignment: Object.freeze(["horizontal", "vertical", "textAlign"]),
|
|
87
|
+
FooterResponsiveAlignment: FOOTER_ALIGNMENT_LAYOUTS,
|
|
88
|
+
FooterInlineAlignment: Object.freeze(["horizontal", "textAlign"]),
|
|
89
|
+
FooterResponsiveInlineAlignment: FOOTER_ALIGNMENT_LAYOUTS,
|
|
65
90
|
FooterLinkGroup: Object.freeze(["id", "heading", "links"]),
|
|
66
91
|
FooterLink: Object.freeze(["id", "label", "pageResourceId", "externalUrl"]),
|
|
67
92
|
FooterSocialLink: Object.freeze(["id", "platform", "url", "label"]),
|
|
@@ -82,6 +107,8 @@ export const FOOTER_FIELD_INVENTORY = Object.freeze({
|
|
|
82
107
|
"backgroundFade",
|
|
83
108
|
"backgroundRepeatHeightPx",
|
|
84
109
|
"additionalTopPaddingRem",
|
|
110
|
+
"logoId",
|
|
111
|
+
"logoUrl",
|
|
85
112
|
]),
|
|
86
113
|
FooterFeatureImageSettings: Object.freeze(["imageId", "imageUrl", "alt", "responsiveUrls"]),
|
|
87
114
|
FooterFeatureResponsiveImageUrl: Object.freeze(["minWidth", "url"]),
|
|
@@ -95,6 +122,8 @@ export const SOCIAL_LINK_URL_REQUIREMENT =
|
|
|
95
122
|
+ "to a domain name of unaccented letters, digits and hyphens, like https://www.instagram.com/yourname";
|
|
96
123
|
|
|
97
124
|
export const FOOTER_READ_ONLY_FIELDS = Object.freeze([
|
|
125
|
+
"light.logoUrl",
|
|
126
|
+
"dark.logoUrl",
|
|
98
127
|
"light.backgroundImageUrl",
|
|
99
128
|
"dark.backgroundImageUrl",
|
|
100
129
|
"featureImage.imageUrl",
|
|
@@ -147,6 +176,14 @@ function number(value, defaultValue, path, minimum, maximum) {
|
|
|
147
176
|
return value;
|
|
148
177
|
}
|
|
149
178
|
|
|
179
|
+
function span(value, maximum, path) {
|
|
180
|
+
if (value === undefined) return 1;
|
|
181
|
+
if (!Number.isInteger(value) || value < 1 || value > maximum) {
|
|
182
|
+
fail("footer.field_invalid", `${path} must be a whole number from 1 through ${maximum}.`, path);
|
|
183
|
+
}
|
|
184
|
+
return value;
|
|
185
|
+
}
|
|
186
|
+
|
|
150
187
|
function choice(value, defaultValue, choices, path) {
|
|
151
188
|
if (value === undefined) return defaultValue;
|
|
152
189
|
if (typeof value !== "string" || !choices.includes(value)) {
|
|
@@ -155,6 +192,30 @@ function choice(value, defaultValue, choices, path) {
|
|
|
155
192
|
return value;
|
|
156
193
|
}
|
|
157
194
|
|
|
195
|
+
function alignmentProfile(value, path, tolerateStoredValues, inlineOnly = false) {
|
|
196
|
+
if (!tolerateStoredValues && value !== undefined && value !== null) {
|
|
197
|
+
value = object(value, path);
|
|
198
|
+
closed(value, inlineOnly ? "FooterResponsiveInlineAlignment" : "FooterResponsiveAlignment", path);
|
|
199
|
+
for (const layout of FOOTER_ALIGNMENT_LAYOUTS) {
|
|
200
|
+
const alignmentPath = `${path}.${layout}`;
|
|
201
|
+
const alignment = value[layout];
|
|
202
|
+
if (alignment === undefined || alignment === null) continue;
|
|
203
|
+
object(alignment, alignmentPath);
|
|
204
|
+
const type = inlineOnly ? "FooterInlineAlignment" : "FooterAlignment";
|
|
205
|
+
closed(alignment, type, alignmentPath);
|
|
206
|
+
for (const axis of FOOTER_FIELD_INVENTORY[type]) {
|
|
207
|
+
choice(alignment[axis], "", ["", ...(axis === "textAlign" ? FOOTER_TEXT_ALIGN_VALUES : FOOTER_POSITION_VALUES)], `${alignmentPath}.${axis}`);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return inlineOnly ? normalizeFooterResponsiveInlineAlignment(value) : normalizeFooterResponsiveAlignment(value);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
function authoredAlignment(owner, key, path, tolerateStoredValues, inlineOnly = false) {
|
|
215
|
+
const alignment = alignmentProfile(owner[key], `${path}.${key}`, tolerateStoredValues, inlineOnly);
|
|
216
|
+
return alignment === undefined ? {} : { [key]: alignment };
|
|
217
|
+
}
|
|
218
|
+
|
|
158
219
|
function isDotNetWhiteSpace(character) {
|
|
159
220
|
const codePoint = character.codePointAt(0);
|
|
160
221
|
return (codePoint >= 0x0009 && codePoint <= 0x000d)
|
|
@@ -395,6 +456,7 @@ function scheme(value, path, knownImageIds) {
|
|
|
395
456
|
value = value === undefined || value === null ? {} : object(value, path);
|
|
396
457
|
closed(value, "FooterSchemeSettings", path);
|
|
397
458
|
rejectReadOnly(value, "backgroundImageUrl", path);
|
|
459
|
+
rejectReadOnly(value, "logoUrl", path);
|
|
398
460
|
const repeatHeight = value.backgroundRepeatHeightPx ?? FOOTER_LIMITS.backgroundRepeatHeightDefault;
|
|
399
461
|
if (
|
|
400
462
|
!Number.isInteger(repeatHeight)
|
|
@@ -426,6 +488,7 @@ function scheme(value, path, knownImageIds) {
|
|
|
426
488
|
FOOTER_COLOR_TOKENS.linkHoverColor,
|
|
427
489
|
`${path}.linkHoverColor`,
|
|
428
490
|
),
|
|
491
|
+
logoId: imageId(value.logoId, `${path}.logoId`, knownImageIds),
|
|
429
492
|
backgroundImageId: imageId(value.backgroundImageId, `${path}.backgroundImageId`, knownImageIds),
|
|
430
493
|
backgroundImageOpacity: number(value.backgroundImageOpacity, 1, `${path}.backgroundImageOpacity`, 0, 1),
|
|
431
494
|
backgroundPresentation: choice(
|
|
@@ -489,6 +552,7 @@ export function footerDefaults() {
|
|
|
489
552
|
headingColor: "",
|
|
490
553
|
linkColor: "",
|
|
491
554
|
linkHoverColor: "",
|
|
555
|
+
logoId: "",
|
|
492
556
|
backgroundImageId: "",
|
|
493
557
|
backgroundImageOpacity: 1,
|
|
494
558
|
backgroundPresentation: FOOTER_BACKGROUND_PRESENTATIONS[0],
|
|
@@ -499,6 +563,11 @@ export function footerDefaults() {
|
|
|
499
563
|
return {
|
|
500
564
|
enabled: false,
|
|
501
565
|
showBrand: true,
|
|
566
|
+
brandSpan: 1,
|
|
567
|
+
brandSize: "standard",
|
|
568
|
+
logoScale: "1.0",
|
|
569
|
+
logoBox: "fixed",
|
|
570
|
+
asideSpan: 1,
|
|
502
571
|
asideCta: undefined,
|
|
503
572
|
bottomLinks: [],
|
|
504
573
|
light: defaults(),
|
|
@@ -556,6 +625,8 @@ function normalizeFooterDocument(
|
|
|
556
625
|
return {
|
|
557
626
|
id: stableId(column.id, `${columnPath}.id`, seenColumnIds, "column"),
|
|
558
627
|
groups,
|
|
628
|
+
span: span(column.span, FOOTER_LIMITS.columnSpanMax, `${columnPath}.span`),
|
|
629
|
+
...authoredAlignment(column, "alignment", columnPath, tolerateStoredValues),
|
|
559
630
|
};
|
|
560
631
|
});
|
|
561
632
|
if (groupCount > FOOTER_LIMITS.linkGroups) {
|
|
@@ -567,9 +638,27 @@ function normalizeFooterDocument(
|
|
|
567
638
|
}
|
|
568
639
|
|
|
569
640
|
const normalizedFeatureImage = featureImage(value.featureImage, knownImageIds, tolerateStoredValues);
|
|
641
|
+
const brandSize = choice(value.brandSize === "" ? undefined : value.brandSize, "standard", ["standard", "large"], "footerSettings.brandSize");
|
|
642
|
+
const logoScale = tolerateStoredValues
|
|
643
|
+
? resolveFooterLogoScale(value.logoScale, brandSize)
|
|
644
|
+
: parseFooterLogoScale(value.logoScale, brandSize);
|
|
645
|
+
if (logoScale === null) {
|
|
646
|
+
fail("footer.field_invalid", "footerSettings.logoScale must be a string from 1.0 through 5.0 in 0.1 steps.", "footerSettings.logoScale");
|
|
647
|
+
}
|
|
570
648
|
return {
|
|
571
649
|
enabled: boolean(value.enabled, false, "footerSettings.enabled"),
|
|
572
650
|
showBrand: boolean(value.showBrand, true, "footerSettings.showBrand"),
|
|
651
|
+
brandSpan: span(value.brandSpan, FOOTER_LIMITS.brandSpanMax, "footerSettings.brandSpan"),
|
|
652
|
+
brandSize,
|
|
653
|
+
logoScale: logoScale.canonical,
|
|
654
|
+
logoBox: tolerateStoredValues
|
|
655
|
+
? normalizeFooterLogoBox(value.logoBox)
|
|
656
|
+
: choice(value.logoBox === "" || value.logoBox === null ? undefined : value.logoBox, "fixed", ["fixed", "natural"], "footerSettings.logoBox"),
|
|
657
|
+
...authoredAlignment(value, "alignment", "footerSettings", tolerateStoredValues),
|
|
658
|
+
...authoredAlignment(value, "brandAlignment", "footerSettings", tolerateStoredValues),
|
|
659
|
+
...authoredAlignment(value, "asideAlignment", "footerSettings", tolerateStoredValues),
|
|
660
|
+
...authoredAlignment(value, "bottomAlignment", "footerSettings", tolerateStoredValues, true),
|
|
661
|
+
asideSpan: span(value.asideSpan, FOOTER_LIMITS.asideSpanMax, "footerSettings.asideSpan"),
|
|
573
662
|
...(value.asideCta === undefined || value.asideCta === null
|
|
574
663
|
? {}
|
|
575
664
|
: {
|
|
@@ -631,7 +720,10 @@ export function validateFooterDocument(value, options = {}) {
|
|
|
631
720
|
function withoutServerProjections(value) {
|
|
632
721
|
const projected = structuredClone(isPlainObject(value) ? value : {});
|
|
633
722
|
for (const schemeName of ["light", "dark"]) {
|
|
634
|
-
if (isPlainObject(projected[schemeName]))
|
|
723
|
+
if (isPlainObject(projected[schemeName])) {
|
|
724
|
+
delete projected[schemeName].backgroundImageUrl;
|
|
725
|
+
delete projected[schemeName].logoUrl;
|
|
726
|
+
}
|
|
635
727
|
}
|
|
636
728
|
if (isPlainObject(projected.featureImage)) {
|
|
637
729
|
delete projected.featureImage.imageUrl;
|
|
@@ -648,7 +740,13 @@ export function projectFooterSettingsForWorkspace(value) {
|
|
|
648
740
|
export function footerImageIds(value) {
|
|
649
741
|
const ids = new Set();
|
|
650
742
|
for (
|
|
651
|
-
const candidate of [
|
|
743
|
+
const candidate of [
|
|
744
|
+
value?.light?.logoId,
|
|
745
|
+
value?.dark?.logoId,
|
|
746
|
+
value?.light?.backgroundImageId,
|
|
747
|
+
value?.dark?.backgroundImageId,
|
|
748
|
+
value?.featureImage?.imageId,
|
|
749
|
+
]
|
|
652
750
|
) {
|
|
653
751
|
if (isCanonicalUuid(candidate)) ids.add(candidate);
|
|
654
752
|
}
|
|
@@ -658,6 +756,18 @@ export function footerImageIds(value) {
|
|
|
658
756
|
export const FOOTER_EXAMPLE = Object.freeze({
|
|
659
757
|
enabled: true,
|
|
660
758
|
showBrand: true,
|
|
759
|
+
brandSpan: 2,
|
|
760
|
+
brandSize: "large",
|
|
761
|
+
logoScale: "1.5",
|
|
762
|
+
logoBox: "natural",
|
|
763
|
+
alignment: Object.freeze({ stacked: Object.freeze({ horizontal: "center" }) }),
|
|
764
|
+
brandAlignment: Object.freeze({
|
|
765
|
+
wide: Object.freeze({ vertical: "start" }),
|
|
766
|
+
wrapped: Object.freeze({ horizontal: "center" }),
|
|
767
|
+
}),
|
|
768
|
+
asideAlignment: Object.freeze({ wide: Object.freeze({ textAlign: "justify" }) }),
|
|
769
|
+
bottomAlignment: Object.freeze({ stacked: Object.freeze({ textAlign: "auto" }) }),
|
|
770
|
+
asideSpan: 1,
|
|
661
771
|
// The aside CTA is where a local business puts the thing a visitor came for.
|
|
662
772
|
// A phone number is a `tel:` target, emitted verbatim so it stays dialable.
|
|
663
773
|
asideCta: Object.freeze({
|
|
@@ -683,6 +793,7 @@ export const FOOTER_EXAMPLE = Object.freeze({
|
|
|
683
793
|
headingColor: "--esp-color-headings",
|
|
684
794
|
linkColor: "--esp-color-link",
|
|
685
795
|
linkHoverColor: "--esp-color-link-hover",
|
|
796
|
+
logoId: "",
|
|
686
797
|
backgroundImageId: "d461035a-74b6-4528-a4f5-e5a96fb50037",
|
|
687
798
|
backgroundImageOpacity: 0.18,
|
|
688
799
|
backgroundPresentation: "FOOTER_BACKGROUND_PRESENTATION_COVER",
|
|
@@ -696,6 +807,7 @@ export const FOOTER_EXAMPLE = Object.freeze({
|
|
|
696
807
|
headingColor: "--esp-color-headings",
|
|
697
808
|
linkColor: "--esp-color-link",
|
|
698
809
|
linkHoverColor: "--esp-color-link-hover",
|
|
810
|
+
logoId: "",
|
|
699
811
|
backgroundImageId: "",
|
|
700
812
|
backgroundImageOpacity: 1,
|
|
701
813
|
backgroundPresentation: "FOOTER_BACKGROUND_PRESENTATION_TILE",
|
|
@@ -705,6 +817,8 @@ export const FOOTER_EXAMPLE = Object.freeze({
|
|
|
705
817
|
}),
|
|
706
818
|
linkColumns: Object.freeze([Object.freeze({
|
|
707
819
|
id: "84bf7531-dfc8-453e-a78d-a5fa3348d56b",
|
|
820
|
+
span: 1,
|
|
821
|
+
alignment: Object.freeze({ stacked: Object.freeze({ horizontal: "start", textAlign: "start" }) }),
|
|
708
822
|
groups: Object.freeze([Object.freeze({
|
|
709
823
|
id: "64789fae-8862-43ab-85ca-f3b41819bddb",
|
|
710
824
|
heading: "Explore",
|