@vectoriox/iox-ui 5.90.1 → 5.91.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.
@@ -1,6 +1,6 @@
1
1
  import { DesignMode } from './design-token.model';
2
2
  import { SPEC_A11Y, SPEC_SCHEMES } from './flavor-spec.generated';
3
- import { SCHEME_INK } from './node-classes';
3
+ import { openingFollowerSelector, SCHEME_INK } from './node-classes';
4
4
  import { specTokenNames } from './token-names';
5
5
 
6
6
  /**
@@ -98,7 +98,7 @@ const media = (query: string, rules: ReadonlyArray<string>): string => {
98
98
  };
99
99
 
100
100
  const schemeSelector = (id: string, scope?: string) =>
101
- scope ? `${scope} .iox-scheme-${id}` : `.iox-scheme-${id}`;
101
+ `${openingFollowerSelector(id, scope)}, ${scope ? `${scope} .iox-scheme-${id}` : `.iox-scheme-${id}`}`;
102
102
 
103
103
  const nonDefaultSchemes = (): ReadonlyArray<[string, Readonly<Record<string, string>>]> =>
104
104
  Object.entries(SPEC_SCHEMES)
@@ -262,9 +262,23 @@ export function compileSchemeCss(
262
262
  .map((t): [string, string] => [t.name, t.value]),
263
263
  ])),
264
264
  schemeInkRule(scope),
265
+ rows.some(t => t.name === NAV_BG) ? openingGroundRule(scope) : '',
265
266
  ].filter(Boolean).join('\n');
266
267
  }
267
268
 
269
+ const NAV_BG = 'nav-bg';
270
+
271
+ /**
272
+ * The header that follows the opening (vectoriox/iox-ui#71) stands on the scheme's ground, opaque: a glass look's
273
+ * translucent bar (`color-mix(bg 72%, transparent)`) sits over the PAGE's ground, not the band's, and wearing the band's
274
+ * ink on that mix it read at ~1:1. `!important` so the dark and reduced-transparency twins, emitted later, cannot put
275
+ * the mix back.
276
+ */
277
+ function openingGroundRule(scope?: string): string {
278
+ const selectors = nonDefaultSchemes().map(([id]) => openingFollowerSelector(id, scope));
279
+ return selectors.length ? `${selectors.join(', ')} {\n --iox-${NAV_BG}: var(--iox-bg) !important;\n}` : '';
280
+ }
281
+
268
282
  /**
269
283
  * Every element wearing a scheme takes the scheme's ink (vectoriox/iox-ui#15): the tokens re-resolve inside
270
284
  * it, but `color` is inherited as a COMPUTED value, so without this a scheme'd Container's running text kept
@@ -274,7 +288,8 @@ export function compileSchemeCss(
274
288
  */
275
289
  function schemeInkRule(scope?: string): string {
276
290
  const where = scope ? `:where(${scope}) ` : '';
277
- const selectors = nonDefaultSchemes().map(([id]) => `${where}.iox-scheme-${id}`);
291
+ const ids = nonDefaultSchemes().map(([id]) => id);
292
+ const selectors = [...ids.map(id => `:where(${openingFollowerSelector(id, scope)})`), ...ids.map(id => `${where}.iox-scheme-${id}`)];
278
293
  return selectors.length ? `${selectors.join(', ')} {\n color: ${SCHEME_INK};\n}` : '';
279
294
  }
280
295
 
@@ -8,12 +8,16 @@ import {
8
8
  } from './layout-language';
9
9
  import { DriftBox, driftOverlap, layoutGlideDepth } from './layout-drift';
10
10
  import { layoutLookOf } from './layout-look';
11
- import { patternById } from './patterns';
11
+ import { patternById, SCENE_LEVEL } from './patterns';
12
12
  import { layoutDesignOf, screenWordMisfit } from './layout-type';
13
13
  import { sectionEntrances } from './entrances';
14
14
  import { calmParts, calmUnder, FrameRegion, PhotoInventory, PHOTO_LIGHT_LUMINANCE } from './photo-inventory';
15
15
  import { SerializedNode, walkSerialized } from './serialized-node';
16
16
  import { SPEC_SITE_FACTS, SPEC_SITE_LAYOUT } from './site-spec.generated';
17
+ import {
18
+ LAYOUT_CHECK_VIEWPORT, LAYOUT_DRIFT, LAYOUT_KINETIC_KINDS, LAYOUT_LINE_HEIGHT, layoutBoxPx, layoutDriftPhoto, layoutHeldStill, layoutOpeningDisplayMend, layoutOpeningDisplays, layoutShapeHasPurpose,
19
+ layoutStillLine, layoutTextFits, layoutVoidScreens, layoutVoids,
20
+ } from './layout-space';
17
21
 
18
22
  /**
19
23
  * THE STATIC LAYOUT GATE (premium components M8 gate 2, M8-G2-D6; the prototype's `check` + `check21`, `code/cl2.mjs` and
@@ -108,22 +112,17 @@ export function layoutPresetColours(presetId: string, mode: 'light' | 'dark'): L
108
112
 
109
113
  // ── Geometry ────────────────────────────────────────────────────────────────────────────────────────────
110
114
 
111
- /**
112
- * The laptop the estimates are made on (the render check's 1440 × 900). A grid column is taken as 1440 / 12 px and a row
113
- * as its section's screens × 900 / rows (a held section's grid is its one-screen stage): the gutter and the column gaps
114
- * are left out, so a box reads about a fifth wider than it renders — the render check measures the real one.
115
- */
116
- export const LAYOUT_CHECK_VIEWPORT = { width: 1440, height: 900 } as const;
117
115
  const GRID = 12;
118
116
  const COLUMN_PX = LAYOUT_CHECK_VIEWPORT.width / GRID;
119
- /** A line of words stands its size × this tall. */
120
- const LINE_HEIGHT = 1.2;
121
117
  /** WCAG's large text (≥ 24 px): 3:1 is enough. */
122
118
  const LARGE_TEXT_PX = 24;
123
119
  const CONTRAST_LARGE = 3;
124
120
  const CONTRAST_BODY = 4.5;
125
121
  /** The prototype's numbers the contract does not carry yet. */
126
122
  const TRACK_SCALE_MAX = 1.3;
123
+
124
+ /** A section that holds the page: held two screens or more, or sideways. */
125
+ const isHold = (s: LayoutSection) => !!s.pin && (s.screens >= 2 || (s.track ?? 1) > 1);
127
126
  const INNER_MAX = 3;
128
127
  const BEAT_MAX = 5;
129
128
  const POP_WORDS = 3;
@@ -135,7 +134,6 @@ const START_CLIP_MIN = 40;
135
134
  const HIDDEN_CLIP = 30;
136
135
  /** A button or section that reads as a way to reach the business (the prototype's words, English and Hebrew). */
137
136
  const CONTACT_WORDS = /contact|book|reserve|visit|table|sign.?up|enquir|צור|הזמ|קשר|שולחן|ביקור|הרשמ/i;
138
- const HEBREW = /[֐-׿]/;
139
137
  const LATIN_SENTENCE = /[A-Za-z]{3,}(\s+[A-Za-z]{3,}){2,}/;
140
138
  const NUMBER_GIVEN = /\d[\d:.,]{2,}|[$₪€£]\s?\d+/g;
141
139
  const CHIP_NUMBER = /\d{2,}|[$₪€£]/;
@@ -160,11 +158,7 @@ const isText = (l: LayoutLayer) => LAYOUT_TEXT_KINDS.has(l.kind);
160
158
  const isPictured = (l: LayoutLayer) => l.kind === LayoutLayerKind.Photo || l.kind === LayoutLayerKind.Gallery;
161
159
  const contrastOf = (a: number, b: number) => (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);
162
160
 
163
- /** A grid box's size in px on the laptop. */
164
- function boxPx(col: readonly number[], row: readonly number[], s: LayoutSection): { w: number; h: number } {
165
- const height = (s.pin ? 1 : s.screens) * LAYOUT_CHECK_VIEWPORT.height;
166
- return { w: span(col) * COLUMN_PX, h: (span(row) * height) / Math.max(1, s.rows) };
167
- }
161
+ const boxPx = layoutBoxPx;
168
162
 
169
163
  /** A section of one photo on one side and words on the other: 'start' | 'end' | null (the prototype's `splitSide`). */
170
164
  export function splitSide(s: LayoutSection): 'start' | 'end' | null {
@@ -346,6 +340,7 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
346
340
  let screenWords = 0;
347
341
  let wordsOnPhoto = 0;
348
342
  let holds = 0;
343
+ const allHolds = sections.filter(isHold).length;
349
344
  let pinned = 0;
350
345
  let marquees = 0;
351
346
  let boxes = 0;
@@ -383,7 +378,7 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
383
378
  const layers = Array.isArray(s.layers) ? s.layers : [];
384
379
  if (!layers.length) add(LayoutIssueCode.Structure, `${at}.layers`, 'at least one layer');
385
380
  if (s.pin) pinned++;
386
- if (s.pin && (s.screens >= 2 || track > 1)) holds++;
381
+ if (isHold(s)) holds++;
387
382
  if (i === 0 && daring && splitSide(s)) add(LayoutIssueCode.Daring, at, 'a daring page never opens on a split (photo one side, words the other) — break it');
388
383
  const phone = Array.isArray(s.phone) ? s.phone : [];
389
384
  if (phone.length !== layers.length || new Set(phone).size !== layers.length || phone.some(n => !(Number.isInteger(n) && n >= 0 && n < layers.length))) {
@@ -445,14 +440,9 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
445
440
  if ((l.size === 'm' || l.size === 's') && text.length > LIM.longTextChars && span(l.col) > LIM.longTextColumns) {
446
441
  add(LayoutIssueCode.Reading, `${lp}.col`, `long text is never wider than ${LIM.longTextColumns} columns`);
447
442
  }
448
- if (placed && isText(l) && l.size && l.size !== 'screen' && text) {
449
- const px = L.sizePx[l.size];
450
- const box = boxPx(l.col, l.row, s);
451
- const lines = Math.floor(box.h / (px * LINE_HEIGHT));
452
- const advance = HEBREW.test(text) ? LIM.advance.hebrew : LIM.advance.latin;
453
- const items = l.kind === LayoutLayerKind.List ? Math.max(1, l.items?.length ?? 1) : 1;
454
- const fits = lines >= items && (text.length * px * advance) / Math.max(1, lines) <= box.w * LIM.textFitSlack;
455
- if (!fits) add(LayoutIssueCode.Reading, `${lp}.row`, `${text.length} characters at ${l.size} do not fit a box of ${span(l.col)} columns × ${span(l.row)} rows (about ${Math.max(0, lines)} line${lines === 1 ? '' : 's'}) — give it more rows or columns, or fewer words`);
443
+ if (placed && isText(l) && l.size && l.size !== 'screen' && text && !layoutTextFits(l, s)) {
444
+ const lines = Math.floor(boxPx(l.col, l.row, s).h / (L.sizePx[l.size] * LAYOUT_LINE_HEIGHT));
445
+ add(LayoutIssueCode.Reading, `${lp}.row`, `${text.length} characters at ${l.size} do not fit a box of ${span(l.col)} columns × ${span(l.row)} rows (about ${Math.max(0, lines)} line${lines === 1 ? '' : 's'}) — give it more rows or columns, or fewer words`);
456
446
  }
457
447
  if (l.size === 'screen' || l.size === 'xxl') huge++;
458
448
  if (l.size === 'screen') {
@@ -484,6 +474,10 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
484
474
  if ((l.motion ?? []).some(m => m.prop !== LayoutTrackProp.Opacity)) add(LayoutIssueCode.Motion, `${lp}.motion`, 'decoration only fades — opacity tracks only');
485
475
  if (l.depth === 'front') add(LayoutIssueCode.Motion, `${lp}.depth`, 'decoration never runs ahead — back or mid');
486
476
  }
477
+ if (l.kind === LayoutLayerKind.Shape && !layoutShapeHasPurpose(s, j)) {
478
+ add(LayoutIssueCode.Look, lp, 'a shape that is there for nothing — not a rule (one row high), a band, a frame for a picture or a ground for words, and it does not move: an empty box on the page',
479
+ { kind: LayoutMendKind.Drop, layer: lp });
480
+ }
487
481
  if (l.role === LayoutRole.Static && ((l.enter && l.enter !== LayoutEnter.None) || l.motion?.length || deep)) add(LayoutIssueCode.Motion, `${lp}.role`, 'a static layer has no enter, motion or depth');
488
482
 
489
483
  if (l.rotate) {
@@ -518,7 +512,7 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
518
512
  });
519
513
  if (shows.length && hides.length && Math.max(...hides) > Math.max(...shows)) add(LayoutIssueCode.Motion, `${lp}.motion`, 'it leaves more slowly than it arrived — an exit is shorter than the entrance');
520
514
  if (l.kinetic) {
521
- if (l.kind !== LayoutLayerKind.Word && l.kind !== LayoutLayerKind.Heading) add(LayoutIssueCode.Value, `${lp}.kinetic`, 'only a word or heading');
515
+ if (!LAYOUT_KINETIC_KINDS.has(l.kind)) add(LayoutIssueCode.Value, `${lp}.kinetic`, 'only a word, a heading or a line of text');
522
516
  if (wordsOf(l.text) > LIM.kineticWords) add(LayoutIssueCode.Look, `${lp}.kinetic`, `${wordsOf(l.text)} words — kinetic words hold at most ${LIM.kineticWords}`);
523
517
  if (!s.pin) add(LayoutIssueCode.Motion, `${lp}.kinetic`, 'kinetic words light by the scroll of a HELD section');
524
518
  }
@@ -663,6 +657,16 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
663
657
  if (ctx.locale === 'he' && LATIN_SENTENCE.test(plain)) add(LayoutIssueCode.Content, `${lp}.text`, 'the site is Hebrew — write it in Hebrew');
664
658
  }
665
659
  });
660
+ if (layoutHeldStill(s)) {
661
+ const line = layoutStillLine(s);
662
+ const photo = layoutDriftPhoto(s);
663
+ // A daring page needs its holds: letting this one flow would trade the still screen for a page that holds too little.
664
+ const spare = !daring || allHolds - Number(isHold(s)) >= LIM.daring.holds - carried.holds;
665
+ add(LayoutIssueCode.Motion, at, 'it holds the page and nothing in it moves by the scroll — a held section plays: light its line word by word (kinetic), give a layer a track, or let it flow',
666
+ line >= 0 ? { kind: LayoutMendKind.Words, layer: `${at}.layers[${line}]` }
667
+ : spare ? { kind: LayoutMendKind.Unpin, section: i }
668
+ : photo >= 0 ? { kind: LayoutMendKind.Drift, layer: `${at}.layers[${photo}]` } : undefined);
669
+ }
666
670
  if (limits.rotatedPerSectionMax !== undefined && rotated > limits.rotatedPerSectionMax) add(LayoutIssueCode.Look, at, `${rotated} rotated layers — at most ${limits.rotatedPerSectionMax}`);
667
671
  if (i === 0 && limits.firstButtonsMax !== undefined && layers.filter(l => l.kind === LayoutLayerKind.Button).length > limits.firstButtonsMax) {
668
672
  add(LayoutIssueCode.Look, at, `at most ${limits.firstButtonsMax} button in the first section`);
@@ -678,6 +682,22 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
678
682
  }
679
683
  }
680
684
  });
685
+ const voids = layoutVoids(sections);
686
+ const voidScreens = voids.length ? layoutVoidScreens(sections) : null;
687
+ for (const v of voids) {
688
+ add(LayoutIssueCode.Look, `sections[${v.sections[0]}]`, `${Math.round(v.to - v.from)}px of the laptop's screen with nothing on it (${v.sections.map(i => sections[i].id).join(' → ')}) — a section that flows fills its screens: fewer screens, or layers where the eye would land`,
689
+ voidScreens ? { kind: LayoutMendKind.Screens, sections: voidScreens } : undefined);
690
+ }
691
+ const opening = layoutOpeningDisplays(page);
692
+ if ((daring || ctx.design?.animate === SCENE_LEVEL) && sections[0] && !sections[0].readyMade) {
693
+ if (!opening.length) {
694
+ const display = layoutOpeningDisplayMend(page);
695
+ add(LayoutIssueCode.Daring, 'sections[0]', 'the opening has no display — a daring page opens on one thing set large: a word, or a heading at xxl or screen size',
696
+ display ? { kind: LayoutMendKind.Display, layer: `sections[0].layers[${display.layer}]`, ...(display.size ? { size: display.size } : {}) } : undefined);
697
+ } else if (opening.length > 1) {
698
+ add(LayoutIssueCode.Look, 'sections[0]', `${opening.length} displays in the opening — one moment: one word or one large heading`);
699
+ }
700
+ }
681
701
  if (ctx.first && !reachable) add(LayoutIssueCode.Content, 'sections', 'nothing lets people reach the business — a form, or a button to one');
682
702
  if (galleries < LIM.galleriesMin - carried.galleries) add(LayoutIssueCode.Structure, 'sections', `${galleries} galleries — at least ${LIM.galleriesMin}`);
683
703
  if (LIM.galleriesMin > 0 && galleries && !swappable && !carried.swappable) add(LayoutIssueCode.Structure, 'sections', 'no gallery can be dragged or swiped — at least one without "scroll"');
@@ -953,6 +973,7 @@ const MEND_ROLE_ORDER: ReadonlyArray<`${LayoutRole}` | undefined> = [LayoutRole.
953
973
  */
954
974
  export function mendLayout(page: LayoutPage, issues: ReadonlyArray<LayoutIssue>): { page: LayoutPage; mended: LayoutIssue[] } {
955
975
  const mended: LayoutIssue[] = [];
976
+ const drops: LayoutIssue[] = [];
956
977
  if (!issues.some(i => i.mend)) return { page, mended };
957
978
  const next = structuredClone(page) as LayoutPage;
958
979
  const layerAt = (path: string): LayoutLayer | undefined => {
@@ -988,7 +1009,45 @@ export function mendLayout(page: LayoutPage, issues: ReadonlyArray<LayoutIssue>)
988
1009
  if (!layer?.gallery) continue;
989
1010
  layer.gallery.source = mend.source;
990
1011
  mended.push(issue);
1012
+ } else if (mend?.kind === LayoutMendKind.Words) {
1013
+ const layer = layerAt(mend.layer);
1014
+ if (!layer) continue;
1015
+ layer.kinetic = true;
1016
+ mended.push(issue);
1017
+ } else if (mend?.kind === LayoutMendKind.Display) {
1018
+ const layer = layerAt(mend.layer);
1019
+ if (!layer) continue;
1020
+ layer.kind = LayoutLayerKind.Word;
1021
+ if (mend.size) layer.size = mend.size;
1022
+ mended.push(issue);
1023
+ } else if (mend?.kind === LayoutMendKind.Drift) {
1024
+ const layer = layerAt(mend.layer);
1025
+ if (!layer) continue;
1026
+ layer.motion = [...(layer.motion ?? []), { ...LAYOUT_DRIFT, at: [...LAYOUT_DRIFT.at] as [number, number] }];
1027
+ mended.push(issue);
1028
+ } else if (mend?.kind === LayoutMendKind.Unpin) {
1029
+ const section = next.sections?.[mend.section];
1030
+ if (!section) continue;
1031
+ section.pin = false;
1032
+ delete section.track;
1033
+ section.screens = 1;
1034
+ mended.push(issue);
1035
+ } else if (mend?.kind === LayoutMendKind.Screens) {
1036
+ if (mend.sections.some(m => !next.sections?.[m.section])) continue;
1037
+ for (const m of mend.sections) next.sections[m.section].screens = m.screens;
1038
+ mended.push(issue);
1039
+ } else if (mend?.kind === LayoutMendKind.Drop && layerAt(mend.layer)) {
1040
+ drops.push(issue);
991
1041
  }
992
1042
  }
1043
+ // Last, so every path above still names the layer it was found at: the empty shapes leave, the latest first.
1044
+ const dropAt = (i: LayoutIssue) => /^sections\[(\d+)\]\.layers\[(\d+)\]$/.exec((i.mend as { layer: string }).layer)!.slice(1).map(Number);
1045
+ for (const issue of [...drops].sort((a, b) => dropAt(b)[0] - dropAt(a)[0] || dropAt(b)[1] - dropAt(a)[1])) {
1046
+ const [si, li] = dropAt(issue);
1047
+ const section = next.sections[si];
1048
+ section.layers.splice(li, 1);
1049
+ if (Array.isArray(section.phone)) section.phone = section.phone.filter(n => n !== li).map(n => (n > li ? n - 1 : n));
1050
+ mended.push(issue);
1051
+ }
993
1052
  return { page: mended.length ? next : page, mended };
994
1053
  }
@@ -10,6 +10,7 @@ import {
10
10
  screenFontSize,
11
11
  } from './layout-language';
12
12
  import { layoutGlideDepth } from './layout-drift';
13
+ import { isLayoutRule, layoutRuleEdge } from './layout-space';
13
14
  import { layoutDesignOf, layoutElementStyle, layoutTextWidthEm, screenWordColumns } from './layout-type';
14
15
  import { ComposeError, createSerializedNode, SerializedNode, setStyleProps, assertStyleSlots, walkSerialized } from './serialized-node';
15
16
 
@@ -132,6 +133,8 @@ const GALLERY_SPEED = 900;
132
133
  const GALLERY_STACKED_ASPECT = '4 / 5';
133
134
  const FULL = '100%';
134
135
  const ZERO = '0px';
136
+ /** A rule's line: the looks' hairline. */
137
+ const RULE_PX = '1px';
135
138
  const PHONE_GROUND_BRIGHTNESS = '0.75';
136
139
  const GALLERY_BAR_TOP = '12px';
137
140
  const STRETCH_KINDS: ReadonlySet<string> = new Set([LayoutLayerKind.Photo, LayoutLayerKind.Shape, LayoutLayerKind.Gallery, LayoutLayerKind.Form]);
@@ -589,11 +592,22 @@ function buttonLayer(id: string, l: LayoutLayer, ctx: Ctx): SerializedNode {
589
592
  * scheme re-declares those tokens for that band; on the page's own ground (or the soft one) they wear none. */
590
593
  const BAND_SCHEME_ON: Readonly<Partial<Record<LayoutColour, ColorScheme>>> = {
591
594
  [LayoutColour.Ink]: ColorScheme.Inverse,
592
- [LayoutColour.Muted]: ColorScheme.Inverse,
595
+ [LayoutColour.Muted]: ColorScheme.Muted,
593
596
  [LayoutColour.Accent]: ColorScheme.Accent,
594
597
  };
595
598
 
596
- /** The scheme a form or a gallery on this section ground wears, or null on the page's own ground. */
599
+ /** A wrapper that adds no box (`display: contents` — its children keep their place in the grid) and re-declares the band's
600
+ * tokens for them: a ready-made section's content, a button on a band. */
601
+ function bandColours(id: string, scheme: ColorScheme, children: SerializedNode[]): SerializedNode {
602
+ const band = create(id, T.Container, {}, NO_ELEMENT_STYLE);
603
+ band.label = 'band colours';
604
+ setStyleProps(band, { display: 'contents' });
605
+ setColorScheme(band, scheme);
606
+ band.children = children;
607
+ return band;
608
+ }
609
+
610
+ /** The scheme a form, a gallery, a button or a ready-made section's content on this section ground wears, or null on the page's own ground. */
597
611
  export function layoutBandScheme(ground: string | undefined): ColorScheme | null {
598
612
  return BAND_SCHEME_ON[(ground ?? LayoutColour.Ground) as LayoutColour] ?? null;
599
613
  }
@@ -675,6 +689,10 @@ function composeLayer(l: LayoutLayer, lc: LayerCtx, ctx: Ctx): SerializedNode {
675
689
  }
676
690
  outer.label = `${lc.section.id} · ${l.kind}${l.role ? ` (${l.role})` : ''}`;
677
691
  place(outer, l, lc, ctx);
692
+ // A rule is a line against the words it belongs to, never its row's full height (the bar's grey boxes, M8 demo).
693
+ if (l.kind === LayoutLayerKind.Shape && isLayoutRule(lc.section, lc.li)) {
694
+ setStyleProps(outer, { height: RULE_PX, alignSelf: layoutRuleEdge(lc.section, lc.li), borderRadius: ZERO });
695
+ }
678
696
 
679
697
  // Held: the layer moves by tracks; a kinetic heading lights word by word as the section is read.
680
698
  const tracks: SceneTrackOut[] = [];
@@ -705,7 +723,10 @@ function composeLayer(l: LayoutLayer, lc: LayerCtx, ctx: Ctx): SerializedNode {
705
723
  gap(ctx, LayoutGapCode.DepthSpeed, lc.path, `${depth} glides at the product's one speed`);
706
724
  }
707
725
  if (interactions.length) outer.interactions = [...outer.interactions, ...interactions];
708
- return outer;
726
+ // A button draws its ink from the page's button tokens: on a band they must be the band's, or a text button on the ink
727
+ // (or the muted) band is the ground's own colour — the bar's "See the whole menu" (M8 gate 2, iox-ui#70).
728
+ const scheme = l.kind === LayoutLayerKind.Button ? layoutBandScheme(lc.section.ground) : null;
729
+ return scheme ? bandColours(`${outer.id}-band`, scheme, [outer]) : outer;
709
730
  }
710
731
 
711
732
  // ── Sections ────────────────────────────────────────────────────────────────────────────────────────────
@@ -835,7 +856,7 @@ function composeHeader(ctx: Ctx): SerializedNode | null {
835
856
  gap(ctx, LayoutGapCode.SectionLink, 'nav', 'section links scroll by an action, with no #address');
836
857
  const pages = [{ name: ctx.site.name, route: NAV_ROUTE, isHome: true }, ...links.map(link => ({ name: link.label, route: `/${link.to}` }))];
837
858
  let n = 0;
838
- const { header } = composeNavHeader({ business: { name: ctx.site.name } as never, pages }, { id: `${ctx.p}-nav`, newId: suffix => `${ctx.p}-nav-${++n}-${suffix}` });
859
+ const { header } = composeNavHeader({ business: { name: ctx.site.name } as never, pages, locale: ctx.site.locale }, { id: `${ctx.p}-nav`, newId: suffix => `${ctx.p}-nav-${++n}-${suffix}` });
839
860
  if (ctx.rtl) setStyleProps(header, { textDirection: 'rtl' });
840
861
  let drawer: string | undefined;
841
862
  walkSerialized([header], node => { if (node.role === 'nav.drawer') drawer = node.id; });
@@ -864,6 +885,68 @@ function wireLinks(ctx: Ctx): void {
864
885
  }
865
886
  }
866
887
 
888
+ // ── A ready-made section among composed ones (vectoriox/iox-ui#69) ───────────────────────────────────────
889
+
890
+ /** The pattern's own section padding: its ground's rhythm above and below, the pattern's gutter at the sides. */
891
+ const PATTERN_SECTION_PAD = 'var(--iox-section-pad)';
892
+ const PATTERN_SECTION_SPACE = 'var(--iox-space-section)';
893
+ /** The furthest in a ready-made section's words start: the column grid keeps at least eight columns for them. */
894
+ const READY_MADE_MAX_COLUMN = 3;
895
+
896
+ /** The ground a section paints, by name (a photo ground reads as the ink: its words are light). */
897
+ function groundOf(s: LayoutSection): string {
898
+ const ground = String(s.ground ?? LayoutColour.Ground);
899
+ return ground.startsWith('photo:') ? LayoutColour.Ink : ground;
900
+ }
901
+
902
+ /** The composed section a ready-made place stands beside: the one it follows, or for an opening the one after it; null
903
+ * when the page has no composed section. */
904
+ function readyMadeNeighbour(sections: ReadonlyArray<LayoutSection>, si: number): LayoutSection | null {
905
+ for (let i = si - 1; i >= 0; i--) if (!sections[i].readyMade) return sections[i];
906
+ for (let i = si + 1; i < sections.length; i++) if (!sections[i].readyMade) return sections[i];
907
+ return null;
908
+ }
909
+
910
+ /** The column a ready-made section's words start on: where its neighbour's words start (their first column), so the two
911
+ * share an edge; at most READY_MADE_MAX_COLUMN; 1 (the gutter) when the neighbour has no words. */
912
+ export function readyMadeColumn(neighbour: LayoutSection | null): number {
913
+ const starts = (neighbour?.layers ?? []).filter(l => LAYOUT_TEXT_KINDS.has(l.kind) && Array.isArray(l.col)).map(l => l.col[0]);
914
+ return Math.min(READY_MADE_MAX_COLUMN, Math.max(1, starts.length ? Math.min(...starts) : 1));
915
+ }
916
+
917
+ /** Where column `n` starts from the page's edge, on the composed sections' own grid (`gridLayout`): the gutter, then
918
+ * n - 1 columns and their gaps. */
919
+ function columnInset(n: number): string {
920
+ if (n <= 1) return LAYOUT_GUTTER;
921
+ const column = `((100% - 2 * ${LAYOUT_GUTTER} - ${GRID_COLUMNS - 1} * ${LAYOUT_COLUMN_GAP}) / ${GRID_COLUMNS} + ${LAYOUT_COLUMN_GAP})`;
922
+ return `calc(${LAYOUT_GUTTER} + ${n - 1} * ${column})`;
923
+ }
924
+
925
+ /** A pattern that paints its own ground — a Scene, or a picture behind its words — keeps its colours. */
926
+ function paintsItsOwnGround(root: SerializedNode): boolean {
927
+ return root.role === SceneRole.Scene || (root.children ?? []).some(c => c.styleProps?.['position'] === 'absolute');
928
+ }
929
+
930
+ /**
931
+ * iox-ui#69: a ready-made section reads as the same hand as the composed sections around it. It paints the ground it
932
+ * follows with the composed sections' own paint (the page's tokens on the section), its content wears that band's
933
+ * colour scheme in a wrapper that adds no box (`display: contents` — the pattern's layout is untouched, its tokens
934
+ * re-resolve), and its words start on the layout's column instead of the pattern's gutter; on a phone, the composed
935
+ * sections' gutter. A pattern that paints its own ground keeps its colours.
936
+ */
937
+ function dressReadyMade(root: SerializedNode, ground: string | null, column: number): void {
938
+ if (root.styleProps?.['padding'] === PATTERN_SECTION_PAD) {
939
+ setStyleProps(root, { padding: `${PATTERN_SECTION_SPACE} ${columnInset(column)}` });
940
+ phone(root, { padding: `${PATTERN_SECTION_SPACE} ${LAYOUT_GUTTER}` });
941
+ }
942
+ if (ground === null || paintsItsOwnGround(root)) return;
943
+ setColorScheme(root, ColorScheme.Default);
944
+ setStyleProps(root, { backgroundColor: groundPaint(ground) });
945
+ const scheme = layoutBandScheme(ground);
946
+ if (!scheme || !root.children?.length) return;
947
+ root.children = [bandColours(`${root.id}-band`, scheme, root.children)];
948
+ }
949
+
867
950
  /**
868
951
  * A layout-language page → its layout and header. Deterministic: the same layout composes to byte-identical nodes.
869
952
  * Refuses (ComposeError) a link to a section the layout does not have; everything the product cannot say comes back in
@@ -894,13 +977,15 @@ export function composeLayout(site: LayoutSite, options: ComposeLayoutOptions):
894
977
  if (s.readyMade) {
895
978
  if (!options.readyMade) throw new ComposeError(`sections[${si}]: a ready-made place needs its plan section stamped (options.readyMade)`);
896
979
  const node = options.readyMade(s, `${ctx.p}-s${si}`);
980
+ const neighbour = readyMadeNeighbour(site.sections, si);
981
+ const ground = neighbour ? groundOf(neighbour) : null;
982
+ dressReadyMade(node, ground, readyMadeColumn(neighbour));
897
983
  ctx.sections[s.id] = node.id;
898
- prev = LayoutColour.Ground;
984
+ prev = paintsItsOwnGround(node) || ground === null ? LayoutColour.Ground : ground;
899
985
  return node;
900
986
  }
901
987
  const node = composeSection(s, si, prev, ctx);
902
- const ground = String(s.ground ?? LayoutColour.Ground);
903
- prev = ground.startsWith('photo:') ? LayoutColour.Ink : ground;
988
+ prev = groundOf(s);
904
989
  return node;
905
990
  });
906
991
  const header = composeHeader(ctx);
@@ -1,4 +1,6 @@
1
- import { AnimateId, COLOR_SCHEMES, DesignChoices, LinkType, resolveDesignChoices, setColorScheme } from '@vectoriox/iox-ui/design-core';
1
+ import {
2
+ AnimateId, COLOR_SCHEME_TRAIT, COLOR_SCHEMES, ColorScheme, colorSchemeClass, DesignChoices, LinkType, resolveDesignChoices, setColorScheme,
3
+ } from '@vectoriox/iox-ui/design-core';
2
4
  import { SEO_DESCRIPTION_MAX, SEO_TITLE_MAX, SeoRawDoc } from '@vectoriox/iox-ui/seo-core';
3
5
  import { channelOpensNewTab, FORM_ACTIONS_ROLE, FORM_CHANNEL_ROLE, FormPresetChannel, FormPresetDef, FormPresetField, formPresetById } from '@vectoriox/iox-ui/forms-core';
4
6
  import {
@@ -24,7 +26,7 @@ import { SitePlanSourceKind, ContentFieldControl, ContentFieldPlan,
24
26
  } from './site-plan.model';
25
27
  import { assertValidSitePlan, nextSourceOf, routeParams } from './validate-site-plan';
26
28
  import { NavShape, planNavShape } from './nav-shape';
27
- import { composeLayout, LayoutColourMode } from './compose-layout';
29
+ import { composeLayout, LayoutColourMode, layoutBandScheme } from './compose-layout';
28
30
  import { LayoutGalleryList, LayoutPage, LayoutPhotoShape, LayoutPhotoSource, LayoutSite, parseLayoutPhotoId } from './layout-language';
29
31
  import { layoutMotionOf, layoutPresetOf } from './layout-look';
30
32
 
@@ -148,7 +150,7 @@ export interface ComposedPage {
148
150
  locale: `${SiteLocale}`;
149
151
  /** DS3: every page the wizard creates follows the look (page-bg / text / font-body). M8 gate 2: a composed page names
150
152
  * the plan page its layout is (`layoutSource`; the build adds its run) — what Design ▸ Re-fit recomposes it from. */
151
- pageSettings: { designSystem: true; layoutSource?: { pageKey: string; runId?: string } };
153
+ pageSettings: { designSystem: true; layoutSource?: { pageKey: string; runId?: string }; opening?: `${ColorScheme}` };
152
154
  /** M1-6c: the page's search-result words — written (a static page) or bound to the route item (a template page),
153
155
  * in the seo-core document shape the shared `resolveSeo` reads. */
154
156
  seo: SeoRawDoc;
@@ -335,6 +337,11 @@ interface TextChoice {
335
337
  placeholder?: { kind: PlaceholderKind; fact?: FactKey };
336
338
  }
337
339
 
340
+ /** A pattern node's own words in the site's language: its Hebrew on a Hebrew site when the contract gives one. */
341
+ function ownWords(pn: PatternNode, locale: string | undefined): string {
342
+ return locale === SiteLocale.He && pn.textHe ? pn.textHe : pn.text!;
343
+ }
344
+
338
345
  /** Where a node's words come from: the plan's slot → the business → the customer's fact → the pattern's
339
346
  * own text. A missing fact shows its label and is a placeholder; nothing is ever made up. */
340
347
  function chooseText(pn: PatternNode, ctx: Ctx): TextChoice {
@@ -349,7 +356,7 @@ function chooseText(pn: PatternNode, ctx: Ctx): TextChoice {
349
356
  const given = ctx.plan.business.facts?.[fact];
350
357
  return nonEmpty(given) ? { value: given } : { value: SITE_FACT_LABELS[fact], placeholder: { kind: PlaceholderKind.Fact, fact } };
351
358
  }
352
- const own = pn.text === undefined ? undefined : fillVariables(pn.text, ctx);
359
+ const own = pn.text === undefined ? undefined : fillVariables(ownWords(pn, ctx.plan.locale), ctx);
353
360
  if (pn.ph === PatternPlaceholder.Copy) return { value: own, placeholder: { kind: PlaceholderKind.Copy } };
354
361
  if (pn.ph === PatternPlaceholder.Price) return { value: own, placeholder: { kind: PlaceholderKind.Price } };
355
362
  if (pn.ph === PatternPlaceholder.Stat) return { value: own, placeholder: { kind: PlaceholderKind.Stat } };
@@ -1303,9 +1310,10 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
1303
1310
  const pages: ComposedPage[] = plan.pages.map(page => {
1304
1311
  const nextAlias = page.routeSource ? nextSourceOf(relatives, page.routeSource) : null;
1305
1312
  if (page.layout) {
1313
+ const opening = layoutBandScheme(page.layout.sections[0]?.ground);
1306
1314
  return {
1307
1315
  key: page.key, name: page.name, route: { path: page.route }, isHome: page.isHome === true, status: STATUS_DRAFT, locale,
1308
- pageSettings: { designSystem: true, layoutSource: { pageKey: page.key } }, seo: composePageSeo(page, plan),
1316
+ pageSettings: { designSystem: true, layoutSource: { pageKey: page.key }, ...(opening ? { opening } : {}) }, seo: composePageSeo(page, plan),
1309
1317
  layout: composeLayoutPage(page, page.layout, plan, context, design, placeholders, (section, id) =>
1310
1318
  composePattern(patternById(section.pattern) as SitePattern, id, { ...base, owner: page.key, page, section, nextAlias },
1311
1319
  { level: section.enter ?? design.animate ?? null, rtl })),
@@ -1316,6 +1324,7 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
1316
1324
  const motion: SectionMotion = { level: section.enter ?? design.animate ?? null, rtl };
1317
1325
  return composePattern(pattern, `${page.key}-${i}`, { ...base, owner: page.key, page, section, nextAlias }, motion);
1318
1326
  });
1327
+ const opening = colorSchemeClass(layout[0]?.props?.[COLOR_SCHEME_TRAIT]) ? (layout[0].props[COLOR_SCHEME_TRAIT] as ColorScheme) : null;
1319
1328
  return {
1320
1329
  key: page.key,
1321
1330
  name: page.name,
@@ -1323,7 +1332,7 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
1323
1332
  isHome: page.isHome === true,
1324
1333
  status: STATUS_DRAFT,
1325
1334
  locale,
1326
- pageSettings: { designSystem: true },
1335
+ pageSettings: { designSystem: true, ...(opening ? { opening } : {}) },
1327
1336
  seo: composePageSeo(page, plan),
1328
1337
  layout,
1329
1338
  };
@@ -1381,6 +1390,8 @@ export interface NavHeaderInput {
1381
1390
  readonly business: SiteBusiness;
1382
1391
  /** Every page of the studio, in the order the navigation should list them. */
1383
1392
  readonly pages: ReadonlyArray<SitePageRef>;
1393
+ /** The site's language (`SiteLocale`): the header's own words (its call to action) in it. English when not given. */
1394
+ readonly locale?: string;
1384
1395
  }
1385
1396
 
1386
1397
  export interface NavHeaderOptions {
@@ -1428,7 +1439,7 @@ export function composeNavHeader(input: NavHeaderInput, options: NavHeaderOption
1428
1439
  const all = navPagePlans(input.pages);
1429
1440
  const navRoutes = new Set(siteNavPages(input.pages).map(p => p.route));
1430
1441
  const pages = all.map(p => ({ ...p, inNav: navRoutes.has(p.route) }));
1431
- const plan = { business: input.business, pages, dataSources: [], contentTypes: [] } as unknown as SitePlan;
1442
+ const plan = { business: input.business, pages, dataSources: [], contentTypes: [], locale: input.locale } as unknown as SitePlan;
1432
1443
  const email = nonEmpty(input.business.facts?.email) ? input.business.facts!.email!.trim() : null;
1433
1444
  const issues: ComposeIssue[] = [];
1434
1445
  const ctx: Ctx = {
@@ -339,6 +339,20 @@ export enum LayoutMendKind {
339
339
  * the section's words name, else the first in plan order. None, or the section's words name the list it named
340
340
  * (iox-ui#66): left to the model. */
341
341
  Source = 'source',
342
+ /** A held section where nothing moves by the scroll (the page stops on a still screen, M8 demo): its line — a word,
343
+ * heading or text of at most the kinetic words — is lit word by word as the hold plays. */
344
+ Words = 'words',
345
+ /** A held section where nothing moves and no line can be lit: it flows, one screen tall — when the page can spare the hold. */
346
+ Unpin = 'unpin',
347
+ /** …and when it cannot (a daring page needs its holds): its largest photo drifts — a slow scale as the hold plays. */
348
+ Drift = 'drift',
349
+ /** A shape with no purpose — not a rule, a band, a frame, a backdrop to words, and it does not move: it is dropped. */
350
+ Drop = 'drop',
351
+ /** A section that leaves a stretch of the laptop's screen with nothing on it: its height comes down (its rows keep
352
+ * their share, the words still fit) until the stretch is gone. */
353
+ Screens = 'screens',
354
+ /** A daring or Expressive page whose opening has no display: the opening's lead line is set as one (a word). */
355
+ Display = 'display',
342
356
  }
343
357
 
344
358
  /** Which rule chose a mended gallery's list. */
@@ -369,7 +383,11 @@ export type LayoutMend =
369
383
  | { kind: LayoutMendKind.Scrim | LayoutMendKind.Ink | LayoutMendKind.Fade; layer: string }
370
384
  | { kind: LayoutMendKind.Accent; over: number; bands?: ReadonlyArray<LayoutBandMove> }
371
385
  | { kind: LayoutMendKind.Depth; layers: ReadonlyArray<string> }
372
- | { kind: LayoutMendKind.Source; layer: string; source: string; by: `${LayoutSourceChoice}` };
386
+ | { kind: LayoutMendKind.Source; layer: string; source: string; by: `${LayoutSourceChoice}` }
387
+ | { kind: LayoutMendKind.Words | LayoutMendKind.Drop | LayoutMendKind.Drift; layer: string }
388
+ | { kind: LayoutMendKind.Display; layer: string; size?: `${LayoutSize}` }
389
+ | { kind: LayoutMendKind.Unpin; section: number }
390
+ | { kind: LayoutMendKind.Screens; sections: ReadonlyArray<{ section: number; screens: number }> };
373
391
 
374
392
  export interface LayoutIssue {
375
393
  code: `${LayoutIssueCode}`;
@@ -101,15 +101,29 @@ const phraseOf = (text: string): { phrase: string; words: number } => {
101
101
  };
102
102
  /** The fewest words a text needs to count as said twice — a two-word label ("The room") may well appear twice. */
103
103
  const REPEAT_MIN_WORDS = 3;
104
+ /** The share of the shorter text's words the longer one holds for the two to be the same sentence said twice: one word
105
+ * changed is still a repeat (the café's quote, "…וחברים צריכים שולחן" and "…וחברים טובים צריכים שולחן"). */
106
+ const REPEAT_SHARED = 0.8;
107
+
108
+ /** Whether two texts say the same thing: one inside the other, or the shorter's words (function words aside) nearly all
109
+ * in the longer. */
110
+ function sameSaying(a: { phrase: string; text: string }, b: { phrase: string; text: string }): boolean {
111
+ if (a.phrase.includes(b.phrase) || b.phrase.includes(a.phrase)) return true;
112
+ const [short, long] = [new Set(wordsOf(a.text)), new Set(wordsOf(b.text))].sort((x, y) => x.size - y.size);
113
+ if (short.size < REPEAT_MIN_WORDS) return false;
114
+ return [...short].filter(w => long.has(w)).length / short.size >= REPEAT_SHARED;
115
+ }
104
116
 
105
117
  /**
106
118
  * Whether the plan section would say again what the sections the model kept already say (iox-ui#68): a title or a text of
107
- * its slots found inside a kept layer's words, or a kept layer's words found inside it — each of three words or more.
119
+ * its slots found inside a kept layer's words, or a kept layer's words found inside it, or the two the same sentence
120
+ * with a word changed — each of three words or more.
108
121
  */
109
122
  function repeatsKept(plan: PageSectionPlan, kept: ReadonlyArray<LayoutSection>): boolean {
110
- const said = kept.flatMap(s => (s.layers ?? []).flatMap(layerTexts)).map(phraseOf).filter(p => p.words >= REPEAT_MIN_WORDS);
111
- return Object.values(plan.slots ?? {}).map(phraseOf).filter(p => p.words >= REPEAT_MIN_WORDS)
112
- .some(slot => said.some(k => k.phrase.includes(slot.phrase) || slot.phrase.includes(k.phrase)));
123
+ const long = (text: string) => ({ ...phraseOf(text), text });
124
+ const said = kept.flatMap(s => (s.layers ?? []).flatMap(layerTexts)).map(long).filter(p => p.words >= REPEAT_MIN_WORDS);
125
+ return Object.values(plan.slots ?? {}).map(long).filter(p => p.words >= REPEAT_MIN_WORDS)
126
+ .some(slot => said.some(k => sameSaying(slot, k)));
113
127
  }
114
128
 
115
129
  /** How well a ready-made section stands for a model's section: the same list, the form, the words they share. */