@taprootio/site-authoring 0.38.1 → 0.40.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.
Files changed (39) hide show
  1. package/README.md +73 -17
  2. package/examples/riverbend-wellness/manifest.fixture.json +1 -1
  3. package/examples/riverbend-wellness/settings/site-publishing-preferences.json +29 -14
  4. package/package.json +2 -2
  5. package/src/api.js +4 -5
  6. package/src/appearance-contract.js +64 -55
  7. package/src/atomic-file.js +2 -1
  8. package/src/changelog.json +37 -0
  9. package/src/cli.js +2 -2
  10. package/src/content/free-form-sections.js +2 -3
  11. package/src/display-scale.js +17 -0
  12. package/src/footer-alignment.js +97 -0
  13. package/src/footer-brand-inputs.js +33 -0
  14. package/src/footer-branding.js +44 -0
  15. package/src/footer-content.js +10 -0
  16. package/src/footer-contract.js +167 -43
  17. package/src/footer-draft-hash.js +26 -27
  18. package/src/footer-fit-widths.js +10 -0
  19. package/src/footer-fit.js +328 -0
  20. package/src/footer-font-metrics.js +8345 -0
  21. package/src/footer-workspace.js +4 -6
  22. package/src/header-presentation.js +17 -15
  23. package/src/logo-inputs.js +38 -0
  24. package/src/logo-surface-checks.js +67 -0
  25. package/src/presentation-reference.js +119 -46
  26. package/src/reference-help.js +3 -3
  27. package/src/setting-reference.js +15 -4
  28. package/src/settings-catalog.js +10 -3
  29. package/src/site-check-findings.js +73 -11
  30. package/src/site-check-rules.json +4 -2
  31. package/src/theme-contexts.js +82 -0
  32. package/src/theme-resolve.js +2 -2
  33. package/src/theme-validation.js +30 -13
  34. package/src/verbs/footer-push.js +20 -9
  35. package/src/verbs/plan.js +2 -2
  36. package/src/verbs/theme-push.js +46 -41
  37. package/src/verbs/validate.js +33 -17
  38. package/src/workspace-check.js +1 -1
  39. package/src/workspace.js +1 -1
@@ -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,33 @@
1
+ import { APPEARANCE_FILES } from "./appearance-contract.js";
2
+ import { resolveFooterLogoPairs } from "./footer-branding.js";
3
+ import { footerLogoAspectRatio } from "./footer-fit.js";
4
+ import { logoInputsFromSettings } from "./logo-inputs.js";
5
+ import { SETTINGS_TYPE_SITE_HEADER, SETTINGS_TYPE_TAPROOT_STYLES } from "./settings-catalog.js";
6
+ import { MEDIA_MANIFEST_FILE_NAME, readWorkspaceJson, WORKSPACE_LIMITS } from "./workspace.js";
7
+
8
+ async function optionalSettings(workspaceDir, settingsType) {
9
+ try {
10
+ const document = await readWorkspaceJson(workspaceDir, APPEARANCE_FILES[settingsType], WORKSPACE_LIMITS.settingsBytes);
11
+ return document?.settings;
12
+ } catch {
13
+ return undefined;
14
+ }
15
+ }
16
+
17
+ /** Optional files are independent: losing the header must not discard a known logo, or the reverse. */
18
+ export async function readFooterBrandInputs(workspaceDir, footerSettings) {
19
+ const [header, styles, media] = await Promise.all([
20
+ optionalSettings(workspaceDir, SETTINGS_TYPE_SITE_HEADER),
21
+ optionalSettings(workspaceDir, SETTINGS_TYPE_TAPROOT_STYLES),
22
+ readWorkspaceJson(workspaceDir, MEDIA_MANIFEST_FILE_NAME, WORKSPACE_LIMITS.manifestBytes).then(value => value?.media ?? {}).catch(() => ({})),
23
+ ]);
24
+ const pair = resolveFooterLogoPairs({ ...logoInputsFromSettings(styles, footerSettings, media), logoVariant: footerSettings?.logoVariant });
25
+ const visible = [pair.light, pair.dark].filter(value => value.url !== "");
26
+ const ratios = visible.map(value => Number(value.aspectRatio));
27
+ const knownRatios = visible.length > 0 && ratios.every(value => Number.isFinite(value) && value > 0);
28
+ return {
29
+ brandText: typeof header?.brandText === "string" ? header.brandText : "",
30
+ hasLogo: visible.length > 0,
31
+ ...(knownRatios ? { logoAspectRatio: footerLogoAspectRatio(ratios) } : {}),
32
+ };
33
+ }
@@ -0,0 +1,44 @@
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, resolveLogoVariant, } 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 footerBrandSizeStyleMap(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 declarations;
29
+ }
30
+ export function footerBrandSizeStyles(size, logoScale) {
31
+ return Object.entries(footerBrandSizeStyleMap(size, logoScale)).map(([key, value]) => `${key}: ${value};`).join(" ");
32
+ }
33
+ /** An unset footer scheme inherits its site scheme, never the other footer override. */
34
+ export function resolveFooterLogoPairs(input) {
35
+ // A footer inherits the site pair before either surface selects its artwork.
36
+ const site = resolveHeaderLogoPairs({ ...input, logoVariant: "" });
37
+ const override = (id, url = "", aspectRatio = "", inherited) => id ? { url, aspectRatio: url ? aspectRatio : "" } : inherited;
38
+ const effective = {
39
+ light: override(input.lightFooterLogoId, input.lightFooterLogoUrl, input.lightFooterLogoAspectRatio, site.light),
40
+ dark: override(input.darkFooterLogoId, input.darkFooterLogoUrl, input.darkFooterLogoAspectRatio, site.dark),
41
+ };
42
+ const variant = resolveLogoVariant(input.logoVariant);
43
+ return variant ? { light: effective[variant], dark: effective[variant] } : effective;
44
+ }
@@ -0,0 +1,10 @@
1
+ // Generated from shared/footer-content.ts by scripts/sync-field-validation.mjs. Do not edit.
2
+ /** These fields belong to presentation; footer content saves and dirty checks leave them alone. */
3
+ export const FOOTER_PRESENTATION_FIELDS = ["context", "logoVariant"];
4
+ /** Preserve raw content values; callers decide whether their document needs normalization. */
5
+ export function projectFooterContent(settings) {
6
+ const content = { ...settings };
7
+ for (const field of FOOTER_PRESENTATION_FIELDS)
8
+ delete content[field];
9
+ return content;
10
+ }
@@ -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 { LOGO_VARIANTS, resolveLogoVariant } from "./header-presentation.js";
8
+ import { parseFooterLogoScale, resolveFooterLogoScale } from "./footer-branding.js";
9
+ import {
10
+ FOOTER_ALIGNMENT_LAYOUTS,
11
+ FOOTER_POSITION_VALUES,
12
+ FOOTER_TEXT_ALIGN_VALUES,
13
+ normalizeFooterLogoBox,
14
+ normalizeFooterResponsiveAlignment,
15
+ normalizeFooterResponsiveInlineAlignment,
16
+ } from "./footer-alignment.js";
7
17
  import { isSocialLinkUrl, SOCIAL_LINK_URL_MAX_LENGTH, trimSocialLinkInput } from "./social-link-url.js";
8
18
  import socialPlatforms from "./social-platforms.json" with { type: "json" };
9
- 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 three
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,23 @@ 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",
84
+ "context",
85
+ "logoVariant",
63
86
  ]),
64
- FooterLinkColumn: Object.freeze(["id", "groups"]),
87
+ FooterLinkColumn: Object.freeze(["id", "groups", "span", "alignment"]),
88
+ FooterAlignment: Object.freeze(["horizontal", "vertical", "textAlign"]),
89
+ FooterResponsiveAlignment: FOOTER_ALIGNMENT_LAYOUTS,
90
+ FooterInlineAlignment: Object.freeze(["horizontal", "textAlign"]),
91
+ FooterResponsiveInlineAlignment: FOOTER_ALIGNMENT_LAYOUTS,
65
92
  FooterLinkGroup: Object.freeze(["id", "heading", "links"]),
66
93
  FooterLink: Object.freeze(["id", "label", "pageResourceId", "externalUrl"]),
67
94
  FooterSocialLink: Object.freeze(["id", "platform", "url", "label"]),
@@ -70,11 +97,6 @@ export const FOOTER_FIELD_INVENTORY = Object.freeze({
70
97
  FooterRichTextRun: Object.freeze(["text", "bold", "italic", "underline", "link"]),
71
98
  FooterInlineLink: Object.freeze(["pageResourceId", "externalUrl"]),
72
99
  FooterSchemeSettings: Object.freeze([
73
- "backgroundColor",
74
- "textColor",
75
- "headingColor",
76
- "linkColor",
77
- "linkHoverColor",
78
100
  "backgroundImageId",
79
101
  "backgroundImageUrl",
80
102
  "backgroundImageOpacity",
@@ -82,6 +104,8 @@ export const FOOTER_FIELD_INVENTORY = Object.freeze({
82
104
  "backgroundFade",
83
105
  "backgroundRepeatHeightPx",
84
106
  "additionalTopPaddingRem",
107
+ "logoId",
108
+ "logoUrl",
85
109
  ]),
86
110
  FooterFeatureImageSettings: Object.freeze(["imageId", "imageUrl", "alt", "responsiveUrls"]),
87
111
  FooterFeatureResponsiveImageUrl: Object.freeze(["minWidth", "url"]),
@@ -95,6 +119,8 @@ export const SOCIAL_LINK_URL_REQUIREMENT =
95
119
  + "to a domain name of unaccented letters, digits and hyphens, like https://www.instagram.com/yourname";
96
120
 
97
121
  export const FOOTER_READ_ONLY_FIELDS = Object.freeze([
122
+ "light.logoUrl",
123
+ "dark.logoUrl",
98
124
  "light.backgroundImageUrl",
99
125
  "dark.backgroundImageUrl",
100
126
  "featureImage.imageUrl",
@@ -109,6 +135,23 @@ function fail(code, message, field) {
109
135
  throw new SiteAuthoringError(code, message, { field });
110
136
  }
111
137
 
138
+ /** Refuse the retired model before closed-object errors obscure the migration recipe. */
139
+ export function refuseRetiredFooterColors(footer) {
140
+ for (const schemeName of ["light", "dark"]) {
141
+ const scheme = footer?.[schemeName];
142
+ if (!isPlainObject(scheme)) continue;
143
+ for (const name of ["backgroundColor", "textColor", "headingColor", "linkColor", "linkHoverColor"]) {
144
+ if (!Object.hasOwn(scheme, name)) continue;
145
+ const field = `footerSettings.${schemeName}.${name}`;
146
+ fail(
147
+ "appearance.retired_footer_color",
148
+ `${field} is retired. Declare a context in both themes and set footerSettings.context; 'taproot-site help appearance' gives the color-to-context recipe.`,
149
+ field,
150
+ );
151
+ }
152
+ }
153
+ }
154
+
112
155
  function object(value, path, { nullable = false } = {}) {
113
156
  if (nullable && (value === null || value === undefined)) return null;
114
157
  if (!isPlainObject(value)) fail("footer.document_invalid", `${path} must be a JSON object.`, path);
@@ -147,6 +190,14 @@ function number(value, defaultValue, path, minimum, maximum) {
147
190
  return value;
148
191
  }
149
192
 
193
+ function span(value, maximum, path) {
194
+ if (value === undefined) return 1;
195
+ if (!Number.isInteger(value) || value < 1 || value > maximum) {
196
+ fail("footer.field_invalid", `${path} must be a whole number from 1 through ${maximum}.`, path);
197
+ }
198
+ return value;
199
+ }
200
+
150
201
  function choice(value, defaultValue, choices, path) {
151
202
  if (value === undefined) return defaultValue;
152
203
  if (typeof value !== "string" || !choices.includes(value)) {
@@ -155,6 +206,30 @@ function choice(value, defaultValue, choices, path) {
155
206
  return value;
156
207
  }
157
208
 
209
+ function alignmentProfile(value, path, tolerateStoredValues, inlineOnly = false) {
210
+ if (!tolerateStoredValues && value !== undefined && value !== null) {
211
+ value = object(value, path);
212
+ closed(value, inlineOnly ? "FooterResponsiveInlineAlignment" : "FooterResponsiveAlignment", path);
213
+ for (const layout of FOOTER_ALIGNMENT_LAYOUTS) {
214
+ const alignmentPath = `${path}.${layout}`;
215
+ const alignment = value[layout];
216
+ if (alignment === undefined || alignment === null) continue;
217
+ object(alignment, alignmentPath);
218
+ const type = inlineOnly ? "FooterInlineAlignment" : "FooterAlignment";
219
+ closed(alignment, type, alignmentPath);
220
+ for (const axis of FOOTER_FIELD_INVENTORY[type]) {
221
+ choice(alignment[axis], "", ["", ...(axis === "textAlign" ? FOOTER_TEXT_ALIGN_VALUES : FOOTER_POSITION_VALUES)], `${alignmentPath}.${axis}`);
222
+ }
223
+ }
224
+ }
225
+ return inlineOnly ? normalizeFooterResponsiveInlineAlignment(value) : normalizeFooterResponsiveAlignment(value);
226
+ }
227
+
228
+ function authoredAlignment(owner, key, path, tolerateStoredValues, inlineOnly = false) {
229
+ const alignment = alignmentProfile(owner[key], `${path}.${key}`, tolerateStoredValues, inlineOnly);
230
+ return alignment === undefined ? {} : { [key]: alignment };
231
+ }
232
+
158
233
  function isDotNetWhiteSpace(character) {
159
234
  const codePoint = character.codePointAt(0);
160
235
  return (codePoint >= 0x0009 && codePoint <= 0x000d)
@@ -395,6 +470,7 @@ function scheme(value, path, knownImageIds) {
395
470
  value = value === undefined || value === null ? {} : object(value, path);
396
471
  closed(value, "FooterSchemeSettings", path);
397
472
  rejectReadOnly(value, "backgroundImageUrl", path);
473
+ rejectReadOnly(value, "logoUrl", path);
398
474
  const repeatHeight = value.backgroundRepeatHeightPx ?? FOOTER_LIMITS.backgroundRepeatHeightDefault;
399
475
  if (
400
476
  !Number.isInteger(repeatHeight)
@@ -409,23 +485,7 @@ function scheme(value, path, knownImageIds) {
409
485
  );
410
486
  }
411
487
  return {
412
- backgroundColor: requireAppearanceColor(
413
- value.backgroundColor ?? "",
414
- FOOTER_COLOR_TOKENS.backgroundColor,
415
- `${path}.backgroundColor`,
416
- ),
417
- textColor: requireAppearanceColor(value.textColor ?? "", FOOTER_COLOR_TOKENS.textColor, `${path}.textColor`),
418
- headingColor: requireAppearanceColor(
419
- value.headingColor ?? "",
420
- FOOTER_COLOR_TOKENS.headingColor,
421
- `${path}.headingColor`,
422
- ),
423
- linkColor: requireAppearanceColor(value.linkColor ?? "", FOOTER_COLOR_TOKENS.linkColor, `${path}.linkColor`),
424
- linkHoverColor: requireAppearanceColor(
425
- value.linkHoverColor ?? "",
426
- FOOTER_COLOR_TOKENS.linkHoverColor,
427
- `${path}.linkHoverColor`,
428
- ),
488
+ logoId: imageId(value.logoId, `${path}.logoId`, knownImageIds),
429
489
  backgroundImageId: imageId(value.backgroundImageId, `${path}.backgroundImageId`, knownImageIds),
430
490
  backgroundImageOpacity: number(value.backgroundImageOpacity, 1, `${path}.backgroundImageOpacity`, 0, 1),
431
491
  backgroundPresentation: choice(
@@ -484,11 +544,7 @@ function featureImage(value, knownImageIds, tolerateStoredValues) {
484
544
 
485
545
  export function footerDefaults() {
486
546
  const defaults = () => ({
487
- backgroundColor: "",
488
- textColor: "",
489
- headingColor: "",
490
- linkColor: "",
491
- linkHoverColor: "",
547
+ logoId: "",
492
548
  backgroundImageId: "",
493
549
  backgroundImageOpacity: 1,
494
550
  backgroundPresentation: FOOTER_BACKGROUND_PRESENTATIONS[0],
@@ -499,6 +555,11 @@ export function footerDefaults() {
499
555
  return {
500
556
  enabled: false,
501
557
  showBrand: true,
558
+ brandSpan: 1,
559
+ brandSize: "standard",
560
+ logoScale: "1.0",
561
+ logoBox: "fixed",
562
+ asideSpan: 1,
502
563
  asideCta: undefined,
503
564
  bottomLinks: [],
504
565
  light: defaults(),
@@ -518,6 +579,7 @@ function normalizeFooterDocument(
518
579
  { knownPageResourceIds, knownImageIds, tolerateStoredValues = false } = {},
519
580
  ) {
520
581
  value = object(value ?? {}, "footerSettings");
582
+ refuseRetiredFooterColors(value);
521
583
  closed(value, "FooterSettings", "footerSettings");
522
584
  const seenColumnIds = new Set();
523
585
  const seenGroupIds = new Set();
@@ -556,6 +618,8 @@ function normalizeFooterDocument(
556
618
  return {
557
619
  id: stableId(column.id, `${columnPath}.id`, seenColumnIds, "column"),
558
620
  groups,
621
+ span: span(column.span, FOOTER_LIMITS.columnSpanMax, `${columnPath}.span`),
622
+ ...authoredAlignment(column, "alignment", columnPath, tolerateStoredValues),
559
623
  };
560
624
  });
561
625
  if (groupCount > FOOTER_LIMITS.linkGroups) {
@@ -567,9 +631,52 @@ function normalizeFooterDocument(
567
631
  }
568
632
 
569
633
  const normalizedFeatureImage = featureImage(value.featureImage, knownImageIds, tolerateStoredValues);
634
+ const brandSize = choice(
635
+ value.brandSize === "" ? undefined : value.brandSize,
636
+ "standard",
637
+ ["standard", "large"],
638
+ "footerSettings.brandSize",
639
+ );
640
+ const logoScale = tolerateStoredValues
641
+ ? resolveFooterLogoScale(value.logoScale, brandSize)
642
+ : parseFooterLogoScale(value.logoScale, brandSize);
643
+ if (logoScale === null) {
644
+ fail(
645
+ "footer.field_invalid",
646
+ "footerSettings.logoScale must be a string from 1.0 through 5.0 in 0.1 steps.",
647
+ "footerSettings.logoScale",
648
+ );
649
+ }
650
+ const context = value.context === undefined ? "" : value.context;
651
+ if (typeof context !== "string") {
652
+ fail(
653
+ "settings.context_unknown",
654
+ "footerSettings.context must name a shared theme context or be empty.",
655
+ "footerSettings.context",
656
+ );
657
+ }
658
+ const logoVariant = tolerateStoredValues
659
+ ? resolveLogoVariant(value.logoVariant)
660
+ : choice(value.logoVariant, "", LOGO_VARIANTS, "footerSettings.logoVariant");
570
661
  return {
662
+ ...(context === "" ? {} : { context }),
663
+ ...(logoVariant === "" ? {} : { logoVariant }),
571
664
  enabled: boolean(value.enabled, false, "footerSettings.enabled"),
572
665
  showBrand: boolean(value.showBrand, true, "footerSettings.showBrand"),
666
+ brandSpan: span(value.brandSpan, FOOTER_LIMITS.brandSpanMax, "footerSettings.brandSpan"),
667
+ brandSize,
668
+ logoScale: logoScale.canonical,
669
+ logoBox: tolerateStoredValues
670
+ ? normalizeFooterLogoBox(value.logoBox)
671
+ : choice(value.logoBox === "" || value.logoBox === null ? undefined : value.logoBox, "fixed", [
672
+ "fixed",
673
+ "natural",
674
+ ], "footerSettings.logoBox"),
675
+ ...authoredAlignment(value, "alignment", "footerSettings", tolerateStoredValues),
676
+ ...authoredAlignment(value, "brandAlignment", "footerSettings", tolerateStoredValues),
677
+ ...authoredAlignment(value, "asideAlignment", "footerSettings", tolerateStoredValues),
678
+ ...authoredAlignment(value, "bottomAlignment", "footerSettings", tolerateStoredValues, true),
679
+ asideSpan: span(value.asideSpan, FOOTER_LIMITS.asideSpanMax, "footerSettings.asideSpan"),
573
680
  ...(value.asideCta === undefined || value.asideCta === null
574
681
  ? {}
575
682
  : {
@@ -619,7 +726,9 @@ function normalizeFooterDocument(
619
726
  ...(normalizedFeatureImage === undefined ? {} : { featureImage: normalizedFeatureImage }),
620
727
  showBrandText: boolean(value.showBrandText, true, "footerSettings.showBrandText"),
621
728
  socialLinks: array(value.socialLinks, "footerSettings.socialLinks", FOOTER_LIMITS.socialLinks)
622
- .map((link, index) => socialLink(link, `footerSettings.socialLinks[${index}]`, seenLinkIds, tolerateStoredValues)),
729
+ .map((link, index) =>
730
+ socialLink(link, `footerSettings.socialLinks[${index}]`, seenLinkIds, tolerateStoredValues)
731
+ ),
623
732
  };
624
733
  }
625
734
 
@@ -631,7 +740,10 @@ export function validateFooterDocument(value, options = {}) {
631
740
  function withoutServerProjections(value) {
632
741
  const projected = structuredClone(isPlainObject(value) ? value : {});
633
742
  for (const schemeName of ["light", "dark"]) {
634
- if (isPlainObject(projected[schemeName])) delete projected[schemeName].backgroundImageUrl;
743
+ if (isPlainObject(projected[schemeName])) {
744
+ delete projected[schemeName].backgroundImageUrl;
745
+ delete projected[schemeName].logoUrl;
746
+ }
635
747
  }
636
748
  if (isPlainObject(projected.featureImage)) {
637
749
  delete projected.featureImage.imageUrl;
@@ -648,7 +760,13 @@ export function projectFooterSettingsForWorkspace(value) {
648
760
  export function footerImageIds(value) {
649
761
  const ids = new Set();
650
762
  for (
651
- const candidate of [value?.light?.backgroundImageId, value?.dark?.backgroundImageId, value?.featureImage?.imageId]
763
+ const candidate of [
764
+ value?.light?.logoId,
765
+ value?.dark?.logoId,
766
+ value?.light?.backgroundImageId,
767
+ value?.dark?.backgroundImageId,
768
+ value?.featureImage?.imageId,
769
+ ]
652
770
  ) {
653
771
  if (isCanonicalUuid(candidate)) ids.add(candidate);
654
772
  }
@@ -658,6 +776,18 @@ export function footerImageIds(value) {
658
776
  export const FOOTER_EXAMPLE = Object.freeze({
659
777
  enabled: true,
660
778
  showBrand: true,
779
+ brandSpan: 2,
780
+ brandSize: "large",
781
+ logoScale: "1.5",
782
+ logoBox: "natural",
783
+ alignment: Object.freeze({ stacked: Object.freeze({ horizontal: "center" }) }),
784
+ brandAlignment: Object.freeze({
785
+ wide: Object.freeze({ vertical: "start" }),
786
+ wrapped: Object.freeze({ horizontal: "center" }),
787
+ }),
788
+ asideAlignment: Object.freeze({ wide: Object.freeze({ textAlign: "justify" }) }),
789
+ bottomAlignment: Object.freeze({ stacked: Object.freeze({ textAlign: "auto" }) }),
790
+ asideSpan: 1,
661
791
  // The aside CTA is where a local business puts the thing a visitor came for.
662
792
  // A phone number is a `tel:` target, emitted verbatim so it stays dialable.
663
793
  asideCta: Object.freeze({
@@ -678,11 +808,7 @@ export const FOOTER_EXAMPLE = Object.freeze({
678
808
  }),
679
809
  ]),
680
810
  light: Object.freeze({
681
- backgroundColor: "--esp-color-layer-1",
682
- textColor: "--esp-color-text",
683
- headingColor: "--esp-color-headings",
684
- linkColor: "--esp-color-link",
685
- linkHoverColor: "--esp-color-link-hover",
811
+ logoId: "",
686
812
  backgroundImageId: "d461035a-74b6-4528-a4f5-e5a96fb50037",
687
813
  backgroundImageOpacity: 0.18,
688
814
  backgroundPresentation: "FOOTER_BACKGROUND_PRESENTATION_COVER",
@@ -691,11 +817,7 @@ export const FOOTER_EXAMPLE = Object.freeze({
691
817
  additionalTopPaddingRem: 0,
692
818
  }),
693
819
  dark: Object.freeze({
694
- backgroundColor: "--esp-color-background",
695
- textColor: "--esp-color-text",
696
- headingColor: "--esp-color-headings",
697
- linkColor: "--esp-color-link",
698
- linkHoverColor: "--esp-color-link-hover",
820
+ logoId: "",
699
821
  backgroundImageId: "",
700
822
  backgroundImageOpacity: 1,
701
823
  backgroundPresentation: "FOOTER_BACKGROUND_PRESENTATION_TILE",
@@ -705,6 +827,8 @@ export const FOOTER_EXAMPLE = Object.freeze({
705
827
  }),
706
828
  linkColumns: Object.freeze([Object.freeze({
707
829
  id: "84bf7531-dfc8-453e-a78d-a5fa3348d56b",
830
+ span: 1,
831
+ alignment: Object.freeze({ stacked: Object.freeze({ horizontal: "start", textAlign: "start" }) }),
708
832
  groups: Object.freeze([Object.freeze({
709
833
  id: "64789fae-8862-43ab-85ca-f3b41819bddb",
710
834
  heading: "Explore",
@@ -1,12 +1,9 @@
1
1
  import { createHash } from "node:crypto";
2
2
 
3
3
  import { SiteAuthoringError } from "./errors.js";
4
- import { FOOTER_COLOR_TOKENS } from "./theme-validation.js";
5
-
6
- // The ten scheme colors theme push owns — light/dark times the color-token
7
- // registry — so a new footer color changes one executable registry, not a
8
- // hand-copied list. Every other footer field is footer-push content.
9
- const THEME_OWNED_SCHEME_COLORS = Object.freeze(Object.keys(FOOTER_COLOR_TOKENS));
4
+ import { resolveFooterLogoScale } from "./footer-branding.js";
5
+ import { footerAlignmentProfileValues, normalizeFooterLogoBox } from "./footer-alignment.js";
6
+ import { projectFooterContent } from "./footer-content.js";
10
7
 
11
8
  // Matches the package's document-depth convention (CONTENT_LIMITS.documentDepth):
12
9
  // the baseline hashes raw hand-editable JSON, and unbounded nesting would
@@ -15,8 +12,8 @@ const MAXIMUM_CONTENT_DEPTH = 64;
15
12
 
16
13
  /**
17
14
  * The pull baseline over everything `footer push` owns: a stable, type- and
18
- * shape-preserving JSON hash of the raw footer document with exactly the ten
19
- * scheme colors `theme push` overlays removed. The draft hash's canonical
15
+ * shape-preserving JSON hash of the raw footer document with presentation
16
+ * fields removed. The draft hash's canonical
20
17
  * form deliberately normalizes types and shapes the way the server does, so
21
18
  * it cannot see a hand-edit such as `enabled: "true"` or `bottomLinks: {}`;
22
19
  * this baseline must, because `theme push` would otherwise silently discard
@@ -26,16 +23,8 @@ const MAXIMUM_CONTENT_DEPTH = 64;
26
23
  */
27
24
  export function computeFooterContentHash(settings = {}) {
28
25
  requireBoundedDepth(settings);
29
- let content = settings;
30
- if (isContentObject(settings)) {
31
- content = structuredClone(settings);
32
- for (const scheme of ["light", "dark"]) {
33
- if (isContentObject(content[scheme])) {
34
- for (const color of THEME_OWNED_SCHEME_COLORS) delete content[scheme][color];
35
- }
36
- }
37
- }
38
- return createHash("sha256").update(`footer-content-v2${stableJson(content)}`, "utf8").digest("hex");
26
+ const content = isContentObject(settings) ? projectFooterContent(settings) : settings;
27
+ return createHash("sha256").update(`footer-content-v3${stableJson(content)}`, "utf8").digest("hex");
39
28
  }
40
29
 
41
30
  function isContentObject(value) {
@@ -83,20 +72,29 @@ export function stableJson(value) {
83
72
  }
84
73
 
85
74
  // Byte-for-byte port of FooterDraftConcurrency.ComputeHash. The token protects
86
- // the whole footer document while theme push overlays only its ten scheme color
87
- // fields onto a fresh read. Response-only image URLs deliberately do not enter
88
- // the canonical form.
75
+ // footer content independently of theme-owned presentation fields.
76
+ // Response-only image URLs stay outside the canonical form.
89
77
  export function computeFooterDraftHash(settings = {}) {
90
78
  const canonical = [];
91
- append(canonical, "footer-draft-v4");
79
+ append(canonical, "footer-draft-v8");
92
80
  append(canonical, settings.enabled === true);
93
81
  append(canonical, settings.showBrand ?? true);
94
82
  append(canonical, settings.showBrandText ?? true);
83
+ append(canonical, settings.brandSpan ?? 1);
84
+ append(canonical, settings.brandSize || "standard");
85
+ append(canonical, resolveFooterLogoScale(settings.logoScale, settings.brandSize).canonical);
86
+ append(canonical, normalizeFooterLogoBox(settings.logoBox));
87
+ appendAlignment(canonical, settings.alignment);
88
+ appendAlignment(canonical, settings.brandAlignment);
89
+ appendAlignment(canonical, settings.asideAlignment);
90
+ appendAlignment(canonical, settings.bottomAlignment, true);
95
91
 
96
92
  const columns = Array.isArray(settings.linkColumns) ? settings.linkColumns : [];
97
93
  append(canonical, columns.length);
98
94
  for (const column of columns) {
99
95
  append(canonical, normalizeId(column?.id));
96
+ append(canonical, column?.span ?? 1);
97
+ appendAlignment(canonical, column?.alignment);
100
98
  const groups = Array.isArray(column?.groups) ? column.groups : [];
101
99
  append(canonical, groups.length);
102
100
  for (const group of groups) {
@@ -111,6 +109,7 @@ export function computeFooterDraftHash(settings = {}) {
111
109
  const hasAsideCta = settings.asideCta !== undefined && settings.asideCta !== null;
112
110
  append(canonical, hasAsideCta);
113
111
  if (hasAsideCta) appendLink(canonical, settings.asideCta);
112
+ append(canonical, settings.asideSpan ?? 1);
114
113
  appendRichText(canonical, settings.bottomContent);
115
114
  appendLinks(canonical, settings.bottomLinks);
116
115
  appendSocialLinks(canonical, settings.socialLinks);
@@ -127,6 +126,10 @@ export function computeFooterDraftHash(settings = {}) {
127
126
  return createHash("sha256").update(canonical.join(""), "utf8").digest("hex");
128
127
  }
129
128
 
129
+ function appendAlignment(canonical, profile, inlineOnly = false) {
130
+ for (const value of footerAlignmentProfileValues(profile, inlineOnly)) append(canonical, value);
131
+ }
132
+
130
133
  function appendLinks(canonical, rawLinks) {
131
134
  const links = Array.isArray(rawLinks) ? rawLinks : [];
132
135
  append(canonical, links.length);
@@ -181,11 +184,7 @@ function appendRichText(canonical, richText) {
181
184
 
182
185
  function appendScheme(canonical, rawScheme) {
183
186
  const scheme = rawScheme ?? {};
184
- append(canonical, scheme.backgroundColor ?? "");
185
- append(canonical, scheme.textColor ?? "");
186
- append(canonical, scheme.headingColor ?? "");
187
- append(canonical, scheme.linkColor ?? "");
188
- append(canonical, scheme.linkHoverColor ?? "");
187
+ append(canonical, normalizeId(scheme.logoId));
189
188
  append(canonical, normalizeId(scheme.backgroundImageId));
190
189
  append(canonical, doubleBits(scheme.backgroundImageOpacity ?? 1));
191
190
  append(canonical, presentationValue(scheme.backgroundPresentation));