@vectoriox/iox-ui 5.107.0 → 5.108.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 +20 -3
- package/design-core/index.d.ts +89 -0
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs +52 -8
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +106 -0
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +411 -11
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/generation-core/index.d.ts +236 -105
- package/package.json +1 -1
- package/src/composite-core/card.ts +50 -7
- package/src/composite-core/structure.ts +4 -0
- package/src/design-core/flavor-spec.generated.ts +106 -0
- package/src/generation-core/compose-layout.ts +242 -2
- package/src/generation-core/compose-site.ts +23 -1
- package/src/generation-core/layout-language.ts +71 -0
- package/src/generation-core/layout-wire.ts +111 -3
- package/styles/iox-design.css +20 -0
|
@@ -778,6 +778,16 @@ export const SPEC_TIERS = {
|
|
|
778
778
|
"type": "shadow",
|
|
779
779
|
"default": "var(--iox-card-shadow-hover)"
|
|
780
780
|
},
|
|
781
|
+
{
|
|
782
|
+
"name": "card-logo-height",
|
|
783
|
+
"type": "size",
|
|
784
|
+
"default": "28px"
|
|
785
|
+
},
|
|
786
|
+
{
|
|
787
|
+
"name": "list-rest-opacity",
|
|
788
|
+
"type": "number",
|
|
789
|
+
"default": "0.5"
|
|
790
|
+
},
|
|
781
791
|
{
|
|
782
792
|
"name": "panel-bg",
|
|
783
793
|
"type": "color",
|
|
@@ -4210,6 +4220,18 @@ export const SPEC_ELEMENT_STYLES = [
|
|
|
4210
4220
|
"scaleY": "var(--iox-image-hover-scale)"
|
|
4211
4221
|
}
|
|
4212
4222
|
},
|
|
4223
|
+
{
|
|
4224
|
+
"id": "card-logo",
|
|
4225
|
+
"label": "Card logo",
|
|
4226
|
+
"group": "Media",
|
|
4227
|
+
"appliesTo": [
|
|
4228
|
+
"Image"
|
|
4229
|
+
],
|
|
4230
|
+
"base": {
|
|
4231
|
+
"height": "var(--iox-card-logo-height)",
|
|
4232
|
+
"objectFit": "contain"
|
|
4233
|
+
}
|
|
4234
|
+
},
|
|
4213
4235
|
{
|
|
4214
4236
|
"id": "rule",
|
|
4215
4237
|
"label": "Divider",
|
|
@@ -6701,6 +6723,20 @@ export const SPEC_FLAVOR_PACKS = [
|
|
|
6701
6723
|
"group": "components",
|
|
6702
6724
|
"value": "var(--iox-card-shadow-hover)"
|
|
6703
6725
|
},
|
|
6726
|
+
{
|
|
6727
|
+
"name": "card-logo-height",
|
|
6728
|
+
"tier": "component",
|
|
6729
|
+
"type": "size",
|
|
6730
|
+
"group": "components",
|
|
6731
|
+
"value": "28px"
|
|
6732
|
+
},
|
|
6733
|
+
{
|
|
6734
|
+
"name": "list-rest-opacity",
|
|
6735
|
+
"tier": "component",
|
|
6736
|
+
"type": "number",
|
|
6737
|
+
"group": "components",
|
|
6738
|
+
"value": "0.5"
|
|
6739
|
+
},
|
|
6704
6740
|
{
|
|
6705
6741
|
"name": "panel-bg",
|
|
6706
6742
|
"tier": "component",
|
|
@@ -9021,6 +9057,20 @@ export const SPEC_FLAVOR_PACKS = [
|
|
|
9021
9057
|
"group": "components",
|
|
9022
9058
|
"value": "var(--iox-card-shadow-hover)"
|
|
9023
9059
|
},
|
|
9060
|
+
{
|
|
9061
|
+
"name": "card-logo-height",
|
|
9062
|
+
"tier": "component",
|
|
9063
|
+
"type": "size",
|
|
9064
|
+
"group": "components",
|
|
9065
|
+
"value": "28px"
|
|
9066
|
+
},
|
|
9067
|
+
{
|
|
9068
|
+
"name": "list-rest-opacity",
|
|
9069
|
+
"tier": "component",
|
|
9070
|
+
"type": "number",
|
|
9071
|
+
"group": "components",
|
|
9072
|
+
"value": "0.5"
|
|
9073
|
+
},
|
|
9024
9074
|
{
|
|
9025
9075
|
"name": "panel-bg",
|
|
9026
9076
|
"tier": "component",
|
|
@@ -11349,6 +11399,20 @@ export const SPEC_FLAVOR_PACKS = [
|
|
|
11349
11399
|
"group": "components",
|
|
11350
11400
|
"value": "var(--iox-card-shadow-hover)"
|
|
11351
11401
|
},
|
|
11402
|
+
{
|
|
11403
|
+
"name": "card-logo-height",
|
|
11404
|
+
"tier": "component",
|
|
11405
|
+
"type": "size",
|
|
11406
|
+
"group": "components",
|
|
11407
|
+
"value": "28px"
|
|
11408
|
+
},
|
|
11409
|
+
{
|
|
11410
|
+
"name": "list-rest-opacity",
|
|
11411
|
+
"tier": "component",
|
|
11412
|
+
"type": "number",
|
|
11413
|
+
"group": "components",
|
|
11414
|
+
"value": "0.5"
|
|
11415
|
+
},
|
|
11352
11416
|
{
|
|
11353
11417
|
"name": "panel-bg",
|
|
11354
11418
|
"tier": "component",
|
|
@@ -13689,6 +13753,20 @@ export const SPEC_FLAVOR_PACKS = [
|
|
|
13689
13753
|
"group": "components",
|
|
13690
13754
|
"value": "var(--iox-card-shadow-hover)"
|
|
13691
13755
|
},
|
|
13756
|
+
{
|
|
13757
|
+
"name": "card-logo-height",
|
|
13758
|
+
"tier": "component",
|
|
13759
|
+
"type": "size",
|
|
13760
|
+
"group": "components",
|
|
13761
|
+
"value": "28px"
|
|
13762
|
+
},
|
|
13763
|
+
{
|
|
13764
|
+
"name": "list-rest-opacity",
|
|
13765
|
+
"tier": "component",
|
|
13766
|
+
"type": "number",
|
|
13767
|
+
"group": "components",
|
|
13768
|
+
"value": "0.5"
|
|
13769
|
+
},
|
|
13692
13770
|
{
|
|
13693
13771
|
"name": "panel-bg",
|
|
13694
13772
|
"tier": "component",
|
|
@@ -16032,6 +16110,20 @@ export const SPEC_FLAVOR_PACKS = [
|
|
|
16032
16110
|
"group": "components",
|
|
16033
16111
|
"value": "var(--iox-card-shadow-hover)"
|
|
16034
16112
|
},
|
|
16113
|
+
{
|
|
16114
|
+
"name": "card-logo-height",
|
|
16115
|
+
"tier": "component",
|
|
16116
|
+
"type": "size",
|
|
16117
|
+
"group": "components",
|
|
16118
|
+
"value": "28px"
|
|
16119
|
+
},
|
|
16120
|
+
{
|
|
16121
|
+
"name": "list-rest-opacity",
|
|
16122
|
+
"tier": "component",
|
|
16123
|
+
"type": "number",
|
|
16124
|
+
"group": "components",
|
|
16125
|
+
"value": "0.5"
|
|
16126
|
+
},
|
|
16035
16127
|
{
|
|
16036
16128
|
"name": "panel-bg",
|
|
16037
16129
|
"tier": "component",
|
|
@@ -18356,6 +18448,20 @@ export const SPEC_FLAVOR_PACKS = [
|
|
|
18356
18448
|
"group": "components",
|
|
18357
18449
|
"value": "var(--iox-card-shadow-hover)"
|
|
18358
18450
|
},
|
|
18451
|
+
{
|
|
18452
|
+
"name": "card-logo-height",
|
|
18453
|
+
"tier": "component",
|
|
18454
|
+
"type": "size",
|
|
18455
|
+
"group": "components",
|
|
18456
|
+
"value": "28px"
|
|
18457
|
+
},
|
|
18458
|
+
{
|
|
18459
|
+
"name": "list-rest-opacity",
|
|
18460
|
+
"tier": "component",
|
|
18461
|
+
"type": "number",
|
|
18462
|
+
"group": "components",
|
|
18463
|
+
"value": "0.5"
|
|
18464
|
+
},
|
|
18359
18465
|
{
|
|
18360
18466
|
"name": "panel-bg",
|
|
18361
18467
|
"tier": "component",
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
buildCardRecipe, buildMarqueeRecipe, CardLayout, CardPart, CardRole, CompositeNode, CompositeNodeSpec, findByRole, NO_ELEMENT_STYLE, SceneRole,
|
|
3
|
+
SLIDER_PLACEMENT_TRAIT, SliderPlacement, SliderRole, syncSliderParts,
|
|
4
|
+
} from '@vectoriox/iox-ui/composite-core';
|
|
2
5
|
|
|
3
6
|
import { ColorScheme, DesignChoices, LinkType, setColorScheme } from '@vectoriox/iox-ui/design-core';
|
|
4
7
|
import { FORM_AFTER_SEND_TRAIT, FormAfterSend, FormPresetId } from '@vectoriox/iox-ui/forms-core';
|
|
@@ -6,6 +9,7 @@ import { composeNavHeader, composePresetForm } from './compose-site';
|
|
|
6
9
|
import {
|
|
7
10
|
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,
|
|
8
11
|
LAYOUT_PHONE_PADDING, LAYOUT_RISE, LAYOUT_TEXT_KINDS, LayoutBleed, LayoutColour, LayoutEase, LayoutEnter, LayoutForm, LayoutGallery, LayoutLayer,
|
|
12
|
+
LayoutListArrange, LayoutListArrive, LayoutListHover, LayoutListItem, LayoutListMix, LayoutListMove, LayoutListPhone, LayoutListWho,
|
|
9
13
|
LayoutLayerKind, LayoutNavKind, LayoutPace, LayoutPhotoShape, LayoutRole, LayoutSection, LayoutSide, LayoutSite, LayoutTrack, LayoutTrackProp, LayoutTransition, phoneGapBefore,
|
|
10
14
|
screenFontSize,
|
|
11
15
|
} from './layout-language';
|
|
@@ -52,6 +56,13 @@ export enum LayoutGapCode {
|
|
|
52
56
|
FormPreset = 'form-preset',
|
|
53
57
|
/** A gallery naming a list with no pictures and no slides of its own shows photo boxes (iox-ui#59). */
|
|
54
58
|
GalleryNoPictures = 'gallery-no-pictures',
|
|
59
|
+
/** List ingredients: an arrangement or a feel the product draws in a later phase (strips LI3, deck and standing out
|
|
60
|
+
* LI4) — the list is laid out as the nearest one it has. */
|
|
61
|
+
ListLater = 'list-later',
|
|
62
|
+
/** A list item that rises or zooms under the mouse links somewhere (decision D3): this one has nowhere to go. */
|
|
63
|
+
ListUnlinked = 'list-unlinked',
|
|
64
|
+
/** A list section naming a list the composer was not told how to read (no `listOf`): today's gallery instead. */
|
|
65
|
+
ListUnbound = 'list-unbound',
|
|
55
66
|
}
|
|
56
67
|
|
|
57
68
|
export interface LayoutGap {
|
|
@@ -86,8 +97,42 @@ export interface ComposeLayoutOptions {
|
|
|
86
97
|
/** Gate 2: a list data source's picture and name fields — a gallery naming the source shows its items. Null when the
|
|
87
98
|
* source has no picture field (the gallery keeps its own slides). */
|
|
88
99
|
sourceFields?: (alias: string) => { image: string; title?: string } | null;
|
|
100
|
+
/** List ingredients (LI1): how a list's items are read — the field that plays each role and the item's own page. Null
|
|
101
|
+
* when the alias is no list. A gallery with a `list` mix needs it; without it the gallery is today's. */
|
|
102
|
+
listOf?: (alias: string) => LayoutListBinding | null;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** A list as the list composer reads it (`ComposeLayoutOptions.listOf`). */
|
|
106
|
+
export interface LayoutListBinding {
|
|
107
|
+
/** Role → the field that plays it (`title` → `name`). */
|
|
108
|
+
roles: Readonly<Record<string, string>>;
|
|
109
|
+
/** The page that shows one item, when the plan has one: its route, its param and the item's field that fills it. */
|
|
110
|
+
detail?: { route: string; param: string; field: string };
|
|
89
111
|
}
|
|
90
112
|
|
|
113
|
+
/** List ingredients (LI1): the roles a composed list's nodes play — read by the shared CSS (iox-design.css), never by a
|
|
114
|
+
* renderer: the list's frame (`list.dim` when the others dim under the mouse), a masonry wall's Repeater, and an item
|
|
115
|
+
* that is a picture (a card item is a Card v2, `card`). */
|
|
116
|
+
export enum LayoutListRole {
|
|
117
|
+
List = 'list',
|
|
118
|
+
Dim = 'list.dim',
|
|
119
|
+
Masonry = 'list.masonry',
|
|
120
|
+
MasonryTwo = 'list.masonry-two',
|
|
121
|
+
Item = 'list.item',
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** A list role → the Card v2 part that shows it (the title is the card's locked title; `link` links the card). */
|
|
125
|
+
export const LIST_CARD_PART: Readonly<Record<string, CardPart>> = {
|
|
126
|
+
image: CardPart.Media,
|
|
127
|
+
logo: CardPart.Logo,
|
|
128
|
+
icon: CardPart.Icon,
|
|
129
|
+
meta: CardPart.Eyebrow,
|
|
130
|
+
date: CardPart.Eyebrow,
|
|
131
|
+
summary: CardPart.Text,
|
|
132
|
+
quote: CardPart.Quote,
|
|
133
|
+
person: CardPart.Person,
|
|
134
|
+
};
|
|
135
|
+
|
|
91
136
|
export interface ComposedLayout {
|
|
92
137
|
/** The page's layout: one root per section. */
|
|
93
138
|
layout: SerializedNode[];
|
|
@@ -162,6 +207,7 @@ interface Ctx {
|
|
|
162
207
|
photoAlt: (id: string) => string;
|
|
163
208
|
photoAspect: (id: string) => string;
|
|
164
209
|
sourceFields: (alias: string) => { image: string; title?: string } | null;
|
|
210
|
+
listOf: (alias: string) => LayoutListBinding | null;
|
|
165
211
|
/** Every node a section link was written on, with the section id it scrolls to (resolved once all are stamped). */
|
|
166
212
|
links: Array<{ node: SerializedNode; to: string; closes?: string }>;
|
|
167
213
|
headingSeen: boolean;
|
|
@@ -493,6 +539,9 @@ function photoLayer(id: string, l: LayoutLayer, ctx: Ctx, path: string): { frame
|
|
|
493
539
|
|
|
494
540
|
function galleryLayer(id: string, l: LayoutLayer, lc: LayerCtx, ctx: Ctx): SerializedNode {
|
|
495
541
|
const g: LayoutGallery = l.gallery ?? { slides: [] };
|
|
542
|
+
const list = listOfLayer(l, ctx);
|
|
543
|
+
if (list) return composeList(id, l, g.list!, g.source!, list, lc, ctx);
|
|
544
|
+
if (g.list) gap(ctx, LayoutGapCode.ListUnbound, `${lc.path}.gallery.list`, `${g.source ?? 'no list'}: not a list the page can read — shown as a gallery`);
|
|
496
545
|
const frame = create(id, T.Container, {}, NO_ELEMENT_STYLE);
|
|
497
546
|
setStyleProps(frame, { position: 'relative' });
|
|
498
547
|
phone(frame, { height: 'auto' });
|
|
@@ -570,6 +619,194 @@ function galleryLayer(id: string, l: LayoutLayer, lc: LayerCtx, ctx: Ctx): Seria
|
|
|
570
619
|
return frame;
|
|
571
620
|
}
|
|
572
621
|
|
|
622
|
+
// ── List ingredients (list-ingredients-plan.md, LI1) ───────────────────────────────────────────────────────────
|
|
623
|
+
|
|
624
|
+
/** The width a row's card takes: three across a laptop, most of a phone's width with the next one peeking. */
|
|
625
|
+
const LIST_ROW_SLIDE = `calc((100% - ${2 * SLIDE_GAP}px) / 3)`;
|
|
626
|
+
const LIST_ROW_SLIDE_PHONE = '82%';
|
|
627
|
+
const LIST_GAP = 'var(--iox-space-gap)';
|
|
628
|
+
const LIST_PHOTO_ASPECT = '4 / 3';
|
|
629
|
+
/** A row or a deck turns by itself this often (the wire's autoplay). */
|
|
630
|
+
const LIST_AUTOPLAY_MS = 5000;
|
|
631
|
+
/** How far apart items arrive one by one (ms, before the pace), and after how many the stagger stops growing. */
|
|
632
|
+
const LIST_STAGGER = 90;
|
|
633
|
+
const LIST_STAGGER_CAP = 6;
|
|
634
|
+
const LIST_SLIDE_DISTANCE = 48;
|
|
635
|
+
const ROUTE_PARAM_PROP = 'routeParam:';
|
|
636
|
+
|
|
637
|
+
/** The list a gallery layer shows by its mix, or null: no mix, no source, or a source the page cannot read. */
|
|
638
|
+
function listOfLayer(l: LayoutLayer, ctx: Ctx): LayoutListBinding | null {
|
|
639
|
+
const g = l.gallery;
|
|
640
|
+
return g?.list && g.source ? ctx.listOf(g.source) : null;
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
/** How many columns a grid of items takes in a cell `span` columns wide: three across most of the page, fewer in less room. */
|
|
644
|
+
function listColumns(span: number): number {
|
|
645
|
+
return span >= 9 ? 3 : span >= 5 ? 2 : 1;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/** An item's way in, as the ONE interaction runtime plays it: together, one after another, or sliding in from the side
|
|
649
|
+
* the page reads from (mirrored in RTL). A Repeater's rows take their share of the stagger at runtime. */
|
|
650
|
+
function listArriveInteraction(nodeId: string, arrive: `${LayoutListArrive}`, ctx: Ctx): unknown {
|
|
651
|
+
const duration = ctx.pace.support;
|
|
652
|
+
const stagger = Math.round(LIST_STAGGER * ctx.pace.gap);
|
|
653
|
+
const action =
|
|
654
|
+
arrive === LayoutListArrive.Together ? { type: 'fadeIn', params: {} }
|
|
655
|
+
: arrive === LayoutListArrive.SlideIn ? { type: ctx.rtl ? 'moveRight' : 'moveLeft', params: { distance: LIST_SLIDE_DISTANCE, stagger, cap: LIST_STAGGER_CAP } }
|
|
656
|
+
: { type: 'moveUp', params: { distance: LAYOUT_RISE[LayoutRole.Support], stagger, cap: LIST_STAGGER_CAP } };
|
|
657
|
+
return {
|
|
658
|
+
id: `${nodeId}-enter`,
|
|
659
|
+
trigger: 'viewportEnter',
|
|
660
|
+
actions: [{ type: action.type, target: 'self', duration, delay: 0, easing: ctx.ease, once: true, ...(Object.keys(action.params).length ? { params: action.params } : {}) }],
|
|
661
|
+
};
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
/** An item's link to its own page: the page's route, its param filled from the row's field. */
|
|
665
|
+
function linkToDetail(node: SerializedNode, source: string, detail: NonNullable<LayoutListBinding['detail']>): void {
|
|
666
|
+
setProp(node, 'linkType', LinkType.Page);
|
|
667
|
+
setProp(node, 'pageRoute', detail.route);
|
|
668
|
+
node.bindings.push({ prop: `${ROUTE_PARAM_PROP}${detail.param}`, source, path: detail.field });
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/** 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): SerializedNode {
|
|
673
|
+
const shown = new Set(mix.parts.filter(r => !!list.roles[r]));
|
|
674
|
+
const field = (role: string) => (shown.has(role) ? list.roles[role] : undefined);
|
|
675
|
+
const eyebrow = field('meta') ?? field('date');
|
|
676
|
+
const partOn = (part: CardPart, role: string | undefined) => [part, !!role] as const;
|
|
677
|
+
const parts = Object.fromEntries([
|
|
678
|
+
partOn(CardPart.Media, field('image')), partOn(CardPart.Logo, field('logo')), partOn(CardPart.Icon, field('icon')),
|
|
679
|
+
partOn(CardPart.Eyebrow, eyebrow), partOn(CardPart.Text, field('summary')), partOn(CardPart.Quote, field('quote')),
|
|
680
|
+
partOn(CardPart.Person, field('person')), [CardPart.Badge, false], [CardPart.Actions, false],
|
|
681
|
+
]) as Partial<Record<CardPart, boolean>>;
|
|
682
|
+
const card = buildCardRecipe(partFactory(id), { layout: CardLayout.Top, parts }) as unknown as SerializedNode;
|
|
683
|
+
card.id = id;
|
|
684
|
+
const bind = (role: CardRole, prop: string, f: string | undefined) => {
|
|
685
|
+
const part = findByRole(card as unknown as CompositeNode, role) as SerializedNode | undefined;
|
|
686
|
+
if (!part || !f) return part;
|
|
687
|
+
const node = role === CardRole.Media ? part.children?.find(c => c.type === T.Image) : part;
|
|
688
|
+
node?.bindings.push({ prop, source, path: f });
|
|
689
|
+
return node;
|
|
690
|
+
};
|
|
691
|
+
const title = list.roles['title'];
|
|
692
|
+
const image = bind(CardRole.Media, 'src', field('image'));
|
|
693
|
+
if (image && title) image.bindings.push({ prop: 'alt', source, path: title });
|
|
694
|
+
// A wall keeps every picture's own shape.
|
|
695
|
+
if (image && masonry) setStyleProps(image, { aspectRatio: 'auto', height: 'auto' });
|
|
696
|
+
const logo = bind(CardRole.Logo, 'src', field('logo'));
|
|
697
|
+
if (logo && title) logo.bindings.push({ prop: 'alt', source, path: title });
|
|
698
|
+
bind(CardRole.Icon, 'iconClass', field('icon'));
|
|
699
|
+
bind(CardRole.Eyebrow, 'content', eyebrow);
|
|
700
|
+
bind(CardRole.Text, 'content', field('summary'));
|
|
701
|
+
bind(CardRole.Quote, 'content', field('quote'));
|
|
702
|
+
bind(CardRole.Person, 'content', field('person'));
|
|
703
|
+
const heading = bind(CardRole.Title, 'content', title);
|
|
704
|
+
// The whole card links (the stretched link, through its title): to the item's own page, else to the address the list
|
|
705
|
+
// keeps for it when the mix shows it. A card that rises or zooms under the mouse and links nowhere is said (D3).
|
|
706
|
+
if (heading && list.detail) linkToDetail(heading, source, list.detail);
|
|
707
|
+
else if (heading && field('link')) {
|
|
708
|
+
setProp(heading, 'linkType', LinkType.External);
|
|
709
|
+
heading.bindings.push({ prop: 'url', source, path: field('link')! });
|
|
710
|
+
} else if (mix.hover.some(h => h === LayoutListHover.Rise || h === LayoutListHover.Zoom)) {
|
|
711
|
+
gap(ctx, LayoutGapCode.ListUnlinked, path, `${source}: its items link nowhere, so they neither rise nor zoom (D3)`);
|
|
712
|
+
}
|
|
713
|
+
return card;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/** A picture item: the row's picture, linked to its own page when the plan has one. */
|
|
717
|
+
function listPhoto(id: string, source: string, list: LayoutListBinding, masonry: boolean): SerializedNode {
|
|
718
|
+
const item = create(id, list.detail ? 'LinkedContainer' : T.Container, {}, NO_ELEMENT_STYLE);
|
|
719
|
+
item.role = LayoutListRole.Item;
|
|
720
|
+
setStyleProps(item, { position: 'relative', display: 'block', width: FULL, overflow: 'hidden' });
|
|
721
|
+
if (list.detail) linkToDetail(item, source, list.detail);
|
|
722
|
+
const image = create(`${id}-img`, T.Image, { src: '', alt: '' }, 'media');
|
|
723
|
+
setStyleProps(image, { display: 'block', width: FULL, maxWidth: 'none', height: 'auto', aspectRatio: masonry ? 'auto' : LIST_PHOTO_ASPECT, objectFit: 'cover' });
|
|
724
|
+
if (list.roles['image']) image.bindings.push({ prop: 'src', source, path: list.roles['image'] });
|
|
725
|
+
if (list.roles['title']) image.bindings.push({ prop: 'alt', source, path: list.roles['title'] });
|
|
726
|
+
item.children = [image];
|
|
727
|
+
return item;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
/**
|
|
731
|
+
* THE list composer (LI1): a gallery layer whose mix names a list → the list's items as ordinary nodes — a Slider over
|
|
732
|
+
* the list (`row`), or a Repeater laid as a grid or as a wall (`masonry`), its ONE template a Card v2 (the palette's
|
|
733
|
+
* recipe) or a picture, each part bound to the row's field by role. The feels are the shared CSS's and the look's tokens
|
|
734
|
+
* (`list.dim`, a linked card's lift and zoom), the arrival the ONE interaction runtime's. What a later phase draws
|
|
735
|
+
* (strips, deck, standing out) is laid out as the nearest arrangement and said. Pure.
|
|
736
|
+
*/
|
|
737
|
+
function composeList(id: string, l: LayoutLayer, mix: LayoutListMix, source: string, list: LayoutListBinding, lc: LayerCtx, ctx: Ctx): SerializedNode {
|
|
738
|
+
const frame = create(id, T.Container, {}, NO_ELEMENT_STYLE);
|
|
739
|
+
frame.role = mix.hover.includes(LayoutListHover.Dim) ? LayoutListRole.Dim : LayoutListRole.List;
|
|
740
|
+
setStyleProps(frame, { position: 'relative' });
|
|
741
|
+
phone(frame, { height: 'auto' });
|
|
742
|
+
const scheme = layoutBandScheme(lc.section.ground);
|
|
743
|
+
if (scheme) setColorScheme(frame, scheme);
|
|
744
|
+
|
|
745
|
+
let arrange = mix.arrange;
|
|
746
|
+
if (arrange === LayoutListArrange.Strips || arrange === LayoutListArrange.Deck) {
|
|
747
|
+
const nearest = arrange === LayoutListArrange.Deck ? LayoutListArrange.Row : LayoutListArrange.Grid;
|
|
748
|
+
gap(ctx, LayoutGapCode.ListLater, `${lc.path}.gallery.list.arrange`, `${arrange} is drawn in a later phase: laid out as a ${nearest}`);
|
|
749
|
+
arrange = nearest;
|
|
750
|
+
}
|
|
751
|
+
if (mix.standout && mix.standout.who !== LayoutListWho.None) {
|
|
752
|
+
gap(ctx, LayoutGapCode.ListLater, `${lc.path}.gallery.list.standout`, `standing out (${mix.standout.who}) is drawn in a later phase`);
|
|
753
|
+
}
|
|
754
|
+
const masonry = arrange === LayoutListArrange.Masonry;
|
|
755
|
+
const item = mix.item === LayoutListItem.Card
|
|
756
|
+
? listCard(`${id}-item`, mix, source, list, masonry, lc.path, ctx)
|
|
757
|
+
: listPhoto(`${id}-item`, source, list, masonry);
|
|
758
|
+
item.interactions = [...item.interactions, listArriveInteraction(item.id, mix.arrive, ctx)];
|
|
759
|
+
|
|
760
|
+
if (arrange === LayoutListArrange.Row) {
|
|
761
|
+
const scrollPlays = mix.move.includes(LayoutListMove.Page) && !lc.held;
|
|
762
|
+
const played = scrollPlays || lc.held;
|
|
763
|
+
const drag = mix.move.includes(LayoutListMove.Drag);
|
|
764
|
+
const slider = create(`${id}-slider`, T.Slider, {
|
|
765
|
+
dir: ctx.rtl ? 'rtl' : 'ltr', effect: 'slide', slidesPerView: 'auto', spaceBetween: SLIDE_GAP,
|
|
766
|
+
centeredSlides: mix.standout?.who === LayoutListWho.Middle, loop: 'off', freeMode: drag && !played, grabCursor: drag && !played,
|
|
767
|
+
speed: GALLERY_SPEED, enableParallax: false, enableAutoplay: mix.move.includes(LayoutListMove.Auto) && !played,
|
|
768
|
+
autoplayDelay: LIST_AUTOPLAY_MS, autoplayDisableOnInteraction: true, enableKeyboard: true, scrollPlays,
|
|
769
|
+
enableCaption: false, enableCount: false, enableNavigation: mix.move.includes(LayoutListMove.Arrows) && !played,
|
|
770
|
+
[SLIDER_PLACEMENT_TRAIT]: SliderPlacement.Under, ariaLabel: l.text ?? '',
|
|
771
|
+
}, NO_ELEMENT_STYLE);
|
|
772
|
+
slider.bindings.push({ prop: 'source', source, path: '' });
|
|
773
|
+
setStyleProps(slider, scrollPlays ? { width: FULL, height: FULL, minHeight: ZERO } : {
|
|
774
|
+
position: 'absolute', top: ZERO, right: ZERO, bottom: ZERO, left: ZERO, width: FULL, height: FULL, minHeight: ZERO,
|
|
775
|
+
display: 'flex', flexDirection: 'column',
|
|
776
|
+
});
|
|
777
|
+
phone(slider, scrollPlays ? { height: 'auto' } : { position: 'relative', height: 'auto' });
|
|
778
|
+
if (mix.phone !== LayoutListPhone.Swipe) gap(ctx, LayoutGapCode.ListLater, `${lc.path}.gallery.list.phone`, `a row stays a row you swipe on a phone (${mix.phone} is a grid's)`);
|
|
779
|
+
const slide = create(`${id}-slide`, T.Slide, { caption: '' }, NO_ELEMENT_STYLE);
|
|
780
|
+
setStyleProps(slide, { width: LIST_ROW_SLIDE, height: FULL, display: 'flex', aspectRatio: 'auto' });
|
|
781
|
+
phone(slide, { width: LIST_ROW_SLIDE_PHONE });
|
|
782
|
+
slide.children = [item];
|
|
783
|
+
slider.children = [slide];
|
|
784
|
+
syncSliderParts(slider as unknown as CompositeNode, partFactory(`${id}-slider`));
|
|
785
|
+
walkSerialized([slider], node => {
|
|
786
|
+
if (node.role === SliderRole.Prev || node.role === SliderRole.Next) node.props[LAYOUT_TOOLTIP_TRAIT] = node.props['ariaLabel'];
|
|
787
|
+
});
|
|
788
|
+
frame.children = [slider];
|
|
789
|
+
return frame;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
const items = create(`${id}-items`, 'Repeater', {}, 'box');
|
|
793
|
+
items.bindings.push({ prop: 'source', source, path: '' });
|
|
794
|
+
const columns = listColumns((l.col?.[1] ?? 13) - (l.col?.[0] ?? 1));
|
|
795
|
+
if (masonry) {
|
|
796
|
+
// A wall: CSS columns over the rows (iox-design.css), as many as the room holds — never a breakpoint, so the
|
|
797
|
+
// canvas's frame and the live page agree; `two-up` keeps two on a phone.
|
|
798
|
+
items.role = mix.phone === LayoutListPhone.TwoUp ? LayoutListRole.MasonryTwo : LayoutListRole.Masonry;
|
|
799
|
+
setStyleProps(items, { display: 'block', width: FULL });
|
|
800
|
+
} else {
|
|
801
|
+
setStyleProps(items, { display: 'grid', gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))`, gap: LIST_GAP, alignItems: 'stretch', width: FULL });
|
|
802
|
+
phone(items, { gridTemplateColumns: mix.phone === LayoutListPhone.TwoUp ? 'repeat(2, minmax(0, 1fr))' : 'minmax(0, 1fr)' });
|
|
803
|
+
if (mix.phone === LayoutListPhone.Swipe) gap(ctx, LayoutGapCode.ListLater, `${lc.path}.gallery.list.phone`, 'a grid stacks on a phone; only a row swipes');
|
|
804
|
+
}
|
|
805
|
+
items.children = [item];
|
|
806
|
+
frame.children = [items];
|
|
807
|
+
return frame;
|
|
808
|
+
}
|
|
809
|
+
|
|
573
810
|
/** Recipe parts stamped with this composer's ids (`<id>-<key>`). */
|
|
574
811
|
function partFactory(id: string): (spec: CompositeNodeSpec) => CompositeNode {
|
|
575
812
|
return spec => create(`${id}-${spec.key}`, spec.type, { ...(spec.props ?? {}) }, spec.elementStyle ?? null) as unknown as CompositeNode;
|
|
@@ -712,7 +949,9 @@ function composeLayer(l: LayoutLayer, lc: LayerCtx, ctx: Ctx): SerializedNode {
|
|
|
712
949
|
}
|
|
713
950
|
|
|
714
951
|
const interactions: unknown[] = [];
|
|
715
|
-
|
|
952
|
+
// A list's items arrive on their own (its mix's `arrive`): the frame never enters on top of them.
|
|
953
|
+
const itemsArrive = l.kind === LayoutLayerKind.Gallery && !!listOfLayer(l, ctx);
|
|
954
|
+
if (!(lc.held && l.kinetic && textual) && !itemsArrive) {
|
|
716
955
|
const enter = enterInteraction(entering.id, l, ctx, lc.path, textual);
|
|
717
956
|
if (enter) entering.interactions = [...entering.interactions, enter];
|
|
718
957
|
if (image && l.enter === LayoutEnter.ClipReveal && l.role !== LayoutRole.Decoration) image.interactions = [...image.interactions, zoomInteraction(image.id, l, ctx)];
|
|
@@ -969,6 +1208,7 @@ export function composeLayout(site: LayoutSite, options: ComposeLayoutOptions):
|
|
|
969
1208
|
photoAlt: options.photoAlt ?? (() => ''),
|
|
970
1209
|
photoAspect: id => LAYOUT_PHOTO_ASPECT[(options.photoShape?.(id) ?? LayoutPhotoShape.Landscape) as LayoutPhotoShape] ?? LAYOUT_PHOTO_ASPECT[LayoutPhotoShape.Landscape],
|
|
971
1210
|
sourceFields: options.sourceFields ?? (() => null),
|
|
1211
|
+
listOf: options.listOf ?? (() => null),
|
|
972
1212
|
links: [],
|
|
973
1213
|
headingSeen: false,
|
|
974
1214
|
};
|
|
@@ -28,7 +28,7 @@ import { SitePlanSourceKind, ContentFieldControl, ContentFieldPlan,
|
|
|
28
28
|
} from './site-plan.model';
|
|
29
29
|
import { assertValidSitePlan, nextSourceOf, routeParams } from './validate-site-plan';
|
|
30
30
|
import { NavRole, NavShape, planNavShape } from './nav-shape';
|
|
31
|
-
import { composeLayout, LayoutColourMode, layoutBandScheme } from './compose-layout';
|
|
31
|
+
import { composeLayout, LayoutColourMode, layoutBandScheme, LayoutListBinding } from './compose-layout';
|
|
32
32
|
import { LayoutGalleryList, LayoutPage, LayoutPhotoShape, LayoutPhotoSource, LayoutSite, parseLayoutPhotoId } from './layout-language';
|
|
33
33
|
import { layoutMotionOf, layoutPresetOf } from './layout-look';
|
|
34
34
|
|
|
@@ -520,6 +520,27 @@ export function layoutListShapes(plan: SitePlan): LayoutListShape[] {
|
|
|
520
520
|
});
|
|
521
521
|
}
|
|
522
522
|
|
|
523
|
+
/**
|
|
524
|
+
* How the list composer reads one list (LI1, `ComposeLayoutOptions.listOf`): the field that plays each role, and the
|
|
525
|
+
* plan's page that shows one item — its route, its param and the item's field that fills it. Null for an alias that is
|
|
526
|
+
* no list (the plan's query sources, as `layoutListShapes`).
|
|
527
|
+
*/
|
|
528
|
+
export function layoutListBinding(alias: string, plan: SitePlan): LayoutListBinding | null {
|
|
529
|
+
const ds = plan.dataSources.find(d => d.alias === alias);
|
|
530
|
+
if (!ds || ds.type !== PlanDataSourceType.Cms || ds.mode !== PlanDataSourceMode.Query) return null;
|
|
531
|
+
const type = contentTypeOfSource(alias, plan);
|
|
532
|
+
const roles: Record<string, string> = {};
|
|
533
|
+
for (const role of Object.values(ContentRole) as `${ContentRole}`[]) {
|
|
534
|
+
const field = roleField(type, role);
|
|
535
|
+
if (field) roles[role] = field;
|
|
536
|
+
}
|
|
537
|
+
const page = type ? plan.pages.find(p => p.template === type.name && !!p.routeSource) : undefined;
|
|
538
|
+
const byRoute = page ? plan.dataSources.find(d => d.alias === page.routeSource) : undefined;
|
|
539
|
+
const filter = byRoute && byRoute.type !== PlanDataSourceType.Relative ? byRoute.filterByRouteParam : undefined;
|
|
540
|
+
const [param] = page ? routeParams(page.route) : [];
|
|
541
|
+
return { roles, ...(page && filter && param ? { detail: { route: page.route, param, field: filter.field } } : {}) };
|
|
542
|
+
}
|
|
543
|
+
|
|
523
544
|
/** One line of the brief: `works (Works): 6 items · name, picture, detail, quote (long)`. */
|
|
524
545
|
export function describeListShape(shape: LayoutListShape): string {
|
|
525
546
|
const roles = shape.roles.map(r => `${LIST_ROLE_WORDS[r]}${shape.long.includes(r) ? ' (long)' : ''}`).join(', ');
|
|
@@ -1454,6 +1475,7 @@ function composeLayoutPage(
|
|
|
1454
1475
|
const image = roleField(type, 'image');
|
|
1455
1476
|
return image ? { image, ...(roleField(type, 'title') ? { title: roleField(type, 'title')! } : {}) } : null;
|
|
1456
1477
|
},
|
|
1478
|
+
listOf: alias => layoutListBinding(alias, plan),
|
|
1457
1479
|
});
|
|
1458
1480
|
const facts = plan.business.facts ?? {};
|
|
1459
1481
|
walkSerialized(nodes, node => {
|
|
@@ -166,6 +166,75 @@ export enum LayoutNavKind {
|
|
|
166
166
|
Side = 'side',
|
|
167
167
|
}
|
|
168
168
|
|
|
169
|
+
/** List ingredients (list-ingredients-plan.md §2): the seven choices a list section mixes. Held equal to the contract's
|
|
170
|
+
* `site.layout.list` by layout-language.spec. */
|
|
171
|
+
export enum LayoutListItem {
|
|
172
|
+
Photo = 'photo',
|
|
173
|
+
Card = 'card',
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export enum LayoutListArrange {
|
|
177
|
+
Row = 'row',
|
|
178
|
+
Grid = 'grid',
|
|
179
|
+
Masonry = 'masonry',
|
|
180
|
+
Strips = 'strips',
|
|
181
|
+
Deck = 'deck',
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export enum LayoutListWho {
|
|
185
|
+
None = 'none',
|
|
186
|
+
Middle = 'middle',
|
|
187
|
+
First = 'first',
|
|
188
|
+
Pointed = 'pointed',
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export enum LayoutListHow {
|
|
192
|
+
Bigger = 'bigger',
|
|
193
|
+
Wider = 'wider',
|
|
194
|
+
Raised = 'raised',
|
|
195
|
+
Brighter = 'brighter',
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export enum LayoutListMove {
|
|
199
|
+
Arrows = 'arrows',
|
|
200
|
+
Drag = 'drag',
|
|
201
|
+
Auto = 'auto',
|
|
202
|
+
Page = 'page',
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export enum LayoutListHover {
|
|
206
|
+
Rise = 'rise',
|
|
207
|
+
Open = 'open',
|
|
208
|
+
Zoom = 'zoom',
|
|
209
|
+
Dim = 'dim',
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export enum LayoutListArrive {
|
|
213
|
+
Together = 'together',
|
|
214
|
+
OneByOne = 'one-by-one',
|
|
215
|
+
SlideIn = 'slide-in',
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export enum LayoutListPhone {
|
|
219
|
+
Swipe = 'swipe',
|
|
220
|
+
Stack = 'stack',
|
|
221
|
+
TwoUp = 'two-up',
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** One list section's mix: what each item holds (its `parts` — roles its list has), how the items sit, which stands out
|
|
225
|
+
* and how, how you move through them, what a mouse does, how they arrive and what a phone shows. */
|
|
226
|
+
export interface LayoutListMix {
|
|
227
|
+
item: `${LayoutListItem}`;
|
|
228
|
+
/** The list's roles each item shows (`title`, `image`, `quote`…) — only roles the list has. */
|
|
229
|
+
parts: string[];
|
|
230
|
+
arrange: `${LayoutListArrange}`;
|
|
231
|
+
standout?: { who: `${LayoutListWho}`; how?: `${LayoutListHow}` };
|
|
232
|
+
move: Array<`${LayoutListMove}`>;
|
|
233
|
+
hover: Array<`${LayoutListHover}`>;
|
|
234
|
+
arrive: `${LayoutListArrive}`;
|
|
235
|
+
phone: `${LayoutListPhone}`;
|
|
236
|
+
}
|
|
237
|
+
|
|
169
238
|
export interface LayoutTrack {
|
|
170
239
|
prop: `${LayoutTrackProp}`;
|
|
171
240
|
from: number;
|
|
@@ -190,6 +259,8 @@ export interface LayoutGallery {
|
|
|
190
259
|
scroll?: boolean;
|
|
191
260
|
/** Gate 2: a list data source of the plan whose items the slides show (their image role) instead of fixed photos. */
|
|
192
261
|
source?: string;
|
|
262
|
+
/** List ingredients: how the `source` list's items are shown. Absent: today's gallery (a picture per slide). */
|
|
263
|
+
list?: LayoutListMix;
|
|
193
264
|
}
|
|
194
265
|
|
|
195
266
|
export interface LayoutForm {
|