@vectoriox/iox-ui 5.147.0 → 5.148.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/composite-core/index.d.ts +15 -1
- package/design-core/index.d.ts +70 -6
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs +31 -2
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +101 -12
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +1154 -959
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/generation-core/index.d.ts +81 -36
- package/harness-core/index.d.ts +8 -1
- package/package.json +1 -1
- package/src/composite-core/slider.ts +33 -2
- package/src/design-core/design-apply.ts +6 -0
- package/src/design-core/flavor-spec.generated.ts +48 -0
- package/src/design-core/flavor-tokens.ts +6 -2
- package/src/design-core/header-behaviour.ts +25 -8
- package/src/design-core/node-classes.ts +15 -0
- package/src/design-core/token-css.ts +6 -3
- package/src/generation-core/check-layout.ts +34 -6
- package/src/generation-core/compose-layout.ts +64 -41
- package/src/generation-core/compose-site.ts +6 -2
- package/src/generation-core/footer-mix.ts +7 -2
- package/src/generation-core/layout-column.ts +120 -0
- package/src/generation-core/layout-language.ts +66 -12
- package/src/generation-core/layout-space.ts +6 -5
- package/src/generation-core/layout-type.ts +6 -3
- package/src/generation-core/layout-wire.ts +27 -5
- package/src/generation-core/site-spec.generated.ts +11 -23
- package/src/harness-core/business-types.ts +8 -0
- package/styles/iox-design.css +14 -3
|
@@ -92,6 +92,14 @@ export const COLUMN_SETTING = 'column';
|
|
|
92
92
|
export const CONTENT_WIDTH_TOKEN = 'content-width';
|
|
93
93
|
/** What `content-width` holds for Wide: the whole page, so the inset is the one gutter (`space-edge`). */
|
|
94
94
|
export const WIDE_CONTENT_WIDTH = '100%';
|
|
95
|
+
/**
|
|
96
|
+
* Award §0c CW2 (iox-ui#117): the column in force as a LENGTH a `font-size` can read — a `%` there is the parent's
|
|
97
|
+
* font size, so `content-width` (100% in wide) cannot be read by a screen word. The column's px, `100vw` in wide;
|
|
98
|
+
* re-declared beside `content-width` by a page's word, so a global footer's closing name fits the page it is on.
|
|
99
|
+
*/
|
|
100
|
+
export const CONTENT_CAP_TOKEN = 'content-cap';
|
|
101
|
+
/** What `content-cap` holds for Wide: the window. */
|
|
102
|
+
export const WIDE_CONTENT_CAP = '100vw';
|
|
95
103
|
|
|
96
104
|
type ColumnWord = keyof typeof SPEC_AXES.columns;
|
|
97
105
|
const COLUMN_WORDS = SPEC_AXES.columns as Readonly<Record<string, { readonly column: string | null }>>;
|
|
@@ -113,6 +121,13 @@ export function contentWidthOf(column: unknown, rowValue: (name: string) => stri
|
|
|
113
121
|
return row ? rowValue(row) ?? null : WIDE_CONTENT_WIDTH;
|
|
114
122
|
}
|
|
115
123
|
|
|
124
|
+
/** The literal `content-cap` holds for a column word: the column's px (the same row `content-width` reads), `100vw` in
|
|
125
|
+
* wide. Null for an unknown word or a column row the set lacks. */
|
|
126
|
+
export function contentCapOf(column: unknown, rowValue: (name: string) => string | undefined): string | null {
|
|
127
|
+
const width = contentWidthOf(column, rowValue);
|
|
128
|
+
return width === WIDE_CONTENT_WIDTH ? WIDE_CONTENT_CAP : width;
|
|
129
|
+
}
|
|
130
|
+
|
|
116
131
|
/** The selector a column word's block is declared on, inside `scope` (the builder's token scope — the attribute sits on
|
|
117
132
|
* the scope element itself) or anywhere (the engine's `<body>`). */
|
|
118
133
|
export function columnSelector(word: string, scope?: string): string {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DesignMode } from './design-token.model';
|
|
2
2
|
import { SPEC_A11Y, SPEC_AXES, SPEC_SCHEMES } from './flavor-spec.generated';
|
|
3
|
-
import { columnSelector, CONTENT_WIDTH_TOKEN, contentWidthOf, openingFollowerSelector, SCHEME_INK } from './node-classes';
|
|
3
|
+
import { columnSelector, CONTENT_CAP_TOKEN, CONTENT_WIDTH_TOKEN, contentCapOf, contentWidthOf, openingFollowerSelector, SCHEME_INK } from './node-classes';
|
|
4
4
|
import { specTokenNames } from './token-names';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -13,7 +13,7 @@ import { specTokenNames } from './token-names';
|
|
|
13
13
|
* 1. base `:root { --iox-*: … }`
|
|
14
14
|
* 2. schemes `.iox-scheme-<id> { overrides; every var()-referencing token re-declared }`, then the
|
|
15
15
|
* ONE scheme-ink rule `.iox-scheme-subtle, … { color: var(--iox-text) }` (iox-ui#15)
|
|
16
|
-
* columns `[data-iox-column="<word>"] { --iox-content-width: <literal>; every token reading it }` (award §0c)
|
|
16
|
+
* columns `[data-iox-column="<word>"] { --iox-content-width: <literal>; --iox-content-cap: <length>; every token reading it }` (award §0c)
|
|
17
17
|
* 3. reduced motion `@media (prefers-reduced-motion: reduce)`
|
|
18
18
|
* 4. reduced transparency `@media (prefers-reduced-transparency: reduce)`
|
|
19
19
|
* 5. dark — LAST `@media (prefers-color-scheme: dark)`
|
|
@@ -351,9 +351,12 @@ function columnCss(rows: ReadonlyArray<DesignTokenLike>, scope?: string): { base
|
|
|
351
351
|
.map(word => [word, contentWidthOf(word, value)] as const)
|
|
352
352
|
.filter((w): w is readonly [string, string] => w[1] !== null);
|
|
353
353
|
const darkDependents = dependents.map((t): [string, string | null] => [t.name, darkOf(t)]).filter((e): e is [string, string] => e[1] !== null);
|
|
354
|
+
// iox-ui#117: `content-cap` (the column as a length) moves with the word — only where the rows hold it.
|
|
355
|
+
const capped = rows.some(t => t.name === CONTENT_CAP_TOKEN);
|
|
354
356
|
return {
|
|
355
357
|
base: words.map(([word, width]) => rule(columnSelector(word, scope), [
|
|
356
|
-
[CONTENT_WIDTH_TOKEN, width], ...
|
|
358
|
+
[CONTENT_WIDTH_TOKEN, width], ...(capped ? [[CONTENT_CAP_TOKEN, contentCapOf(word, value)!] as [string, string]] : []),
|
|
359
|
+
...dependents.filter(t => t.name !== CONTENT_CAP_TOKEN).map((t): [string, string] => [t.name, t.value]),
|
|
357
360
|
])).filter(Boolean).join('\n'),
|
|
358
361
|
// A dependent with a dark value would keep its LIGHT value under the word's block in a dark visit.
|
|
359
362
|
dark: darkDependents.length ? words.map(([word]) => rule(columnSelector(word, scope), darkDependents, ' ')).join('\n') : '',
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { DesignChoices, designTokenRows, parseCssColour, presetChoices, relativeLuminance, resolveTokenValues, ScrubId, scrubOfChoices, toHexColor } from '@vectoriox/iox-ui/design-core';
|
|
1
|
+
import { columnWordOf, DesignChoices, designTokenRows, parseCssColour, presetChoices, relativeLuminance, resolveTokenValues, ScrubId, scrubOfChoices, SPEC_AXES, toHexColor } from '@vectoriox/iox-ui/design-core';
|
|
2
2
|
import { ParallaxDepth } from '@vectoriox/iox-ui/scene-core';
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
LAYOUT_HIDDEN_OPACITY, LAYOUT_OPERATED, LAYOUT_TEXT_KINDS, LayoutBandMove, LayoutColour, LayoutDepth, LayoutDial, LayoutEnter, LayoutGalleryList, LayoutIssue, LayoutListShape, LayoutIssueCode, LayoutLayer, LayoutLayerKind, LayoutMend, LayoutMendKind,
|
|
5
|
+
LAYOUT_COLUMN_MENDED, LAYOUT_HIDDEN_OPACITY, LAYOUT_OPERATED, LAYOUT_TEXT_KINDS, LayoutBandMove, LayoutColour, LayoutDepth, LayoutDial, LayoutEnter, LayoutGalleryList, LayoutIssue, LayoutListShape, LayoutIssueCode, LayoutLayer, LayoutLayerKind, LayoutMend, LayoutMendKind,
|
|
6
6
|
LayoutGivenAway, LayoutListArrange, LayoutListArrive, LayoutListHover, LayoutListItem, LayoutListMix, LayoutListPhone, LayoutPage, LayoutPhotoSource,
|
|
7
7
|
LayoutRole, LayoutScrubRefusal, LayoutSection, LayoutSectionKind, LayoutSourceChoice, LayoutTrackProp, parseLayoutPhotoId,
|
|
8
8
|
} from './layout-language';
|
|
9
9
|
import { layoutScrubTakes } from './text-scroll';
|
|
10
|
+
import { layoutColumnsOffered } from './layout-wire';
|
|
11
|
+
import { layoutColumnWord, layoutJudgeColumnPx } from './layout-column';
|
|
10
12
|
import { DriftBox, driftOverlap, layoutGlideDepth } from './layout-drift';
|
|
11
13
|
import { layoutLookOf } from './layout-look';
|
|
12
14
|
import { patternById, SCENE_LEVEL } from './patterns';
|
|
@@ -80,6 +82,9 @@ export interface CheckLayoutContext {
|
|
|
80
82
|
rhythm?: string | null;
|
|
81
83
|
/** AW6: how the footer's ground reads — the `tail` rhythm's last sections wear it. Absent: the tail is not judged. */
|
|
82
84
|
footerTone?: GroundTone | null;
|
|
85
|
+
/** Award §0c CW2 (AW-D34): the column words this business type never wears (harness-core `BusinessType.column.never`):
|
|
86
|
+
* a page asking one is mended to the first word it may wear (`column-mended`). */
|
|
87
|
+
columnNever?: ReadonlyArray<string>;
|
|
83
88
|
}
|
|
84
89
|
|
|
85
90
|
/** The look's composition notes, read as one shape (the contract's looks differ in which limits they set). */
|
|
@@ -127,6 +132,21 @@ function presetPaint(presetId: string, mode: 'light' | 'dark'): { colours: Layou
|
|
|
127
132
|
return { colours, accentText: hex(ACCENT_TEXT_TOKEN) ?? colours[LayoutColour.Accent] };
|
|
128
133
|
}
|
|
129
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Award §0c CW2 (AW-D34, R-H25): the page's column word — a word outside the axis is dropped (the page wears the site's);
|
|
137
|
+
* a word the business type never wears (a formal type's `wide`) takes the first it may (`contained`). Both mend alone.
|
|
138
|
+
*/
|
|
139
|
+
export function columnIssues(page: Pick<LayoutPage, 'column'>, ctx: Pick<CheckLayoutContext, 'columnNever'>): LayoutIssue[] {
|
|
140
|
+
if (page?.column === undefined || page.column === null) return [];
|
|
141
|
+
const offered = layoutColumnsOffered(ctx.columnNever);
|
|
142
|
+
if (!columnWordOf(page.column)) {
|
|
143
|
+
return [{ code: LayoutIssueCode.Value, path: 'column', message: `${Object.keys(SPEC_AXES.columns).join(' | ')} — "${page.column}" is no column: the page wears the site's`, mend: { kind: LayoutMendKind.Column, column: null } }];
|
|
144
|
+
}
|
|
145
|
+
if (offered.includes(page.column)) return [];
|
|
146
|
+
const column = offered.includes(SPEC_AXES.columnChoices.new) ? SPEC_AXES.columnChoices.new : offered[0] ?? null;
|
|
147
|
+
return [{ code: LayoutIssueCode.Value, path: 'column', message: `${LAYOUT_COLUMN_MENDED}: this business never wears "${page.column}" — composed ${column ?? "in the site's column"}`, mend: { kind: LayoutMendKind.Column, column } }];
|
|
148
|
+
}
|
|
149
|
+
|
|
130
150
|
/** A preset's five colours in a mode as `#rrggbb` (the prototype's `presetColours`), or null when it does not wear that mode. */
|
|
131
151
|
export function layoutPresetColours(presetId: string, mode: 'light' | 'dark'): LayoutColours | null {
|
|
132
152
|
return presetPaint(presetId, mode)?.colours ?? null;
|
|
@@ -319,6 +339,10 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
|
|
|
319
339
|
const limits = look?.limits ?? {};
|
|
320
340
|
const daring = page.dial === LayoutDial.Daring;
|
|
321
341
|
if (!inList(V.dials, page.dial)) add(LayoutIssueCode.Value, 'dial', V.dials.join(' | '));
|
|
342
|
+
for (const issue of columnIssues(page, ctx)) issues.push(issue);
|
|
343
|
+
// Award §0c CW2 (AW-D38): the px judges read the page's column — its own word, else the design's when one is given.
|
|
344
|
+
const columnWord = layoutColumnWord(columnWordOf(page.column) ? page.column : undefined, ctx.design);
|
|
345
|
+
const judgeColumnPx = layoutJudgeColumnPx(columnWord, design.density, LAYOUT_CHECK_VIEWPORT.width);
|
|
322
346
|
const facts = String(ctx.facts ?? '');
|
|
323
347
|
const factKeys = ctx.factKeys ?? Object.keys(SPEC_SITE_FACTS);
|
|
324
348
|
const routes = ctx.routes ?? [];
|
|
@@ -468,14 +492,14 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
|
|
|
468
492
|
if ((l.size === 'm' || l.size === 's') && text.length > LIM.longTextChars && span(l.col) > LIM.longTextColumns) {
|
|
469
493
|
add(LayoutIssueCode.Reading, `${lp}.col`, `long text is never wider than ${LIM.longTextColumns} columns`);
|
|
470
494
|
}
|
|
471
|
-
if (placed && isText(l) && l.size && l.size !== 'screen' && text && !layoutTextFits(l, s)) {
|
|
472
|
-
const lines = Math.floor(boxPx(l.col, l.row, s).h / (L.sizePx[l.size] * LAYOUT_LINE_HEIGHT));
|
|
495
|
+
if (placed && isText(l) && l.size && l.size !== 'screen' && text && !layoutTextFits(l, s, l.size, judgeColumnPx)) {
|
|
496
|
+
const lines = Math.floor(boxPx(l.col, l.row, s, judgeColumnPx).h / (L.sizePx[l.size] * LAYOUT_LINE_HEIGHT));
|
|
473
497
|
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`);
|
|
474
498
|
}
|
|
475
499
|
if (l.size === 'screen' || l.size === 'xxl') huge++;
|
|
476
500
|
if (l.size === 'screen') {
|
|
477
501
|
screenWords++;
|
|
478
|
-
const misfit = text ? screenWordMisfit(l, design) : null;
|
|
502
|
+
const misfit = text ? screenWordMisfit(l, design, columnWord) : null;
|
|
479
503
|
if (misfit) add(LayoutIssueCode.Reading, `${lp}.text`, `"${text}" is ${misfit.px}px too wide for ${misfit.phone ? `a ${misfit.width}px phone` : 'its columns'} even at the smallest screen size — fewer letters, ${misfit.phone ? '' : 'more columns, '}or size xxl`);
|
|
480
504
|
}
|
|
481
505
|
if (l.bleed && l.bleed !== 'none') bleeds++;
|
|
@@ -642,7 +666,7 @@ function examineLayout(page: LayoutPage, ctx: CheckLayoutContext, carried: Layou
|
|
|
642
666
|
if (placed && (isText(l) || l.kind === LayoutLayerKind.Button)) {
|
|
643
667
|
const under: PhotoUnder[] = layers
|
|
644
668
|
.filter(o => o !== l && o.kind === LayoutLayerKind.Photo && (o.z ?? 0) < (l.z ?? 0) && overlaps(o, l) && o.photo?.id)
|
|
645
|
-
.map(o => ({ id: o.photo!.id, frame: boxPx(o.col, o.row, s), region: regionInLayer(o, l) }));
|
|
669
|
+
.map(o => ({ id: o.photo!.id, frame: boxPx(o.col, o.row, s, judgeColumnPx), region: regionInLayer(o, l) }));
|
|
646
670
|
if (groundPhoto) under.push({ id: groundPhoto, frame: { w: LAYOUT_CHECK_VIEWPORT.width, h: s.screens * LAYOUT_CHECK_VIEWPORT.height }, region: regionOnGround(s, l) });
|
|
647
671
|
const fgHex = isText(l) ? colourHex(l.color, true) : null;
|
|
648
672
|
const fg = fgHex ? lumOf(fgHex) : null;
|
|
@@ -1177,6 +1201,10 @@ export function mendLayout(page: LayoutPage, issues: ReadonlyArray<LayoutIssue>)
|
|
|
1177
1201
|
if (mend.sections.some(m => !next.sections?.[m.section])) continue;
|
|
1178
1202
|
for (const m of mend.sections) next.sections[m.section].screens = m.screens;
|
|
1179
1203
|
mended.push(issue);
|
|
1204
|
+
} else if (mend?.kind === LayoutMendKind.Column) {
|
|
1205
|
+
if (mend.column) next.column = mend.column;
|
|
1206
|
+
else delete next.column;
|
|
1207
|
+
mended.push(issue);
|
|
1180
1208
|
} else if (mend?.kind === LayoutMendKind.Drop && layerAt(mend.layer)) {
|
|
1181
1209
|
drops.push(issue);
|
|
1182
1210
|
}
|
|
@@ -4,22 +4,27 @@ import {
|
|
|
4
4
|
SLIDER_PLACEMENT_TRAIT, SliderPlacement, SliderRole, syncSliderParts, SHOP_RECIPES, ShopRecipe, ShopRole, bindShopPart, ShopBindTarget,
|
|
5
5
|
} from '@vectoriox/iox-ui/composite-core';
|
|
6
6
|
|
|
7
|
-
import { ColorScheme, DesignChoices, LIST_MIX_PROP, LinkType, scrubOfChoices, setColorScheme } from '@vectoriox/iox-ui/design-core';
|
|
7
|
+
import { ColorScheme, DesignChoices, LIST_MIX_PROP, LinkType, scrubOfChoices, setColorScheme, SPEC_AXES } from '@vectoriox/iox-ui/design-core';
|
|
8
8
|
import { TextRevealBy } from '@vectoriox/iox-ui/scene-core';
|
|
9
9
|
import { FORM_AFTER_SEND_TRAIT, FormAfterSend, FormPresetId } from '@vectoriox/iox-ui/forms-core';
|
|
10
10
|
import { composeNavHeader, composePresetForm } from './compose-site';
|
|
11
11
|
import { drawnHeaderMix, headerMixOfNavKind } from './header-mix';
|
|
12
12
|
import { LIST_RULES, LIST_RHYTHMS, listWait } from './list-table';
|
|
13
|
+
import { SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
13
14
|
import { listMixWords } from './layout-wire';
|
|
14
15
|
import {
|
|
15
|
-
LAYOUT_ACCENT_TEXT, LAYOUT_BEAT_DELAY, LAYOUT_COLOUR_TOKEN, LAYOUT_COLUMN_GAP, LAYOUT_DEPTH_ON_PHONE, LAYOUT_EASING,
|
|
16
|
+
LAYOUT_ACCENT_TEXT, LAYOUT_BEAT_DELAY, LAYOUT_COLOUR_TOKEN, LAYOUT_COLUMN_GAP, LAYOUT_DEPTH_ON_PHONE, LAYOUT_EASING, LAYOUT_PACE, LAYOUT_PHONE_BREAKPOINT, LAYOUT_PHOTO_ASPECT, LAYOUT_TOOLTIP_TRAIT,
|
|
16
17
|
LAYOUT_PHONE_PADDING, LAYOUT_RISE, LAYOUT_TEXT_KINDS, LayoutBleed, LayoutColour, LayoutEase, LayoutEnter, LayoutForm, LayoutGallery, LayoutLayer,
|
|
17
18
|
LayoutListArrange, LayoutListArrive, LayoutListHover, LayoutListHow, LayoutListItem, LayoutListMix, LayoutListMove, LayoutListPhone, LayoutListWho,
|
|
18
19
|
LayoutLayerKind, LayoutNavKind, LayoutPace, LayoutPhotoShape, LayoutRole, LayoutSection, LayoutSide, LayoutSite, LayoutTrack, LayoutTrackProp, LayoutTransition, phoneGapBefore,
|
|
19
20
|
screenFontSize,
|
|
20
21
|
} from './layout-language';
|
|
21
22
|
import { layoutGlideDepth } from './layout-drift';
|
|
22
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
LAYOUT_BLEED_END_LINE, LAYOUT_BLEED_START_LINE, LAYOUT_INSET, layoutBledBarInset, layoutColumnPx, layoutColumnStart, layoutColumnWord, layoutGapPx,
|
|
25
|
+
layoutGridColumns, layoutGridLine, layoutGridPx,
|
|
26
|
+
} from './layout-column';
|
|
27
|
+
import { isLayoutRule, LAYOUT_CHECK_VIEWPORT, layoutRuleEdge } from './layout-space';
|
|
23
28
|
import { LIST_DECK_MAX_PX, LIST_DECK_SHARE, listOverhang } from './list-space';
|
|
24
29
|
import { layoutDesignOf, layoutElementStyle, layoutTextWidthEm, screenWordColumns } from './layout-type';
|
|
25
30
|
import { ComposeError, createSerializedNode, SerializedNode, setStyleProps, assertStyleSlots, walkSerialized } from './serialized-node';
|
|
@@ -257,6 +262,9 @@ interface Ctx {
|
|
|
257
262
|
sections: Record<string, string>;
|
|
258
263
|
gaps: LayoutGap[];
|
|
259
264
|
design: DesignChoices;
|
|
265
|
+
/** Award §0c CW2: the page's content column in px at its density, or null (wide): what a `screen` word, a bled
|
|
266
|
+
* gallery's bar and a list's item count are stamped for (`layout-column.ts`). */
|
|
267
|
+
columnPx: number | null;
|
|
260
268
|
photoSrc: (id: string) => string;
|
|
261
269
|
photoAlt: (id: string) => string;
|
|
262
270
|
photoAspect: (id: string) => string;
|
|
@@ -388,14 +396,15 @@ function isLight(colour: string | undefined, mode: LayoutColourMode): boolean {
|
|
|
388
396
|
|
|
389
397
|
const gridTemplate = (count: number) => `repeat(${count}, minmax(0, 1fr))`;
|
|
390
398
|
|
|
391
|
-
/** The grid a section's layers are placed on: 12 columns per screen
|
|
399
|
+
/** The grid a section's layers are placed on: 12 columns per screen between an outer track a side (the page's column,
|
|
400
|
+
* award §0c CW2 — `layoutGridColumns`), its rows. No inline padding: a bleed spans into an outer track. */
|
|
392
401
|
function gridLayout(rows: number, track: number): Record<string, string> {
|
|
393
402
|
return {
|
|
394
403
|
display: 'grid',
|
|
395
|
-
gridTemplateColumns:
|
|
404
|
+
gridTemplateColumns: layoutGridColumns(track),
|
|
396
405
|
gridTemplateRows: gridTemplate(rows),
|
|
397
406
|
gap: `${ZERO} ${LAYOUT_COLUMN_GAP}`,
|
|
398
|
-
padding:
|
|
407
|
+
padding: ZERO,
|
|
399
408
|
};
|
|
400
409
|
}
|
|
401
410
|
|
|
@@ -406,16 +415,10 @@ function phoneStack(first: boolean): Record<string, string> {
|
|
|
406
415
|
flexDirection: 'column',
|
|
407
416
|
height: 'auto',
|
|
408
417
|
gap: ZERO,
|
|
409
|
-
padding: `${first ? PHONE_FIRST_TOP : LAYOUT_PHONE_PADDING} ${
|
|
418
|
+
padding: `${first ? PHONE_FIRST_TOP : LAYOUT_PHONE_PADDING} ${LAYOUT_INSET} ${LAYOUT_PHONE_PADDING} ${LAYOUT_INSET}`,
|
|
410
419
|
};
|
|
411
420
|
}
|
|
412
421
|
|
|
413
|
-
/** A bleed's width: its cell and the gutters it runs into (a negative margin alone moves a box that holds its width). */
|
|
414
|
-
function bleedWidth(bleed: string | undefined): string | null {
|
|
415
|
-
if (!bleed || bleed === LayoutBleed.None) return null;
|
|
416
|
-
return bleed === LayoutBleed.Both ? `calc(100% + 2 * ${LAYOUT_GUTTER})` : `calc(100% + ${LAYOUT_GUTTER})`;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
422
|
/** The physical sides a bleed runs into, from the page's direction. */
|
|
420
423
|
function bleedSides(bleed: string | undefined, rtl: boolean): { left: boolean; right: boolean } | null {
|
|
421
424
|
if (!bleed || bleed === LayoutBleed.None) return null;
|
|
@@ -424,12 +427,16 @@ function bleedSides(bleed: string | undefined, rtl: boolean): { left: boolean; r
|
|
|
424
427
|
return rtl ? { left: end, right: start } : { left: start, right: end };
|
|
425
428
|
}
|
|
426
429
|
|
|
427
|
-
/**
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
430
|
+
/**
|
|
431
|
+
* A layer's columns on the grid (award §0c CW2): its layout lines past the outer track — and a bleed spans into the outer
|
|
432
|
+
* track on its side, to the window's edge (grid lines are logical, so a start bleed is the right edge in Hebrew). Never a
|
|
433
|
+
* negative margin: inside a cell a `%` is the cell's (T-CW2).
|
|
434
|
+
*/
|
|
435
|
+
function gridColumnOf(l: LayoutLayer): string {
|
|
436
|
+
const bleed = l.bleed && l.bleed !== LayoutBleed.None ? l.bleed : null;
|
|
437
|
+
const start = bleed === LayoutBleed.Start || bleed === LayoutBleed.Both ? LAYOUT_BLEED_START_LINE : layoutGridLine(l.col[0]);
|
|
438
|
+
const end = bleed === LayoutBleed.End || bleed === LayoutBleed.Both ? LAYOUT_BLEED_END_LINE : layoutGridLine(l.col[1]);
|
|
439
|
+
return `${start} / ${end}`;
|
|
433
440
|
}
|
|
434
441
|
|
|
435
442
|
// ── Motion ──────────────────────────────────────────────────────────────────────────────────────────────
|
|
@@ -552,17 +559,13 @@ interface LayerCtx {
|
|
|
552
559
|
function place(node: SerializedNode, l: LayoutLayer, lc: LayerCtx, ctx: Ctx): void {
|
|
553
560
|
const stretch = STRETCH_KINDS.has(l.kind);
|
|
554
561
|
const values: Record<string, unknown> = {
|
|
555
|
-
gridColumn:
|
|
562
|
+
gridColumn: gridColumnOf(l),
|
|
556
563
|
gridRow: `${l.row[0]} / ${l.row[1]}`,
|
|
557
564
|
alignSelf: stretch ? 'stretch' : 'center',
|
|
558
565
|
zIndex: String(1 + (l.z ?? 0)),
|
|
559
566
|
position: 'relative',
|
|
560
567
|
minWidth: ZERO,
|
|
561
568
|
};
|
|
562
|
-
const margin = bleedMargin(l.bleed, ctx.rtl);
|
|
563
|
-
if (margin) values['margin'] = margin;
|
|
564
|
-
const width = l.kind === LayoutLayerKind.Button ? null : bleedWidth(l.bleed);
|
|
565
|
-
if (width) values['width'] = width;
|
|
566
569
|
if (l.rotate) values['rotate'] = `${l.rotate}deg`;
|
|
567
570
|
if (l.kind === LayoutLayerKind.Button) values['justifySelf'] = l.align === 'center' ? 'center' : l.align === 'end' ? 'end' : 'start';
|
|
568
571
|
else if (l.kind !== LayoutLayerKind.Photo && l.kind !== LayoutLayerKind.Gallery && l.kind !== LayoutLayerKind.Shape) values['textAlign'] = l.align ?? 'start';
|
|
@@ -571,7 +574,6 @@ function place(node: SerializedNode, l: LayoutLayer, lc: LayerCtx, ctx: Ctx): vo
|
|
|
571
574
|
gridColumn: 'auto', gridRow: 'auto', alignSelf: l.kind === LayoutLayerKind.Button ? 'flex-start' : 'stretch', order: String(lc.order),
|
|
572
575
|
margin: `${lc.phoneGap}px ${ZERO} ${ZERO} ${ZERO}`,
|
|
573
576
|
};
|
|
574
|
-
if (width) onPhone['width'] = FULL;
|
|
575
577
|
if (l.kind === LayoutLayerKind.Button && lc.phoneAlign === 'center') onPhone['alignSelf'] = 'center';
|
|
576
578
|
if (values['textAlign']) onPhone['textAlign'] = lc.phoneAlign;
|
|
577
579
|
if (l.kind === LayoutLayerKind.Shape) onPhone['display'] = 'none';
|
|
@@ -633,7 +635,7 @@ function textLayer(id: string, l: LayoutLayer, lc: LayerCtx, ctx: Ctx): Serializ
|
|
|
633
635
|
const rows = l.row[1] - l.row[0];
|
|
634
636
|
const em = layoutTextWidthEm(l, ctx.design);
|
|
635
637
|
const screens = lc.held ? 1 : lc.section.screens;
|
|
636
|
-
setStyleProps(node, { fontSize: screenFontSize(em, screenWordColumns(l), rows, lc.section.rows, screens) });
|
|
638
|
+
setStyleProps(node, { fontSize: screenFontSize(em, screenWordColumns(l), rows, lc.section.rows, screens, ctx.columnPx) });
|
|
637
639
|
phone(node, { fontSize: screenFontSize(em, GRID_COLUMNS, 0, 0, 0) });
|
|
638
640
|
gap(ctx, LayoutGapCode.ScreenFit, lc.path, 'sized from its face\'s measured letters (no kerning), not fitted in the browser');
|
|
639
641
|
}
|
|
@@ -758,7 +760,8 @@ function galleryLayer(id: string, l: LayoutLayer, lc: LayerCtx, ctx: Ctx): Seria
|
|
|
758
760
|
const sides = bleedSides(l.bleed, ctx.rtl);
|
|
759
761
|
const bar = (slider.children ?? []).find(c => c.role === SliderRole.Bar);
|
|
760
762
|
if (sides && bar) {
|
|
761
|
-
|
|
763
|
+
const inset = layoutBledBarInset(ctx.columnPx);
|
|
764
|
+
setStyleProps(bar, { padding: `${GALLERY_BAR_TOP} ${sides.right ? inset : ZERO} ${ZERO} ${sides.left ? inset : ZERO}` });
|
|
762
765
|
phone(bar, { padding: `${GALLERY_BAR_TOP} ${ZERO} ${ZERO} ${ZERO}` });
|
|
763
766
|
}
|
|
764
767
|
if (lc.held) gap(ctx, LayoutGapCode.StageSlider, lc.path, 'played by the Scene\'s driver, which plays any slider on its stage (vectoriox/iox-ui#54)');
|
|
@@ -797,9 +800,30 @@ function listOfLayer(l: LayoutLayer, ctx: Ctx): LayoutListBinding | null {
|
|
|
797
800
|
return g?.list && g.source ? ctx.listOf(g.source) : null;
|
|
798
801
|
}
|
|
799
802
|
|
|
800
|
-
/**
|
|
801
|
-
|
|
802
|
-
|
|
803
|
+
/** Award §0c CW2 (AW-D38, amended 2026-11-23 — Doron: half the contained column holds TWO pictures, not one): the least an
|
|
804
|
+
* item of a grid may stand at the check's laptop — a picture item, a words-only one. The ONE table: the contract's
|
|
805
|
+
* `layout.limits.listItemMinPx` (layout.mjs LIMITS), which build-spec's column gate holds every look to. */
|
|
806
|
+
export const LIST_ITEM_MIN_PX: Readonly<{ picture: number; words: number }> = SPEC_SITE_LAYOUT.limits.listItemMinPx;
|
|
807
|
+
const pxOf = (value: unknown): number => parseFloat(String(value ?? '')) || 0;
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* How many columns a grid of items takes in a cell `span` columns wide: three across most of the page, fewer in less
|
|
811
|
+
* room. On a page in a column (award §0c CW2, AW-D38) the count is also judged in px of the COLUMN at the check's laptop
|
|
812
|
+
* (1440): the most items that each keep their least (`LIST_ITEM_MIN_PX`: 280px a picture item, 240px words only) — contained keeps three
|
|
813
|
+
* across, narrow gives two pictures. Wide stays as it was (the span alone).
|
|
814
|
+
*/
|
|
815
|
+
export function listColumns(span: number, columnPx: number | null = null, picture = true, density?: string): number {
|
|
816
|
+
const most = span >= 9 ? 3 : span >= 5 ? 2 : 1;
|
|
817
|
+
if (columnPx === null) return most;
|
|
818
|
+
const width = LAYOUT_CHECK_VIEWPORT.width;
|
|
819
|
+
const room = (SPEC_AXES.densities as Readonly<Record<string, Readonly<Record<string, string>>>>)[String(density)] ?? SPEC_AXES.densities.regular;
|
|
820
|
+
const grid = layoutGridPx(width, columnPx, pxOf(room['space-gutter']));
|
|
821
|
+
const g = layoutGapPx(width);
|
|
822
|
+
const cell = (span * (grid - (GRID_COLUMNS - 1) * g)) / GRID_COLUMNS + Math.max(0, span - 1) * g;
|
|
823
|
+
const gap = pxOf(room['space-gap']);
|
|
824
|
+
const least = picture ? LIST_ITEM_MIN_PX.picture : LIST_ITEM_MIN_PX.words;
|
|
825
|
+
for (let n = most; n > 1; n--) if ((cell - (n - 1) * gap) / n >= least) return n;
|
|
826
|
+
return 1;
|
|
803
827
|
}
|
|
804
828
|
|
|
805
829
|
/** An item's way in, as the ONE interaction runtime plays it: together, one after another, or sliding in from the side
|
|
@@ -1020,7 +1044,7 @@ function composeList(id: string, l: LayoutLayer, mix: LayoutListMix, source: str
|
|
|
1020
1044
|
|
|
1021
1045
|
const items = create(`${id}-items`, 'Repeater', {}, 'box');
|
|
1022
1046
|
items.bindings.push({ prop: 'source', source, path: '' });
|
|
1023
|
-
const columns = listColumns((l.col?.[1] ?? 13) - (l.col?.[0] ?? 1));
|
|
1047
|
+
const columns = listColumns((l.col?.[1] ?? 13) - (l.col?.[0] ?? 1), ctx.columnPx, !!list.roles['image'], ctx.design?.density);
|
|
1024
1048
|
if (masonry) {
|
|
1025
1049
|
// A wall: CSS columns over the rows (iox-design.css), as many as the room holds — never a breakpoint, so the
|
|
1026
1050
|
// canvas's frame and the live page agree; `two-up` keeps two on a phone.
|
|
@@ -1060,6 +1084,10 @@ export interface ListFrameInput {
|
|
|
1060
1084
|
readonly col?: readonly [number, number];
|
|
1061
1085
|
/** Where the gaps are said (`sections[i].layers[j]`). */
|
|
1062
1086
|
readonly path?: string;
|
|
1087
|
+
/** Award §0c CW2: the page's column word and the look's Spacing — a grid's item count is judged in px of the column
|
|
1088
|
+
* (`listColumns`). Absent: wide, as before. */
|
|
1089
|
+
readonly column?: string;
|
|
1090
|
+
readonly density?: string;
|
|
1063
1091
|
}
|
|
1064
1092
|
|
|
1065
1093
|
/** A recomposed list frame, and what the composer said while composing it (a word drawn as its stand-in…). */
|
|
@@ -1089,6 +1117,7 @@ export function composeListFrame(input: ListFrameInput, previous?: SerializedNod
|
|
|
1089
1117
|
p: id, site, rtl: layoutRtl(input.locale), mode: LayoutColourMode.Light, pace,
|
|
1090
1118
|
ease: LAYOUT_EASING[(input.motion?.ease ?? LayoutEase.Out) as LayoutEase] ?? LAYOUT_EASING[LayoutEase.Out],
|
|
1091
1119
|
sections: {}, gaps: [], links: [], headingSeen: false, carry: new Map(), keptArrangement: [],
|
|
1120
|
+
columnPx: layoutColumnPx(input.column, input.density), design: input.density ? { density: input.density } : undefined,
|
|
1092
1121
|
listOf: () => input.list, sourceFields: () => null, photoSrc: () => '', photoAlt: () => '', photoAspect: () => LAYOUT_PHOTO_ASPECT[LayoutPhotoShape.Landscape],
|
|
1093
1122
|
} as unknown as Ctx;
|
|
1094
1123
|
const col = input.col ?? [1, 13];
|
|
@@ -1675,14 +1704,6 @@ export function readyMadeColumn(neighbour: LayoutSection | null): number {
|
|
|
1675
1704
|
return Math.min(READY_MADE_MAX_COLUMN, Math.max(1, starts.length ? Math.min(...starts) : 1));
|
|
1676
1705
|
}
|
|
1677
1706
|
|
|
1678
|
-
/** Where column `n` starts from the page's edge, on the composed sections' own grid (`gridLayout`): the gutter, then
|
|
1679
|
-
* n - 1 columns and their gaps. */
|
|
1680
|
-
function columnInset(n: number): string {
|
|
1681
|
-
if (n <= 1) return LAYOUT_GUTTER;
|
|
1682
|
-
const column = `((100% - 2 * ${LAYOUT_GUTTER} - ${GRID_COLUMNS - 1} * ${LAYOUT_COLUMN_GAP}) / ${GRID_COLUMNS} + ${LAYOUT_COLUMN_GAP})`;
|
|
1683
|
-
return `calc(${LAYOUT_GUTTER} + ${n - 1} * ${column})`;
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
1707
|
/** A pattern that paints its own ground — a Scene, or a picture behind its words — keeps its colours. */
|
|
1687
1708
|
function paintsItsOwnGround(root: SerializedNode): boolean {
|
|
1688
1709
|
return root.role === SceneRole.Scene || (root.children ?? []).some(c => c.styleProps?.['position'] === 'absolute');
|
|
@@ -1697,8 +1718,8 @@ function paintsItsOwnGround(root: SerializedNode): boolean {
|
|
|
1697
1718
|
*/
|
|
1698
1719
|
function dressReadyMade(root: SerializedNode, ground: string | null, column: number): void {
|
|
1699
1720
|
if (root.styleProps?.['padding'] === PATTERN_SECTION_PAD) {
|
|
1700
|
-
setStyleProps(root, { padding: `${PATTERN_SECTION_SPACE} ${
|
|
1701
|
-
phone(root, { padding: `${PATTERN_SECTION_SPACE} ${
|
|
1721
|
+
setStyleProps(root, { padding: `${PATTERN_SECTION_SPACE} ${layoutColumnStart(column)}` });
|
|
1722
|
+
phone(root, { padding: `${PATTERN_SECTION_SPACE} ${LAYOUT_INSET}` });
|
|
1702
1723
|
}
|
|
1703
1724
|
if (ground === null || paintsItsOwnGround(root)) return;
|
|
1704
1725
|
setColorScheme(root, ColorScheme.Default);
|
|
@@ -1770,6 +1791,8 @@ export function composeLayout(site: LayoutSite, options: ComposeLayoutOptions):
|
|
|
1770
1791
|
sections: {},
|
|
1771
1792
|
gaps: [],
|
|
1772
1793
|
design: options.design ?? layoutDesignOf(site.look?.preset, options.mode),
|
|
1794
|
+
// The page's word, else the design's when one is given (a layout composed with no design keeps today's wide).
|
|
1795
|
+
columnPx: layoutColumnPx(layoutColumnWord(site.column, options.design), options.design?.density),
|
|
1773
1796
|
photoSrc: options.photoSrc,
|
|
1774
1797
|
photoAlt: options.photoAlt ?? (() => ''),
|
|
1775
1798
|
photoAspect: id => LAYOUT_PHOTO_ASPECT[(options.photoShape?.(id) ?? LayoutPhotoShape.Landscape) as LayoutPhotoShape] ?? LAYOUT_PHOTO_ASPECT[LayoutPhotoShape.Landscape],
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { carryInto, swapParts, type PageCarry } from './carry';
|
|
2
2
|
import {
|
|
3
3
|
AnimateId, COLOR_SCHEME_TRAIT, COLOR_SCHEMES, ColorScheme, colorSchemeClass, DEFAULT_MENU_LOOK, DesignChoices, LinkType, MenuLook, motionLanguageForPlan, resolveDesignChoices, setColorScheme, headerInkOf,
|
|
4
|
+
columnWordOf,
|
|
4
5
|
} from '@vectoriox/iox-ui/design-core';
|
|
5
6
|
import { SEO_DESCRIPTION_MAX, SEO_TITLE_MAX, SeoRawDoc } from '@vectoriox/iox-ui/seo-core';
|
|
6
7
|
import { channelOpensNewTab, FORM_ACTIONS_ROLE, FORM_CHANNEL_ROLE, FormPresetChannel, FormPresetDef, FormPresetField, formPresetById, presetFormActions } from '@vectoriox/iox-ui/forms-core';
|
|
@@ -197,7 +198,7 @@ export interface ComposedPage {
|
|
|
197
198
|
locale: `${SiteLocale}`;
|
|
198
199
|
/** DS3: every page the wizard creates follows the look (page-bg / text / font-body). M8 gate 2: a composed page names
|
|
199
200
|
* the plan page its layout is (`layoutSource`; the build adds its run) — what Design ▸ Re-fit recomposes it from. */
|
|
200
|
-
pageSettings: { designSystem: true; layoutSource?: { pageKey: string; runId?: string }; opening?: `${ColorScheme}`; legal?: `${LegalKind}
|
|
201
|
+
pageSettings: { designSystem: true; layoutSource?: { pageKey: string; runId?: string }; opening?: `${ColorScheme}`; legal?: `${LegalKind}`; column?: string };
|
|
201
202
|
/** M1-6c: the page's search-result words — written (a static page) or bound to the route item (a template page),
|
|
202
203
|
* in the seo-core document shape the shared `resolveSeo` reads. */
|
|
203
204
|
seo: SeoRawDoc;
|
|
@@ -1649,6 +1650,7 @@ function composeLayoutPage(
|
|
|
1649
1650
|
name: plan.business.name,
|
|
1650
1651
|
locale: plan.locale ?? DEFAULT_SITE_LOCALE,
|
|
1651
1652
|
dial: layout.dial,
|
|
1653
|
+
...(layout.column ? { column: layout.column } : {}),
|
|
1652
1654
|
look: { preset: preset.id },
|
|
1653
1655
|
motion: layoutMotionOf(preset.id),
|
|
1654
1656
|
sections: layout.sections,
|
|
@@ -1745,9 +1747,11 @@ export function composeSite(plan: SitePlan, context: ComposeContext): ComposedSi
|
|
|
1745
1747
|
const first = layout.sections[0];
|
|
1746
1748
|
const worn = wearPlanOpening(page, stamped, plan, context, design, placeholders, issues, !!(first?.pin || first?.carry));
|
|
1747
1749
|
const opening = worn === stamped ? layoutBandScheme(first?.ground) : schemeOfFirst(worn);
|
|
1750
|
+
// Award §0c CW2 (AW-D34): the column the model chose for this page is the page's own word (absent: the site's).
|
|
1751
|
+
const column = columnWordOf(layout.column);
|
|
1748
1752
|
return {
|
|
1749
1753
|
key: page.key, name: page.name, route: { path: page.route }, isHome: page.isHome === true, status: STATUS_DRAFT, locale,
|
|
1750
|
-
pageSettings: { designSystem: true, layoutSource: { pageKey: page.key }, ...(opening ? { opening } : {}) }, seo: composePageSeo(page, plan),
|
|
1754
|
+
pageSettings: { designSystem: true, layoutSource: { pageKey: page.key }, ...(opening ? { opening } : {}), ...(column ? { column } : {}) }, seo: composePageSeo(page, plan),
|
|
1751
1755
|
layout: wearBodyMix(worn, body),
|
|
1752
1756
|
};
|
|
1753
1757
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { DesignChoices, elementStyleFace, resolveDesignChoices, textWidthEm } from '@vectoriox/iox-ui/design-core';
|
|
2
2
|
|
|
3
|
+
import { layoutColumnPx, layoutGutterPx } from './layout-column';
|
|
3
4
|
import { screenFontSize, screenWordOverflowPx } from './layout-language';
|
|
4
5
|
import { PatternGlobalPosition, PatternNode, SITE_PATTERNS, SitePattern } from './patterns';
|
|
5
6
|
import { SPEC_SITE_FOOTER_PARTS, SPEC_SITE_LAYOUT } from './site-spec.generated';
|
|
@@ -271,7 +272,7 @@ export function checkFooter(given: FooterMix, ctx: FooterContext): { mix: Footer
|
|
|
271
272
|
if (left.length) repairs.push({ code: FooterRepairCode.LineHolds, said: `a one-line footer holds only ${F.rules.lineHolds.join(' and ')}: ${left.join(' and ')} left out` });
|
|
272
273
|
holds = kept;
|
|
273
274
|
}
|
|
274
|
-
if (closing === FooterClosing.Name && screenWordOverflowPx(nameWidthEm(ctx), 12, PHONE_WIDTH, true) > 0) {
|
|
275
|
+
if (closing === FooterClosing.Name && screenWordOverflowPx(nameWidthEm(ctx), 12, PHONE_WIDTH, true, { gutter: layoutGutterPx(ctx.design.density) }) > 0) {
|
|
275
276
|
repairs.push({ code: FooterRepairCode.NameTooLong, said: `"${ctx.name}" is too long to stand across a phone: the footer closes with nothing` });
|
|
276
277
|
closing = FooterClosing.None;
|
|
277
278
|
}
|
|
@@ -315,7 +316,11 @@ function columnsOf(count: number): Pick<PatternNode, 'lay' | 'resp'> {
|
|
|
315
316
|
/** The closing name: the business name across the width — fitted to the name in the look's display face as a layout's
|
|
316
317
|
* screen word is (`screenFontSize`, the 12-column room), never under the smallest or over the largest screen word. */
|
|
317
318
|
function closingName(ctx: FooterContext): PatternNode {
|
|
318
|
-
|
|
319
|
+
// Award §0c CW2: in a column the name never runs past it — the site's word stamped as px (a `%` in font-size is the
|
|
320
|
+
// parent's size). A page that wears a narrower word of its own is not known here (the footer is the site's).
|
|
321
|
+
// iox-ui#117: the name reads the column of the PAGE it is on (`content-cap`, re-declared by a page's word), the site's
|
|
322
|
+
// word only its fallback — a global footer fits a narrow page of a contained site.
|
|
323
|
+
return laid(part('name'), { fontSize: screenFontSize(nameWidthEm(ctx), 12, 0, 0, 0, layoutColumnPx(ctx.design.column, ctx.design.density), true) });
|
|
319
324
|
}
|
|
320
325
|
|
|
321
326
|
/** A block it holds: how to reach the business leaves its city to the visit block when the footer holds both. */
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { ColumnId, columnWordOf, contentWidthOf, DensityId, DesignChoices, SPEC_AXES } from '@vectoriox/iox-ui/design-core';
|
|
2
|
+
|
|
3
|
+
import { LAYOUT_COLUMN_GAP } from './layout-language';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A COMPOSED page on the content column (award plan §0c, CW2 — AW-D33…AW-D41). Every composed (CL2) section is the
|
|
7
|
+
* 12-column grid the layout language places its layers on; since CW2 that grid sits on the SAME edge as the header, the
|
|
8
|
+
* footer and every pattern section: `space-inline` (= max(the one gutter `space-edge`, half of what the column leaves)).
|
|
9
|
+
*
|
|
10
|
+
* - The grid's inset is two OUTER tracks, never padding: `[bleed] inset − gap [12 columns] inset − gap [bleed]` — so a
|
|
11
|
+
* layer that bleeds spans into an outer track and reaches the window's edge with no negative margin (T-CW2: a `%` in a
|
|
12
|
+
* cell's margin is the CELL's). A `%` in `grid-template-columns` is the grid's own width, which for a section is the
|
|
13
|
+
* page's (the engine's page without its scrollbar, the canvas's simulated frame) — what `space-inline`'s `%` means.
|
|
14
|
+
* - A grid a sideways section carries `t` screens wide resolves its `%` against `t` pages: its inset is written for it
|
|
15
|
+
* from the same tokens (`layoutTrackInset`).
|
|
16
|
+
* - What cannot read a token — a `screen` word's size (a `%` in `font-size` is the parent's size) and the bar of a gallery
|
|
17
|
+
* that bleeds (a `%` there is the slider's) — is stamped from the PAGE's word at compose time (`layoutColumnPx`): the
|
|
18
|
+
* word composeSite writes as `pageSettings.column`. Wide stamps exactly what a page was before the column.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** The one inset every composed grid reads — the token, with today's composed gutter where a studio's rows predate it. */
|
|
22
|
+
export const LAYOUT_INSET = 'var(--iox-space-inline, max(4vw, 16px))';
|
|
23
|
+
/** What a composed section stamped before CW2 (`max(4vw, 16px)` a side): the old grid's gutter. */
|
|
24
|
+
export const LAYOUT_LEGACY_GUTTER = 'max(4vw, 16px)';
|
|
25
|
+
/** The share of the window the one gutter takes (`space-edge` = max(4%, space-gutter)) — the contract's `axes.edgeShare`. */
|
|
26
|
+
const EDGE_SHARE = String(SPEC_AXES.edgeShare);
|
|
27
|
+
const EDGE_SHARE_NUM = parseFloat(EDGE_SHARE) / 100;
|
|
28
|
+
const GUTTER_FALLBACK = '16px';
|
|
29
|
+
/** The density a column is read at when the design names none (the packs' usual Spacing). */
|
|
30
|
+
const DEFAULT_DENSITY: DensityId = 'regular';
|
|
31
|
+
const GRID = 12;
|
|
32
|
+
/** The column gap in vw (`LAYOUT_COLUMN_GAP`, `1.2vw`). */
|
|
33
|
+
const GAP_VW = parseFloat(LAYOUT_COLUMN_GAP);
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The inset of a grid `track` screens wide, from its own width: a section (`track` 1) reads `space-inline` itself; a
|
|
37
|
+
* sideways section's track holds its `%` against `track` pages, so the same rule is written over `100% / track`.
|
|
38
|
+
*/
|
|
39
|
+
export function layoutTrackInset(track = 1): string {
|
|
40
|
+
if (track <= 1) return LAYOUT_INSET;
|
|
41
|
+
return `max(calc(${EDGE_SHARE} / ${track}), var(--iox-space-gutter, ${GUTTER_FALLBACK}), calc((100% / ${track} - var(--iox-content-width, 100%)) / 2))`;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** A composed grid's columns: an outer track a side (the inset less the gap that follows it), then 12 per screen. */
|
|
45
|
+
export function layoutGridColumns(track = 1): string {
|
|
46
|
+
const outer = `calc(${layoutTrackInset(track)} - ${LAYOUT_COLUMN_GAP})`;
|
|
47
|
+
return `${outer} repeat(${GRID * track}, minmax(0, 1fr)) ${outer}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** The grid line a layout line (1..13, 1..12×track+1) stands on, past the start's outer track. */
|
|
51
|
+
export const layoutGridLine = (line: number): number => line + 1;
|
|
52
|
+
/** The first and last lines of a composed grid: a bleed's ends (the window's edges — logical, so RTL mirrors them). */
|
|
53
|
+
export const LAYOUT_BLEED_START_LINE = 1;
|
|
54
|
+
export const LAYOUT_BLEED_END_LINE = -1;
|
|
55
|
+
|
|
56
|
+
/** The column word a composed page wears: its own (`LayoutPage.column`), else the site's (`design.column`), else wide. */
|
|
57
|
+
export function layoutColumnWord(own: unknown, design?: Pick<DesignChoices, 'column'> | null): ColumnId {
|
|
58
|
+
return (columnWordOf(own) ?? columnWordOf(design?.column) ?? SPEC_AXES.columnChoices.pre) as ColumnId;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** A column word's width in px at a density (`column-contained` / `column-narrow`), or null for wide (the window). */
|
|
62
|
+
export function layoutColumnPx(word: unknown, density: DensityId | string | undefined): number | null {
|
|
63
|
+
const densities = SPEC_AXES.densities as Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
64
|
+
const row = densities[String(density)] ?? densities[DEFAULT_DENSITY];
|
|
65
|
+
const value = contentWidthOf(word, name => row?.[name]);
|
|
66
|
+
if (!value || !/px$/.test(value)) return null;
|
|
67
|
+
return parseFloat(value);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** The page's inset at a window `width` px wide (no scrollbar), in px — `space-inline` evaluated: what the e2e and the
|
|
71
|
+
* judges read. `gutter` is the density's `space-gutter`. */
|
|
72
|
+
export function layoutInsetPx(width: number, columnPx: number | null, gutter: number): number {
|
|
73
|
+
const edge = Math.max(EDGE_SHARE_NUM * width, gutter);
|
|
74
|
+
return columnPx === null ? edge : Math.max(edge, (width - columnPx) / 2);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* The bled side's inset of a gallery's bar, in viewport units (inside the slider a `%` is the slider's): the one gutter,
|
|
79
|
+
* and half of what the column leaves when the page wears one. A classic scrollbar shifts it by ≤ 8px — the trade the
|
|
80
|
+
* slider bar already makes (composite-core `BAR_INLINE_PAD`).
|
|
81
|
+
*/
|
|
82
|
+
export function layoutBledBarInset(columnPx: number | null): string {
|
|
83
|
+
const edge = `max(${EDGE_SHARE.replace('%', 'vw')}, var(--iox-space-gutter, ${GUTTER_FALLBACK}))`;
|
|
84
|
+
return columnPx === null ? edge : `max(${EDGE_SHARE.replace('%', 'vw')}, var(--iox-space-gutter, ${GUTTER_FALLBACK}), calc((100vw - ${columnPx}px) / 2))`;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Where column `n` (1-based) starts from the page's edge on a composed grid — the inset, then n − 1 columns and their
|
|
89
|
+
* gaps. A ready-made section's padding (`%` = the page's) so its words share the composed sections' edge.
|
|
90
|
+
*/
|
|
91
|
+
export function layoutColumnStart(n: number): string {
|
|
92
|
+
if (n <= 1) return LAYOUT_INSET;
|
|
93
|
+
const column = `((100% - 2 * ${LAYOUT_INSET} - ${GRID - 1} * ${LAYOUT_COLUMN_GAP}) / ${GRID} + ${LAYOUT_COLUMN_GAP})`;
|
|
94
|
+
return `calc(${LAYOUT_INSET} + ${n - 1} * ${column})`;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** The grid's room on a laptop `width` px wide, in px: inside the inset, capped at the column (12 columns and 11 gaps). */
|
|
98
|
+
export function layoutGridPx(width: number, columnPx: number | null, gutter: number): number {
|
|
99
|
+
return width - 2 * layoutInsetPx(width, columnPx, gutter);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** The column gap at a window `width` px wide, in px. */
|
|
103
|
+
export const layoutGapPx = (width: number): number => (GAP_VW / 100) * width;
|
|
104
|
+
|
|
105
|
+
/** A density's `space-gutter` in px (the one gutter's floor). */
|
|
106
|
+
export function layoutGutterPx(density: DensityId | string | undefined): number {
|
|
107
|
+
const densities = SPEC_AXES.densities as Readonly<Record<string, Readonly<Record<string, string>>>>;
|
|
108
|
+
return parseFloat((densities[String(density)] ?? densities[DEFAULT_DENSITY])['space-gutter']) || 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The px one grid column is judged at on the check's laptop (`LAYOUT_CHECK_VIEWPORT`, AW-D38): wide stays the window's
|
|
113
|
+
* twelfth (the judges' model before the column — no wide page is judged differently); in a column, the column's twelfth
|
|
114
|
+
* (never more than the window's grid). Both contained and narrow bind at 1440.
|
|
115
|
+
*/
|
|
116
|
+
export function layoutJudgeColumnPx(word: unknown, density: DensityId | string | undefined, width: number): number {
|
|
117
|
+
const columnPx = layoutColumnPx(word, density);
|
|
118
|
+
if (columnPx === null) return width / GRID;
|
|
119
|
+
return Math.min(columnPx, width - 2 * layoutGutterPx(density)) / GRID;
|
|
120
|
+
}
|