@vectoriox/iox-ui 5.137.0 → 5.138.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/assist-core/index.d.ts +22 -4
- package/composite-core/index.d.ts +10 -2
- package/design-core/index.d.ts +225 -20
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs +12 -2
- package/fesm2022/vectoriox-iox-ui-actions-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs +29 -5
- package/fesm2022/vectoriox-iox-ui-assist-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs +18 -2
- package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-design-core.mjs +376 -61
- package/fesm2022/vectoriox-iox-ui-design-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs +986 -230
- package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs +5 -4
- package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs +197 -28
- package/fesm2022/vectoriox-iox-ui-scene-core.mjs.map +1 -1
- package/fesm2022/vectoriox-iox-ui.mjs +185 -11
- package/fesm2022/vectoriox-iox-ui.mjs.map +1 -1
- package/generation-core/index.d.ts +1111 -732
- package/harness-core/index.d.ts +2 -2
- package/index.d.ts +46 -2
- package/package.json +1 -1
- package/scene-core/index.d.ts +69 -13
- package/src/actions-core/element-actions.ts +14 -4
- package/src/assist-core/assist-turn.ts +3 -1
- package/src/assist-core/route-schema.ts +20 -5
- package/src/assist-core/surfaces.ts +12 -0
- package/src/composite-core/header.ts +18 -1
- package/src/design-core/design-settings.ts +14 -3
- package/src/design-core/design-token.model.ts +3 -0
- package/src/design-core/flavor-spec.generated.ts +64 -25
- package/src/design-core/graphemes.ts +16 -0
- package/src/design-core/header-behaviour.ts +20 -2
- package/src/design-core/motion-language.ts +11 -7
- package/src/design-core/node-classes.ts +10 -4
- package/src/design-core/preloader.ts +3 -4
- package/src/design-core/public-api.ts +3 -0
- package/src/design-core/scrub.ts +37 -0
- package/src/design-core/section-edge.ts +223 -0
- package/src/design-core/style-presets.ts +2 -0
- package/src/generation-core/body-mix.ts +443 -0
- package/src/generation-core/check-layout.ts +42 -4
- package/src/generation-core/compose-layout.ts +28 -6
- package/src/generation-core/compose-site.ts +26 -8
- package/src/generation-core/header-mix.ts +4 -0
- package/src/generation-core/layout-fingerprint.ts +19 -1
- package/src/generation-core/layout-language.ts +21 -1
- package/src/generation-core/layout-wire.ts +27 -2
- package/src/generation-core/node-baselines.generated.ts +7 -2
- package/src/generation-core/opening-mix.ts +32 -0
- package/src/generation-core/plan-wire.ts +1 -0
- package/src/generation-core/public-api.ts +2 -0
- package/src/generation-core/redesign-run.ts +27 -0
- package/src/generation-core/site-build-run.ts +24 -6
- package/src/generation-core/site-plan.model.ts +2 -0
- package/src/generation-core/site-spec.generated.ts +120 -58
- package/src/generation-core/text-scroll.ts +179 -0
- package/src/generation-core/validate-site-plan.ts +4 -2
- package/src/harness-core/starting-design.ts +6 -5
- package/src/scene-core/scroll-range.ts +4 -0
- package/src/scene-core/split-text.ts +216 -28
- package/styles/iox-design.css +87 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DesignChoices, presetChoices, PRELOADER_LEVELS } from '@vectoriox/iox-ui/design-core';
|
|
1
|
+
import { DesignChoices, presetChoices, PRELOADER_LEVELS, SCRUB_LEVELS } from '@vectoriox/iox-ui/design-core';
|
|
2
2
|
|
|
3
3
|
import { motionFor, MotionInput } from './motion';
|
|
4
4
|
import { RankInput, rankWithReferences, StyleRead } from './rank';
|
|
@@ -17,12 +17,12 @@ import { referenceSeed } from './reference-colour';
|
|
|
17
17
|
* when that colour passes AA in every mode the preset offers (`referenceSeed` — judged as used), and what the owner
|
|
18
18
|
* already set kept. The ONE rule for a Look pick and for Build with these. The style's first-visit preloader (AW5) is kept
|
|
19
19
|
* only while the start is Lively or Expressive (PL-D6) — a calm business (its ceiling below Standard) or "little
|
|
20
|
-
* movement" never opens with one.
|
|
20
|
+
* movement" never opens with one. Its By the scroll (AW10) likewise, only on a Lively or Expressive start (AW10-D7).
|
|
21
21
|
*/
|
|
22
22
|
export function presetDesign(
|
|
23
23
|
presetId: string,
|
|
24
24
|
input: MotionInput | string | null,
|
|
25
|
-
kept: Partial<Pick<DesignChoices, 'scroll' | 'animate' | 'between' | 'motion' | 'feel' | 'headings' | 'preloader'>> = {},
|
|
25
|
+
kept: Partial<Pick<DesignChoices, 'scroll' | 'animate' | 'between' | 'motion' | 'feel' | 'headings' | 'preloader' | 'scrub'>> = {},
|
|
26
26
|
read: StyleRead | null = null,
|
|
27
27
|
): DesignChoices | null {
|
|
28
28
|
const base = presetChoices(presetId);
|
|
@@ -30,9 +30,10 @@ export function presetDesign(
|
|
|
30
30
|
const motionInput: MotionInput = typeof input === 'object' && input !== null ? input : { businessType: input as string | null };
|
|
31
31
|
const start = motionFor(motionInput, presetId, read);
|
|
32
32
|
const seed = referenceSeed(read, presetId);
|
|
33
|
-
const { preloader, ...rest } = base;
|
|
33
|
+
const { preloader, scrub, ...rest } = base;
|
|
34
34
|
const opens = preloader && PRELOADER_LEVELS.includes(start.animate) ? { preloader } : {};
|
|
35
|
-
|
|
35
|
+
const scrubs = scrub && SCRUB_LEVELS.includes(start.animate) ? { scrub } : {};
|
|
36
|
+
return { ...rest, ...opens, ...scrubs, ...(seed?.used ? { seed: seed.seed } : {}), scroll: start.scroll, animate: start.animate, between: start.between, ...kept };
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
export interface StartingDesign {
|
|
@@ -168,6 +168,8 @@ export enum ScrollActionKind {
|
|
|
168
168
|
Progress = 'progress',
|
|
169
169
|
/** Any entrance or exit, played by the scroll instead of the clock. */
|
|
170
170
|
Scrub = 'scrub',
|
|
171
|
+
/** AW10: a text whose pieces (lines, words, letters) the scroll plays. */
|
|
172
|
+
Text = 'text',
|
|
171
173
|
}
|
|
172
174
|
|
|
173
175
|
/** What a visitor gets of one scroll-driven action. */
|
|
@@ -193,6 +195,8 @@ const PLAY: Readonly<Record<ScrollActionKind, { reduced: ScrollPlay; light: Scro
|
|
|
193
195
|
[ScrollActionKind.Progress]: { reduced: ScrollPlay.Full, light: ScrollPlay.Full },
|
|
194
196
|
// A scrubbed fade keeps its fade under reduced motion; a light device sees the element as it rests.
|
|
195
197
|
[ScrollActionKind.Scrub]: { reduced: ScrollPlay.Gentle, light: ScrollPlay.Rest },
|
|
198
|
+
// AW10 (MOTION.reduced `scrubbedText: 'whole'`, `splitLetters: false`): a text the scroll would play stands whole.
|
|
199
|
+
[ScrollActionKind.Text]: { reduced: ScrollPlay.Rest, light: ScrollPlay.Rest },
|
|
196
200
|
};
|
|
197
201
|
|
|
198
202
|
/** THE degrade (motion-v2 §3d/§3e): one table, read by the canvas and both engine paths. */
|
|
@@ -5,14 +5,51 @@
|
|
|
5
5
|
* framework may hold that node, and a layer may hold live components.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import { graphemes } from '@vectoriox/iox-ui/design-core';
|
|
9
|
+
|
|
10
|
+
import { SCENE_WORD_DIM } from './scene';
|
|
11
|
+
|
|
8
12
|
export enum TextRevealBy {
|
|
9
13
|
Line = 'line',
|
|
10
14
|
Word = 'word',
|
|
15
|
+
/** AW10: letter by letter. Display words only (`LETTER_PIECE_CAP`), never a script whose letters join. */
|
|
16
|
+
Letter = 'letter',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** How a reveal's pieces arrive (AW10): rising out of their masks, or lighting from dim (a Scene's words track's look). */
|
|
20
|
+
export enum TextRevealLook {
|
|
21
|
+
Rise = 'rise',
|
|
22
|
+
Light = 'light',
|
|
11
23
|
}
|
|
12
24
|
|
|
13
25
|
/** Past these a text is plainly no heading: it fades whole, and lights up whole. */
|
|
14
26
|
export const REVEAL_PIECE_CAP = 120;
|
|
15
27
|
export const LIGHT_UP_PIECE_CAP = 300;
|
|
28
|
+
/** AW10: past this many letters a text is no display line — it splits by word instead (the waiting word's stand-in). */
|
|
29
|
+
export const LETTER_PIECE_CAP = 80;
|
|
30
|
+
|
|
31
|
+
const REVEAL_BYS: ReadonlySet<string> = new Set(Object.values(TextRevealBy));
|
|
32
|
+
|
|
33
|
+
/** A saved `params.by`: a reveal's pieces, line by default (what `mask-rise` has always been). */
|
|
34
|
+
export function textRevealByOf(value: unknown): TextRevealBy {
|
|
35
|
+
return typeof value === 'string' && REVEAL_BYS.has(value) ? (value as TextRevealBy) : TextRevealBy.Line;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** A saved `params.look`: rising by default. */
|
|
39
|
+
export function textRevealLookOf(value: unknown): TextRevealLook {
|
|
40
|
+
return value === TextRevealLook.Light ? TextRevealLook.Light : TextRevealLook.Rise;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Scripts whose letters change shape with their neighbours (Arabic joins, an Indic consonant takes its vowel): pulled
|
|
45
|
+
* apart, every letter would show its isolated form, so they never split by letter — they split by word.
|
|
46
|
+
*/
|
|
47
|
+
const JOINED_SCRIPTS = /[\p{Script=Arabic}\p{Script=Syriac}\p{Script=Thaana}\p{Script=Nko}\p{Script=Mongolian}\p{Script=Devanagari}\p{Script=Bengali}\p{Script=Gurmukhi}\p{Script=Gujarati}\p{Script=Oriya}\p{Script=Tamil}\p{Script=Telugu}\p{Script=Kannada}\p{Script=Malayalam}\p{Script=Sinhala}\p{Script=Thai}\p{Script=Lao}\p{Script=Tibetan}\p{Script=Myanmar}\p{Script=Khmer}]/u;
|
|
48
|
+
|
|
49
|
+
/** True when `text` may come apart letter by letter without a letter changing its shape (Hebrew, Latin, Cyrillic…). */
|
|
50
|
+
export function lettersSplittable(text: string): boolean {
|
|
51
|
+
return !JOINED_SCRIPTS.test(text);
|
|
52
|
+
}
|
|
16
53
|
|
|
17
54
|
const SKIPPED_TAGS: ReadonlySet<string> = new Set(['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'SELECT', 'OPTION']);
|
|
18
55
|
const SHOW_TEXT = 4;
|
|
@@ -26,17 +63,21 @@ export interface TextPiece {
|
|
|
26
63
|
}
|
|
27
64
|
|
|
28
65
|
/**
|
|
29
|
-
* A string as words and the space between them. With `keepLtrRuns` a run of words holding no
|
|
30
|
-
*
|
|
66
|
+
* A string as words and the space between them. With `keepLtrRuns` (a right-to-left element) a run of words holding no
|
|
67
|
+
* RTL letter stays ONE word; with `keepRtlRuns` (a left-to-right element) a run of words holding an RTL letter does: an
|
|
68
|
+
* inline-block is neutral to the bidi algorithm, so "Studio Alma" inside a Hebrew heading, split, would read reversed —
|
|
69
|
+
* and so would a Hebrew name inside an English one.
|
|
31
70
|
*/
|
|
32
|
-
export function textPieces(text: string, keepLtrRuns = false): TextPiece[] {
|
|
71
|
+
export function textPieces(text: string, keepLtrRuns = false, keepRtlRuns = false): TextPiece[] {
|
|
33
72
|
const pieces: TextPiece[] = (text.match(/\s+|\S+/g) ?? []).map(part => ({ text: part, word: /\S/.test(part) }));
|
|
34
|
-
if (!keepLtrRuns) return pieces;
|
|
73
|
+
if (!keepLtrRuns && !keepRtlRuns) return pieces;
|
|
74
|
+
const against = (word: string): boolean => (RTL_LETTER.test(word) ? keepRtlRuns : keepLtrRuns);
|
|
35
75
|
const merged: TextPiece[] = [];
|
|
36
76
|
for (const piece of pieces) {
|
|
37
77
|
const space = merged[merged.length - 1];
|
|
38
78
|
const word = merged[merged.length - 2];
|
|
39
|
-
if (piece.word &&
|
|
79
|
+
if (piece.word && against(piece.text) && space && !space.word && word?.word && against(word.text)
|
|
80
|
+
&& RTL_LETTER.test(word.text) === RTL_LETTER.test(piece.text)) {
|
|
40
81
|
word.text += space.text + piece.text;
|
|
41
82
|
merged.pop();
|
|
42
83
|
} else {
|
|
@@ -46,12 +87,20 @@ export function textPieces(text: string, keepLtrRuns = false): TextPiece[] {
|
|
|
46
87
|
return merged;
|
|
47
88
|
}
|
|
48
89
|
|
|
90
|
+
/** The direction a word reads in: its first letter's. */
|
|
91
|
+
function wordDirection(text: string): 'rtl' | 'ltr' {
|
|
92
|
+
const first = text.match(/\p{L}/u)?.[0] ?? '';
|
|
93
|
+
return RTL_LETTER.test(first) ? 'rtl' : 'ltr';
|
|
94
|
+
}
|
|
95
|
+
|
|
49
96
|
export interface SplitTextOptions {
|
|
50
97
|
cap: number;
|
|
51
98
|
/** Each piece in a clipping mask, to rise out of (and so an inline-block). Without it a piece is a plain inline span. */
|
|
52
99
|
mask?: boolean;
|
|
53
|
-
/** The element reads right-to-left. Only a mask needs to know. */
|
|
100
|
+
/** The element reads right-to-left. Only an inline-block (a mask, a word of letters) needs to know. */
|
|
54
101
|
rtl?: boolean;
|
|
102
|
+
/** AW10: letters, not words. Null is returned for a script whose letters join (`lettersSplittable`). */
|
|
103
|
+
letters?: boolean;
|
|
55
104
|
}
|
|
56
105
|
|
|
57
106
|
export interface SplitText {
|
|
@@ -76,6 +125,9 @@ function textNodesOf(root: HTMLElement): Text[] {
|
|
|
76
125
|
return found;
|
|
77
126
|
}
|
|
78
127
|
|
|
128
|
+
/** A clip-path and not overflow, which would move the box's baseline. The negative sides leave descenders and italics. */
|
|
129
|
+
const MASK_CLIP = 'inset(-0.1em -0.1em -0.18em -0.1em)';
|
|
130
|
+
|
|
79
131
|
function pieceOf(doc: Document, text: string, mask: boolean): { outer: HTMLElement; moving: HTMLElement } {
|
|
80
132
|
const moving = doc.createElement('span');
|
|
81
133
|
moving.textContent = text;
|
|
@@ -83,8 +135,7 @@ function pieceOf(doc: Document, text: string, mask: boolean): { outer: HTMLEleme
|
|
|
83
135
|
moving.style.display = 'inline-block';
|
|
84
136
|
const outer = doc.createElement('span');
|
|
85
137
|
outer.style.display = 'inline-block';
|
|
86
|
-
|
|
87
|
-
outer.style.clipPath = 'inset(-0.1em -0.1em -0.18em -0.1em)';
|
|
138
|
+
outer.style.clipPath = MASK_CLIP;
|
|
88
139
|
outer.appendChild(moving);
|
|
89
140
|
return { outer, moving };
|
|
90
141
|
}
|
|
@@ -93,17 +144,26 @@ function pieceOf(doc: Document, text: string, mask: boolean): { outer: HTMLEleme
|
|
|
93
144
|
export function splitText(root: HTMLElement, options: SplitTextOptions): SplitText | null {
|
|
94
145
|
const doc = root.ownerDocument;
|
|
95
146
|
const mask = !!options.mask;
|
|
96
|
-
const
|
|
97
|
-
const
|
|
147
|
+
const letters = !!options.letters;
|
|
148
|
+
const texts = textNodesOf(root);
|
|
149
|
+
if (letters && texts.some(text => !lettersSplittable(text.nodeValue ?? ''))) return null;
|
|
150
|
+
// Words of letters in a mask are inline-blocks too: a run against the element's direction stays one.
|
|
151
|
+
const keepRuns = mask;
|
|
152
|
+
const planned = texts.map(original => ({
|
|
153
|
+
original, parts: textPieces(original.nodeValue ?? '', keepRuns && !!options.rtl, keepRuns && !options.rtl),
|
|
154
|
+
}));
|
|
155
|
+
const pieceCount = (part: TextPiece): number => (!part.word ? 0 : letters ? graphemes(part.text.replace(/\s+/g, '')).length : 1);
|
|
156
|
+
const count = planned.reduce((sum, { parts }) => sum + parts.reduce((n, part) => n + pieceCount(part), 0), 0);
|
|
98
157
|
if (!count || count > options.cap) return null;
|
|
99
158
|
|
|
100
159
|
const pieces: HTMLElement[] = [];
|
|
101
160
|
const replacements: Replacement[] = planned.map(({ original, parts }) => {
|
|
102
|
-
const nodes = parts.
|
|
103
|
-
if (!part.word) return doc.createTextNode(part.text);
|
|
161
|
+
const nodes = parts.flatMap((part): Node[] => {
|
|
162
|
+
if (!part.word) return [doc.createTextNode(part.text)];
|
|
163
|
+
if (letters) return lettersOf(doc, part.text, mask, pieces);
|
|
104
164
|
const { outer, moving } = pieceOf(doc, part.text, mask);
|
|
105
165
|
pieces.push(moving);
|
|
106
|
-
return outer;
|
|
166
|
+
return [outer];
|
|
107
167
|
});
|
|
108
168
|
const parent = original.parentNode as ParentNode & Node;
|
|
109
169
|
for (const node of nodes) parent.insertBefore(node, original);
|
|
@@ -124,6 +184,32 @@ export function splitText(root: HTMLElement, options: SplitTextOptions): SplitTe
|
|
|
124
184
|
};
|
|
125
185
|
}
|
|
126
186
|
|
|
187
|
+
/**
|
|
188
|
+
* A word as letters (AW10). Unmasked, each letter is a plain inline span: the line breaks, the bidi order and the
|
|
189
|
+
* shaping are the text's own. Masked, the WORD is the mask — an inline-block that never breaks inside, reading in its
|
|
190
|
+
* own direction (an inline-block's letters would otherwise take the element's) — and each letter an inline-block that
|
|
191
|
+
* rises inside it.
|
|
192
|
+
*/
|
|
193
|
+
function lettersOf(doc: Document, word: string, mask: boolean, pieces: HTMLElement[]): Node[] {
|
|
194
|
+
const letterOf = (letter: string): HTMLElement => {
|
|
195
|
+
const span = doc.createElement('span');
|
|
196
|
+
span.textContent = letter;
|
|
197
|
+
if (mask) span.style.display = 'inline-block';
|
|
198
|
+
pieces.push(span);
|
|
199
|
+
return span;
|
|
200
|
+
};
|
|
201
|
+
// A run of words held together (`textPieces`) keeps its spaces as bare text.
|
|
202
|
+
const parts: Node[] = (word.match(/\s+|\S+/g) ?? []).flatMap((part): Node[] => (/\S/.test(part) ? graphemes(part).map(letterOf) : [doc.createTextNode(part)]));
|
|
203
|
+
if (!mask) return parts;
|
|
204
|
+
const outer = doc.createElement('span');
|
|
205
|
+
outer.style.display = 'inline-block';
|
|
206
|
+
outer.style.whiteSpace = 'nowrap';
|
|
207
|
+
outer.style.clipPath = MASK_CLIP;
|
|
208
|
+
outer.dir = wordDirection(word);
|
|
209
|
+
for (const part of parts) outer.appendChild(part);
|
|
210
|
+
return [outer];
|
|
211
|
+
}
|
|
212
|
+
|
|
127
213
|
/** The line each piece stands on: 0, 0, 1, 1, 1, 2… Read once, as a reveal starts. */
|
|
128
214
|
export function lineIndexes(tops: ReadonlyArray<number>, heights: ReadonlyArray<number>): number[] {
|
|
129
215
|
let line = 0;
|
|
@@ -139,40 +225,75 @@ export function lineIndexes(tops: ReadonlyArray<number>, heights: ReadonlyArray<
|
|
|
139
225
|
|
|
140
226
|
const LINE_STAGGER_MS = 90;
|
|
141
227
|
const WORD_STAGGER_MS = 40;
|
|
228
|
+
/** AW10: letters follow one another closely — a word assembles, it is not spelled out. */
|
|
229
|
+
const LETTER_STAGGER_MS = 24;
|
|
142
230
|
/** However long the heading, the last piece starts within this. */
|
|
143
231
|
const STAGGER_BUDGET_MS = 1000;
|
|
144
232
|
|
|
233
|
+
const STAGGER_MS: Readonly<Record<TextRevealBy, number>> = {
|
|
234
|
+
[TextRevealBy.Line]: LINE_STAGGER_MS,
|
|
235
|
+
[TextRevealBy.Word]: WORD_STAGGER_MS,
|
|
236
|
+
[TextRevealBy.Letter]: LETTER_STAGGER_MS,
|
|
237
|
+
};
|
|
238
|
+
|
|
145
239
|
export function revealStagger(groups: number, by: TextRevealBy): number {
|
|
146
|
-
|
|
147
|
-
return groups > 1 ? Math.min(step, STAGGER_BUDGET_MS / (groups - 1)) : 0;
|
|
240
|
+
return groups > 1 ? Math.min(STAGGER_MS[by], STAGGER_BUDGET_MS / (groups - 1)) : 0;
|
|
148
241
|
}
|
|
149
242
|
|
|
150
243
|
/** Past the mask's negative inset, so nothing shows before a piece's turn. */
|
|
151
244
|
const PIECE_FRAMES: Keyframe[] = [{ transform: 'translateY(120%)' }, { transform: 'translateY(0)' }];
|
|
245
|
+
/** A lit piece goes from the Scene words track's dim to whole: it never moves. */
|
|
246
|
+
const LIGHT_FRAMES: Keyframe[] = [{ opacity: SCENE_WORD_DIM }, { opacity: 1 }];
|
|
152
247
|
const DEFAULT_PIECE_MS = 700;
|
|
153
248
|
|
|
154
|
-
|
|
249
|
+
/** A text split for a reveal: its pieces in reading order and the group (line, word, letter) each plays with. */
|
|
250
|
+
export interface RevealSplit {
|
|
251
|
+
split: SplitText;
|
|
252
|
+
/** What it really split by: a letter split a text refuses falls to words (`LETTER_PIECE_CAP`, a joined script). */
|
|
253
|
+
by: TextRevealBy;
|
|
254
|
+
order: number[];
|
|
255
|
+
groups: number;
|
|
256
|
+
}
|
|
155
257
|
|
|
156
258
|
/**
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* is put back whole, which leaves nothing for a screen reader to stumble on and nothing to re-split on a resize. Null
|
|
160
|
-
* when there is nothing to split or it is being edited: the caller plays its plain fade.
|
|
259
|
+
* Split `el` for a reveal by `by` in `look`, or null when there is nothing to split or it is being edited (the caller
|
|
260
|
+
* plays its plain fade). Letters a text cannot give (too many, a joined script) are words instead.
|
|
161
261
|
*/
|
|
162
|
-
export function
|
|
163
|
-
playing.get(el)?.cancel();
|
|
262
|
+
export function splitForReveal(el: HTMLElement, by: TextRevealBy, look: TextRevealLook = TextRevealLook.Rise): RevealSplit | null {
|
|
164
263
|
if (el.isContentEditable) return null;
|
|
165
264
|
const rtl = el.ownerDocument.defaultView?.getComputedStyle(el).direction === 'rtl';
|
|
166
|
-
const
|
|
265
|
+
const mask = look === TextRevealLook.Rise;
|
|
266
|
+
let used = by;
|
|
267
|
+
let split = by === TextRevealBy.Letter ? splitText(el, { cap: LETTER_PIECE_CAP, mask, rtl, letters: true }) : null;
|
|
268
|
+
if (!split) {
|
|
269
|
+
if (used === TextRevealBy.Letter) used = TextRevealBy.Word;
|
|
270
|
+
split = splitText(el, { cap: REVEAL_PIECE_CAP, mask, rtl });
|
|
271
|
+
}
|
|
167
272
|
if (!split) return null;
|
|
273
|
+
const boxes = used === TextRevealBy.Line ? split.pieces.map(piece => ((mask ? piece.parentElement : piece) as HTMLElement).getBoundingClientRect()) : [];
|
|
274
|
+
const order = used === TextRevealBy.Line ? lineIndexes(boxes.map(box => box.top), boxes.map(box => box.height)) : split.pieces.map((_, i) => i);
|
|
275
|
+
return { split, by: used, order, groups: Math.max(...order) + 1 };
|
|
276
|
+
}
|
|
168
277
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
278
|
+
const playing = new WeakMap<HTMLElement, Animation>();
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Play a text reveal: each piece rises out of its mask (or lights from dim), line by line, word by word or letter by
|
|
282
|
+
* letter. Returns ONE animation for the whole, so a runtime treats it as any other: it finishes when the last piece
|
|
283
|
+
* lands, and on finish or cancel the text is put back whole, which leaves nothing for a screen reader to stumble on and
|
|
284
|
+
* nothing to re-split on a resize. Null when there is nothing to split or it is being edited: the caller plays its plain
|
|
285
|
+
* fade.
|
|
286
|
+
*/
|
|
287
|
+
export function playTextReveal(el: HTMLElement, by: TextRevealBy, timing: KeyframeAnimationOptions, look: TextRevealLook = TextRevealLook.Rise): Animation | null {
|
|
288
|
+
playing.get(el)?.cancel();
|
|
289
|
+
const planned = splitForReveal(el, by, look);
|
|
290
|
+
if (!planned) return null;
|
|
291
|
+
const { split, order, groups } = planned;
|
|
292
|
+
const step = revealStagger(groups, planned.by);
|
|
173
293
|
const duration = Number(timing.duration) || DEFAULT_PIECE_MS;
|
|
174
294
|
const delay = timing.delay ?? 0;
|
|
175
|
-
const
|
|
295
|
+
const frames = look === TextRevealLook.Light ? LIGHT_FRAMES : PIECE_FRAMES;
|
|
296
|
+
const pieces = split.pieces.map((piece, i) => piece.animate(frames, { duration, delay: delay + order[i] * step, easing: timing.easing, fill: 'both' }));
|
|
176
297
|
// The element itself just stands visible: its entrance's first frame had hidden it whole.
|
|
177
298
|
const whole = el.animate([{ opacity: 1 }, { opacity: 1 }], { duration: delay + duration + step * (groups - 1), fill: timing.fill ?? 'both' });
|
|
178
299
|
playing.set(el, whole);
|
|
@@ -185,3 +306,70 @@ export function playTextReveal(el: HTMLElement, by: TextRevealBy, timing: Keyfra
|
|
|
185
306
|
whole.addEventListener('cancel', finished, { once: true });
|
|
186
307
|
return whole;
|
|
187
308
|
}
|
|
309
|
+
|
|
310
|
+
/** AW10: how many pieces are on their way at once while the scroll plays a text — a wave, not one piece at a time. */
|
|
311
|
+
export const SCRUB_PIECES_IN_FLIGHT = 3;
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Where piece group `group` of `groups` stands when the scroll has played `progress` (0–1) of its text: each group plays
|
|
315
|
+
* over its own window, `inFlight` groups overlapping, the first starting at 0 and the last ending at 1. Pure.
|
|
316
|
+
*/
|
|
317
|
+
export function scrubPieceProgress(progress: number, group: number, groups: number, inFlight = SCRUB_PIECES_IN_FLIGHT): number {
|
|
318
|
+
const n = Math.max(1, groups);
|
|
319
|
+
const k = Math.max(1, Math.min(inFlight, n));
|
|
320
|
+
const slots = n + k - 1;
|
|
321
|
+
const start = group / slots;
|
|
322
|
+
const local = (progress - start) / (k / slots);
|
|
323
|
+
return Math.min(1, Math.max(0, local));
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/** A paused timeline this long is moved to the progress. */
|
|
327
|
+
const SCRUB_TIMELINE_MS = 1000;
|
|
328
|
+
|
|
329
|
+
/** A text the scroll plays (AW10 `scrub`): moved to a progress, then let go — put back whole. */
|
|
330
|
+
export interface TextScrub {
|
|
331
|
+
/** What it really split by. */
|
|
332
|
+
readonly by: TextRevealBy;
|
|
333
|
+
seek(progress: number): void;
|
|
334
|
+
release(): void;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Split `el` once and let the scroll play its pieces (AW10, mode `scrubbed`): `seek` moves every piece to where the
|
|
339
|
+
* progress puts it — rising out of its mask or lighting from dim, `SCRUB_PIECES_IN_FLIGHT` at a time — and `release`
|
|
340
|
+
* puts the text back whole. Null when there is nothing to split or it is being edited: the caller scrubs its plain fade.
|
|
341
|
+
* Transform and opacity only; nothing changes a box.
|
|
342
|
+
*/
|
|
343
|
+
export function scrubTextReveal(el: HTMLElement, by: TextRevealBy, look: TextRevealLook = TextRevealLook.Rise, easing = 'linear'): TextScrub | null {
|
|
344
|
+
playing.get(el)?.cancel();
|
|
345
|
+
const planned = splitForReveal(el, by, look);
|
|
346
|
+
if (!planned) return null;
|
|
347
|
+
const { split, order, groups } = planned;
|
|
348
|
+
const frames = look === TextRevealLook.Light ? LIGHT_FRAMES : PIECE_FRAMES;
|
|
349
|
+
const anims = split.pieces.map(piece => {
|
|
350
|
+
const anim = piece.animate(frames, { duration: SCRUB_TIMELINE_MS, fill: 'both', easing });
|
|
351
|
+
anim.pause();
|
|
352
|
+
anim.currentTime = 0;
|
|
353
|
+
return anim;
|
|
354
|
+
});
|
|
355
|
+
const at = anims.map(() => 0);
|
|
356
|
+
let released = false;
|
|
357
|
+
return {
|
|
358
|
+
by: planned.by,
|
|
359
|
+
seek: (progress: number) => {
|
|
360
|
+
if (released) return;
|
|
361
|
+
anims.forEach((anim, i) => {
|
|
362
|
+
const time = scrubPieceProgress(progress, order[i], groups) * SCRUB_TIMELINE_MS;
|
|
363
|
+
if (time === at[i]) return;
|
|
364
|
+
anim.currentTime = time;
|
|
365
|
+
at[i] = time;
|
|
366
|
+
});
|
|
367
|
+
},
|
|
368
|
+
release: () => {
|
|
369
|
+
if (released) return;
|
|
370
|
+
released = true;
|
|
371
|
+
for (const anim of anims) anim.cancel();
|
|
372
|
+
split.restore();
|
|
373
|
+
},
|
|
374
|
+
};
|
|
375
|
+
}
|
package/styles/iox-design.css
CHANGED
|
@@ -1773,3 +1773,90 @@ dialog[data-iox-dialog].iox-es.iox-role-shop-cart-drawer:is([data-iox-closing],
|
|
|
1773
1773
|
at its resting crop from the first frame. */
|
|
1774
1774
|
.iox-role-opening .iox-role-opening-media-zooms { animation: iox-opening-zoom min(calc(var(--iox-dur-slow, 320ms) * 1000), 18s) var(--iox-ease-enter, ease-out) both; }
|
|
1775
1775
|
}
|
|
1776
|
+
|
|
1777
|
+
/* ── AW6: a section's EDGE into the one above it, its card shape, and a header whose ink follows the sections ──────
|
|
1778
|
+
(award-ingredients plan §7.1d, board award-body, AW6-D1…D11). Keyed on the classes design-core's node-class helper
|
|
1779
|
+
writes from a Section's `seam` / `sectionShape` traits (`sectionDesignClasses`) — the same in every renderer.
|
|
1780
|
+
The edge belongs to the LOWER section (D2): its `::before`, filled with its own ground (`background-color: inherit` —
|
|
1781
|
+
its scheme's token or the author's colour), rises into the section above by the seam's depth. It is PAINTED, never
|
|
1782
|
+
laid out (R-H16, `seamPaintsOnly`): no box moves and the canvas selection stays square. Two neighbours on one ground
|
|
1783
|
+
paint nothing visible (D3). Every number is the contract's (`BODY.seams`, laptop · phone — held equal by
|
|
1784
|
+
generation-core `body-mix.spec.ts`). `translate: 0px` is identity: it makes the section the pseudo's
|
|
1785
|
+
containing block whatever position the canvas forces (the linked card's precedent), and paints it above the section
|
|
1786
|
+
before it. */
|
|
1787
|
+
:is(.iox-seam-wave, .iox-seam-drip, .iox-seam-torn, .iox-seam-rounded) {
|
|
1788
|
+
translate: 0px;
|
|
1789
|
+
}
|
|
1790
|
+
/* A section with no ground of its own would hand its edge `transparent`, and the edge would paint nothing: a section with
|
|
1791
|
+
no Section style holds no colour, and the DEFAULT scheme's section ground is `transparent` itself (the page shows
|
|
1792
|
+
through) — so the edge into a light section under a dark band never showed (found by e2e:bodyproof). A section with an
|
|
1793
|
+
edge stands on the page's ground instead: its section ground is re-declared as the page's on the section itself (a
|
|
1794
|
+
scheme class re-declares its own and wins), and a section with no colour wears it. Zero specificity — the Section
|
|
1795
|
+
style's and the author's own colour win. Over a plain page this is the colour the visitor saw through it. */
|
|
1796
|
+
:where(.iox-seam-wave, .iox-seam-drip, .iox-seam-torn, .iox-seam-rounded) {
|
|
1797
|
+
--iox-section-bg: var(--iox-page-bg);
|
|
1798
|
+
background-color: var(--iox-section-bg);
|
|
1799
|
+
}
|
|
1800
|
+
.iox-seam-wave { --seam-depth: 48px; --seam-shape: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 560 48' preserveAspectRatio='none'%3E%3Cpath d='M0 48C150 0 410 0 560 48Z'/%3E%3C/svg%3E"); }
|
|
1801
|
+
.iox-seam-drip { --seam-depth: 64px; --seam-shape: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 560 64' preserveAspectRatio='none'%3E%3Cpath d='M0 64V10H40V36a14 14 0 0 0 28 0V10H150V50a14 14 0 0 0 28 0V10H300V30a12 12 0 0 0 24 0V10H430V46a14 14 0 0 0 28 0V10H560V64Z'/%3E%3C/svg%3E"); }
|
|
1802
|
+
.iox-seam-torn { --seam-depth: 20px; --seam-shape: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 560 20' preserveAspectRatio='none'%3E%3Cpath d='M0 20L0 8L18 2L34 12L52 4L70 14L86 6L104 16L120 3L140 11L158 5L176 15L192 7L212 13L230 2L248 10L266 4L284 16L300 8L320 12L338 3L356 14L372 6L392 11L410 2L428 15L446 7L464 12L482 4L500 14L518 6L540 10L560 4L560 20Z'/%3E%3C/svg%3E"); }
|
|
1803
|
+
.iox-seam-rounded { --seam-radius: 48px; }
|
|
1804
|
+
:is(.iox-seam-wave, .iox-seam-drip, .iox-seam-torn)::before {
|
|
1805
|
+
content: '';
|
|
1806
|
+
position: absolute;
|
|
1807
|
+
inset-inline: 0;
|
|
1808
|
+
inset-block-end: 100%;
|
|
1809
|
+
block-size: var(--seam-depth);
|
|
1810
|
+
background-color: inherit;
|
|
1811
|
+
pointer-events: none;
|
|
1812
|
+
-webkit-mask: var(--seam-shape) 0 0 / 100% 100% no-repeat;
|
|
1813
|
+
mask: var(--seam-shape) 0 0 / 100% 100% no-repeat;
|
|
1814
|
+
}
|
|
1815
|
+
/* Rounded (D4): the upper section's lower corners, painted away in THIS section's ground — the upper reads as laid over
|
|
1816
|
+
this one, its corners at the table's radius; no depth. */
|
|
1817
|
+
.iox-seam-rounded::before {
|
|
1818
|
+
content: '';
|
|
1819
|
+
position: absolute;
|
|
1820
|
+
inset-inline: 0;
|
|
1821
|
+
inset-block-end: 100%;
|
|
1822
|
+
block-size: var(--seam-radius);
|
|
1823
|
+
background-color: inherit;
|
|
1824
|
+
pointer-events: none;
|
|
1825
|
+
-webkit-mask:
|
|
1826
|
+
radial-gradient(circle at 100% 0, #0000 calc(var(--seam-radius) - 0.5px), #000 var(--seam-radius)) left bottom / var(--seam-radius) var(--seam-radius) no-repeat,
|
|
1827
|
+
radial-gradient(circle at 0 0, #0000 calc(var(--seam-radius) - 0.5px), #000 var(--seam-radius)) right bottom / var(--seam-radius) var(--seam-radius) no-repeat;
|
|
1828
|
+
mask:
|
|
1829
|
+
radial-gradient(circle at 100% 0, #0000 calc(var(--seam-radius) - 0.5px), #000 var(--seam-radius)) left bottom / var(--seam-radius) var(--seam-radius) no-repeat,
|
|
1830
|
+
radial-gradient(circle at 0 0, #0000 calc(var(--seam-radius) - 0.5px), #000 var(--seam-radius)) right bottom / var(--seam-radius) var(--seam-radius) no-repeat;
|
|
1831
|
+
}
|
|
1832
|
+
/* The first section has nothing above it — its edge would meet the header (the panel says so). */
|
|
1833
|
+
:is(.iox-seam-wave, .iox-seam-drip, .iox-seam-torn, .iox-seam-rounded):first-child::before {
|
|
1834
|
+
content: none;
|
|
1835
|
+
}
|
|
1836
|
+
/* A right-to-left section draws an asymmetric edge mirrored (D5, R-H18). design-core decides it from the section's own
|
|
1837
|
+
Text Direction and writes `iox-seam-mirrored` beside the edge — never `:dir(rtl)`, which cannot see a CSS `direction`
|
|
1838
|
+
and, on the builder canvas, would read the ADMIN's language. The raw SSR is already right. */
|
|
1839
|
+
.iox-seam-mirrored::before {
|
|
1840
|
+
scale: -1 1;
|
|
1841
|
+
}
|
|
1842
|
+
/* A phone's depths (the table's second number). The canvas sizes by its frame. */
|
|
1843
|
+
@media (max-width: 767px) {
|
|
1844
|
+
.iox-seam-wave { --seam-depth: 24px; }
|
|
1845
|
+
.iox-seam-drip { --seam-depth: 32px; }
|
|
1846
|
+
.iox-seam-torn { --seam-depth: 14px; }
|
|
1847
|
+
.iox-seam-rounded { --seam-radius: 28px; }
|
|
1848
|
+
}
|
|
1849
|
+
@container iox-canvas (max-width: 767px) {
|
|
1850
|
+
.iox-seam-wave { --seam-depth: 24px; }
|
|
1851
|
+
.iox-seam-drip { --seam-depth: 32px; }
|
|
1852
|
+
.iox-seam-torn { --seam-depth: 14px; }
|
|
1853
|
+
.iox-seam-rounded { --seam-radius: 28px; }
|
|
1854
|
+
}
|
|
1855
|
+
/* The header whose ink FOLLOWS the sections (D10): the header ink runtime moves `data-iox-opening` as each section passes
|
|
1856
|
+
under the bar; its ground and words cross-fade by a transition (interruptible from the live value), on the look's fast
|
|
1857
|
+
duration — 0ms under motion Off. A colour change, not movement: it stays under reduced motion. */
|
|
1858
|
+
:root [data-iox-header-ink="follows"] {
|
|
1859
|
+
transition-property: background-color, color;
|
|
1860
|
+
transition-duration: var(--iox-dur-fast, 160ms);
|
|
1861
|
+
transition-timing-function: var(--iox-ease-standard, ease-out);
|
|
1862
|
+
}
|