@vectoriox/iox-ui 5.122.0 → 5.123.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/fesm2022/vectoriox-iox-ui-generation-core.mjs +2306 -1842
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/generation-core/index.d.ts +487 -228
- package/package.json +1 -1
- package/src/generation-core/compose-layout.ts +3 -5
- package/src/generation-core/compose-site.ts +60 -17
- package/src/generation-core/header-mix.ts +355 -4
- package/src/generation-core/layout-fingerprint.ts +3 -3
- package/src/generation-core/nav-shape.ts +49 -3
- package/src/generation-core/plan-wire.ts +30 -15
- package/src/generation-core/site-spec.generated.ts +104 -22
- package/src/generation-core/validate-site-plan.ts +2 -1
package/package.json
CHANGED
|
@@ -6,9 +6,8 @@ import {
|
|
|
6
6
|
import { ColorScheme, DesignChoices, LinkType, setColorScheme } from '@vectoriox/iox-ui/design-core';
|
|
7
7
|
import { FORM_AFTER_SEND_TRAIT, FormAfterSend, FormPresetId } from '@vectoriox/iox-ui/forms-core';
|
|
8
8
|
import { composeNavHeader, composePresetForm } from './compose-site';
|
|
9
|
-
import { drawnHeaderMix,
|
|
9
|
+
import { drawnHeaderMix, headerMixOfNavKind } from './header-mix';
|
|
10
10
|
import { listWait } from './list-table';
|
|
11
|
-
import { NavShape, planNavShape } from './nav-shape';
|
|
12
11
|
import {
|
|
13
12
|
LAYOUT_ACCENT_TEXT, LAYOUT_BEAT_DELAY, LAYOUT_COLOUR_TOKEN, LAYOUT_COLUMN_GAP, LAYOUT_DEPTH_ON_PHONE, LAYOUT_EASING, LAYOUT_GUTTER, LAYOUT_PACE, LAYOUT_PHONE_BREAKPOINT, LAYOUT_PHOTO_ASPECT, LAYOUT_TOOLTIP_TRAIT,
|
|
14
13
|
LAYOUT_PHONE_PADDING, LAYOUT_RISE, LAYOUT_TEXT_KINDS, LayoutBleed, LayoutColour, LayoutEase, LayoutEnter, LayoutForm, LayoutGallery, LayoutLayer,
|
|
@@ -1189,9 +1188,8 @@ function composeHeader(ctx: Ctx): SerializedNode | null {
|
|
|
1189
1188
|
const pages = [{ name: ctx.site.name, route: NAV_ROUTE, isHome: true }, ...links.map(link => ({ name: link.label, route: `/${link.to}` }))];
|
|
1190
1189
|
let n = 0;
|
|
1191
1190
|
const newId = (suffix: string) => `${ctx.p}-nav-${++n}-${suffix}`;
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
if (drawn[HeaderIngredient.Pages] !== 'inline') header = planNavShape([header], NavShape.Drawer, { everyWidth: true, newId }, header.id).globals[0];
|
|
1191
|
+
// ONE recipe (HI1): the mix as drawn, arranged by composeNavHeader — a menu header's button and drawer at every width.
|
|
1192
|
+
const { header } = composeNavHeader({ business: { name: ctx.site.name } as never, pages, locale: ctx.site.locale, mix: drawn, asAsked: true }, { id: `${ctx.p}-nav`, newId });
|
|
1195
1193
|
if (ctx.rtl) setStyleProps(header, { textDirection: 'rtl' });
|
|
1196
1194
|
let drawer: string | undefined;
|
|
1197
1195
|
walkSerialized([header], node => { if (node.role === 'nav.drawer') drawer = node.id; });
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
import { EntranceMark, EntrancePart, planEntrances } from './entrances';
|
|
16
16
|
import { filmOfPlan } from './film';
|
|
17
17
|
import { checkFooter, footerMixOfPlan, footerPattern } from './footer-mix';
|
|
18
|
+
import { checkHeader, drawnHeaderMix, HeaderContext, headerContextOfPlan, headerMix, HeaderMix, headerRecipe, HeaderRecipe, wornHeaderOfPlan } from './header-mix';
|
|
18
19
|
import { NODE_BASELINES } from './node-baselines.generated';
|
|
19
20
|
import {
|
|
20
21
|
BindScope, CardBindTarget, parsePatternPath, PatternDirective, PatternGlobalPosition, PatternNode, PatternOpens, PatternPlaceholder, PatternRecipe, PatternTrack,
|
|
@@ -28,7 +29,7 @@ import { SitePlanSourceKind, ContentFieldControl, ContentFieldPlan,
|
|
|
28
29
|
PlanDataSourceType, RelativeOp, roleField, SiteLocale, SitePlan, SitePlanSource, SITE_FACT_LABELS, SiteBusiness,
|
|
29
30
|
} from './site-plan.model';
|
|
30
31
|
import { assertValidSitePlan, nextSourceOf, routeParams } from './validate-site-plan';
|
|
31
|
-
import { NavRole, NavShape, planNavShape } from './nav-shape';
|
|
32
|
+
import { MenuSide, NavRole, NavShape, planNavShape } from './nav-shape';
|
|
32
33
|
import { composeLayout, LayoutColourMode, layoutBandScheme, LayoutListBinding } from './compose-layout';
|
|
33
34
|
import { LayoutGalleryList, LayoutListShape, LayoutPage, LayoutPhotoShape, LayoutPhotoSource, LayoutSite, parseLayoutPhotoId } from './layout-language';
|
|
34
35
|
import { layoutMotionOf, layoutPresetOf } from './layout-look';
|
|
@@ -98,6 +99,9 @@ export enum ComposeIssueCode {
|
|
|
98
99
|
LinkUnlinked = 'link-unlinked',
|
|
99
100
|
/** LI5: the footer's mix broke one of its table's rules and was mended (`checkFooter`): the detail says how. */
|
|
100
101
|
FooterMended = 'footer-mended',
|
|
102
|
+
/** HI1: the header's mix asked for what the site cannot carry (`checkHeader`), or for a word the product does not draw
|
|
103
|
+
* yet (drawn as its stand-in): the detail says how. */
|
|
104
|
+
HeaderMended = 'header-mended',
|
|
101
105
|
}
|
|
102
106
|
|
|
103
107
|
/** The issues that are a dangling link (a route the plan has no page for) and what was done about it. */
|
|
@@ -1539,26 +1543,31 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
|
|
|
1539
1543
|
// contract's footer parts; each mend is said.
|
|
1540
1544
|
const footer = checkFooter(footerMixOfPlan(plan), { name: plan.business.name, design });
|
|
1541
1545
|
for (const r of footer.repairs) issues.push({ code: ComposeIssueCode.FooterMended, nodeId: GlobalSlot.Footer, owner: GlobalSlot.Footer, detail: r.said });
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
+
// HI1: the header is the plan's header MIX (a stored pattern id is read as one), drawn as the product draws it, checked
|
|
1547
|
+
// against the site and arranged from the contract's header parts; each mend is said.
|
|
1548
|
+
const header = planHeader(plan);
|
|
1549
|
+
for (const said of header.said) issues.push({ code: ComposeIssueCode.HeaderMended, nodeId: GlobalSlot.Header, owner: GlobalSlot.Header, detail: said });
|
|
1550
|
+
const patternOf = (slot: GlobalSlot): SitePattern => slot === GlobalSlot.Footer
|
|
1551
|
+
? footerPattern(footer.mix, { name: plan.business.name, design, tagline: plan.business.tagline })
|
|
1552
|
+
: header.recipe.pattern;
|
|
1553
|
+
const slotPatterns = Object.values(GlobalSlot).map(slot => [slot, patternOf(slot)] as const);
|
|
1554
|
+
let globals = slotPatterns.map(([slot, pattern]) => {
|
|
1546
1555
|
const node = composePattern(pattern, slot, { ...base, owner: slot, page: null, section: null, nextAlias: null });
|
|
1547
1556
|
node.isGlobal = true;
|
|
1548
1557
|
node.globalPosition = pattern.global;
|
|
1549
1558
|
return node;
|
|
1550
1559
|
});
|
|
1551
1560
|
// CC1: a header pattern that names its phone shape gets it — the same edit the author's "Phone menu"
|
|
1552
|
-
// section makes, so the composed header and a hand-switched one are one structure.
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
if (
|
|
1561
|
+
// section makes, so the composed header and a hand-switched one are one structure. HI-D8 / HI-D15: a header whose
|
|
1562
|
+
// pages are behind its menu shows the menu at every width, on the side the mix names.
|
|
1563
|
+
for (const [slot, pattern] of slotPatterns) {
|
|
1564
|
+
if (!pattern.phoneMenu) continue;
|
|
1565
|
+
globals = planNavShape(globals, pattern.phoneMenu as NavShape, headerShapeOptions(slot === GlobalSlot.Header ? header.recipe : null), slot).globals;
|
|
1556
1566
|
}
|
|
1557
1567
|
// Premium M4 (T2): a header pattern's behaviour as the page scrolls — the same edit the Header section makes.
|
|
1558
|
-
for (const slot of
|
|
1559
|
-
const
|
|
1560
|
-
|
|
1561
|
-
if (header && root) setHeaderBehaviour(root as unknown as CompositeNode, header.behaviour, header.edge ?? null);
|
|
1568
|
+
for (const [slot, pattern] of slotPatterns) {
|
|
1569
|
+
const root = pattern.header ? globals.find(g => g.id === slot) : null;
|
|
1570
|
+
if (pattern.header && root) setHeaderBehaviour(root as unknown as CompositeNode, pattern.header.behaviour, pattern.header.edge ?? null);
|
|
1562
1571
|
}
|
|
1563
1572
|
if (planSells(plan)) globals = withStore(globals, plan.locale ?? DEFAULT_SITE_LOCALE);
|
|
1564
1573
|
|
|
@@ -1578,6 +1587,20 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
|
|
|
1578
1587
|
};
|
|
1579
1588
|
}
|
|
1580
1589
|
|
|
1590
|
+
/** A plan's header (HI1): its mix as the product draws it, checked against the site, and the recipe to stamp — with what
|
|
1591
|
+
* was mended or drawn as something else, in words. */
|
|
1592
|
+
export function planHeader(plan: SitePlan): { recipe: HeaderRecipe; context: HeaderContext; said: string[] } {
|
|
1593
|
+
const { mix, context, said } = wornHeaderOfPlan(plan);
|
|
1594
|
+
return { recipe: headerRecipe(mix, context), context, said };
|
|
1595
|
+
}
|
|
1596
|
+
|
|
1597
|
+
/** The phone-menu options a header recipe asks for: its menu at every width and on its side (none for the defaults, so a
|
|
1598
|
+
* stored header's edit is the one it always was). */
|
|
1599
|
+
function headerShapeOptions(recipe: HeaderRecipe | null): { everyWidth?: boolean; menuSide?: MenuSide } {
|
|
1600
|
+
if (!recipe) return {};
|
|
1601
|
+
return { ...(recipe.everyWidth ? { everyWidth: true } : {}), ...(recipe.menuSide === MenuSide.Start ? { menuSide: MenuSide.Start } : {}) };
|
|
1602
|
+
}
|
|
1603
|
+
|
|
1581
1604
|
// ── The site header on its own (CC1.1) ──────────────────────────────────────────────────────────
|
|
1582
1605
|
|
|
1583
1606
|
/** The header pattern the Studio template stamps — and the builder palette's "Navigation bar". */
|
|
@@ -1597,6 +1620,15 @@ export interface NavHeaderInput {
|
|
|
1597
1620
|
readonly pages: ReadonlyArray<SitePageRef>;
|
|
1598
1621
|
/** The site's language (`SiteLocale`): the header's own words (its call to action) in it. English when not given. */
|
|
1599
1622
|
readonly locale?: string;
|
|
1623
|
+
/** HI1: the header's mix (the palette's arrangement presets, Bindings ▸ Header). The Studio header when not given. */
|
|
1624
|
+
readonly mix?: HeaderMix;
|
|
1625
|
+
/** HI1: the look the header is measured in (`checkHeader`). The default look when not given. */
|
|
1626
|
+
readonly design?: Readonly<Partial<DesignChoices>>;
|
|
1627
|
+
/** HI1: the studio's shop page, when it sells (the second action; the page a menu header pins). */
|
|
1628
|
+
readonly shop?: string | null;
|
|
1629
|
+
/** HI1: draw the mix as asked, never repaired — the layout language's header, whose links are its SECTIONS (a corner
|
|
1630
|
+
* header with two section links is still the name and a menu, HI0). */
|
|
1631
|
+
readonly asAsked?: boolean;
|
|
1600
1632
|
}
|
|
1601
1633
|
|
|
1602
1634
|
export interface NavHeaderOptions {
|
|
@@ -1610,6 +1642,8 @@ export interface ComposedNavHeader {
|
|
|
1610
1642
|
/** The header — a global BEFORE element — carrying the pattern's phone shape (the drawer). */
|
|
1611
1643
|
header: SerializedNode;
|
|
1612
1644
|
issues: ComposeIssue[];
|
|
1645
|
+
/** HI1: the mix it was composed as, after the site's check (what Bindings ▸ Header shows). */
|
|
1646
|
+
mix: HeaderMix;
|
|
1613
1647
|
}
|
|
1614
1648
|
|
|
1615
1649
|
const ROUTE_PARAM = ':';
|
|
@@ -1640,13 +1674,22 @@ function navPagePlans(pages: ReadonlyArray<SitePageRef>): PagePlan[] {
|
|
|
1640
1674
|
*/
|
|
1641
1675
|
export function composeNavHeader(input: NavHeaderInput, options: NavHeaderOptions): ComposedNavHeader {
|
|
1642
1676
|
if (!nonEmpty(options?.id)) throw new ComposeError('composeNavHeader needs the header id');
|
|
1643
|
-
const pattern = patternById(SITE_HEADER_PATTERN) as SitePattern;
|
|
1644
1677
|
const all = navPagePlans(input.pages);
|
|
1645
1678
|
const navRoutes = new Set(siteNavPages(input.pages).map(p => p.route));
|
|
1646
1679
|
const pages = all.map(p => ({ ...p, inNav: navRoutes.has(p.route) }));
|
|
1647
|
-
const plan = { business: input.business, pages, dataSources: [], contentTypes: [], locale: input.locale } as unknown as SitePlan;
|
|
1680
|
+
const plan = { business: input.business, pages, dataSources: [], contentTypes: [], locale: input.locale, design: input.design ?? {} } as unknown as SitePlan;
|
|
1648
1681
|
const email = nonEmpty(input.business.facts?.email) ? input.business.facts!.email!.trim() : null;
|
|
1649
1682
|
const issues: ComposeIssue[] = [];
|
|
1683
|
+
// HI1: ONE recipe with composeSite — the mix drawn as the product draws it, checked against this studio, arranged.
|
|
1684
|
+
const context = headerContextOfPlan(plan, input.shop ?? null);
|
|
1685
|
+
const { drawn, gaps } = drawnHeaderMix(input.mix ?? headerMix());
|
|
1686
|
+
// R-H4: the Studio header (no mix asked) composes as it always did; a chosen mix is judged against the studio.
|
|
1687
|
+
const checked = input.mix && !input.asAsked ? checkHeader(drawn, context) : { mix: drawn, repairs: [] };
|
|
1688
|
+
for (const said of [...gaps.map(g => `the header's ${g.ingredient} "${g.word}" is drawn as "${g.drawnAs}" until ${g.phase}`), ...checked.repairs.map(r => r.said)]) {
|
|
1689
|
+
issues.push({ code: ComposeIssueCode.HeaderMended, nodeId: options.id, owner: GlobalSlot.Header, detail: said });
|
|
1690
|
+
}
|
|
1691
|
+
const recipe = headerRecipe(checked.mix, context);
|
|
1692
|
+
const pattern = recipe.pattern;
|
|
1650
1693
|
const ctx: Ctx = {
|
|
1651
1694
|
owner: GlobalSlot.Header, page: null, section: null, plan, year: 0, email, navPage: null, nextAlias: null,
|
|
1652
1695
|
placeholders: [], issues, routes: new Set(pages.map(p => p.route)),
|
|
@@ -1655,9 +1698,9 @@ export function composeNavHeader(input: NavHeaderInput, options: NavHeaderOption
|
|
|
1655
1698
|
root.isGlobal = true;
|
|
1656
1699
|
root.globalPosition = pattern.global;
|
|
1657
1700
|
const shape = pattern.phoneMenu as NavShape | undefined;
|
|
1658
|
-
const header = shape ? planNavShape([root], shape, { newId: options.newId }, root.id).globals[0] : root;
|
|
1701
|
+
const header = shape ? planNavShape([root], shape, { newId: options.newId, ...headerShapeOptions(recipe) }, root.id).globals[0] : root;
|
|
1659
1702
|
if (pattern.header) setHeaderBehaviour(header as unknown as CompositeNode, pattern.header.behaviour, pattern.header.edge ?? null);
|
|
1660
|
-
return { header, issues };
|
|
1703
|
+
return { header, issues, mix: checked.mix };
|
|
1661
1704
|
}
|
|
1662
1705
|
|
|
1663
1706
|
// ── One pattern on its own (CC4b) ───────────────────────────────────────────────────────────────
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DesignChoices, elementStyleFace, resolveDesignChoices, textWidthEm } from '@vectoriox/iox-ui/design-core';
|
|
2
|
+
|
|
3
|
+
import { MenuSide, NavRole, NavShape } from './nav-shape';
|
|
4
|
+
import { PatternGlobalPosition, PatternNode, SITE_PATTERNS, SitePattern } from './patterns';
|
|
5
|
+
import { planSells, ShopSourceRole, shopSourceAliases } from './shop-plan';
|
|
6
|
+
import { SPEC_SITE_HEADER_PARTS, SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
2
7
|
|
|
3
8
|
/**
|
|
4
9
|
* HEADER INGREDIENTS (header-ingredients-plan.md, HI0): a site's header is a MIX — one word per ingredient — never a
|
|
@@ -9,6 +14,7 @@ import { SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
|
9
14
|
*/
|
|
10
15
|
|
|
11
16
|
const H = SPEC_SITE_LAYOUT.header;
|
|
17
|
+
const PARTS = SPEC_SITE_HEADER_PARTS as unknown as Readonly<Record<string, PatternNode>>;
|
|
12
18
|
|
|
13
19
|
/** The ingredients, by the contract's keys (held equal to it by header-mix.spec). */
|
|
14
20
|
export enum HeaderIngredient {
|
|
@@ -26,11 +32,34 @@ export enum HeaderIngredient {
|
|
|
26
32
|
Phone = 'phone',
|
|
27
33
|
}
|
|
28
34
|
|
|
35
|
+
export enum HeaderArrange {
|
|
36
|
+
Split = 'split',
|
|
37
|
+
Centred = 'centred',
|
|
38
|
+
Between = 'between',
|
|
39
|
+
NameOnly = 'name-only',
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export enum HeaderPages {
|
|
43
|
+
Inline = 'inline',
|
|
44
|
+
Menu = 'menu',
|
|
45
|
+
MenuPinned = 'menu-pinned',
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export enum HeaderAction {
|
|
49
|
+
None = 'none',
|
|
50
|
+
Button = 'button',
|
|
51
|
+
Link = 'link',
|
|
52
|
+
Two = 'two',
|
|
53
|
+
}
|
|
54
|
+
|
|
29
55
|
/** One word per ingredient. */
|
|
30
56
|
export type HeaderMix = Record<`${HeaderIngredient}`, string>;
|
|
31
57
|
|
|
32
58
|
export class HeaderMixError extends Error {}
|
|
33
59
|
|
|
60
|
+
/** The header pattern a plan names when it names none the table knows (the Studio header). */
|
|
61
|
+
export const DEFAULT_HEADER_PATTERN = 'nav.inline-cta';
|
|
62
|
+
|
|
34
63
|
const INGREDIENTS = H.ingredients as Readonly<Record<string, ReadonlyArray<string>>>;
|
|
35
64
|
const WAITS = H.waits as Readonly<Record<string, { phase: string; drawnAs: string }>>;
|
|
36
65
|
const MEANINGS = H.meanings as Readonly<Record<string, string>>;
|
|
@@ -109,8 +138,330 @@ export function headerReferences(): ReadonlyArray<{ id: string; after: string; a
|
|
|
109
138
|
.map(r => ({ id: r.id, after: r.after, added: r.added, mix: headerMix(r.mix) }));
|
|
110
139
|
}
|
|
111
140
|
|
|
112
|
-
/** The site plan's header as a mix: its `
|
|
113
|
-
*
|
|
114
|
-
export function headerMixOfPlan(plan: { readonly globals?: Readonly<Record<string, string
|
|
141
|
+
/** The site plan's header as a mix: its `mixes.header` when it has one (HI1), else its `globals.header` pattern read as a
|
|
142
|
+
* named mix (HI-D4), else the Studio header. */
|
|
143
|
+
export function headerMixOfPlan(plan: { readonly globals?: Readonly<Record<string, string>>; readonly mixes?: { readonly header?: ReadonlyArray<string> } }): HeaderMix {
|
|
144
|
+
if (plan.mixes?.header?.length) return headerMixFromWords(plan.mixes.header);
|
|
115
145
|
return namedHeaderMix(plan.globals?.['header'] ?? '') ?? headerMix();
|
|
116
146
|
}
|
|
147
|
+
|
|
148
|
+
// ── The wire: ONE list of <ingredient>:<word> words (the list and footer wires' encoding) ─────────────────────────
|
|
149
|
+
|
|
150
|
+
/** A mix on the wire: one `<ingredient>:<word>` per ingredient, in the table's order. */
|
|
151
|
+
export function headerMixWords(mix: HeaderMix): string[] {
|
|
152
|
+
return Object.values(HeaderIngredient).map(k => `${k}:${mix[k]}`);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/** Every `<ingredient>:<word>` the wire may carry: only the words the product DRAWS (ingredients.md §3) — a waiting word
|
|
156
|
+
* is never offered, so the model never chooses what the site would show as something else. */
|
|
157
|
+
export function headerWireWords(): string[] {
|
|
158
|
+
return Object.values(HeaderIngredient).flatMap(k => headerWords(k).filter(w => !WAITS[`${k}.${w}`]).map(w => `${k}:${w}`));
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** The words back into a mix: an ingredient not named is the default. Refuses an unknown word and two words for one
|
|
162
|
+
* ingredient. */
|
|
163
|
+
export function headerMixFromWords(words: ReadonlyArray<string>): HeaderMix {
|
|
164
|
+
const partial: Partial<Record<string, string>> = {};
|
|
165
|
+
for (const pair of words) {
|
|
166
|
+
const [k, w] = String(pair).split(':');
|
|
167
|
+
if (!INGREDIENTS[k] || !w) throw new HeaderMixError(`"${pair}" is no header word (<ingredient>:<word>)`);
|
|
168
|
+
if (partial[k] !== undefined && partial[k] !== w) throw new HeaderMixError(`a header has one ${k} ("${partial[k]}" and "${w}")`);
|
|
169
|
+
partial[k] = w;
|
|
170
|
+
}
|
|
171
|
+
return headerMix(partial as Partial<HeaderMix>);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/** The stored header pattern a mix is exactly (`nav.inline-cta`, `nav.centered-logo`), else null. */
|
|
175
|
+
export function headerPatternIdOf(mix: HeaderMix): string | null {
|
|
176
|
+
const key = JSON.stringify(headerMixWords(mix));
|
|
177
|
+
return Object.keys(H.named).find(id => JSON.stringify(headerMixWords(namedHeaderMix(id)!)) === key) ?? null;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// ── The check: any mix, judged against the site and mended (§3, §6 — the rules for the words HI1 draws) ──────────
|
|
181
|
+
|
|
182
|
+
export enum HeaderRepairCode {
|
|
183
|
+
/** A name-and-menu header has its pages behind the menu. */
|
|
184
|
+
NameOnlyInline = 'name-only-inline',
|
|
185
|
+
/** The name at the start with the pages behind a menu IS the name-and-menu header. */
|
|
186
|
+
SplitMenu = 'split-menu',
|
|
187
|
+
/** Pages either side of the name are pages in the bar: behind a menu the name is centred. */
|
|
188
|
+
BetweenMenu = 'between-menu',
|
|
189
|
+
/** A menu for so few pages is a detour: they go in the bar. */
|
|
190
|
+
FewPages = 'few-pages',
|
|
191
|
+
/** The pages do not fit beside the name on a laptop: they go behind a menu. */
|
|
192
|
+
TooManyPages = 'too-many-pages',
|
|
193
|
+
/** The name is too long, or the pages too few, to sit between two halves: the name is centred above them. */
|
|
194
|
+
BetweenUnbalanced = 'between-unbalanced',
|
|
195
|
+
/** Two actions need two destinations (the contact page and the shop): one button. */
|
|
196
|
+
OneDestination = 'one-destination',
|
|
197
|
+
/** Another site already wears this header: the nearest free one (`distinctHeader`). */
|
|
198
|
+
Worn = 'worn',
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface HeaderRepair {
|
|
202
|
+
code: HeaderRepairCode;
|
|
203
|
+
/** In plain words, for the wizard and the model's next turn. */
|
|
204
|
+
said: string;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** A page the header links to (a page in the navigation, never Home — the name links there). */
|
|
208
|
+
export interface HeaderPage {
|
|
209
|
+
readonly name: string;
|
|
210
|
+
readonly route: string;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** What the check and the recipe need of the site. */
|
|
214
|
+
export interface HeaderContext {
|
|
215
|
+
readonly name: string;
|
|
216
|
+
readonly design: DesignChoices;
|
|
217
|
+
/** The pages in the navigation, in order. */
|
|
218
|
+
readonly pages: ReadonlyArray<HeaderPage>;
|
|
219
|
+
/** The shop's page when the site sells (the second action, and the page a shop pins — HI-D16). */
|
|
220
|
+
readonly shop?: string | null;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const RULES = H.rules as Readonly<{ menuMinLinks: number; pinnedMax: number; inlineRoomPx: number; betweenNameEm: number; betweenMinPages: number }>;
|
|
224
|
+
/** How a laptop's bar is measured (an estimate on the look's own faces — never a guess at a page's words): the name at
|
|
225
|
+
* the brand's size, each page at the link's, the gap between them, and a button's padding around its words. */
|
|
226
|
+
const BRAND_PX = 24;
|
|
227
|
+
const LINK_PX = 16;
|
|
228
|
+
const GAP_PX = 24;
|
|
229
|
+
const BUTTON_PAD_PX = 48;
|
|
230
|
+
const ACTION_WORDS = 'Get in touch';
|
|
231
|
+
|
|
232
|
+
/** How wide the bar's words stand on a laptop: the pages and the action, and — beside them — the name. */
|
|
233
|
+
function barWidthPx(mix: HeaderMix, ctx: HeaderContext): number {
|
|
234
|
+
const link = elementStyleFace(ctx.design, 'link');
|
|
235
|
+
const pages = ctx.pages.reduce((w, p) => w + textWidthEm(p.name, link) * LINK_PX + GAP_PX, 0);
|
|
236
|
+
const action = mix.action === HeaderAction.None ? 0 : textWidthEm(ACTION_WORDS, link) * LINK_PX + BUTTON_PAD_PX + GAP_PX;
|
|
237
|
+
const name = mix.arrange === HeaderArrange.Centred ? 0 : textWidthEm(ctx.name, elementStyleFace(ctx.design, 'h3')) * BRAND_PX + GAP_PX;
|
|
238
|
+
return pages + action * (mix.action === HeaderAction.Two ? 2 : 1) + name;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
const behindMenu = (mix: HeaderMix): boolean => mix.pages !== HeaderPages.Inline;
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* The ONE judge of a header mix against the site (§3): what the site cannot carry is mended to the nearest mix that it
|
|
245
|
+
* can, and each mend is said. Judges the mix as DRAWN (`drawnHeaderMix` first). Never throws on a well-formed mix. Pure.
|
|
246
|
+
*/
|
|
247
|
+
export function checkHeader(mix: HeaderMix, ctx: HeaderContext): { mix: HeaderMix; repairs: HeaderRepair[] } {
|
|
248
|
+
const m = { ...mix };
|
|
249
|
+
const repairs: HeaderRepair[] = [];
|
|
250
|
+
const say = (code: HeaderRepairCode, said: string) => repairs.push({ code, said });
|
|
251
|
+
const count = ctx.pages.length;
|
|
252
|
+
if (m.arrange === HeaderArrange.NameOnly && !behindMenu(m)) {
|
|
253
|
+
m.pages = HeaderPages.Menu;
|
|
254
|
+
say(HeaderRepairCode.NameOnlyInline, 'a name-and-menu header keeps its pages behind the menu');
|
|
255
|
+
}
|
|
256
|
+
if (behindMenu(m) && count < RULES.menuMinLinks) {
|
|
257
|
+
m.pages = HeaderPages.Inline;
|
|
258
|
+
if (m.arrange === HeaderArrange.NameOnly) m.arrange = HeaderArrange.Split;
|
|
259
|
+
say(HeaderRepairCode.FewPages, `a menu for ${count} page${count === 1 ? '' : 's'} is a detour: they stand in the bar`);
|
|
260
|
+
}
|
|
261
|
+
if (!behindMenu(m) && barWidthPx(m, ctx) > RULES.inlineRoomPx) {
|
|
262
|
+
m.pages = HeaderPages.Menu;
|
|
263
|
+
say(HeaderRepairCode.TooManyPages, `${count} pages do not fit in the bar on a laptop: they go behind the menu`);
|
|
264
|
+
}
|
|
265
|
+
if (m.arrange === HeaderArrange.Split && behindMenu(m)) {
|
|
266
|
+
m.arrange = HeaderArrange.NameOnly;
|
|
267
|
+
say(HeaderRepairCode.SplitMenu, 'the name at the start with the pages behind a menu is the name-and-menu header');
|
|
268
|
+
}
|
|
269
|
+
if (m.arrange === HeaderArrange.Between && behindMenu(m)) {
|
|
270
|
+
m.arrange = HeaderArrange.Centred;
|
|
271
|
+
say(HeaderRepairCode.BetweenMenu, 'with the pages behind a menu the name is centred');
|
|
272
|
+
}
|
|
273
|
+
if (m.arrange === HeaderArrange.Between) {
|
|
274
|
+
const long = textWidthEm(ctx.name, elementStyleFace(ctx.design, 'h3')) > RULES.betweenNameEm;
|
|
275
|
+
if (long || count < RULES.betweenMinPages) {
|
|
276
|
+
m.arrange = HeaderArrange.Centred;
|
|
277
|
+
say(HeaderRepairCode.BetweenUnbalanced, long ? `"${ctx.name}" is too long to sit between the pages: it is centred above them`
|
|
278
|
+
: 'too few pages to share either side of the name: it is centred above them');
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
if (m.action === HeaderAction.Two && !ctx.shop) {
|
|
282
|
+
m.action = HeaderAction.Button;
|
|
283
|
+
say(HeaderRepairCode.OneDestination, 'two actions need two places to go (the contact page and the shop): one button');
|
|
284
|
+
}
|
|
285
|
+
return { mix: m, repairs };
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// ── The recipe: the mix arranged from the contract's parts (§4 — ONE recipe for the palette and the generator) ────
|
|
289
|
+
|
|
290
|
+
const clone = <T>(v: T): T => JSON.parse(JSON.stringify(v));
|
|
291
|
+
const part = (id: string): PatternNode => clone(PARTS[id]);
|
|
292
|
+
const laid = (node: PatternNode, lay: Readonly<Record<string, string>>): PatternNode => ({ ...node, lay: { ...(node.lay ?? {}), ...lay } });
|
|
293
|
+
const GAP = 'var(--iox-space-gap)';
|
|
294
|
+
/** A side of a centred name: half the room each, so the name sits in the true middle (never nudged by what is beside it). */
|
|
295
|
+
const cell = (side: 'start' | 'end', c: PatternNode[]): PatternNode => ({
|
|
296
|
+
t: 'Container', es: 'box', role: NavRole.Cell, lay: { display: 'flex', flexWrap: 'nowrap', alignItems: 'center', gap: GAP, flexGrow: '1', flexShrink: '1', flexBasis: '0px', minWidth: '0px', justifyContent: side === 'start' ? 'flex-start' : 'flex-end' }, c,
|
|
297
|
+
});
|
|
298
|
+
/** A page as a plain link (a pinned page; a half of the pages either side of the name). */
|
|
299
|
+
const pageLink = (p: HeaderPage, role?: string): PatternNode => ({ t: 'Link', es: 'link', text: p.name, href: p.route, ...(role ? { role } : {}) });
|
|
300
|
+
|
|
301
|
+
/** What a header asks for, in the order it shows them. */
|
|
302
|
+
function actionsOf(mix: HeaderMix, ctx: HeaderContext): PatternNode[] {
|
|
303
|
+
switch (mix.action) {
|
|
304
|
+
case HeaderAction.Button: return [part('button')];
|
|
305
|
+
case HeaderAction.Link: return [part('quiet')];
|
|
306
|
+
case HeaderAction.Two: return ctx.shop ? [part('button'), { ...part('outlined'), href: ctx.shop }] : [part('button')];
|
|
307
|
+
default: return [];
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** The page(s) a menu header keeps in the bar (HI-D16): a selling site's shop, else its first page. */
|
|
312
|
+
export function pinnedPagesOf(ctx: HeaderContext): HeaderPage[] {
|
|
313
|
+
const shop = ctx.shop ? ctx.pages.find(p => p.route === ctx.shop) : undefined;
|
|
314
|
+
return (shop ? [shop, ...ctx.pages.filter(p => p !== shop)] : [...ctx.pages]).slice(0, RULES.pinnedMax);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/** A header's pieces once the menu takes its pages: the pinned pages and the actions, each kept in the bar. */
|
|
318
|
+
function keptInBar(mix: HeaderMix, ctx: HeaderContext): { pinned: PatternNode | null; actions: PatternNode | null } {
|
|
319
|
+
const pins = mix.pages === HeaderPages.MenuPinned ? pinnedPagesOf(ctx) : [];
|
|
320
|
+
const acts = actionsOf(mix, ctx);
|
|
321
|
+
const pinned = pins.length ? { ...part('pinned'), c: pins.map(p => pageLink(p)) } : null;
|
|
322
|
+
const actions = acts.length ? { ...part('links'), role: NavRole.Actions, c: acts } : null;
|
|
323
|
+
return { pinned, actions };
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** The root's children for the mix (the menu button is the phone shape's — `planNavShape` places it). */
|
|
327
|
+
function bodyOf(mix: HeaderMix, ctx: HeaderContext): { lay: Record<string, string>; resp?: PatternNode['resp']; c: PatternNode[] } {
|
|
328
|
+
const brand = part('brand');
|
|
329
|
+
const links = (more: PatternNode[], lay: Record<string, string> = {}) => ({ ...laid(part('links'), lay), c: [part('link'), ...more] });
|
|
330
|
+
const flex = { display: 'flex', flexWrap: 'nowrap', justifyContent: 'space-between', alignItems: 'center', gap: GAP };
|
|
331
|
+
if (!behindMenu(mix)) {
|
|
332
|
+
switch (mix.arrange) {
|
|
333
|
+
case HeaderArrange.Centred:
|
|
334
|
+
return { lay: { display: 'flex', flexDirection: 'column', alignItems: 'center', gap: '14px' }, resp: { mobile: { flexDirection: 'row', justifyContent: 'space-between' } },
|
|
335
|
+
c: [brand, links(actionsOf(mix, ctx), { justifyContent: 'center' })] };
|
|
336
|
+
case HeaderArrange.Between: {
|
|
337
|
+
const half = Math.ceil(ctx.pages.length / 2);
|
|
338
|
+
const row = (pages: ReadonlyArray<HeaderPage>, more: PatternNode[]) => ({ ...part('links'), c: [...pages.map(p => pageLink(p, NavRole.Link)), ...more] });
|
|
339
|
+
return { lay: flex, c: [cell('start', [row(ctx.pages.slice(0, half), [])]), brand, cell('end', [row(ctx.pages.slice(half), actionsOf(mix, ctx))])] };
|
|
340
|
+
}
|
|
341
|
+
default:
|
|
342
|
+
return { lay: { display: 'flex', flexWrap: 'wrap', justifyContent: 'space-between', alignItems: 'center', gap: GAP }, c: [brand, links(actionsOf(mix, ctx))] };
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
// Behind a menu: the links row stays (hidden at every width — the drawer lists its pages, and an author who brings the
|
|
346
|
+
// pages back gets the row back); the pinned pages and the actions stay in the bar.
|
|
347
|
+
const { pinned, actions } = keptInBar(mix, ctx);
|
|
348
|
+
const kept = [pinned, actions].filter((n): n is PatternNode => !!n);
|
|
349
|
+
const start = mix.menuSide === MenuSide.Start;
|
|
350
|
+
if (mix.arrange === HeaderArrange.Centred) {
|
|
351
|
+
// The name in the middle; the menu button's side holds the pinned pages, the other side the actions.
|
|
352
|
+
const menuSide = pinned ? [pinned] : [];
|
|
353
|
+
const other = actions ? [actions] : [];
|
|
354
|
+
return { lay: flex, c: [cell('start', start ? menuSide : other), brand, links([]), cell('end', start ? other : menuSide)] };
|
|
355
|
+
}
|
|
356
|
+
// The name and the menu: the name at the far side from the button; what the bar keeps sits by the button.
|
|
357
|
+
return { lay: flex, c: start ? [cell('start', pinned ? [pinned] : []), brand, links([]), ...(actions ? [actions] : [])] : [brand, links([]), cell('end', kept)] };
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/** What the composer stamps for a header mix: the pattern, its phone shape and where its menu button sits. Check it first
|
|
361
|
+
* (`checkHeader` on the drawn mix). */
|
|
362
|
+
export interface HeaderRecipe {
|
|
363
|
+
pattern: SitePattern;
|
|
364
|
+
/** The pages are behind a menu at every width (HI-D8). */
|
|
365
|
+
everyWidth: boolean;
|
|
366
|
+
menuSide: MenuSide;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
/** The phone ingredient as the phone menu's shape (`full` waits for HI2 and is drawn as the drawer). */
|
|
370
|
+
const PHONE_SHAPE: Readonly<Record<string, NavShape>> = { drawer: NavShape.Drawer, bar: NavShape.Bar, both: NavShape.Both, full: NavShape.Drawer };
|
|
371
|
+
|
|
372
|
+
/** A header mix as a pattern: what the composer stamps as the site's header (global, before the page). A mix that IS a
|
|
373
|
+
* stored header (`nav.inline-cta`, `nav.centered-logo`) composes byte-identical to it (R-H4). Pure. */
|
|
374
|
+
export function headerRecipe(mix: HeaderMix, ctx: HeaderContext): HeaderRecipe {
|
|
375
|
+
const everyWidth = behindMenu(mix);
|
|
376
|
+
const menuSide = mix.menuSide === MenuSide.Start ? MenuSide.Start : MenuSide.End;
|
|
377
|
+
const stored = SITE_PATTERNS[headerPatternIdOf(mix) ?? ''];
|
|
378
|
+
const { lay, resp, c } = bodyOf(mix, ctx);
|
|
379
|
+
const node: PatternNode = { ...part('root'), lay, ...(resp ? { resp } : {}), c };
|
|
380
|
+
const pattern: SitePattern = {
|
|
381
|
+
family: 'nav',
|
|
382
|
+
label: stored?.label ?? `Header — ${headerTokenWords(headerTokenOf(mix))}`,
|
|
383
|
+
intent: stored?.intent ?? [headerMeaning(HeaderIngredient.Arrange, mix.arrange), headerMeaning(HeaderIngredient.Pages, mix.pages), headerMeaning(HeaderIngredient.Action, mix.action)].join('; '),
|
|
384
|
+
global: PatternGlobalPosition.Before,
|
|
385
|
+
// A menu at every width is the drawer's (only a drawer shows at every width — planNavShape).
|
|
386
|
+
phoneMenu: everyWidth ? NavShape.Drawer : PHONE_SHAPE[mix.phone] ?? NavShape.Drawer,
|
|
387
|
+
header: { behaviour: mix.scroll, edge: mix.edge },
|
|
388
|
+
node,
|
|
389
|
+
} as SitePattern;
|
|
390
|
+
return { pattern, everyWidth, menuSide };
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
// ── No sameness: another site's header is never worn again (§7, R-H2) ──────────────────────────────────────────────
|
|
394
|
+
|
|
395
|
+
/** The ingredients `distinctHeader` may change, in the order it tries them: how the pages are reached before where the
|
|
396
|
+
* name sits (the model chose the arrangement; the fingerprint sees both). */
|
|
397
|
+
const MEND_ORDER: ReadonlyArray<HeaderIngredient.Pages | HeaderIngredient.Arrange> = [HeaderIngredient.Pages, HeaderIngredient.Arrange];
|
|
398
|
+
|
|
399
|
+
/** The words of an ingredient the product draws. */
|
|
400
|
+
const drawnWords = (k: `${HeaderIngredient}`): string[] => headerWords(k).filter(w => !WAITS[`${k}.${w}`]);
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* A header no other site wears: the mix when its token is free, else the nearest mix whose token is — one changed
|
|
404
|
+
* ingredient before two, in `MEND_ORDER` — that the site can carry as it is (`checkHeader` mends nothing), and said. When
|
|
405
|
+
* every header is worn, the mix as it is. Pure, deterministic.
|
|
406
|
+
*/
|
|
407
|
+
export function distinctHeader(mix: HeaderMix, taken: ReadonlyArray<string>, ctx: HeaderContext): { mix: HeaderMix; repairs: HeaderRepair[] } {
|
|
408
|
+
const used = new Set(taken);
|
|
409
|
+
if (!used.has(headerTokenOf(mix))) return { mix, repairs: [] };
|
|
410
|
+
const tries: HeaderMix[] = [];
|
|
411
|
+
for (const k of MEND_ORDER) for (const w of drawnWords(k)) tries.push({ ...mix, [k]: w });
|
|
412
|
+
for (const w of drawnWords(HeaderIngredient.Pages)) for (const a of drawnWords(HeaderIngredient.Arrange)) tries.push({ ...mix, pages: w, arrange: a });
|
|
413
|
+
for (const t of tries) {
|
|
414
|
+
const checked = checkHeader(t, ctx);
|
|
415
|
+
if (checked.repairs.length || used.has(headerTokenOf(checked.mix))) continue;
|
|
416
|
+
return { mix: checked.mix, repairs: [{ code: HeaderRepairCode.Worn, said: `another site wears ${headerTokenWords(headerTokenOf(mix))}: this one is ${headerTokenWords(headerTokenOf(checked.mix))}` }] };
|
|
417
|
+
}
|
|
418
|
+
return { mix, repairs: [] };
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
type HeaderPlan = {
|
|
422
|
+
readonly business: { readonly name: string }; readonly design?: Readonly<Partial<DesignChoices>>;
|
|
423
|
+
readonly pages: ReadonlyArray<{ readonly name: string; readonly route: string; readonly inNav?: boolean; readonly isHome?: boolean; readonly sections?: ReadonlyArray<{ readonly binding?: string }> }>;
|
|
424
|
+
};
|
|
425
|
+
|
|
426
|
+
/** The shop's page of a selling plan: the page in the navigation that lists the store's products (else null). */
|
|
427
|
+
export function shopPageOfPlan(plan: HeaderPlan): string | null {
|
|
428
|
+
if (!planSells(plan)) return null;
|
|
429
|
+
const list = shopSourceAliases(plan)[ShopSourceRole.List];
|
|
430
|
+
return plan.pages.find(p => p.inNav && list && (p.sections ?? []).some(s => s.binding === list))?.route ?? null;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** The header context of a plan: its name, its look, its pages in the navigation and its shop page (found in the plan
|
|
434
|
+
* when not given). */
|
|
435
|
+
export function headerContextOfPlan(plan: HeaderPlan, shop?: string | null): HeaderContext {
|
|
436
|
+
return {
|
|
437
|
+
name: plan.business.name,
|
|
438
|
+
design: resolveDesignChoices(JSON.parse(JSON.stringify(plan.design ?? {}))),
|
|
439
|
+
pages: plan.pages.filter(p => p.inNav && !p.isHome && p.route !== '/').map(p => ({ name: p.name, route: p.route })),
|
|
440
|
+
shop: shop === undefined ? shopPageOfPlan(plan) : shop,
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
/**
|
|
445
|
+
* The header a plan's site WEARS (ONE rule for the composer, the fingerprint and the distinct check): its mix as the
|
|
446
|
+
* product draws it, judged against the site when the mix was chosen (`mixes.header`) — a stored header pattern (no mix)
|
|
447
|
+
* is worn as it always was (R-H4). With what was drawn as something else or mended, in words. Pure.
|
|
448
|
+
*/
|
|
449
|
+
export function wornHeaderOfPlan(plan: HeaderPlan & { readonly globals?: Readonly<Record<string, string>>; readonly mixes?: { readonly header?: ReadonlyArray<string> } }):
|
|
450
|
+
{ mix: HeaderMix; context: HeaderContext; said: string[] } {
|
|
451
|
+
const context = headerContextOfPlan(plan);
|
|
452
|
+
const { drawn, gaps } = drawnHeaderMix(headerMixOfPlan(plan));
|
|
453
|
+
const checked = plan.mixes?.header?.length ? checkHeader(drawn, context) : { mix: drawn, repairs: [] };
|
|
454
|
+
const said = [...gaps.map(g => `the header's ${g.ingredient} "${g.word}" is drawn as "${g.drawnAs}" until ${g.phase}`), ...checked.repairs.map(r => r.said)];
|
|
455
|
+
return { mix: checked.mix, context, said };
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
/** A plan's header made distinct (R-H2): `distinctHeader` over the plan's own mix as drawn and checked; the plan unchanged
|
|
459
|
+
* when nothing was mended, else with the new mix in `mixes.header`. Pure. */
|
|
460
|
+
export function withDistinctHeader<P extends HeaderPlan & {
|
|
461
|
+
readonly globals?: Readonly<Record<string, string>>; readonly mixes?: { readonly header?: ReadonlyArray<string>; readonly footer?: ReadonlyArray<string> };
|
|
462
|
+
}>(plan: P, taken: ReadonlyArray<string>): { plan: P; repairs: HeaderRepair[] } {
|
|
463
|
+
const worn = wornHeaderOfPlan(plan);
|
|
464
|
+
const done = distinctHeader(worn.mix, taken, worn.context);
|
|
465
|
+
if (!done.repairs.length) return { plan, repairs: [] };
|
|
466
|
+
return { plan: { ...plan, mixes: { ...(plan.mixes ?? {}), header: headerMixWords(done.mix) } }, repairs: done.repairs };
|
|
467
|
+
}
|
|
@@ -3,7 +3,7 @@ import { parseCssColour, relativeLuminance } from '@vectoriox/iox-ui/design-core
|
|
|
3
3
|
import { layoutPresetColours, splitSide } from './check-layout';
|
|
4
4
|
import { LayoutColour, LayoutIssue, LayoutIssueCode, LayoutLayerKind, LayoutListMix, LayoutListWho, LayoutPage, LayoutRole, LayoutSection, LayoutSectionKind, LayoutSize, LayoutTrackProp } from './layout-language';
|
|
5
5
|
import { FooterMix, footerMixOfPlan, footerTokenOf } from './footer-mix';
|
|
6
|
-
import { HeaderMix,
|
|
6
|
+
import { HeaderMix, headerTokenOf, wornHeaderOfPlan } from './header-mix';
|
|
7
7
|
import { PHOTO_LIGHT_LUMINANCE, PhotoTone } from './photo-inventory';
|
|
8
8
|
import { SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
9
9
|
|
|
@@ -164,8 +164,8 @@ export function fingerprintOf(page: LayoutPage, preset: string, mode: 'light' |
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
/** A composed page's fingerprint under its site plan's header and footer — the ONE call every reader of a plan makes. */
|
|
167
|
-
export function fingerprintOfPlanPage(page: LayoutPage, preset: string, mode: 'light' | 'dark', plan: Parameters<typeof footerMixOfPlan>[0]): LayoutFingerprint {
|
|
168
|
-
return fingerprintOf(page, preset, mode,
|
|
167
|
+
export function fingerprintOfPlanPage(page: LayoutPage, preset: string, mode: 'light' | 'dark', plan: Parameters<typeof wornHeaderOfPlan>[0] & Parameters<typeof footerMixOfPlan>[0]): LayoutFingerprint {
|
|
168
|
+
return fingerprintOf(page, preset, mode, wornHeaderOfPlan(plan).mix, footerMixOfPlan(plan));
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
/** The longest common subsequence of two sequences. */
|