@vectoriox/iox-ui 5.109.1 → 5.111.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 +680 -125
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/generation-core/index.d.ts +539 -45
- package/package.json +1 -1
- package/src/generation-core/check-list.ts +8 -7
- package/src/generation-core/compose-layout.ts +67 -13
- package/src/generation-core/header-mix.ts +116 -0
- package/src/generation-core/layout-fingerprint.ts +9 -2
- package/src/generation-core/layout-wire.ts +8 -15
- package/src/generation-core/list-table.ts +39 -0
- package/src/generation-core/nav-shape.ts +56 -5
- package/src/generation-core/public-api.ts +2 -0
- package/src/generation-core/site-spec.generated.ts +418 -76
- package/styles/iox-design.css +103 -0
package/package.json
CHANGED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
LayoutIssue, LayoutIssueCode, LayoutLayerKind, LayoutListArrange, LayoutListArrive, LayoutListHow, LayoutListHover, LayoutListItem, LayoutListMix,
|
|
3
3
|
LayoutListMove, LayoutListPhone, LayoutListShape, LayoutListWho, LayoutMendKind, LayoutPage,
|
|
4
4
|
} from './layout-language';
|
|
5
|
+
import { listMeaning } from './list-table';
|
|
5
6
|
import { SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
6
7
|
|
|
7
8
|
/**
|
|
@@ -18,7 +19,7 @@ const enumValues = (e: object): string[] => Object.values(e);
|
|
|
18
19
|
const has = <T extends string>(list: ReadonlyArray<T>, v: string): boolean => (list as ReadonlyArray<string>).includes(v);
|
|
19
20
|
|
|
20
21
|
/** The words a repaired mix is said in (the brief and the owner read them). */
|
|
21
|
-
const say = (
|
|
22
|
+
const say = (arrange: string) => listMeaning('arrange', arrange);
|
|
22
23
|
|
|
23
24
|
/**
|
|
24
25
|
* Judge one list section's mix against the list it shows (`shape`, from `layoutListShapes`; null when the source is no
|
|
@@ -104,11 +105,11 @@ export function checkList(mix: LayoutListMix, shape: LayoutListShape | null, lay
|
|
|
104
105
|
if (next.standout.how) repair('nothing stands out — no way to stand out');
|
|
105
106
|
delete next.standout;
|
|
106
107
|
} else {
|
|
107
|
-
if (has(R.onlyRow.
|
|
108
|
+
if (has(R.onlyRow.who, next.standout.who) && !row) {
|
|
108
109
|
repair(`"${next.standout.who}" is a row's — the first stands out`);
|
|
109
110
|
next.standout.who = LayoutListWho.First;
|
|
110
111
|
}
|
|
111
|
-
if (next.standout.how && has(R.onlyStrips.
|
|
112
|
+
if (next.standout.how && has(R.onlyStrips.how, next.standout.how)) {
|
|
112
113
|
repair(`"${next.standout.how}" is a strip's — bigger instead`);
|
|
113
114
|
next.standout.how = LayoutListHow.Bigger;
|
|
114
115
|
}
|
|
@@ -122,10 +123,10 @@ export function checkList(mix: LayoutListMix, shape: LayoutListShape | null, lay
|
|
|
122
123
|
next.move = [];
|
|
123
124
|
}
|
|
124
125
|
if (moving) {
|
|
125
|
-
const onlyRow = next.move.filter(m => has(R.onlyRow.
|
|
126
|
+
const onlyRow = next.move.filter(m => has(R.onlyRow.move, m));
|
|
126
127
|
if (onlyRow.length && !row) {
|
|
127
128
|
repair(`"${onlyRow.join(', ')}" carries a row only`);
|
|
128
|
-
next.move = next.move.filter(m => !has(R.onlyRow.
|
|
129
|
+
next.move = next.move.filter(m => !has(R.onlyRow.move, m));
|
|
129
130
|
}
|
|
130
131
|
if (next.move.includes(LayoutListMove.Page) && next.move.length > 1) {
|
|
131
132
|
repair('the page\'s scroll carries the row alone');
|
|
@@ -136,10 +137,10 @@ export function checkList(mix: LayoutListMix, shape: LayoutListShape | null, lay
|
|
|
136
137
|
next.move = [LayoutListMove.Drag];
|
|
137
138
|
}
|
|
138
139
|
}
|
|
139
|
-
const stripHovers = next.hover.filter(h => has(R.onlyStrips.
|
|
140
|
+
const stripHovers = next.hover.filter(h => has(R.onlyStrips.hover, h));
|
|
140
141
|
if (stripHovers.length && !strips) {
|
|
141
142
|
repair(`"${stripHovers.join(', ')}" is a strip's`);
|
|
142
|
-
next.hover = next.hover.filter(h => !has(R.onlyStrips.
|
|
143
|
+
next.hover = next.hover.filter(h => !has(R.onlyStrips.hover, h));
|
|
143
144
|
}
|
|
144
145
|
if (new Set(next.hover).size !== next.hover.length) next.hover = [...new Set(next.hover)];
|
|
145
146
|
|
|
@@ -6,10 +6,13 @@ 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, HeaderIngredient, headerMixOfNavKind } from './header-mix';
|
|
10
|
+
import { listWait } from './list-table';
|
|
11
|
+
import { NavShape, planNavShape } from './nav-shape';
|
|
9
12
|
import {
|
|
10
13
|
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,
|
|
11
14
|
LAYOUT_PHONE_PADDING, LAYOUT_RISE, LAYOUT_TEXT_KINDS, LayoutBleed, LayoutColour, LayoutEase, LayoutEnter, LayoutForm, LayoutGallery, LayoutLayer,
|
|
12
|
-
LayoutListArrange, LayoutListArrive, LayoutListHover, LayoutListItem, LayoutListMix, LayoutListMove, LayoutListPhone, LayoutListWho,
|
|
15
|
+
LayoutListArrange, LayoutListArrive, LayoutListHover, LayoutListHow, LayoutListItem, LayoutListMix, LayoutListMove, LayoutListPhone, LayoutListWho,
|
|
13
16
|
LayoutLayerKind, LayoutNavKind, LayoutPace, LayoutPhotoShape, LayoutRole, LayoutSection, LayoutSide, LayoutSite, LayoutTrack, LayoutTrackProp, LayoutTransition, phoneGapBefore,
|
|
14
17
|
screenFontSize,
|
|
15
18
|
} from './layout-language';
|
|
@@ -118,9 +121,19 @@ export enum LayoutListRole {
|
|
|
118
121
|
Dim = 'list.dim',
|
|
119
122
|
Masonry = 'list.masonry',
|
|
120
123
|
MasonryTwo = 'list.masonry-two',
|
|
124
|
+
/** LI3: strips (the Repeater) — stacked on a phone, two across, or a row to swipe; each row a strip item. */
|
|
125
|
+
Strips = 'list.strips',
|
|
126
|
+
StripsTwo = 'list.strips-two',
|
|
127
|
+
StripsSwipe = 'list.strips-swipe',
|
|
128
|
+
StripItem = 'list.strip-item',
|
|
121
129
|
Item = 'list.item',
|
|
122
130
|
}
|
|
123
131
|
|
|
132
|
+
/** A strips list's Repeater role by the phone the mix asks for. */
|
|
133
|
+
const STRIPS_ROLE: Readonly<Record<`${LayoutListPhone}`, LayoutListRole>> = {
|
|
134
|
+
stack: LayoutListRole.Strips, 'two-up': LayoutListRole.StripsTwo, swipe: LayoutListRole.StripsSwipe,
|
|
135
|
+
};
|
|
136
|
+
|
|
124
137
|
/** A list role → the Card v2 part that shows it (the title is the card's locked title; `link` links the card). */
|
|
125
138
|
export const LIST_CARD_PART: Readonly<Record<string, CardPart>> = {
|
|
126
139
|
image: CardPart.Media,
|
|
@@ -669,7 +682,8 @@ function linkToDetail(node: SerializedNode, source: string, detail: NonNullable<
|
|
|
669
682
|
}
|
|
670
683
|
|
|
671
684
|
/** A card item: Card v2 (the palette's recipe) with a part per role the mix shows, each bound to the row's field. */
|
|
672
|
-
function listCard(id: string, mix: LayoutListMix, source: string, list: LayoutListBinding, masonry: boolean, path: string, ctx: Ctx
|
|
685
|
+
function listCard(id: string, mix: LayoutListMix, source: string, list: LayoutListBinding, masonry: boolean, path: string, ctx: Ctx,
|
|
686
|
+
layout: CardLayout = CardLayout.Top): SerializedNode {
|
|
673
687
|
const shown = new Set(mix.parts.filter(r => !!list.roles[r]));
|
|
674
688
|
const field = (role: string) => (shown.has(role) ? list.roles[role] : undefined);
|
|
675
689
|
const eyebrow = field('meta') ?? field('date');
|
|
@@ -679,7 +693,7 @@ function listCard(id: string, mix: LayoutListMix, source: string, list: LayoutLi
|
|
|
679
693
|
partOn(CardPart.Eyebrow, eyebrow), partOn(CardPart.Text, field('summary')), partOn(CardPart.Quote, field('quote')),
|
|
680
694
|
partOn(CardPart.Person, field('person')), [CardPart.Badge, false], [CardPart.Actions, false],
|
|
681
695
|
]) as Partial<Record<CardPart, boolean>>;
|
|
682
|
-
const card = buildCardRecipe(partFactory(id), { layout
|
|
696
|
+
const card = buildCardRecipe(partFactory(id), { layout, parts }) as unknown as SerializedNode;
|
|
683
697
|
card.id = id;
|
|
684
698
|
const bind = (role: CardRole, prop: string, f: string | undefined) => {
|
|
685
699
|
const part = findByRole(card as unknown as CompositeNode, role) as SerializedNode | undefined;
|
|
@@ -742,19 +756,25 @@ function composeList(id: string, l: LayoutLayer, mix: LayoutListMix, source: str
|
|
|
742
756
|
const scheme = layoutBandScheme(lc.section.ground);
|
|
743
757
|
if (scheme) setColorScheme(frame, scheme);
|
|
744
758
|
|
|
759
|
+
// A word the product does not draw yet (the contract's list table): drawn as its stand-in, and said.
|
|
745
760
|
let arrange = mix.arrange;
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
gap(ctx, LayoutGapCode.ListLater, `${lc.path}.gallery.list.arrange`, `${arrange} is drawn in
|
|
749
|
-
arrange =
|
|
761
|
+
const arrangeWait = listWait('arrange', arrange);
|
|
762
|
+
if (arrangeWait?.drawnAs) {
|
|
763
|
+
gap(ctx, LayoutGapCode.ListLater, `${lc.path}.gallery.list.arrange`, `${arrange} is drawn in ${arrangeWait.phase}: laid out as a ${arrangeWait.drawnAs}`);
|
|
764
|
+
arrange = arrangeWait.drawnAs as LayoutListMix['arrange'];
|
|
750
765
|
}
|
|
751
|
-
|
|
752
|
-
|
|
766
|
+
const strips = arrange === LayoutListArrange.Strips;
|
|
767
|
+
// Strips draw their own standing out (the open one, wider); any other is said until its phase draws it.
|
|
768
|
+
if (mix.standout && mix.standout.who !== LayoutListWho.None && !(strips && mix.standout.how === LayoutListHow.Wider)) {
|
|
769
|
+
const wait = listWait('who', mix.standout.who) ?? (mix.standout.how ? listWait('how', mix.standout.how) : null);
|
|
770
|
+
gap(ctx, LayoutGapCode.ListLater, `${lc.path}.gallery.list.standout`,
|
|
771
|
+
`standing out (${mix.standout.who}${mix.standout.how ? ` · ${mix.standout.how}` : ''}) is drawn ${wait ? `in ${wait.phase}` : 'by strips only'}`);
|
|
753
772
|
}
|
|
754
773
|
const masonry = arrange === LayoutListArrange.Masonry;
|
|
755
774
|
const item = mix.item === LayoutListItem.Card
|
|
756
|
-
? listCard(`${id}-item`, mix, source, list, masonry, lc.path, ctx)
|
|
775
|
+
? listCard(`${id}-item`, mix, source, list, masonry, lc.path, ctx, strips ? CardLayout.Overlay : CardLayout.Top)
|
|
757
776
|
: listPhoto(`${id}-item`, source, list, masonry);
|
|
777
|
+
if (strips) return composeStrips(id, frame, item, mix, source, ctx);
|
|
758
778
|
item.interactions = [...item.interactions, listArriveInteraction(item.id, mix.arrive, ctx)];
|
|
759
779
|
|
|
760
780
|
if (arrange === LayoutListArrange.Row) {
|
|
@@ -810,6 +830,32 @@ function composeList(id: string, l: LayoutLayer, mix: LayoutListMix, source: str
|
|
|
810
830
|
return frame;
|
|
811
831
|
}
|
|
812
832
|
|
|
833
|
+
/**
|
|
834
|
+
* Strips (LI3): a Repeater over the list whose ONE row is a strip item holding the card (picture filling it, words on
|
|
835
|
+
* the scrim) or the picture. Everything strips DO — the open one wider, pointing and focus, the phone — is the shared
|
|
836
|
+
* CSS's (iox-design.css, by the Repeater's role), so the canvas and the live site draw the same strips with no runtime.
|
|
837
|
+
*/
|
|
838
|
+
function composeStrips(id: string, frame: SerializedNode, item: SerializedNode, mix: LayoutListMix, source: string, ctx: Ctx): SerializedNode {
|
|
839
|
+
const strip = create(`${id}-strip`, T.Container, {}, NO_ELEMENT_STYLE);
|
|
840
|
+
strip.role = LayoutListRole.StripItem;
|
|
841
|
+
setStyleProps(strip, { position: 'relative', display: 'block', width: FULL, height: FULL, minHeight: ZERO, overflow: 'hidden' });
|
|
842
|
+
setStyleProps(item, { width: FULL, height: FULL, minHeight: ZERO });
|
|
843
|
+
if (item.role === LayoutListRole.Item) {
|
|
844
|
+
const image = item.children?.[0];
|
|
845
|
+
if (image) setStyleProps(image, { height: FULL, aspectRatio: 'auto' });
|
|
846
|
+
}
|
|
847
|
+
// The arrival plays on the card, never on the strip: the strip's own transform is the strips' geometry.
|
|
848
|
+
item.interactions = [...item.interactions, listArriveInteraction(item.id, mix.arrive, ctx)];
|
|
849
|
+
strip.children = [item];
|
|
850
|
+
const items = create(`${id}-items`, 'Repeater', {}, 'box');
|
|
851
|
+
items.role = STRIPS_ROLE[mix.phone];
|
|
852
|
+
items.bindings.push({ prop: 'source', source, path: '' });
|
|
853
|
+
setStyleProps(items, { display: 'block', width: FULL });
|
|
854
|
+
items.children = [strip];
|
|
855
|
+
frame.children = [items];
|
|
856
|
+
return frame;
|
|
857
|
+
}
|
|
858
|
+
|
|
813
859
|
/** Recipe parts stamped with this composer's ids (`<id>-<key>`). */
|
|
814
860
|
function partFactory(id: string): (spec: CompositeNodeSpec) => CompositeNode {
|
|
815
861
|
return spec => create(`${id}-${spec.key}`, spec.type, { ...(spec.props ?? {}) }, spec.elementStyle ?? null) as unknown as CompositeNode;
|
|
@@ -1089,16 +1135,24 @@ const NAV_ROUTE = '/';
|
|
|
1089
1135
|
const PAGE_ROUTE_MARK = '/';
|
|
1090
1136
|
|
|
1091
1137
|
/** The product's site header (composeNavHeader) with the layout's section links: each one scrolls to its section; in the
|
|
1092
|
-
* phone menu it closes the drawer first.
|
|
1138
|
+
* phone menu it closes the drawer first. The layout's `nav.kind` is read as a header MIX (header-mix.ts, HI0): a `corner`
|
|
1139
|
+
* or `index` header is the name and a menu at every width; a word the product does not draw yet is drawn as its built
|
|
1140
|
+
* stand-in and said as a gap. */
|
|
1093
1141
|
function composeHeader(ctx: Ctx): SerializedNode | null {
|
|
1094
1142
|
const links = ctx.site.nav?.links ?? [];
|
|
1095
1143
|
if (!links.length) return null;
|
|
1096
1144
|
const kind = ctx.site.nav?.kind ?? LayoutNavKind.Bar;
|
|
1097
|
-
|
|
1145
|
+
const { drawn, gaps } = drawnHeaderMix(headerMixOfNavKind(kind));
|
|
1146
|
+
// ONE gap for the header (gaps keep one per place): every word it waits for, its stand-in and the phase.
|
|
1147
|
+
if (gaps.length) gap(ctx, LayoutGapCode.NavKind, 'nav', `${/^[aeiou]/.test(kind) ? 'an' : 'a'} ${kind} header is drawn with `
|
|
1148
|
+
+ gaps.map(g => `${g.ingredient} "${g.drawnAs}" for "${g.word}" (until ${g.phase})`).join(', '));
|
|
1098
1149
|
gap(ctx, LayoutGapCode.SectionLink, 'nav', 'section links scroll by an action, with no #address');
|
|
1099
1150
|
const pages = [{ name: ctx.site.name, route: NAV_ROUTE, isHome: true }, ...links.map(link => ({ name: link.label, route: `/${link.to}` }))];
|
|
1100
1151
|
let n = 0;
|
|
1101
|
-
const
|
|
1152
|
+
const newId = (suffix: string) => `${ctx.p}-nav-${++n}-${suffix}`;
|
|
1153
|
+
let { header } = composeNavHeader({ business: { name: ctx.site.name } as never, pages, locale: ctx.site.locale }, { id: `${ctx.p}-nav`, newId });
|
|
1154
|
+
// The pages behind a menu: the menu button and its drawer at every width (HI-D8).
|
|
1155
|
+
if (drawn[HeaderIngredient.Pages] !== 'inline') header = planNavShape([header], NavShape.Drawer, { everyWidth: true, newId }, header.id).globals[0];
|
|
1102
1156
|
if (ctx.rtl) setStyleProps(header, { textDirection: 'rtl' });
|
|
1103
1157
|
let drawer: string | undefined;
|
|
1104
1158
|
walkSerialized([header], node => { if (node.role === 'nav.drawer') drawer = node.id; });
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* HEADER INGREDIENTS (header-ingredients-plan.md, HI0): a site's header is a MIX — one word per ingredient — never a
|
|
5
|
+
* header pattern. Every word, its meaning, whether the product draws it yet, the named mixes stored plans use, what a CL2
|
|
6
|
+
* `nav.kind` asks for, the fingerprint and Doron's references live in ONE table, the contract's `site.layout.header`
|
|
7
|
+
* (layout.mjs `HEADER`). This module only reads it: adding an option is a row there, not a change here
|
|
8
|
+
* (architecture/ai/ingredients.md). Pure.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const H = SPEC_SITE_LAYOUT.header;
|
|
12
|
+
|
|
13
|
+
/** The ingredients, by the contract's keys (held equal to it by header-mix.spec). */
|
|
14
|
+
export enum HeaderIngredient {
|
|
15
|
+
Arrange = 'arrange',
|
|
16
|
+
MenuSide = 'menuSide',
|
|
17
|
+
Pages = 'pages',
|
|
18
|
+
Menu = 'menu',
|
|
19
|
+
MenuShows = 'menuShows',
|
|
20
|
+
Action = 'action',
|
|
21
|
+
Ground = 'ground',
|
|
22
|
+
Shape = 'shape',
|
|
23
|
+
Brand = 'brand',
|
|
24
|
+
Scroll = 'scroll',
|
|
25
|
+
Edge = 'edge',
|
|
26
|
+
Phone = 'phone',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** One word per ingredient. */
|
|
30
|
+
export type HeaderMix = Record<`${HeaderIngredient}`, string>;
|
|
31
|
+
|
|
32
|
+
export class HeaderMixError extends Error {}
|
|
33
|
+
|
|
34
|
+
const INGREDIENTS = H.ingredients as Readonly<Record<string, ReadonlyArray<string>>>;
|
|
35
|
+
const WAITS = H.waits as Readonly<Record<string, { phase: string; drawnAs: string }>>;
|
|
36
|
+
const MEANINGS = H.meanings as Readonly<Record<string, string>>;
|
|
37
|
+
|
|
38
|
+
/** The words an ingredient may take. */
|
|
39
|
+
export function headerWords(ingredient: `${HeaderIngredient}`): ReadonlyArray<string> {
|
|
40
|
+
return INGREDIENTS[ingredient] ?? [];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** What a word means, as the brief and the builder say it. */
|
|
44
|
+
export function headerMeaning(ingredient: `${HeaderIngredient}`, word: string): string {
|
|
45
|
+
return MEANINGS[`${ingredient}.${word}`] ?? word;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** A whole mix from part of one: what is not named is the default (the Studio header). Refuses a word the table lacks. */
|
|
49
|
+
export function headerMix(partial: Partial<HeaderMix> = {}): HeaderMix {
|
|
50
|
+
const mix = { ...(H.defaults as HeaderMix) };
|
|
51
|
+
for (const [k, w] of Object.entries(partial)) {
|
|
52
|
+
if (w === undefined) continue;
|
|
53
|
+
if (!INGREDIENTS[k]) throw new HeaderMixError(`no header ingredient "${k}"`);
|
|
54
|
+
if (!INGREDIENTS[k].includes(w)) throw new HeaderMixError(`a header's ${k} cannot be "${w}" (${INGREDIENTS[k].join(' · ')})`);
|
|
55
|
+
mix[k as HeaderIngredient] = w;
|
|
56
|
+
}
|
|
57
|
+
return mix;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** The mix a stored header pattern id stands for (`nav.inline-cta`, `nav.centered-logo`), or null for an unknown id. */
|
|
61
|
+
export function namedHeaderMix(patternId: string): HeaderMix | null {
|
|
62
|
+
const named = (H.named as Readonly<Record<string, Partial<HeaderMix>>>)[patternId];
|
|
63
|
+
return named ? headerMix(named) : null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The mix a CL2 layout's `nav.kind` asks for (`bar` when it names none). */
|
|
67
|
+
export function headerMixOfNavKind(kind: string | undefined): HeaderMix {
|
|
68
|
+
const asked = (H.navKinds as Readonly<Record<string, Partial<HeaderMix>>>)[kind ?? 'bar'];
|
|
69
|
+
if (!asked) throw new HeaderMixError(`no nav kind "${kind}"`);
|
|
70
|
+
return headerMix(asked);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** A word the product does not draw yet, with the phase it waits for and what is drawn instead. */
|
|
74
|
+
export interface HeaderGap {
|
|
75
|
+
ingredient: `${HeaderIngredient}`;
|
|
76
|
+
word: string;
|
|
77
|
+
phase: string;
|
|
78
|
+
drawnAs: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The mix the product DRAWS today: every waiting word becomes its built stand-in, and each one is said as a gap. */
|
|
82
|
+
export function drawnHeaderMix(mix: HeaderMix): { drawn: HeaderMix; gaps: HeaderGap[] } {
|
|
83
|
+
const drawn = { ...mix };
|
|
84
|
+
const gaps: HeaderGap[] = [];
|
|
85
|
+
for (const k of Object.values(HeaderIngredient)) {
|
|
86
|
+
const wait = WAITS[`${k}.${mix[k]}`];
|
|
87
|
+
if (!wait) continue;
|
|
88
|
+
gaps.push({ ingredient: k, word: mix[k], phase: wait.phase, drawnAs: wait.drawnAs });
|
|
89
|
+
drawn[k] = wait.drawnAs;
|
|
90
|
+
}
|
|
91
|
+
return { drawn, gaps };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The fingerprint's prefix for a header. */
|
|
95
|
+
export const HEADER_TOKEN = 'header';
|
|
96
|
+
|
|
97
|
+
/** A header as the fingerprint sees it (§7): `header:<arrange>/<pages>/<menu>/<ground>/<shape>` — what a visitor takes in
|
|
98
|
+
* at once, in the contract's order. Two sites with the same token wear the same header. */
|
|
99
|
+
export function headerTokenOf(mix: HeaderMix): string {
|
|
100
|
+
return `${HEADER_TOKEN}:${(H.fingerprint as ReadonlyArray<`${HeaderIngredient}`>).map(k => mix[k]).join('/')}`;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** A header token in words: `header:name-only/menu/drawer/solid/bar` → "name-only · menu · drawer · solid · bar". */
|
|
104
|
+
export const headerTokenWords = (token: string): string => token.replace(`${HEADER_TOKEN}:`, '').split('/').join(' · ');
|
|
105
|
+
|
|
106
|
+
/** Doron's reference headers (§2b), each as a whole mix. */
|
|
107
|
+
export function headerReferences(): ReadonlyArray<{ id: string; after: string; added: string; mix: HeaderMix }> {
|
|
108
|
+
return (H.references as ReadonlyArray<{ id: string; after: string; added: string; mix: Partial<HeaderMix> }>)
|
|
109
|
+
.map(r => ({ id: r.id, after: r.after, added: r.added, mix: headerMix(r.mix) }));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/** The site plan's header as a mix: its `globals.header` pattern read as a named mix (HI-D4), the Studio header when it
|
|
113
|
+
* names none or one the table does not know. */
|
|
114
|
+
export function headerMixOfPlan(plan: { readonly globals?: Readonly<Record<string, string>> }): HeaderMix {
|
|
115
|
+
return namedHeaderMix(plan.globals?.['header'] ?? '') ?? headerMix();
|
|
116
|
+
}
|
|
@@ -2,6 +2,7 @@ import { parseCssColour, relativeLuminance } from '@vectoriox/iox-ui/design-core
|
|
|
2
2
|
|
|
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
|
+
import { HeaderMix, headerTokenOf } from './header-mix';
|
|
5
6
|
import { PHOTO_LIGHT_LUMINANCE, PhotoTone } from './photo-inventory';
|
|
6
7
|
import { SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
7
8
|
|
|
@@ -48,6 +49,10 @@ export interface LayoutFingerprint {
|
|
|
48
49
|
preset: string;
|
|
49
50
|
/** Every list mix the page shows (`listTokenOf`); absent on a fingerprint stored before LI2. */
|
|
50
51
|
lists?: string[];
|
|
52
|
+
/** The site's header (`headerTokenOf`, header ingredients HI0); absent on a fingerprint stored before it. Recorded and
|
|
53
|
+
* named in the brief, never a refusal until the model chooses the header (HI1) — a refusal it cannot answer by
|
|
54
|
+
* changing its page would only spend a repair. */
|
|
55
|
+
header?: string;
|
|
51
56
|
}
|
|
52
57
|
|
|
53
58
|
export interface FingerprintedPage {
|
|
@@ -132,8 +137,9 @@ function openingOf(s: LayoutSection | undefined): string {
|
|
|
132
137
|
return lead.size ? `${lead.size}-${lead.kind}` : lead.kind;
|
|
133
138
|
}
|
|
134
139
|
|
|
135
|
-
/** A page's fingerprint, worn in `preset` and `mode
|
|
136
|
-
|
|
140
|
+
/** A page's fingerprint, worn in `preset` and `mode`, under the site's `header` when it is known. A photo ground opens on
|
|
141
|
+
* the page's own ground colour. */
|
|
142
|
+
export function fingerprintOf(page: LayoutPage, preset: string, mode: 'light' | 'dark', header?: HeaderMix): LayoutFingerprint {
|
|
137
143
|
const sections = page.sections ?? [];
|
|
138
144
|
const lists = listTokensOf(page);
|
|
139
145
|
const first = sections[0];
|
|
@@ -148,6 +154,7 @@ export function fingerprintOf(page: LayoutPage, preset: string, mode: 'light' |
|
|
|
148
154
|
ground: light ? PhotoTone.Light : PhotoTone.Dark,
|
|
149
155
|
preset,
|
|
150
156
|
...(lists.length ? { lists } : {}),
|
|
157
|
+
...(header ? { header: headerTokenOf(header) } : {}),
|
|
151
158
|
};
|
|
152
159
|
}
|
|
153
160
|
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
LayoutListHow, LayoutListItem, LayoutListMix, LayoutListPhone, LayoutListWho, LayoutPage, LayoutSection, LayoutTrack,
|
|
5
5
|
} from './layout-language';
|
|
6
6
|
import { isPlainObject, PlainObject } from './shape-check';
|
|
7
|
+
import { LIST_INGREDIENTS, LIST_TABLE, listBuiltWords, listIngredientWords } from './list-table';
|
|
7
8
|
import { SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
8
9
|
|
|
9
10
|
/**
|
|
@@ -35,7 +36,6 @@ const VARIANT_ON_WIRE: ReadonlyArray<string> = [NONE, ...V.buttonVariants, ...V.
|
|
|
35
36
|
* request stays inside the 40 the budget allows, and the parts enum is generated from the plan's own lists: a model
|
|
36
37
|
* cannot name a part its list does not have (R-H2).
|
|
37
38
|
*/
|
|
38
|
-
const L = SPEC_SITE_LAYOUT.list;
|
|
39
39
|
export enum LayoutMixIngredient {
|
|
40
40
|
Item = 'item',
|
|
41
41
|
Arrange = 'arrange',
|
|
@@ -46,21 +46,14 @@ export enum LayoutMixIngredient {
|
|
|
46
46
|
Arrive = 'arrive',
|
|
47
47
|
Phone = 'phone',
|
|
48
48
|
}
|
|
49
|
-
const MIX_WORDS: Readonly<Record<LayoutMixIngredient, ReadonlyArray<string>>> = {
|
|
50
|
-
[LayoutMixIngredient.Item]: L.items,
|
|
51
|
-
[LayoutMixIngredient.Arrange]: L.arranges,
|
|
52
|
-
[LayoutMixIngredient.Who]: L.standoutWho,
|
|
53
|
-
[LayoutMixIngredient.How]: L.standoutHow,
|
|
54
|
-
[LayoutMixIngredient.Move]: L.moves,
|
|
55
|
-
[LayoutMixIngredient.Hover]: L.hovers,
|
|
56
|
-
[LayoutMixIngredient.Arrive]: L.arrives,
|
|
57
|
-
[LayoutMixIngredient.Phone]: L.phones,
|
|
58
|
-
};
|
|
59
49
|
const MIX_SEPARATOR = ':';
|
|
60
50
|
const PART_SEPARATOR = '.';
|
|
61
|
-
/** Every word
|
|
62
|
-
export const LAYOUT_MIX_WORDS: ReadonlyArray<string> = (
|
|
63
|
-
|
|
51
|
+
/** Every word a stored mix may hold, ingredient by ingredient (a waiting word too: a stored answer still reads). */
|
|
52
|
+
export const LAYOUT_MIX_WORDS: ReadonlyArray<string> = LIST_INGREDIENTS.flatMap(k => listIngredientWords(k).map(w => `${k}${MIX_SEPARATOR}${w}`));
|
|
53
|
+
/** The words the wire OFFERS — the built ones only (ingredients.md §3.3): a waiting word would put its stand-in on every
|
|
54
|
+
* site that asked for it. */
|
|
55
|
+
export const LAYOUT_MIX_OFFERED: ReadonlyArray<string> = LIST_INGREDIENTS.flatMap(k => listBuiltWords(k).map(w => `${k}${MIX_SEPARATOR}${w}`));
|
|
56
|
+
const MIX_HINT = LIST_INGREDIENTS.map(k => `${k}:${listBuiltWords(k).join('|')}${(LIST_TABLE.many as ReadonlyArray<string>).includes(k) ? ' (any)' : ''}`).join(' · ');
|
|
64
57
|
|
|
65
58
|
/** A list a composed page may show, as the wire's parts enum needs it (`layoutListShapes` gives these). */
|
|
66
59
|
export interface LayoutWireList { alias: string; roles: ReadonlyArray<string> }
|
|
@@ -103,7 +96,7 @@ export function layoutWireJsonSchema(options: LayoutWireOptions = {}): JsonSchem
|
|
|
103
96
|
const partWords = options.lists ? layoutWirePartWords(options.lists) : [];
|
|
104
97
|
const lists: Record<string, JsonSchema> = options.lists
|
|
105
98
|
? {
|
|
106
|
-
mix: listOf(jsonOneOf(
|
|
99
|
+
mix: listOf(jsonOneOf(LAYOUT_MIX_OFFERED), `gallery showing a list (source): how its items are shown, one word per choice — ${MIX_HINT}; [] for none`),
|
|
107
100
|
parts: listOf(jsonOneOf(partWords.length ? partWords : [NONE]), "gallery showing a list as cards: the list's fields each card shows, <list>.<role>, the source's own; [] for none"),
|
|
108
101
|
}
|
|
109
102
|
: {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* THE LIST TABLE (list-ingredients-plan.md; the contract's `layout.mjs` `LIST`, in the shape every mixed part shares —
|
|
5
|
+
* ingredients.md §2): the words of each ingredient, what each means, and which wait for a later phase and are drawn as
|
|
6
|
+
* a built word meanwhile. Everything that offers, says or draws a list word reads it here; nothing retypes one.
|
|
7
|
+
*/
|
|
8
|
+
export const LIST_TABLE = SPEC_SITE_LAYOUT.list;
|
|
9
|
+
|
|
10
|
+
export type ListIngredient = keyof typeof LIST_TABLE.ingredients;
|
|
11
|
+
|
|
12
|
+
/** The ingredients, in the table's order. */
|
|
13
|
+
export const LIST_INGREDIENTS = Object.keys(LIST_TABLE.ingredients) as ListIngredient[];
|
|
14
|
+
|
|
15
|
+
/** A word that is not drawn yet: the phase it waits for and the built word it is drawn as (null: drawn without it). */
|
|
16
|
+
export interface ListWait { phase: string; drawnAs: string | null }
|
|
17
|
+
|
|
18
|
+
const WAITS = LIST_TABLE.waits as Readonly<Record<string, ListWait>>;
|
|
19
|
+
const MEANINGS = LIST_TABLE.meanings as Readonly<Record<string, string>>;
|
|
20
|
+
|
|
21
|
+
/** Every word of an ingredient. */
|
|
22
|
+
export function listIngredientWords(k: ListIngredient): ReadonlyArray<string> {
|
|
23
|
+
return LIST_TABLE.ingredients[k] as ReadonlyArray<string>;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** The wait of a word, or null when the product draws it. */
|
|
27
|
+
export function listWait(k: ListIngredient, word: string): ListWait | null {
|
|
28
|
+
return WAITS[`${k}.${word}`] ?? null;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The words of an ingredient the product draws — the only ones the wire offers (ingredients.md §3.3). */
|
|
32
|
+
export function listBuiltWords(k: ListIngredient): string[] {
|
|
33
|
+
return listIngredientWords(k).filter(w => !listWait(k, w));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** What a word means, in the words the model and the owner read (the word itself when the table has none). */
|
|
37
|
+
export function listMeaning(k: ListIngredient, word: string): string {
|
|
38
|
+
return MEANINGS[`${k}.${word}`] ?? word;
|
|
39
|
+
}
|
|
@@ -70,6 +70,10 @@ export interface NavShapeOptions {
|
|
|
70
70
|
newId?: (suffix: string) => string;
|
|
71
71
|
/** The studio's pages, for a header that links to none (a hand-built one): its menu lists these. */
|
|
72
72
|
pages?: ReadonlyArray<NavPage>;
|
|
73
|
+
/** Header ingredients (header-ingredients-plan.md HI-D8): the menu button and its drawer at EVERY width — the header's
|
|
74
|
+
* links and call to action are hidden at every width and the pages live in the drawer (a "name and menu" header).
|
|
75
|
+
* Drawer only. Default: what the header already does (`menuAtEveryWidth`), else phone widths only. */
|
|
76
|
+
everyWidth?: boolean;
|
|
73
77
|
}
|
|
74
78
|
|
|
75
79
|
export interface NavShapeResult {
|
|
@@ -77,6 +81,8 @@ export interface NavShapeResult {
|
|
|
77
81
|
globals: SerializedNode[];
|
|
78
82
|
shape: NavShape;
|
|
79
83
|
at: PhoneMenuBreakpoint;
|
|
84
|
+
/** The menu button shows at every width (`NavShapeOptions.everyWidth`). */
|
|
85
|
+
everyWidth: boolean;
|
|
80
86
|
}
|
|
81
87
|
|
|
82
88
|
export class NavShapeError extends Error {}
|
|
@@ -290,11 +296,34 @@ function clickTo(kit: Kit, suffix: string, type: NavDialogAction, target: string
|
|
|
290
296
|
}
|
|
291
297
|
|
|
292
298
|
/** Show at the phone width, hidden above it (base `display: none`, the breakpoint's own `display`). */
|
|
299
|
+
const MENU_DISPLAY = 'inline-flex';
|
|
300
|
+
/** What a header part hidden at every width shows again when the menu goes back to phone widths only. */
|
|
301
|
+
const BUILT_DISPLAY: Readonly<Record<string, string>> = { [NavRole.Links]: 'flex' };
|
|
302
|
+
|
|
293
303
|
function phoneOnly(node: SerializedNode, at: string, display: string): void {
|
|
294
304
|
node.styleProps[DISPLAY] = NONE;
|
|
295
305
|
node.responsive = { ...(node.responsive ?? {}), [at]: { ...(node.responsive?.[at] ?? {}), styleProps: { ...(node.responsive?.[at]?.styleProps ?? {}), [DISPLAY]: display } } };
|
|
296
306
|
}
|
|
297
307
|
|
|
308
|
+
/** At every width (HI-D8): `display` lives in the base styles and no breakpoint overrides it. */
|
|
309
|
+
function displayEverywhere(node: SerializedNode, display: string): void {
|
|
310
|
+
node.styleProps[DISPLAY] = display;
|
|
311
|
+
for (const [bp, layer] of Object.entries(node.responsive ?? {})) {
|
|
312
|
+
if (!layer?.styleProps || !(DISPLAY in layer.styleProps)) continue;
|
|
313
|
+
const { [DISPLAY]: _drop, ...rest } = layer.styleProps;
|
|
314
|
+
node.responsive![bp] = { ...layer, styleProps: rest };
|
|
315
|
+
if (!Object.keys(rest).length && Object.keys(layer).length === 1) delete node.responsive![bp];
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** Does the header show its menu button at every width (a "name and menu" header)? Read from the button itself, so a
|
|
320
|
+
* later change of shape or breakpoint keeps it. */
|
|
321
|
+
export function menuAtEveryWidth(globals: ReadonlyArray<SerializedNode>, navId?: string | null): boolean {
|
|
322
|
+
const root = findNavRoot(globals, navId);
|
|
323
|
+
const menu = root ? find([root], NavRole.MenuButton) : null;
|
|
324
|
+
return !!menu && menu.styleProps?.[DISPLAY] !== NONE;
|
|
325
|
+
}
|
|
326
|
+
|
|
298
327
|
/** Hidden at the phone width: the header's links row. */
|
|
299
328
|
function hideAt(node: SerializedNode, at: string): void {
|
|
300
329
|
node.responsive = { ...(node.responsive ?? {}), [at]: { ...(node.responsive?.[at] ?? {}), styleProps: { ...(node.responsive?.[at]?.styleProps ?? {}), [DISPLAY]: NONE } } };
|
|
@@ -331,7 +360,7 @@ function menuButton(kit: Kit, drawerId: string, at: string): SerializedNode {
|
|
|
331
360
|
const btn = part(kit, 'menu', BUTTON, { tag: 'button', ariaLabel: NAV_SHAPE_COPY.menu }, 'button-ghost', NavRole.MenuButton, { ...MENU_BUTTON_LAY });
|
|
332
361
|
btn.children = [iconNode(kit, 'menu-icon', MENU_ICON)];
|
|
333
362
|
btn.interactions = [clickTo(kit, 'menu', NavDialogAction.Toggle, drawerId)];
|
|
334
|
-
phoneOnly(btn, at,
|
|
363
|
+
phoneOnly(btn, at, MENU_DISPLAY);
|
|
335
364
|
return btn;
|
|
336
365
|
}
|
|
337
366
|
|
|
@@ -496,6 +525,9 @@ export function planNavShape(globals: ReadonlyArray<SerializedNode>, shape: NavS
|
|
|
496
525
|
if (!root) throw new NavShapeError('no Navigation bar among the globals');
|
|
497
526
|
const at = (options.at ?? navShapeBreakpoint(out)) as PhoneMenuBreakpoint;
|
|
498
527
|
if (!(Object.values(PhoneMenuBreakpoint) as string[]).includes(at)) throw new NavShapeError(`a phone menu cannot switch at "${at}"`);
|
|
528
|
+
const wasEveryWidth = menuAtEveryWidth(out, root.id);
|
|
529
|
+
const everyWidth = shape === NavShape.Drawer && (options.everyWidth ?? wasEveryWidth);
|
|
530
|
+
if (options.everyWidth && shape !== NavShape.Drawer) throw new NavShapeError('only a drawer menu shows at every width');
|
|
499
531
|
const kit = makeKit(out, root.id, options.newId);
|
|
500
532
|
|
|
501
533
|
adoptRoles(root);
|
|
@@ -511,18 +543,37 @@ export function planNavShape(globals: ReadonlyArray<SerializedNode>, shape: NavS
|
|
|
511
543
|
if (dr) { delete dr.isGlobal; delete dr.globalPosition; }
|
|
512
544
|
if (wantDrawer && !dr) dr = drawer(kit, root, pages, at);
|
|
513
545
|
if (!wantDrawer) dr = null;
|
|
514
|
-
|
|
546
|
+
// A drawer reached at every width never closes itself above a breakpoint.
|
|
547
|
+
if (dr) dr.props = { ...dr.props, closeAbove: everyWidth ? '' : at };
|
|
515
548
|
|
|
516
549
|
// The menu button: Drawer only (Q4: with a bar, the phone header keeps only the brand).
|
|
517
550
|
const existingMenu = removeRole(root, NavRole.MenuButton);
|
|
518
551
|
const menu = wantMenuButton ? (existingMenu ? asToggle(existingMenu) : menuButton(kit, dr!.id, at)) : null;
|
|
519
552
|
|
|
520
|
-
for (const p of phoneHiddenParts(root)) {
|
|
553
|
+
for (const p of phoneHiddenParts(root)) {
|
|
554
|
+
if (everyWidth) { displayEverywhere(p, NONE); continue; }
|
|
555
|
+
// Back from every width: the base `none` was this function's, not the author's. Base styles hold ONE display, so
|
|
556
|
+
// the part takes back what its role is built with (the links row is a row), else its type's own.
|
|
557
|
+
if (wasEveryWidth && p.styleProps?.[DISPLAY] === NONE) {
|
|
558
|
+
const back = BUILT_DISPLAY[roleOf(p) ?? ''];
|
|
559
|
+
if (back) p.styleProps[DISPLAY] = back;
|
|
560
|
+
else delete p.styleProps[DISPLAY];
|
|
561
|
+
}
|
|
562
|
+
moveDisplayOverride(p, at);
|
|
563
|
+
hideAt(p, at);
|
|
564
|
+
}
|
|
521
565
|
centerBrandAt(root, at, wantBar);
|
|
522
566
|
phoneRowAt(root, at, wantMenuButton);
|
|
523
567
|
|
|
524
568
|
const kids = root.children ?? (root.children = []);
|
|
525
|
-
if (menu) {
|
|
569
|
+
if (menu) {
|
|
570
|
+
if (everyWidth) displayEverywhere(menu, MENU_DISPLAY);
|
|
571
|
+
else {
|
|
572
|
+
moveDisplayOverride(menu, at);
|
|
573
|
+
if (wasEveryWidth) phoneOnly(menu, at, MENU_DISPLAY);
|
|
574
|
+
}
|
|
575
|
+
kids.push(menu);
|
|
576
|
+
}
|
|
526
577
|
if (dr && shape === NavShape.Drawer) kids.push(dr);
|
|
527
578
|
if (dr && shape === NavShape.Both) {
|
|
528
579
|
dr.isGlobal = true;
|
|
@@ -552,7 +603,7 @@ export function planNavShape(globals: ReadonlyArray<SerializedNode>, shape: NavS
|
|
|
552
603
|
}
|
|
553
604
|
out.push(b);
|
|
554
605
|
}
|
|
555
|
-
return { globals: out, shape, at };
|
|
606
|
+
return { globals: out, shape, at, everyWidth };
|
|
556
607
|
}
|
|
557
608
|
|
|
558
609
|
/** Mark a hand-built header's parts with their roles, so every later edit can find them. */
|
|
@@ -52,6 +52,8 @@ export * from './layout-photos';
|
|
|
52
52
|
export * from './photo-inventory';
|
|
53
53
|
export * from './check-layout';
|
|
54
54
|
export * from './check-list';
|
|
55
|
+
export * from './list-table';
|
|
55
56
|
export * from './layout-space';
|
|
56
57
|
export * from './layout-fingerprint';
|
|
58
|
+
export * from './header-mix';
|
|
57
59
|
export * from './layout-edits';
|