@vectoriox/iox-ui 5.198.0 → 5.200.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/actions-core/index.d.ts +7 -1
- package/data-core/index.d.ts +11 -3
- package/design-core/index.d.ts +479 -52
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs +6 -1
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-data-core.mjs +30 -4
- package/fesm2022/vectoriox-iox-ui-data-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +704 -55
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-forms-core.mjs +5 -2
- package/fesm2022/vectoriox-iox-ui-forms-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +16659 -15146
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +653 -70
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +5 -2
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +883 -235
- package/harness-core/index.d.ts +372 -9
- package/package.json +1 -1
- package/src/actions-core/element-actions.ts +6 -0
- package/src/data-core/placeholder-rows.ts +29 -4
- package/src/design-core/brand-neutrals.ts +125 -3
- package/src/design-core/colour-words.ts +48 -0
- package/src/design-core/design-settings.ts +24 -5
- package/src/design-core/design-token.model.ts +8 -0
- package/src/design-core/flavor-fixtures.generated.ts +272 -2
- package/src/design-core/flavor-spec.generated.ts +310 -40
- package/src/design-core/flavor-tokens.ts +5 -1
- package/src/design-core/menu-look.ts +23 -0
- package/src/design-core/node-classes.ts +39 -0
- package/src/design-core/public-api.ts +2 -0
- package/src/design-core/signature-move.ts +107 -0
- package/src/design-core/style-presets.ts +9 -3
- package/src/design-core/token-css.ts +59 -1
- package/src/forms-core/form-presets.ts +5 -2
- package/src/generation-core/body-mix.ts +41 -0
- package/src/generation-core/check-free.ts +17 -9
- package/src/generation-core/check-layout.ts +17 -7
- package/src/generation-core/colour-mix.ts +53 -3
- package/src/generation-core/compose-free.ts +7 -2
- package/src/generation-core/compose-site.ts +298 -78
- package/src/generation-core/composition.ts +320 -0
- package/src/generation-core/footer-mix.ts +202 -16
- package/src/generation-core/footer-sign-up.ts +51 -0
- package/src/generation-core/free-opening.ts +13 -2
- package/src/generation-core/free-wire.ts +8 -0
- package/src/generation-core/header-edit.ts +15 -0
- package/src/generation-core/header-mix.ts +31 -2
- package/src/generation-core/legal.ts +24 -0
- package/src/generation-core/menu-shelves.ts +138 -0
- package/src/generation-core/nav-shape.ts +138 -15
- package/src/generation-core/node-baselines.generated.ts +1 -0
- package/src/generation-core/opening-edit.ts +17 -3
- package/src/generation-core/opening-mix.ts +69 -5
- package/src/generation-core/patterns.ts +7 -0
- package/src/generation-core/plan-wire.ts +23 -5
- package/src/generation-core/public-api.ts +3 -0
- package/src/generation-core/site-build-run.ts +11 -0
- package/src/generation-core/site-plan.model.ts +6 -0
- package/src/generation-core/site-spec.generated.ts +472 -166
- package/src/generation-core/type-led.ts +4 -2
- package/src/generation-core/validate-site-plan.ts +4 -1
- package/src/harness-core/business-types.ts +31 -0
- package/src/harness-core/harness-spec.generated.ts +564 -56
- package/src/harness-core/motion.ts +19 -2
- package/src/harness-core/popup-stance.ts +56 -3
- package/src/harness-core/run-compose-context.ts +32 -6
- package/src/harness-core/starting-design.ts +15 -7
- package/styles/iox-design.css +35 -0
- package/styles/iox-forms.css +53 -0
|
@@ -27,6 +27,10 @@ export enum FooterIngredient {
|
|
|
27
27
|
Ground = 'ground',
|
|
28
28
|
/** AW12 (AW12-D12): how the closing name is worn. Not in the fingerprint (AW12-D14). */
|
|
29
29
|
NameStyle = 'nameStyle',
|
|
30
|
+
/** FV1b (FV-D8, FV-D11): a block just before the footer's own that belongs to it — on every page, undone with it. */
|
|
31
|
+
Before = 'before',
|
|
32
|
+
/** FV1b: how the footer folds on a phone. */
|
|
33
|
+
Phone = 'phone',
|
|
30
34
|
}
|
|
31
35
|
|
|
32
36
|
/** The words, by the table (a word that waits for its phase too — `footerWords` offers only the drawn ones). */
|
|
@@ -102,6 +106,26 @@ export enum FooterNameStyle {
|
|
|
102
106
|
Script = 'script',
|
|
103
107
|
}
|
|
104
108
|
|
|
109
|
+
/** FV1b: what opens the footer before its own blocks. */
|
|
110
|
+
export enum FooterBefore {
|
|
111
|
+
None = 'none',
|
|
112
|
+
/** A contact-form area (FV-D11, mdscollective · mooov). */
|
|
113
|
+
ContactForm = 'contact-form',
|
|
114
|
+
/** A sign-up band (cancan; AW12 newsletter). */
|
|
115
|
+
NewsletterBand = 'newsletter-band',
|
|
116
|
+
/** Where and when to visit, as a band. */
|
|
117
|
+
Visit = 'visit',
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** FV1b: how the footer folds on a phone. */
|
|
121
|
+
export enum FooterPhone {
|
|
122
|
+
Stack = 'stack',
|
|
123
|
+
/** The link columns fold into accordions (stroms, schlosshotel; waits — a fold only a phone wears). */
|
|
124
|
+
Accordion = 'accordion',
|
|
125
|
+
/** The sign-up comes first on a phone (8pm; AW12 newsletter). */
|
|
126
|
+
First = 'first',
|
|
127
|
+
}
|
|
128
|
+
|
|
105
129
|
/** The roles a footer's parts carry — the contract's (`site.footerParts` and the stored footers), written to the node's
|
|
106
130
|
* `role`, a class `iox-role-<role>` both renderers emit. */
|
|
107
131
|
export enum FooterRole {
|
|
@@ -126,6 +150,15 @@ export enum FooterRole {
|
|
|
126
150
|
Halves = 'footer.halves',
|
|
127
151
|
/** FV1 `closing.email`: the owner's email set large, the contact link. */
|
|
128
152
|
Email = 'footer.email',
|
|
153
|
+
/** FV1b `holds.social`: the block, and each of its links (the contract part's template). */
|
|
154
|
+
Social = 'footer.social',
|
|
155
|
+
SocialLink = 'footer.social-link',
|
|
156
|
+
/** FV1b `holds.top`: the round button that scrolls to the page's top, at the end of the copyright row. */
|
|
157
|
+
Top = 'footer.top',
|
|
158
|
+
/** FV1b `before`: the block that opens the footer (the contact-form area, the visit band). */
|
|
159
|
+
Before = 'footer.before',
|
|
160
|
+
/** AW12 newsletter: the sign-up block, the band and the closing — the forms-core `newsletter` preset beside its words. */
|
|
161
|
+
Newsletter = 'footer.newsletter',
|
|
129
162
|
}
|
|
130
163
|
|
|
131
164
|
|
|
@@ -138,6 +171,9 @@ export interface FooterMix {
|
|
|
138
171
|
readonly ground: string;
|
|
139
172
|
/** AW12: absent = plain (a stored or hand-made mix written before the name had a style). */
|
|
140
173
|
readonly nameStyle?: string;
|
|
174
|
+
/** FV1b: absent = none / stack (every mix written before FV1b). */
|
|
175
|
+
readonly before?: string;
|
|
176
|
+
readonly phone?: string;
|
|
141
177
|
}
|
|
142
178
|
|
|
143
179
|
export class FooterMixError extends Error {}
|
|
@@ -170,7 +206,9 @@ export function footerWait(ingredient: `${FooterIngredient}`, word: string): Foo
|
|
|
170
206
|
*/
|
|
171
207
|
export const FOOTER_ROW_HOLDS: ReadonlySet<string> = new Set(F.rules.legalAlways ? [FooterHold.Legal] : []);
|
|
172
208
|
/** The blocks of a mix the recipe lays as parts (the legal row is compose-site's). */
|
|
173
|
-
|
|
209
|
+
/** FV1b: a hold the copyright row carries at its end (the back-to-top button) — never a column of its own. */
|
|
210
|
+
const BOTTOM_HOLDS: ReadonlySet<string> = new Set([FooterHold.Top]);
|
|
211
|
+
const partHolds = (holds: ReadonlyArray<string>): string[] => holds.filter(h => !FOOTER_ROW_HOLDS.has(h) && !BOTTOM_HOLDS.has(h));
|
|
174
212
|
|
|
175
213
|
/** The words an ingredient may take — the DRAWN ones, the only ones the wire, the brief and the mender offer
|
|
176
214
|
* (ingredients.md §3.3: offering a waiting word would put its stand-in on every site that asked for it). The legal row
|
|
@@ -209,21 +247,27 @@ export function namedFooterMix(patternId: string): FooterMix | null {
|
|
|
209
247
|
|
|
210
248
|
/** The stored footer pattern a mix is exactly, else null. */
|
|
211
249
|
export function footerPatternIdOf(mix: FooterMix): string | null {
|
|
212
|
-
const key = footerTokenOf(mix) + JSON.stringify(mix.holds) + nameStyleOf(mix);
|
|
250
|
+
const key = footerTokenOf(mix) + JSON.stringify(mix.holds) + nameStyleOf(mix) + beforeOf(mix) + phoneOf(mix);
|
|
213
251
|
return Object.keys(F.named).find(id => {
|
|
214
252
|
const m = namedFooterMix(id)!;
|
|
215
|
-
return footerTokenOf(m) + JSON.stringify(m.holds) + nameStyleOf(m) === key;
|
|
253
|
+
return footerTokenOf(m) + JSON.stringify(m.holds) + nameStyleOf(m) + beforeOf(m) + phoneOf(m) === key;
|
|
216
254
|
}) ?? null;
|
|
217
255
|
}
|
|
218
256
|
|
|
219
257
|
/** The name's style of a mix (absent = plain). */
|
|
220
258
|
export const nameStyleOf = (mix: Pick<FooterMix, 'nameStyle'>): string => mix.nameStyle ?? FooterNameStyle.Plain;
|
|
259
|
+
/** FV1b: what opens the footer (absent = none) and how it folds on a phone (absent = stack). */
|
|
260
|
+
export const beforeOf = (mix: Pick<FooterMix, 'before'>): string => mix.before ?? FooterBefore.None;
|
|
261
|
+
export const phoneOf = (mix: Pick<FooterMix, 'phone'>): string => mix.phone ?? FooterPhone.Stack;
|
|
221
262
|
|
|
222
263
|
/** A mix on the wire: ONE list of `<ingredient>:<word>` words (the list wire's encoding), `holds` once per block. A plain
|
|
223
264
|
* name says nothing (`nameStyle:plain` is every mix's), so a mix stored before AW12 reads and writes the same words. */
|
|
224
265
|
export function footerMixWords(mix: FooterMix): string[] {
|
|
225
266
|
return Object.values(FooterIngredient).flatMap(k => {
|
|
226
267
|
if (k === FooterIngredient.NameStyle) return nameStyleOf(mix) === FooterNameStyle.Plain ? [] : [`${k}:${nameStyleOf(mix)}`];
|
|
268
|
+
// FV1b: nothing before and a stacked phone are every mix's, so a mix stored before FV1b reads and writes the same words.
|
|
269
|
+
if (k === FooterIngredient.Before) return beforeOf(mix) === FooterBefore.None ? [] : [`${k}:${beforeOf(mix)}`];
|
|
270
|
+
if (k === FooterIngredient.Phone) return phoneOf(mix) === FooterPhone.Stack ? [] : [`${k}:${phoneOf(mix)}`];
|
|
227
271
|
return (MANY.includes(k) ? mix[k] as ReadonlyArray<string> : [mix[k] as string]).map(w => `${k}:${w}`);
|
|
228
272
|
});
|
|
229
273
|
}
|
|
@@ -248,7 +292,8 @@ export function drawnFooterMix(mix: FooterMix): { mix: FooterMix; waited: Array<
|
|
|
248
292
|
// In the table's order, so the words that waited are said as the table reads.
|
|
249
293
|
const arrange = one(FooterIngredient.Arrange);
|
|
250
294
|
const holds = inOrder(FooterIngredient.Holds, mix.holds.map(h => drawn(FooterIngredient.Holds, h)).filter((h): h is string => !!h));
|
|
251
|
-
const out = { arrange, holds, closing: one(FooterIngredient.Closing), ground: one(FooterIngredient.Ground), nameStyle: one(FooterIngredient.NameStyle)
|
|
295
|
+
const out = { arrange, holds, closing: one(FooterIngredient.Closing), ground: one(FooterIngredient.Ground), nameStyle: one(FooterIngredient.NameStyle),
|
|
296
|
+
before: one(FooterIngredient.Before), phone: one(FooterIngredient.Phone) };
|
|
252
297
|
return { mix: waited.length ? out : mix, waited };
|
|
253
298
|
}
|
|
254
299
|
|
|
@@ -351,6 +396,19 @@ export enum FooterRepairCode {
|
|
|
351
396
|
EmailTooLong = 'email-too-long',
|
|
352
397
|
/** FV1: halves need a block in the end zone — none held: drawn as columns. */
|
|
353
398
|
HalvesEmpty = 'halves-empty',
|
|
399
|
+
/** FV1b: the social block lists the owner's stated links on a network it can name — none: left out; past
|
|
400
|
+
* `socialMax`, or on no known network: those left out. */
|
|
401
|
+
SocialWithoutLinks = 'social-without-links',
|
|
402
|
+
SocialLeftOut = 'social-left-out',
|
|
403
|
+
/** FV1b: a visit band before the footer says where and when — the visit block is not said twice. */
|
|
404
|
+
VisitBeforeTwice = 'visit-before-twice',
|
|
405
|
+
/** AW12-D6 (H1): a sign-up only where the site has a reason to write (a journal, events, a shop, a kind of business
|
|
406
|
+
* whose references close with one, the owner's newsletter tick) — none: the sign-up is left out, said. */
|
|
407
|
+
NoReasonToWrite = 'no-reason-to-write',
|
|
408
|
+
/** AW12 newsletter: one sign-up per footer — the band before it, else the closing, else the block it holds. */
|
|
409
|
+
SignUpTwice = 'sign-up-twice',
|
|
410
|
+
/** AW12 newsletter: the sign-up first on a phone needs a sign-up block — none held: the blocks stack. */
|
|
411
|
+
FirstWithoutSignUp = 'first-without-sign-up',
|
|
354
412
|
}
|
|
355
413
|
|
|
356
414
|
export interface FooterRepair {
|
|
@@ -387,9 +445,14 @@ export interface FooterContext {
|
|
|
387
445
|
never?: FooterNever | null;
|
|
388
446
|
/** FV1 `closing.email`: the owner's email (the plan's `facts.email`) — none given, the footer never closes with one. */
|
|
389
447
|
email?: string;
|
|
448
|
+
/** FV1b `holds.social`: the owner's social links as stated (the plan's `business.social`) — none, no social block. */
|
|
449
|
+
social?: ReadonlyArray<string>;
|
|
390
450
|
/** The tier the site is built at. Since AW-D42 it mends no word (every tier wears every drawn word); kept so its
|
|
391
451
|
* callers still read. */
|
|
392
452
|
tier?: `${GenerationTier}`;
|
|
453
|
+
/** AW12-D6: whether the site has a reason to write (`planWrites`, footer-sign-up.ts) — false: no sign-up, said
|
|
454
|
+
* (`no-reason-to-write`). Absent = not judged (a stored footer, the builder's own). */
|
|
455
|
+
writes?: boolean;
|
|
393
456
|
}
|
|
394
457
|
|
|
395
458
|
/** The phone the closing name must fit (the render check's). */
|
|
@@ -449,6 +512,49 @@ function statementPhoneLines(tagline: string, ctx: FooterContext): number {
|
|
|
449
512
|
return Math.ceil((widthEm(tagline, ctx) * size) / room);
|
|
450
513
|
}
|
|
451
514
|
|
|
515
|
+
/** FV1b (FV-D10): a network the footer can name a social link by — the contract's `FOOTER.socialNetworks`. */
|
|
516
|
+
export interface FooterSocialNetwork { readonly id: string; readonly name: string; readonly hosts: ReadonlyArray<string> }
|
|
517
|
+
export const FOOTER_SOCIAL_NETWORKS = (F as unknown as { socialNetworks: ReadonlyArray<FooterSocialNetwork> }).socialNetworks;
|
|
518
|
+
|
|
519
|
+
/** One social link the footer shows: the network's name and the owner's address (https). */
|
|
520
|
+
export interface FooterSocialLink { readonly network: string; readonly name: string; readonly url: string }
|
|
521
|
+
|
|
522
|
+
/** The host an address is on, bare (no `www.` / `m.`), or null when it is no http(s) address. */
|
|
523
|
+
function socialAddress(raw: string): URL | null {
|
|
524
|
+
const word = raw.trim().replace(/[.,;:!?)\]]+$/, '').replace(/^[(\[<]+/, '');
|
|
525
|
+
if (!word) return null;
|
|
526
|
+
const scheme = /^[a-z][a-z0-9+.-]*:/i.exec(word)?.[0].toLowerCase();
|
|
527
|
+
if (scheme && scheme !== 'http:' && scheme !== 'https:') return null;
|
|
528
|
+
try {
|
|
529
|
+
const url = new URL(scheme ? word : `https://${word}`);
|
|
530
|
+
url.protocol = 'https:';
|
|
531
|
+
return url;
|
|
532
|
+
} catch {
|
|
533
|
+
return null;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* FV1b (FV-D10, rule 3 + 4): the owner's stated social addresses as the links a footer shows — each on a network the
|
|
539
|
+
* footer can name (by its host), a profile (a path past the host), once per network, in the table's order, at most
|
|
540
|
+
* `socialMax`. Everything else is `leftOut` (and said): the footer never shows a link it cannot name, and never one the
|
|
541
|
+
* owner did not state. An entry may hold several addresses (a stated line, space- or comma-separated). Pure.
|
|
542
|
+
*/
|
|
543
|
+
export function footerSocialLinks(addresses?: ReadonlyArray<string> | null): { links: FooterSocialLink[]; leftOut: string[] } {
|
|
544
|
+
const found = new Map<string, FooterSocialLink>();
|
|
545
|
+
const leftOut: string[] = [];
|
|
546
|
+
for (const raw of (addresses ?? []).flatMap(a => String(a).split(/[\s,]+/)).filter(Boolean)) {
|
|
547
|
+
const url = socialAddress(raw);
|
|
548
|
+
const host = url?.hostname.toLowerCase().replace(/^(www|m)\./, '');
|
|
549
|
+
const network = host ? FOOTER_SOCIAL_NETWORKS.find(n => n.hosts.some(h => host === h || host.endsWith(`.${h}`))) : undefined;
|
|
550
|
+
if (!url || !network || url.pathname.replace(/\/+$/, '') === '' || found.has(network.id)) { leftOut.push(raw); continue; }
|
|
551
|
+
found.set(network.id, { network: network.id, name: network.name, url: url.href });
|
|
552
|
+
}
|
|
553
|
+
const links = FOOTER_SOCIAL_NETWORKS.map(n => found.get(n.id)).filter((l): l is FooterSocialLink => !!l);
|
|
554
|
+
const max = rule('socialMax');
|
|
555
|
+
return { links: links.slice(0, max), leftOut: [...leftOut, ...links.slice(max).map(l => l.url)] };
|
|
556
|
+
}
|
|
557
|
+
|
|
452
558
|
/** True when the call word cannot stand on a phone even split over two balanced lines. */
|
|
453
559
|
function wordTooWide(word: string, ctx: FooterContext): boolean {
|
|
454
560
|
const halves = word.split(/\s+/);
|
|
@@ -491,7 +597,7 @@ export function checkFooter(given: FooterMix, ctx: FooterContext): { mix: Footer
|
|
|
491
597
|
ground = FooterGround.Inverse;
|
|
492
598
|
}
|
|
493
599
|
if (arrange === FooterArrange.Line) {
|
|
494
|
-
const kept = holds.filter(h => (F.rules.lineHolds as ReadonlyArray<string>).includes(h));
|
|
600
|
+
const kept = holds.filter(h => (F.rules.lineHolds as ReadonlyArray<string>).includes(h) || BOTTOM_HOLDS.has(h));
|
|
495
601
|
const left = holds.filter(h => !kept.includes(h));
|
|
496
602
|
if (left.length) say(FooterRepairCode.LineHolds, `a one-line footer holds only ${F.rules.lineHolds.join(' and ')}: ${left.join(' and ')} left out`);
|
|
497
603
|
holds = kept;
|
|
@@ -547,6 +653,40 @@ export function checkFooter(given: FooterMix, ctx: FooterContext): { mix: Footer
|
|
|
547
653
|
say(FooterRepairCode.EmbossNeedsBrand, `${capital(an(nameStyle))} name is a copy of the name the brand block says, and this footer has none: plain`);
|
|
548
654
|
nameStyle = FooterNameStyle.Plain;
|
|
549
655
|
}
|
|
656
|
+
if (holds.includes(FooterHold.Social)) {
|
|
657
|
+
// FV1b (rule 3 + 4, FV-D10): only the links the owner stated, each on a network the footer can name.
|
|
658
|
+
const links = footerSocialLinks(ctx.social);
|
|
659
|
+
if (!links.links.length) {
|
|
660
|
+
say(FooterRepairCode.SocialWithoutLinks, 'the social block lists the owner\'s own links and none was stated: left out');
|
|
661
|
+
holds = holds.filter(h => h !== FooterHold.Social);
|
|
662
|
+
}
|
|
663
|
+
if (links.leftOut.length) say(FooterRepairCode.SocialLeftOut, `${links.leftOut.map(a => `"${a}"`).join(', ')} left out of the social links (${links.links.length ? `past ${rule('socialMax')} or ` : ''}on no network the footer can name)`);
|
|
664
|
+
}
|
|
665
|
+
if (beforeOf(mix) === FooterBefore.Visit && holds.includes(FooterHold.Visit)) {
|
|
666
|
+
say(FooterRepairCode.VisitBeforeTwice, 'the band before the footer says where and when: the visit block is not said twice');
|
|
667
|
+
holds = holds.filter(h => h !== FooterHold.Visit);
|
|
668
|
+
}
|
|
669
|
+
// AW12 newsletter: a sign-up only with a reason to write (AW12-D6), and one per footer — the band before it first.
|
|
670
|
+
let before = beforeOf(mix);
|
|
671
|
+
let phone = phoneOf(mix);
|
|
672
|
+
const signsUp = (): boolean => before === FooterBefore.NewsletterBand || closing === FooterClosing.Newsletter || holds.includes(FooterHold.Newsletter);
|
|
673
|
+
if (ctx.writes === false && signsUp()) {
|
|
674
|
+
say(FooterRepairCode.NoReasonToWrite, 'a sign-up asks people to hear from the business, and this site has nothing to write about yet (no journal, events or shop): left out');
|
|
675
|
+
if (before === FooterBefore.NewsletterBand) before = FooterBefore.None;
|
|
676
|
+
if (closing === FooterClosing.Newsletter) closing = FooterClosing.Call;
|
|
677
|
+
holds = holds.filter(h => h !== FooterHold.Newsletter);
|
|
678
|
+
}
|
|
679
|
+
const twice = [before === FooterBefore.NewsletterBand, closing === FooterClosing.Newsletter, holds.includes(FooterHold.Newsletter)].filter(Boolean).length > 1;
|
|
680
|
+
if (twice) {
|
|
681
|
+
say(FooterRepairCode.SignUpTwice, `a footer asks people to sign up once: the sign-up ${before === FooterBefore.NewsletterBand ? 'band before it' : 'it opens on'} stays`);
|
|
682
|
+
if (before === FooterBefore.NewsletterBand && closing === FooterClosing.Newsletter) closing = FooterClosing.Call;
|
|
683
|
+
holds = holds.filter(h => h !== FooterHold.Newsletter);
|
|
684
|
+
}
|
|
685
|
+
if (phone === FooterPhone.First && !holds.includes(FooterHold.Newsletter)) {
|
|
686
|
+
// The band and the closing already come first; only a held block is moved, so without one the blocks stack.
|
|
687
|
+
if (!signsUp()) say(FooterRepairCode.FirstWithoutSignUp, 'the sign-up first on a phone needs a sign-up, and this footer holds none: the blocks stack');
|
|
688
|
+
phone = FooterPhone.Stack;
|
|
689
|
+
}
|
|
550
690
|
if (arrange === FooterArrange.Halves && !partHolds(holds).length) {
|
|
551
691
|
say(FooterRepairCode.HalvesEmpty, 'halves need a block beside the name and the footer holds none: drawn as columns');
|
|
552
692
|
arrange = FooterArrange.Columns;
|
|
@@ -555,7 +695,7 @@ export function checkFooter(given: FooterMix, ctx: FooterContext): { mix: Footer
|
|
|
555
695
|
say(FooterRepairCode.Empty, 'a footer that holds nothing holds the pages');
|
|
556
696
|
holds = inOrder(FooterIngredient.Holds, [FooterHold.Pages, ...holds]);
|
|
557
697
|
}
|
|
558
|
-
return { mix: { ...mix, holds, closing, arrange, nameStyle, ground }, repairs };
|
|
698
|
+
return { mix: { ...mix, holds, closing, arrange, nameStyle, ground, before, phone }, repairs };
|
|
559
699
|
}
|
|
560
700
|
|
|
561
701
|
// ── The recipe: the mix arranged from the contract's parts ─────────────────────────────────────────────────────────
|
|
@@ -630,9 +770,23 @@ function emailLine(email: string, ctx: FooterContext): PatternNode {
|
|
|
630
770
|
return laid(part('email'), { fontSize: columnSize(widthEm(email, ctx, 'link-display'), ctx) });
|
|
631
771
|
}
|
|
632
772
|
|
|
773
|
+
/** FV1b `holds.social`: the part's template link once per stated link — the network's name, the owner's address. */
|
|
774
|
+
function socialPart(ctx: FooterContext): PatternNode {
|
|
775
|
+
const links = footerSocialLinks(ctx.social).links;
|
|
776
|
+
const fill = (n: PatternNode): PatternNode => {
|
|
777
|
+
const template = (n.c ?? []).find(k => k.role === FooterRole.SocialLink);
|
|
778
|
+
if (template) return { ...n, c: links.map(l => ({ ...template, text: l.name, href: l.url })) };
|
|
779
|
+
return n.c ? { ...n, c: n.c.map(fill) } : n;
|
|
780
|
+
};
|
|
781
|
+
return fill(part(FooterHold.Social));
|
|
782
|
+
}
|
|
783
|
+
|
|
633
784
|
/** A block it holds: how to reach the business leaves its city to the visit block when the footer holds both. */
|
|
634
|
-
function holdPart(hold: string, mix: FooterMix): PatternNode {
|
|
785
|
+
function holdPart(hold: string, mix: FooterMix, ctx: FooterContext): PatternNode {
|
|
786
|
+
if (hold === FooterHold.Social) return socialPart(ctx);
|
|
635
787
|
const node = part(hold);
|
|
788
|
+
// AW12 `phone.first` (8pm): on a phone the sign-up stands before the footer's other blocks — an order, never a copy.
|
|
789
|
+
if (hold === FooterHold.Newsletter) return phoneOf(mix) === FooterPhone.First ? { ...node, resp: { ...(node.resp ?? {}), mobile: { ...(node.resp?.['mobile'] ?? {}), order: '-1' } } } : node;
|
|
636
790
|
if (hold !== FooterHold.Contact || !mix.holds.includes(FooterHold.Visit)) return node;
|
|
637
791
|
return { ...node, c: (node.c ?? []).filter(n => n.ph !== 'city') };
|
|
638
792
|
}
|
|
@@ -650,23 +804,53 @@ function bigPages(ctx: FooterContext): PatternNode[] {
|
|
|
650
804
|
return [big, { ...rest, c: (rest.c ?? []).map(n => (n.each ? { ...n, skip: rule('listBigLarge') } : n)) }];
|
|
651
805
|
}
|
|
652
806
|
|
|
807
|
+
/** FV1b `holds.top`: the copyright row — the back-to-top button at its end when the footer holds it (never a column). */
|
|
808
|
+
function bottomRow(mix: FooterMix, copyright: PatternNode, justify = 'space-between'): PatternNode {
|
|
809
|
+
if (!mix.holds.includes(FooterHold.Top)) return copyright;
|
|
810
|
+
return { t: 'Container', es: 'box', lay: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', justifyContent: justify, gap: GAP },
|
|
811
|
+
c: [laid(copyright, { width: 'auto' }), part(FooterHold.Top)] };
|
|
812
|
+
}
|
|
813
|
+
|
|
814
|
+
/** FV1b `before` (FV-D11): the block that opens the footer, on every page with it — the contact-form area under the kind of
|
|
815
|
+
* business's call line, or where and when as a band — and a rule under it. */
|
|
816
|
+
function beforeBlock(mix: FooterMix, ctx: FooterContext): PatternNode[] {
|
|
817
|
+
switch (beforeOf(mix)) {
|
|
818
|
+
case FooterBefore.ContactForm: {
|
|
819
|
+
const node = part('contact-form');
|
|
820
|
+
const line = footerCallLine(ctx.type);
|
|
821
|
+
const lineHe = footerCallLine(ctx.type, 'he');
|
|
822
|
+
const c = (node.c ?? []).map(n => (n.slot === 'beforeTitle' && line ? { ...n, text: line, ...(lineHe ? { textHe: lineHe } : {}) } : n));
|
|
823
|
+
return [{ ...node, c }, part('rule')];
|
|
824
|
+
}
|
|
825
|
+
case FooterBefore.NewsletterBand:
|
|
826
|
+
// AW12 newsletter (cancan): the sign-up as a band that opens the footer, a rule under it.
|
|
827
|
+
return [part('newsletter-band'), part('rule')];
|
|
828
|
+
case FooterBefore.Visit:
|
|
829
|
+
return [{ t: 'Container', es: 'box', role: FooterRole.Before, lay: { display: 'flex', flexWrap: 'wrap', alignItems: 'baseline', justifyContent: 'space-between', gap: GAP },
|
|
830
|
+
c: part(FooterHold.Visit).c ?? [] }, part('rule')];
|
|
831
|
+
default:
|
|
832
|
+
return [];
|
|
833
|
+
}
|
|
834
|
+
}
|
|
835
|
+
|
|
653
836
|
/** The body: the blocks it holds, arranged. */
|
|
654
837
|
function bodyOf(mix: FooterMix, ctx: FooterContext): PatternNode[] {
|
|
655
|
-
const holds = partHolds(mix.holds).map(h => holdPart(h, mix));
|
|
838
|
+
const holds = partHolds(mix.holds).map(h => holdPart(h, mix, ctx));
|
|
656
839
|
switch (mix.arrange) {
|
|
657
840
|
case FooterArrange.Line: {
|
|
658
841
|
const row: PatternNode = { t: 'Container', es: 'box', lay: { display: 'flex', flexWrap: 'wrap', alignItems: 'center', justifyContent: 'space-between', gap: GAP }, c: [
|
|
659
842
|
laid(part('copyright'), { width: 'auto' }),
|
|
660
843
|
...(mix.holds.includes(FooterHold.Pages) ? [part('pageRow')] : []),
|
|
844
|
+
...(mix.holds.includes(FooterHold.Top) ? [part(FooterHold.Top)] : []),
|
|
661
845
|
] };
|
|
662
846
|
return [row];
|
|
663
847
|
}
|
|
664
848
|
case FooterArrange.Centred: {
|
|
665
|
-
const blocks = partHolds(mix.holds).map(h => (h === FooterHold.Pages ? laid(part('pageRow'), { justifyContent: 'center' }) : centred(holdPart(h, mix))));
|
|
849
|
+
const blocks = partHolds(mix.holds).map(h => (h === FooterHold.Pages ? laid(part('pageRow'), { justifyContent: 'center' }) : centred(holdPart(h, mix, ctx))));
|
|
666
850
|
return [
|
|
667
851
|
{ t: 'Container', es: 'box', lay: { display: 'flex', flexDirection: 'column', gap: '28px', ...CENTRED }, c: [centred(brandPart(ctx, mix)), ...blocks] },
|
|
668
852
|
part('rule'),
|
|
669
|
-
laid(part('copyright'), { textAlign: 'center' }),
|
|
853
|
+
bottomRow(mix, laid(part('copyright'), { textAlign: 'center' }), 'center'),
|
|
670
854
|
];
|
|
671
855
|
}
|
|
672
856
|
case FooterArrange.Ruled: {
|
|
@@ -675,16 +859,16 @@ function bodyOf(mix: FooterMix, ctx: FooterContext): PatternNode[] {
|
|
|
675
859
|
const cells = [brandPart(ctx, mix), ...holds];
|
|
676
860
|
const n = Math.min(cells.length, rule('ruledCells'));
|
|
677
861
|
return [{ t: 'Container', es: 'box', role: FooterRole.Ruled, lay: { display: 'grid', gridTemplateColumns: `repeat(${n}, minmax(0, 1fr))`, gap: `${GAP} 0px` },
|
|
678
|
-
resp: { tablet: { gridTemplateColumns: 'repeat(2, minmax(0, 1fr))' }, mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } }, c: cells }, part('rule'), part('copyright')];
|
|
862
|
+
resp: { tablet: { gridTemplateColumns: 'repeat(2, minmax(0, 1fr))' }, mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } }, c: cells }, part('rule'), bottomRow(mix, part('copyright'))];
|
|
679
863
|
}
|
|
680
864
|
case FooterArrange.ListBig: {
|
|
681
|
-
const others = partHolds(mix.holds).filter(h => h !== FooterHold.Pages).map(h => holdPart(h, mix));
|
|
865
|
+
const others = partHolds(mix.holds).filter(h => h !== FooterHold.Pages).map(h => holdPart(h, mix, ctx));
|
|
682
866
|
const pages = mix.holds.includes(FooterHold.Pages) ? bigPages(ctx) : [];
|
|
683
867
|
return [{ t: 'Container', es: 'box', lay: { display: 'grid', gridTemplateColumns: 'minmax(0, 3fr) minmax(0, 2fr)', gap: GAP, alignItems: 'end' },
|
|
684
868
|
resp: { mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } }, c: [
|
|
685
869
|
{ t: 'Container', es: 'box', lay: { display: 'flex', flexDirection: 'column', gap: GAP }, c: pages },
|
|
686
870
|
{ t: 'Container', es: 'box', lay: { display: 'flex', flexDirection: 'column', gap: GAP }, c: [brandPart(ctx, mix), ...others] },
|
|
687
|
-
] }, part('rule'), part('copyright')];
|
|
871
|
+
] }, part('rule'), bottomRow(mix, part('copyright'))];
|
|
688
872
|
}
|
|
689
873
|
case FooterArrange.Halves: {
|
|
690
874
|
// FV1 (footer-v2 §2, after thepopuphotel and allerstudio): the brand at the start, the blocks in columns at the
|
|
@@ -692,10 +876,10 @@ function bodyOf(mix: FooterMix, ctx: FooterContext): PatternNode[] {
|
|
|
692
876
|
const end: PatternNode = { t: 'Container', es: 'box', lay: { display: 'grid', gridTemplateColumns: `repeat(${Math.max(holds.length, 1)}, minmax(0, 1fr))`, gap: GAP },
|
|
693
877
|
resp: { mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } }, c: holds };
|
|
694
878
|
return [{ t: 'Container', es: 'box', role: FooterRole.Halves, lay: { display: 'grid', gridTemplateColumns: 'minmax(0, 1fr) minmax(0, 1fr)', gap: '0px' },
|
|
695
|
-
resp: { mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } }, c: [brandPart(ctx, mix), end] }, part('rule'), part('copyright')];
|
|
879
|
+
resp: { mobile: { gridTemplateColumns: 'minmax(0, 1fr)' } }, c: [brandPart(ctx, mix), end] }, part('rule'), bottomRow(mix, part('copyright'))];
|
|
696
880
|
}
|
|
697
881
|
default:
|
|
698
|
-
return [{ t: 'Container', es: 'box', ...columnsOf(holds.length), c: [brandPart(ctx, mix), ...holds] }, part('rule'), part('copyright')];
|
|
882
|
+
return [{ t: 'Container', es: 'box', ...columnsOf(holds.length), c: [brandPart(ctx, mix), ...holds] }, part('rule'), bottomRow(mix, part('copyright'))];
|
|
699
883
|
}
|
|
700
884
|
}
|
|
701
885
|
|
|
@@ -728,11 +912,13 @@ export function footerPattern(given: FooterMix, ctx: FooterContext): SitePattern
|
|
|
728
912
|
[FooterClosing.Statement]: () => [part('statement')],
|
|
729
913
|
[FooterClosing.Word]: () => [callWord(ctx)],
|
|
730
914
|
[FooterClosing.Email]: () => (ctx.email?.trim() ? [emailLine(ctx.email.trim(), ctx)] : []),
|
|
915
|
+
// AW12 `closing.newsletter` (enigma): the footer opens on the sign-up, in the call's place.
|
|
916
|
+
[FooterClosing.Newsletter]: () => [mix.arrange === FooterArrange.Centred ? centred(part('newsletter-band')) : part('newsletter-band')],
|
|
731
917
|
} as Readonly<Record<string, () => PatternNode[]>>;
|
|
732
918
|
const before = opens[mix.closing]?.() ?? [];
|
|
733
919
|
const body = mix.closing === FooterClosing.NameAndAction ? endOf(mix, ctx) : bodyOf(mix, ctx);
|
|
734
920
|
const name = mix.closing === FooterClosing.Name ? [closingName(ctx, mix)] : [];
|
|
735
|
-
const c = [...(plain ? [part('rule')] : []), ...before, ...body, ...name];
|
|
921
|
+
const c = [...(plain ? [part('rule')] : []), ...beforeBlock(mix, ctx), ...before, ...body, ...name];
|
|
736
922
|
// The contract's shell; a Section with one child does not stack it (the patterns' rule, build-spec "more than one child").
|
|
737
923
|
const { lay, ...shell } = part('section');
|
|
738
924
|
const scheme = GROUND_SCHEME[mix.ground] ?? null;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { beforeOf, FooterArrange, FooterBefore, FooterClosing, FooterHold, FooterMix, footerTableWords, FooterIngredient } from './footer-mix';
|
|
2
|
+
import { planSells } from './shop-plan';
|
|
3
|
+
import { SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* AW12 newsletter (award-ingredients-plan §7.1g, AW12-D6): a footer asks people to sign up only where the site has a reason
|
|
7
|
+
* to write, and a kind of business whose references close with a sign-up gets one when its plan's footer has none — the
|
|
8
|
+
* same plan composes the same footer, so a rebuild from a kept plan picks the sign-up up with no model call. The sign-up is
|
|
9
|
+
* the forms-core `newsletter` preset: stored, sent nowhere (no third-party list, AW12-D6). Pure.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
const WRITES_WORDS = (SPEC_SITE_LAYOUT.footer.rules as unknown as { writesWords: ReadonlyArray<string> }).writesWords;
|
|
13
|
+
/** A Hebrew word may carry one prefix letter before its stem (ו ה ב ל מ ש כ). */
|
|
14
|
+
const HE_PREFIX = '[והבלמשכ]?';
|
|
15
|
+
const escape = (w: string): string => w.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
16
|
+
const WRITES_RE = new RegExp(`(?:^|[^\\p{L}])${HE_PREFIX}(?:${WRITES_WORDS.map(escape).join('|')})`, 'iu');
|
|
17
|
+
|
|
18
|
+
/** What `planWrites` reads of a plan: its content types, its shop and the owner's popup ticks. */
|
|
19
|
+
export interface WritingPlan {
|
|
20
|
+
readonly contentTypes?: ReadonlyArray<{ readonly name: string; readonly label?: string }>;
|
|
21
|
+
readonly shop?: unknown;
|
|
22
|
+
readonly popup?: { readonly newsletter?: boolean } | null;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* AW12-D6: whether the site has a reason to write — it sells (a shop's new pieces), its kind of business closes with a
|
|
27
|
+
* sign-up (`typeSignUp`, harness FOOTER_SIGNUP: a hotel's seasons, a salon's offers), the owner ticked the newsletter popup,
|
|
28
|
+
* or one of its content types is a journal, events or news (the contract's `FOOTER.rules.writesWords`, at a word's start).
|
|
29
|
+
*/
|
|
30
|
+
export function planWrites(plan: WritingPlan, typeSignUp?: boolean): boolean {
|
|
31
|
+
if (typeSignUp || plan.popup?.newsletter === true || planSells(plan)) return true;
|
|
32
|
+
return (plan.contentTypes ?? []).some(t => WRITES_RE.test(t.name) || WRITES_RE.test(t.label ?? ''));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** True when a mix asks people to sign up anywhere — the band before it, the closing, or a block it holds. */
|
|
36
|
+
export function footerSignsUp(mix: FooterMix): boolean {
|
|
37
|
+
return beforeOf(mix) === FooterBefore.NewsletterBand || mix.closing === FooterClosing.Newsletter || mix.holds.includes(FooterHold.Newsletter);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The type's sign-up (team/reference-cards row 6: hotel 3/3, store 3/3, ceramics 2/3, salon 2/3): a footer that asks for no
|
|
42
|
+
* sign-up holds one when the kind of business closes with one AND the site has a reason to write. A footer that already
|
|
43
|
+
* signs up keeps its own; a one-line footer and a name-and-action footer have no place for a block (`checkFooter` would
|
|
44
|
+
* leave it out), so they are left as the plan wrote them. Pure: the same mix when nothing changes.
|
|
45
|
+
*/
|
|
46
|
+
export function withTypeSignUp(mix: FooterMix, given: { readonly signUp?: boolean; readonly writes?: boolean }): FooterMix {
|
|
47
|
+
if (!given.signUp || given.writes === false || footerSignsUp(mix)) return mix;
|
|
48
|
+
if (mix.arrange === FooterArrange.Line || mix.closing === FooterClosing.NameAndAction) return mix;
|
|
49
|
+
const holds = footerTableWords(FooterIngredient.Holds).filter(h => h === FooterHold.Newsletter || mix.holds.includes(h));
|
|
50
|
+
return { ...mix, holds };
|
|
51
|
+
}
|
|
@@ -46,9 +46,20 @@ export interface FreeOpeningOffer {
|
|
|
46
46
|
|
|
47
47
|
/** What a free page's opening is offered, and whether it must open on a picture. */
|
|
48
48
|
export function freeOpeningOffer(site: FreeOpeningSite): FreeOpeningOffer {
|
|
49
|
-
|
|
49
|
+
const refused = picturesRefusedOf(site.reading);
|
|
50
|
+
if (!site.home || refused === PicturesRefused.All) return { boxes: [], opensOnPicture: false };
|
|
50
51
|
if (site.ownPhotos > 0) return { boxes: [], opensOnPicture: true };
|
|
51
|
-
return site.stockAllowed &&
|
|
52
|
+
return site.stockAllowed && refused !== PicturesRefused.Stock ? { boxes: [...FREE_OPENING_BOXES], opensOnPicture: true } : { boxes: [], opensOnPicture: false };
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** What the owner ruled out of pictures: every picture, or stock only (their own photos may still stand). */
|
|
56
|
+
export enum PicturesRefused { All = 'all', Stock = 'stock' }
|
|
57
|
+
|
|
58
|
+
/** What the owner refused of pictures, read ONCE (the free offer and the build's opening ask the same): `all` — "no
|
|
59
|
+
* pictures" (`PromptLimit.NoPictures`); `stock` — "no stock photos" (only their own may stand); else null. Pure. */
|
|
60
|
+
export function picturesRefusedOf(reading: PromptReading | null | undefined): PicturesRefused | null {
|
|
61
|
+
if (promptLimitsOf(reading).includes(PromptLimit.NoPictures)) return PicturesRefused.All;
|
|
62
|
+
return refusesStock(reading) ? PicturesRefused.Stock : null;
|
|
52
63
|
}
|
|
53
64
|
|
|
54
65
|
/** Is a material id a picture box (`box:<shape>`)? */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { COLOR_SCHEME_TYPES, schemeOfGround } from '@vectoriox/iox-ui/design-core';
|
|
2
|
+
|
|
1
3
|
import { JsonSchema, jsonClosedObject, jsonInteger, jsonListOf, jsonOneOf, jsonText } from './json-schema';
|
|
2
4
|
import { isPlainObject, PlainObject } from './shape-check';
|
|
3
5
|
|
|
@@ -73,6 +75,12 @@ export const FREE_BUILDER_TYPE: Readonly<Record<FreeNodeType, string>> = {
|
|
|
73
75
|
[FreeNodeType.Slot]: 'Container',
|
|
74
76
|
};
|
|
75
77
|
|
|
78
|
+
/** The scheme the stamp gives a free box (iox-ui#186): the scheme its painted ground is (`schemeOfGround`), on a type that
|
|
79
|
+
* offers one — the stamp and the tree check read this ONE answer. */
|
|
80
|
+
export function freeSchemeOf(n: FreeNode): string | null {
|
|
81
|
+
return COLOR_SCHEME_TYPES.includes(FREE_BUILDER_TYPE[n.type]) ? schemeOfGround(n.styleProps?.['backgroundColor']) : null;
|
|
82
|
+
}
|
|
83
|
+
|
|
76
84
|
/** The one role a free node may carry: the heading a visitor reads first. */
|
|
77
85
|
export const FREE_LEAD_ROLE = 'lead';
|
|
78
86
|
|
|
@@ -52,10 +52,25 @@ function pagesOfHeader(current: SerializedNode, companions: ReadonlyArray<Serial
|
|
|
52
52
|
* pages). Only a header that links to no page takes the studio's. A header that holds the bag or the account entry is a
|
|
53
53
|
* selling site's (unless the site says). Pure.
|
|
54
54
|
*/
|
|
55
|
+
/** Whether the header's brand shows a picture (an Image with an address) — the logo a hanging name needs (HI3-D21). */
|
|
56
|
+
function brandHasPicture(current: SerializedNode): boolean {
|
|
57
|
+
let found = false;
|
|
58
|
+
const walk = (n: SerializedNode, inBrand: boolean): void => {
|
|
59
|
+
if (found) return;
|
|
60
|
+
const here = inBrand || n.role === NavRole.Brand;
|
|
61
|
+
if (here && n.type === 'Image' && typeof n.props?.['src'] === 'string' && (n.props['src'] as string).trim()) { found = true; return; }
|
|
62
|
+
(n.children ?? []).forEach(c => walk(c, here));
|
|
63
|
+
};
|
|
64
|
+
walk(current, false);
|
|
65
|
+
return found;
|
|
66
|
+
}
|
|
67
|
+
|
|
55
68
|
export function headerSiteFor(site: HeaderSite, current: SerializedNode, companions: ReadonlyArray<SerializedNode> = []): HeaderSite {
|
|
56
69
|
let at = site;
|
|
57
70
|
const own = pagesOfHeader(current, companions);
|
|
58
71
|
if (own.length) at = { ...at, pages: own };
|
|
72
|
+
// HI3-D21: a hanging name needs a logo picture — the header's own brand says whether it has one.
|
|
73
|
+
if (at.logo === undefined) at = { ...at, logo: brandHasPicture(current) };
|
|
59
74
|
if (at.storeSlots !== undefined) return at;
|
|
60
75
|
let sells = false;
|
|
61
76
|
const walk = (n: SerializedNode): void => { if (n.role && STORE_SLOT_ROLES.has(n.role)) sells = true; (n.children ?? []).forEach(walk); };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DesignChoices, designTokenRows, elementStyleFace, HeaderBrand, HeaderGround, headerGroundIsGlass, headerGroundIsOver, HeaderShape, headerShapeFloats, HeaderTrait, MenuForm, menuButtonOf, menuFormOf, menuHoverOf, MenuLook, MenuPhoneForm,
|
|
3
|
-
menuRevealOf, parseHexColor, resolveDesignChoices, resolveSchemeTokenValues, resolveTokenValues, ResolvedMode, textWidthEm, wcagContrastRatio,
|
|
3
|
+
menuRevealOf, MenuShows, menuShowsOf, parseHexColor, resolveDesignChoices, resolveSchemeTokenValues, resolveTokenValues, ResolvedMode, textWidthEm, wcagContrastRatio,
|
|
4
4
|
} from '@vectoriox/iox-ui/design-core';
|
|
5
5
|
|
|
6
|
+
import { menuCollectionsOfPlan, ShelfPlan } from './menu-shelves';
|
|
6
7
|
import { MenuSide, NavRole, NavShape } from './nav-shape';
|
|
7
8
|
import { OpeningMixError, openingMixOfPlan, OpeningRole } from './opening-mix';
|
|
8
9
|
import { calmUnder, PhotoInventory } from './photo-inventory';
|
|
@@ -295,6 +296,10 @@ export enum HeaderRepairCode {
|
|
|
295
296
|
NoLogo = 'no-logo',
|
|
296
297
|
/** HI3-D25: a kind of business that keeps its header plain never takes islands or a late name. */
|
|
297
298
|
TypeNeverShape = 'type-never-shape',
|
|
299
|
+
/** HI2: pictured cards stand in a top panel, a full screen or a mega panel — never a drawer or a card: the page names. */
|
|
300
|
+
PicturesForm = 'pictures-form',
|
|
301
|
+
/** HI2: pictured cards need the site's main collections with pictures (`menuPicturesMin`): the page names. */
|
|
302
|
+
FewCollections = 'few-collections',
|
|
298
303
|
}
|
|
299
304
|
|
|
300
305
|
export interface HeaderRepair {
|
|
@@ -342,12 +347,16 @@ export interface HeaderContext {
|
|
|
342
347
|
readonly never?: HeaderNever | null;
|
|
343
348
|
/** HI3-D21: the brand has a logo picture (a hanging name needs one). Absent: none known — a hanging name fits. */
|
|
344
349
|
readonly logo?: boolean | null;
|
|
350
|
+
/** HI2: the site's main collections with pictures (`menuCollectionsOfPlan`), in the navigation's order — what a
|
|
351
|
+
* `pictures` menu shows a card for. Absent: not judged. */
|
|
352
|
+
readonly collections?: ReadonlyArray<HeaderPage>;
|
|
345
353
|
}
|
|
346
354
|
|
|
347
355
|
const RULES = H.rules as unknown as Readonly<{
|
|
348
356
|
menuMinLinks: number; pinnedMax: number; inlineRoomPx: number; betweenNameEm: number; betweenMinPages: number;
|
|
349
357
|
overFrames: ReadonlyArray<string>; overMedia: ReadonlyArray<string>; glassFlavors: ReadonlyArray<string>;
|
|
350
358
|
glassIsOwnBar: ReadonlyArray<string>; noEdgeGrounds: ReadonlyArray<string>;
|
|
359
|
+
menuPicturesForms: ReadonlyArray<string>; menuPicturesMin: number;
|
|
351
360
|
}>;
|
|
352
361
|
/** 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
|
|
353
362
|
* the brand's size, each page at the link's, the gap between them, and a button's padding around its words. */
|
|
@@ -410,6 +419,7 @@ export function checkHeader(mix: HeaderMix, ctx: HeaderContext): { mix: HeaderMi
|
|
|
410
419
|
m.action = HeaderAction.Button;
|
|
411
420
|
say(HeaderRepairCode.OneDestination, 'two actions need two places to go (the contact page and the shop): one button');
|
|
412
421
|
}
|
|
422
|
+
mendShelf(m, ctx, say);
|
|
413
423
|
mendGround(m, ctx, say);
|
|
414
424
|
mendShape(m, ctx, say);
|
|
415
425
|
return { mix: m, repairs };
|
|
@@ -443,6 +453,23 @@ function mendShape(m: HeaderMix, ctx: HeaderContext, say: (code: HeaderRepairCod
|
|
|
443
453
|
}
|
|
444
454
|
}
|
|
445
455
|
|
|
456
|
+
/** HI2 (plan §6): what the menu shows, as the site can carry it — pictured cards only in a menu wide enough to hold them
|
|
457
|
+
* beside the page names (Vonder's top panel, a full screen, a mega panel) and only for the collections the site has. */
|
|
458
|
+
function mendShelf(m: HeaderMix, ctx: HeaderContext, say: (code: HeaderRepairCode, said: string) => void): void {
|
|
459
|
+
if (menuShowsOf(m.menuShows) !== MenuShows.Pictures) return;
|
|
460
|
+
const form = menuLookOf(m).form;
|
|
461
|
+
if (!(RULES.menuPicturesForms ?? []).includes(form)) {
|
|
462
|
+
m.menuShows = MenuShows.Links;
|
|
463
|
+
say(HeaderRepairCode.PicturesForm, `pictured cards need a top panel, a full screen or a mega panel — not a ${form}: the menu shows the page names`);
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
const count = ctx.collections?.length;
|
|
467
|
+
if (count !== undefined && count < RULES.menuPicturesMin) {
|
|
468
|
+
m.menuShows = MenuShows.Links;
|
|
469
|
+
say(HeaderRepairCode.FewCollections, `pictured cards need ${RULES.menuPicturesMin} collections with pictures — the site has ${count}: the menu shows the page names`);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
446
473
|
/** HI3-D12: does the home page open on a picture the header can stand over — the contract's frames and media. */
|
|
447
474
|
export function opensOnPicture(opening: HeaderOpening | null | undefined): boolean {
|
|
448
475
|
return !!opening && RULES.overFrames.includes(opening.frame) && RULES.overMedia.includes(opening.media);
|
|
@@ -708,6 +735,7 @@ export function menuLookOf(mix: HeaderMix): MenuLook {
|
|
|
708
735
|
button: menuButtonOf(mix.button),
|
|
709
736
|
hover: menuHoverOf(mix.menuHover),
|
|
710
737
|
phone: phoneFull && form !== MenuForm.Full ? MenuPhoneForm.Full : MenuPhoneForm.Drawer,
|
|
738
|
+
shows: menuShowsOf(mix.menuShows),
|
|
711
739
|
};
|
|
712
740
|
}
|
|
713
741
|
|
|
@@ -768,7 +796,7 @@ export function distinctHeader(mix: HeaderMix, taken: ReadonlyArray<string>, ctx
|
|
|
768
796
|
return { mix, repairs: [] };
|
|
769
797
|
}
|
|
770
798
|
|
|
771
|
-
type HeaderPlan = {
|
|
799
|
+
type HeaderPlan = ShelfPlan & {
|
|
772
800
|
readonly business: { readonly name: string }; readonly design?: Readonly<Partial<DesignChoices>>;
|
|
773
801
|
readonly mixes?: { readonly opening?: ReadonlyArray<string> };
|
|
774
802
|
readonly pages: ReadonlyArray<{ readonly name: string; readonly route: string; readonly inNav?: boolean; readonly isHome?: boolean; readonly sections?: ReadonlyArray<{ readonly binding?: string }> }>;
|
|
@@ -808,6 +836,7 @@ export function headerContextOfPlan(plan: HeaderPlan, shop?: string | null, fact
|
|
|
808
836
|
pages: plan.pages.filter(p => p.inNav && !p.isHome && p.route !== '/').map(p => ({ name: p.name, route: p.route })),
|
|
809
837
|
shop: shop === undefined ? shopPageOfPlan(plan) : shop,
|
|
810
838
|
opening: headerOpeningOfPlan(plan),
|
|
839
|
+
collections: menuCollectionsOfPlan(plan).map(c => ({ name: c.label, route: c.route })),
|
|
811
840
|
...(facts.never ? { never: facts.never } : {}),
|
|
812
841
|
...(facts.readableAtRest !== undefined && facts.readableAtRest !== null ? { readableAtRest: facts.readableAtRest } : {}),
|
|
813
842
|
};
|
|
@@ -173,6 +173,9 @@ export interface LegalContext {
|
|
|
173
173
|
/** ISO 3166-1 alpha-2 — the studio's country (Shop ▸ Settings; a shekel studio starts in Israel). Absent = unknown. */
|
|
174
174
|
country?: string | null;
|
|
175
175
|
trackers?: ReadonlyArray<LegalTracker>;
|
|
176
|
+
/** The site will count its visitors (the studio's or the plan's analytics intent) even before a tracker is connected:
|
|
177
|
+
* it gets its cookie banner and privacy page as a site with an analytics tracker does (`siteMeasures`). */
|
|
178
|
+
measures?: boolean | null;
|
|
176
179
|
/** The studio's own legal pages, by kind: their route. The build links them and never stamps that kind again. */
|
|
177
180
|
existing?: Readonly<Partial<Record<`${LegalKind}`, string>>>;
|
|
178
181
|
/** Every route the studio already has — a stamped legal page never takes one. */
|
|
@@ -211,3 +214,24 @@ export function legalFormLine(lang: string | null | undefined, withTerms: boolea
|
|
|
211
214
|
if (at < template.length) parts.push({ text: template.slice(at) });
|
|
212
215
|
return parts;
|
|
213
216
|
}
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Whether a site MEASURES its visitors (Doron 2026-11-28: "a privacy banner on every site that measures visitors") — a
|
|
220
|
+
* connected tracker, or the intent to count visitors. THE rule the build's banner, its privacy page and its categories
|
|
221
|
+
* read, so a site never measures before it asks. Pure.
|
|
222
|
+
*/
|
|
223
|
+
export function siteMeasures(context: Pick<LegalContext, 'trackers' | 'measures'> | null | undefined): boolean {
|
|
224
|
+
return (context?.trackers?.length ?? 0) > 0 || context?.measures === true;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** The categories a measuring site's banner asks a yes for, each once (Necessary never): its trackers' — or Analytics
|
|
228
|
+
* alone when it measures with none connected yet. */
|
|
229
|
+
export function measuredCategories(context: Pick<LegalContext, 'trackers' | 'measures'> | null | undefined): ConsentCategory[] {
|
|
230
|
+
const out: ConsentCategory[] = [];
|
|
231
|
+
for (const t of context?.trackers ?? []) {
|
|
232
|
+
const c = t.category as ConsentCategory;
|
|
233
|
+
if (c !== ConsentCategory.Necessary && !out.includes(c)) out.push(c);
|
|
234
|
+
}
|
|
235
|
+
if (!out.length && siteMeasures(context)) out.push(ConsentCategory.Analytics);
|
|
236
|
+
return out;
|
|
237
|
+
}
|