@atomic-ui/blocks 0.0.0-stage → 0.6.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/README.md +77 -2
- package/custom-elements.json +8688 -0
- package/dist/chunk-4JW2CHWS.js +708 -0
- package/dist/chunk-4JW2CHWS.js.map +1 -0
- package/dist/chunk-AFN7IAG2.js +379 -0
- package/dist/chunk-AFN7IAG2.js.map +1 -0
- package/dist/chunk-F4BTXUYP.js +65 -0
- package/dist/chunk-F4BTXUYP.js.map +1 -0
- package/dist/chunk-MYTYMOH6.js +193 -0
- package/dist/chunk-MYTYMOH6.js.map +1 -0
- package/dist/chunk-OTOFULMT.js +465 -0
- package/dist/chunk-OTOFULMT.js.map +1 -0
- package/dist/chunk-PORKVHAX.js +255 -0
- package/dist/chunk-PORKVHAX.js.map +1 -0
- package/dist/chunk-T7U4OPTW.js +413 -0
- package/dist/chunk-T7U4OPTW.js.map +1 -0
- package/dist/chunk-WHENVU5E.js +318 -0
- package/dist/chunk-WHENVU5E.js.map +1 -0
- package/dist/chunk-XHFUTZGU.js +228 -0
- package/dist/chunk-XHFUTZGU.js.map +1 -0
- package/dist/chunk-XJMKAK2I.js +442 -0
- package/dist/chunk-XJMKAK2I.js.map +1 -0
- package/dist/components/card-grid.d.ts +72 -0
- package/dist/components/card-grid.js +7 -0
- package/dist/components/card-grid.js.map +1 -0
- package/dist/components/changelog.d.ts +373 -0
- package/dist/components/changelog.js +16 -0
- package/dist/components/changelog.js.map +1 -0
- package/dist/components/estimator.d.ts +246 -0
- package/dist/components/estimator.js +11 -0
- package/dist/components/estimator.js.map +1 -0
- package/dist/components/marketing.d.ts +342 -0
- package/dist/components/marketing.js +17 -0
- package/dist/components/marketing.js.map +1 -0
- package/dist/components/organisms.d.ts +559 -0
- package/dist/components/organisms.js +23 -0
- package/dist/components/organisms.js.map +1 -0
- package/dist/components/property.d.ts +389 -0
- package/dist/components/property.js +17 -0
- package/dist/components/property.js.map +1 -0
- package/dist/components/scene.d.ts +138 -0
- package/dist/components/scene.js +7 -0
- package/dist/components/scene.js.map +1 -0
- package/dist/components/scrubber.d.ts +86 -0
- package/dist/components/scrubber.js +7 -0
- package/dist/components/scrubber.js.map +1 -0
- package/dist/components/selling.d.ts +409 -0
- package/dist/components/selling.js +23 -0
- package/dist/components/selling.js.map +1 -0
- package/dist/components/site.d.ts +235 -0
- package/dist/components/site.js +11 -0
- package/dist/components/site.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +114 -0
- package/dist/index.js.map +1 -0
- package/dist/standalone/atomic-ui-blocks.js +1229 -0
- package/dist/standalone/atomic-ui-blocks.js.map +7 -0
- package/dist/standalone/index.html +78 -0
- package/package.json +64 -3
- package/scripts/copy-to-product.mjs +59 -0
- package/specimen/index.html +78 -0
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
// packages/blocks/src/components/scene.ts
|
|
2
|
+
import { html, css, nothing } from "lit";
|
|
3
|
+
import { say, ImpaktElement, fontSize, fontWeight, space, t, token } from "@atomic-ui/ui";
|
|
4
|
+
var clamp = (n) => Math.min(1, Math.max(0, n));
|
|
5
|
+
var ImpaktScene = class extends ImpaktElement {
|
|
6
|
+
constructor() {
|
|
7
|
+
super();
|
|
8
|
+
/**
|
|
9
|
+
* Whether a loop is paused: the scene's own state, set by its pause button
|
|
10
|
+
* or by `pause()`. A plain field rather than a property, so it is never one
|
|
11
|
+
* of the settings an author is offered.
|
|
12
|
+
*/
|
|
13
|
+
this.paused = false;
|
|
14
|
+
this.frame = 0;
|
|
15
|
+
this.started = 0;
|
|
16
|
+
this.reduced = false;
|
|
17
|
+
this.seekFrom = 0;
|
|
18
|
+
this.seekTo = 0;
|
|
19
|
+
this.seekStart = 0;
|
|
20
|
+
this.seekMs = 0;
|
|
21
|
+
this.onScroll = () => {
|
|
22
|
+
if (this.drive === "view" || this.drive === "page") this.schedule();
|
|
23
|
+
};
|
|
24
|
+
this.tick = (now) => {
|
|
25
|
+
this.frame = 0;
|
|
26
|
+
if (this.seekMs) {
|
|
27
|
+
if (!this.seekStart) this.seekStart = now;
|
|
28
|
+
const p = Math.min(1, (now - this.seekStart) / this.seekMs);
|
|
29
|
+
const e = p < 0.5 ? 4 * p * p * p : 1 - Math.pow(-2 * p + 2, 3) / 2;
|
|
30
|
+
this.progress = this.seekFrom + (this.seekTo - this.seekFrom) * e;
|
|
31
|
+
if (p < 1) this.schedule();
|
|
32
|
+
else this.seekMs = 0;
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (this.drive === "view") {
|
|
36
|
+
const r = this.getBoundingClientRect();
|
|
37
|
+
const vh = window.innerHeight || 1;
|
|
38
|
+
this.progress = clamp(-r.top / Math.max(1, r.height - vh));
|
|
39
|
+
} else if (this.drive === "page") {
|
|
40
|
+
const doc = document.documentElement;
|
|
41
|
+
this.progress = clamp(window.scrollY / Math.max(1, doc.scrollHeight - (window.innerHeight || 0)));
|
|
42
|
+
} else if (this.drive === "loop" && !this.paused && !this.reduced) {
|
|
43
|
+
if (!this.started) this.started = now - this.progress * this.duration * 1e3;
|
|
44
|
+
this.progress = (now - this.started) / (this.duration * 1e3) % 1;
|
|
45
|
+
this.schedule();
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
this.togglePause = () => this.setPaused(!this.paused);
|
|
49
|
+
this.drive = "view";
|
|
50
|
+
this.layout = "stage";
|
|
51
|
+
this.length = 3;
|
|
52
|
+
this.duration = 8;
|
|
53
|
+
this.label = "Animation";
|
|
54
|
+
this.progress = 0;
|
|
55
|
+
this.controls = "below";
|
|
56
|
+
this.bleed = false;
|
|
57
|
+
this.hideOn = "never";
|
|
58
|
+
}
|
|
59
|
+
static {
|
|
60
|
+
this.properties = {
|
|
61
|
+
drive: { type: String, reflect: true },
|
|
62
|
+
layout: { type: String, reflect: true },
|
|
63
|
+
length: { type: Number },
|
|
64
|
+
duration: { type: Number },
|
|
65
|
+
label: { type: String },
|
|
66
|
+
progress: { type: Number },
|
|
67
|
+
controls: { type: String, reflect: true },
|
|
68
|
+
bleed: { type: Boolean, reflect: true },
|
|
69
|
+
hideOn: { type: String, reflect: true, attribute: "hide-on" }
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
static {
|
|
73
|
+
this.styles = [
|
|
74
|
+
...ImpaktElement.styles,
|
|
75
|
+
css`
|
|
76
|
+
:host {
|
|
77
|
+
display: block;
|
|
78
|
+
position: relative;
|
|
79
|
+
}
|
|
80
|
+
:host([drive='view'][layout='stage']) {
|
|
81
|
+
min-height: calc(var(--impakt-scene-length, 3) * 100svh);
|
|
82
|
+
}
|
|
83
|
+
.frame {
|
|
84
|
+
display: grid;
|
|
85
|
+
grid-template-columns: minmax(0, 1fr);
|
|
86
|
+
}
|
|
87
|
+
:host([layout='split']) .frame {
|
|
88
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
89
|
+
gap: ${space(8)};
|
|
90
|
+
}
|
|
91
|
+
.stage {
|
|
92
|
+
position: sticky;
|
|
93
|
+
top: 0;
|
|
94
|
+
height: 100svh;
|
|
95
|
+
display: grid;
|
|
96
|
+
place-items: center;
|
|
97
|
+
overflow: clip;
|
|
98
|
+
}
|
|
99
|
+
/* What is on the stage is layered, as in a motion tool: each thing sits
|
|
100
|
+
over the one before, so a later layer's timeline can reveal it over an
|
|
101
|
+
earlier one. */
|
|
102
|
+
.stage ::slotted(*) {
|
|
103
|
+
grid-area: 1 / 1;
|
|
104
|
+
max-width: 100%;
|
|
105
|
+
}
|
|
106
|
+
:host([drive='loop']) .stage,
|
|
107
|
+
:host([drive='scrubber']) .stage {
|
|
108
|
+
position: relative;
|
|
109
|
+
height: auto;
|
|
110
|
+
min-height: 60svh;
|
|
111
|
+
}
|
|
112
|
+
.controls {
|
|
113
|
+
display: flex;
|
|
114
|
+
gap: ${space(3)};
|
|
115
|
+
align-items: center;
|
|
116
|
+
justify-content: center;
|
|
117
|
+
padding-block: ${space(3)};
|
|
118
|
+
}
|
|
119
|
+
:host([bleed]) { margin-inline: calc(50% - 50vw); }
|
|
120
|
+
@media (max-width: 40rem) { :host([hide-on='phone']) { display: none; } }
|
|
121
|
+
@media (min-width: 40.0625rem) { :host([hide-on='wide']) { display: none; } }
|
|
122
|
+
/* Over the stage, the controls float at its foot, above the layers and clear of its edges. */
|
|
123
|
+
.stage > .controls { position: absolute; inset-inline: ${space(6)}; inset-block-end: ${space(6)}; z-index: 2; padding: 0; }
|
|
124
|
+
.stage > .controls ::slotted(*) { box-shadow: 0 12px 32px rgb(16 19 23 / 14%); border-radius: 16px; background: var(--impakt-color-surface-card, #fff); }
|
|
125
|
+
/* A control takes the row, so a graph scrubber spans the stage; a narrower one centres itself. */
|
|
126
|
+
.controls ::slotted(*) { flex: 1 1 auto; min-width: 0; }
|
|
127
|
+
.pause {
|
|
128
|
+
min-width: ${token("target.min", "24px")};
|
|
129
|
+
min-height: ${token("target.min", "24px")};
|
|
130
|
+
padding: ${space(2)} ${space(4)};
|
|
131
|
+
border-radius: ${token("radius.full", "9999px")};
|
|
132
|
+
border: 1px solid ${t.border};
|
|
133
|
+
background: ${t.surfaceCard};
|
|
134
|
+
color: ${t.text};
|
|
135
|
+
font-size: ${fontSize("sm")};
|
|
136
|
+
font-weight: ${fontWeight("medium")};
|
|
137
|
+
cursor: pointer;
|
|
138
|
+
}
|
|
139
|
+
.pause:focus-visible {
|
|
140
|
+
outline: none;
|
|
141
|
+
box-shadow: ${token("focus.ring.shadow", "0 0 0 2px #fff, 0 0 0 4px #1a1a1a")};
|
|
142
|
+
}
|
|
143
|
+
@media (max-width: 48rem) {
|
|
144
|
+
:host([layout='split']) .frame {
|
|
145
|
+
grid-template-columns: minmax(0, 1fr);
|
|
146
|
+
}
|
|
147
|
+
:host([layout='split']) .stage {
|
|
148
|
+
height: 50svh;
|
|
149
|
+
z-index: 1;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
@media (prefers-reduced-motion: reduce) {
|
|
153
|
+
:host {
|
|
154
|
+
min-height: 0 !important;
|
|
155
|
+
}
|
|
156
|
+
.stage {
|
|
157
|
+
position: relative;
|
|
158
|
+
height: auto;
|
|
159
|
+
gap: ${space(6)};
|
|
160
|
+
}
|
|
161
|
+
/* With less motion the layers are shown one after another, so every
|
|
162
|
+
state the scene would have moved through can still be seen. */
|
|
163
|
+
.stage ::slotted(*) {
|
|
164
|
+
grid-area: auto;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
`
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
/** @ignore */
|
|
171
|
+
connectedCallback() {
|
|
172
|
+
super.connectedCallback();
|
|
173
|
+
try {
|
|
174
|
+
this.reduced = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
175
|
+
} catch {
|
|
176
|
+
this.reduced = false;
|
|
177
|
+
}
|
|
178
|
+
window.addEventListener("scroll", this.onScroll, { passive: true, capture: true });
|
|
179
|
+
window.addEventListener("resize", this.onScroll);
|
|
180
|
+
this.schedule();
|
|
181
|
+
}
|
|
182
|
+
/** @ignore */
|
|
183
|
+
disconnectedCallback() {
|
|
184
|
+
super.disconnectedCallback();
|
|
185
|
+
window.removeEventListener("scroll", this.onScroll, { capture: true });
|
|
186
|
+
window.removeEventListener("resize", this.onScroll);
|
|
187
|
+
if (this.frame) cancelAnimationFrame(this.frame);
|
|
188
|
+
this.frame = 0;
|
|
189
|
+
}
|
|
190
|
+
/** @ignore */
|
|
191
|
+
updated(changed) {
|
|
192
|
+
if (changed.has("length")) this.style.setProperty("--impakt-scene-length", String(this.length));
|
|
193
|
+
if (changed.has("progress")) this.publish();
|
|
194
|
+
if (changed.has("drive")) {
|
|
195
|
+
this.started = 0;
|
|
196
|
+
this.schedule();
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Move to a progress. With `ms`, ease there; without, jump. A scrubber seeks
|
|
201
|
+
* a scene to a named stop this way.
|
|
202
|
+
*/
|
|
203
|
+
seek(to, ms = 0) {
|
|
204
|
+
if (ms <= 0 || this.reduced) {
|
|
205
|
+
this.progress = clamp(to);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
this.seekFrom = this.progress;
|
|
209
|
+
this.seekTo = clamp(to);
|
|
210
|
+
this.seekStart = 0;
|
|
211
|
+
this.seekMs = ms;
|
|
212
|
+
this.schedule();
|
|
213
|
+
}
|
|
214
|
+
schedule() {
|
|
215
|
+
if (!this.frame && typeof requestAnimationFrame === "function") this.frame = requestAnimationFrame(this.tick);
|
|
216
|
+
}
|
|
217
|
+
publish() {
|
|
218
|
+
this.style.setProperty("--impakt-scene-progress", this.progress.toFixed(4));
|
|
219
|
+
this.dispatchEvent(new CustomEvent("impakt-scene-progress", { detail: { progress: this.progress }, bubbles: true, composed: true }));
|
|
220
|
+
}
|
|
221
|
+
setPaused(paused) {
|
|
222
|
+
if (this.paused === paused) return;
|
|
223
|
+
this.paused = paused;
|
|
224
|
+
this.started = 0;
|
|
225
|
+
this.schedule();
|
|
226
|
+
this.requestUpdate();
|
|
227
|
+
}
|
|
228
|
+
/** Stop a loop where it is, as its pause button does. An editor scrubbing the scene calls it. */
|
|
229
|
+
pause() {
|
|
230
|
+
this.setPaused(true);
|
|
231
|
+
}
|
|
232
|
+
render() {
|
|
233
|
+
const loop = this.drive === "loop";
|
|
234
|
+
const over = this.controls === "over" && !this.reduced;
|
|
235
|
+
const controls = html`<div class="controls" part="controls">
|
|
236
|
+
<slot name="controls"></slot>
|
|
237
|
+
${loop && !this.reduced ? html`<button class="pause" type="button" aria-pressed=${this.paused ? "true" : "false"} @click=${this.togglePause}>
|
|
238
|
+
${this.paused ? say("Play {name}", { name: this.label }) : say("Pause {name}", { name: this.label })}
|
|
239
|
+
</button>` : nothing}
|
|
240
|
+
</div>`;
|
|
241
|
+
const stage = html`<div class="stage" part="stage"><slot name="stage"></slot>${over ? controls : nothing}</div>`;
|
|
242
|
+
return html`
|
|
243
|
+
<div class="frame" part="frame" role="region" aria-label=${this.label}>
|
|
244
|
+
${this.layout === "split" ? html`<div class="content" part="content"><slot></slot></div>${stage}` : html`${stage}<div class="content" part="content"><slot></slot></div>`}
|
|
245
|
+
</div>
|
|
246
|
+
${over ? nothing : controls}
|
|
247
|
+
`;
|
|
248
|
+
}
|
|
249
|
+
};
|
|
250
|
+
customElements.define("impakt-scene", ImpaktScene);
|
|
251
|
+
|
|
252
|
+
export {
|
|
253
|
+
ImpaktScene
|
|
254
|
+
};
|
|
255
|
+
//# sourceMappingURL=chunk-PORKVHAX.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/scene.ts"],"sourcesContent":["import { html, css, nothing, type TemplateResult, type PropertyValues } from 'lit';\nimport { say, ImpaktElement, fontSize, fontWeight, space, t, token } from '@atomic-ui/ui';\n\nexport type SceneDrive = 'view' | 'page' | 'loop' | 'scrubber';\nexport type SceneLayout = 'stage' | 'split';\n\nconst clamp = (n: number) => Math.min(1, Math.max(0, n));\n\n/**\n * A scene: a stage whose children move along a progress from 0 to 1.\n *\n * The children declare timelines in their `motion` block, and `@atomic-ui/motion`\n * compiles them to keyframes. This element owns only the progress, and where it\n * comes from is the `drive` (ADR 0027):\n *\n * - `view` — the scene's own passage through the viewport. The stage pins\n * while the scene scrolls past, for `length` screens, or beside the content\n * in the default slot when `layout` is `split`.\n * - `page` — the scroll position of the whole page.\n * - `loop` — time, over `duration` seconds, repeating. **It always shows a\n * pause button**, because anything that moves on its own for more than five\n * seconds must be pausable (WCAG 2.2.2), and a scene that could forget that\n * is one the gate would have to catch on every page.\n * - `scrubber` — an `impakt-scrubber` placed in the `controls` slot.\n *\n * Progress is published three ways: the `progress` property, the\n * `--impakt-scene-progress` custom property on the host, and an\n * `impakt-scene-progress` event. Engines with scroll-driven animations run `view`\n * and `page` scenes natively, and the runtime ignores the event for them.\n *\n * Under reduced motion a `loop` does not start, and nothing pins: the stage\n * and the content stack, so every state of the scene can be read in order.\n *\n * @category layout\n * @icon layers\n * @slot stage - What moves, layered one over another. Pinned while the scene plays,\n * beside the content in `split` layout, after it, so the words are read first.\n * @slot - Content that scrolls past the stage, such as chapters.\n * @slot controls - An `impakt-scrubber`, for a scene driven by one.\n * @fires {CustomEvent<{ progress: number }>} impakt-scene-progress - `{ progress }` whenever the progress changes.\n */\nexport class ImpaktScene extends ImpaktElement {\n static properties = {\n drive: { type: String, reflect: true },\n layout: { type: String, reflect: true },\n length: { type: Number },\n duration: { type: Number },\n label: { type: String },\n progress: { type: Number },\n controls: { type: String, reflect: true },\n bleed: { type: Boolean, reflect: true },\n hideOn: { type: String, reflect: true, attribute: 'hide-on' },\n };\n\n /** Where the progress comes from. */\n declare drive: 'view' | 'page' | 'loop' | 'scrubber';\n /** `stage` pins one full-width stage; `split` pins it beside the content. */\n declare layout: 'stage' | 'split';\n /** How many screens of scrolling a `view` scene lasts, in `stage` layout. */\n declare length: number;\n /** Seconds per cycle of a `loop` scene. */\n declare duration: number;\n /** The scene's accessible name. Also names its pause button. */\n declare label: string;\n /** From 0 to 1. Set it to seek a `scrubber` scene, or where one starts. */\n declare progress: number;\n /**\n * Where the controls sit: `below` the stage, or `over` its foot, floating\n * on what it shows, as a video's do. Under reduced motion they sit below.\n */\n declare controls: 'below' | 'over';\n /** Run the stage to the window's edges, past the page's margins, as a hero drawn edge to edge does. */\n declare bleed: boolean;\n /**\n * Leave it out on a phone, or on anything wider, for a picture drawn twice:\n * once for a wide screen and once for a narrow one. Never both.\n */\n declare hideOn: 'never' | 'phone' | 'wide';\n /**\n * Whether a loop is paused: the scene's own state, set by its pause button\n * or by `pause()`. A plain field rather than a property, so it is never one\n * of the settings an author is offered.\n */\n private paused = false;\n\n private frame = 0;\n private started = 0;\n private reduced = false;\n private seekFrom = 0;\n private seekTo = 0;\n private seekStart = 0;\n private seekMs = 0;\n\n constructor() {\n super();\n this.drive = 'view';\n this.layout = 'stage';\n this.length = 3;\n this.duration = 8;\n this.label = 'Animation';\n this.progress = 0;\n this.controls = 'below';\n this.bleed = false;\n this.hideOn = 'never';\n }\n\n static styles = [\n ...ImpaktElement.styles,\n css`\n :host {\n display: block;\n position: relative;\n }\n :host([drive='view'][layout='stage']) {\n min-height: calc(var(--impakt-scene-length, 3) * 100svh);\n }\n .frame {\n display: grid;\n grid-template-columns: minmax(0, 1fr);\n }\n :host([layout='split']) .frame {\n grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);\n gap: ${space(8)};\n }\n .stage {\n position: sticky;\n top: 0;\n height: 100svh;\n display: grid;\n place-items: center;\n overflow: clip;\n }\n /* What is on the stage is layered, as in a motion tool: each thing sits\n over the one before, so a later layer's timeline can reveal it over an\n earlier one. */\n .stage ::slotted(*) {\n grid-area: 1 / 1;\n max-width: 100%;\n }\n :host([drive='loop']) .stage,\n :host([drive='scrubber']) .stage {\n position: relative;\n height: auto;\n min-height: 60svh;\n }\n .controls {\n display: flex;\n gap: ${space(3)};\n align-items: center;\n justify-content: center;\n padding-block: ${space(3)};\n }\n :host([bleed]) { margin-inline: calc(50% - 50vw); }\n @media (max-width: 40rem) { :host([hide-on='phone']) { display: none; } }\n @media (min-width: 40.0625rem) { :host([hide-on='wide']) { display: none; } }\n /* Over the stage, the controls float at its foot, above the layers and clear of its edges. */\n .stage > .controls { position: absolute; inset-inline: ${space(6)}; inset-block-end: ${space(6)}; z-index: 2; padding: 0; }\n .stage > .controls ::slotted(*) { box-shadow: 0 12px 32px rgb(16 19 23 / 14%); border-radius: 16px; background: var(--impakt-color-surface-card, #fff); }\n /* A control takes the row, so a graph scrubber spans the stage; a narrower one centres itself. */\n .controls ::slotted(*) { flex: 1 1 auto; min-width: 0; }\n .pause {\n min-width: ${token('target.min', '24px')};\n min-height: ${token('target.min', '24px')};\n padding: ${space(2)} ${space(4)};\n border-radius: ${token('radius.full', '9999px')};\n border: 1px solid ${t.border};\n background: ${t.surfaceCard};\n color: ${t.text};\n font-size: ${fontSize('sm')};\n font-weight: ${fontWeight('medium')};\n cursor: pointer;\n }\n .pause:focus-visible {\n outline: none;\n box-shadow: ${token('focus.ring.shadow', '0 0 0 2px #fff, 0 0 0 4px #1a1a1a')};\n }\n @media (max-width: 48rem) {\n :host([layout='split']) .frame {\n grid-template-columns: minmax(0, 1fr);\n }\n :host([layout='split']) .stage {\n height: 50svh;\n z-index: 1;\n }\n }\n @media (prefers-reduced-motion: reduce) {\n :host {\n min-height: 0 !important;\n }\n .stage {\n position: relative;\n height: auto;\n gap: ${space(6)};\n }\n /* With less motion the layers are shown one after another, so every\n state the scene would have moved through can still be seen. */\n .stage ::slotted(*) {\n grid-area: auto;\n }\n }\n `,\n ];\n\n /** @ignore */\n connectedCallback(): void {\n super.connectedCallback();\n try {\n this.reduced = window.matchMedia('(prefers-reduced-motion: reduce)').matches;\n } catch {\n this.reduced = false;\n }\n window.addEventListener('scroll', this.onScroll, { passive: true, capture: true });\n window.addEventListener('resize', this.onScroll);\n this.schedule();\n }\n\n /** @ignore */\n disconnectedCallback(): void {\n super.disconnectedCallback();\n window.removeEventListener('scroll', this.onScroll, { capture: true });\n window.removeEventListener('resize', this.onScroll);\n if (this.frame) cancelAnimationFrame(this.frame);\n this.frame = 0;\n }\n\n /** @ignore */\n protected updated(changed: PropertyValues<this>): void {\n if (changed.has('length')) this.style.setProperty('--impakt-scene-length', String(this.length));\n if (changed.has('progress')) this.publish();\n if (changed.has('drive')) {\n this.started = 0;\n this.schedule();\n }\n }\n\n /**\n * Move to a progress. With `ms`, ease there; without, jump. A scrubber seeks\n * a scene to a named stop this way.\n */\n seek(to: number, ms = 0): void {\n if (ms <= 0 || this.reduced) {\n this.progress = clamp(to);\n return;\n }\n this.seekFrom = this.progress;\n this.seekTo = clamp(to);\n this.seekStart = 0;\n this.seekMs = ms;\n this.schedule();\n }\n\n private onScroll = () => {\n if (this.drive === 'view' || this.drive === 'page') this.schedule();\n };\n\n private schedule(): void {\n if (!this.frame && typeof requestAnimationFrame === 'function') this.frame = requestAnimationFrame(this.tick);\n }\n\n private tick = (now: number) => {\n this.frame = 0;\n if (this.seekMs) {\n if (!this.seekStart) this.seekStart = now;\n const p = Math.min(1, (now - this.seekStart) / this.seekMs);\n // ease-in-out, so a jump between stops reads as travel rather than a cut\n const e = p < 0.5 ? 4 * p * p * p : 1 - Math.pow(-2 * p + 2, 3) / 2;\n this.progress = this.seekFrom + (this.seekTo - this.seekFrom) * e;\n if (p < 1) this.schedule();\n else this.seekMs = 0;\n return;\n }\n if (this.drive === 'view') {\n const r = this.getBoundingClientRect();\n const vh = window.innerHeight || 1;\n this.progress = clamp(-r.top / Math.max(1, r.height - vh));\n } else if (this.drive === 'page') {\n const doc = document.documentElement;\n this.progress = clamp(window.scrollY / Math.max(1, doc.scrollHeight - (window.innerHeight || 0)));\n } else if (this.drive === 'loop' && !this.paused && !this.reduced) {\n if (!this.started) this.started = now - this.progress * this.duration * 1000;\n this.progress = ((now - this.started) / (this.duration * 1000)) % 1;\n this.schedule();\n }\n };\n\n private publish(): void {\n this.style.setProperty('--impakt-scene-progress', this.progress.toFixed(4));\n this.dispatchEvent(new CustomEvent('impakt-scene-progress', { detail: { progress: this.progress }, bubbles: true, composed: true }));\n }\n\n private setPaused(paused: boolean): void {\n if (this.paused === paused) return;\n this.paused = paused;\n this.started = 0;\n this.schedule();\n this.requestUpdate();\n }\n\n private togglePause = () => this.setPaused(!this.paused);\n\n /** Stop a loop where it is, as its pause button does. An editor scrubbing the scene calls it. */\n pause(): void {\n this.setPaused(true);\n }\n\n render(): TemplateResult {\n const loop = this.drive === 'loop';\n const over = this.controls === 'over' && !this.reduced;\n const controls = html`<div class=\"controls\" part=\"controls\">\n <slot name=\"controls\"></slot>\n ${loop && !this.reduced\n ? html`<button class=\"pause\" type=\"button\" aria-pressed=${this.paused ? 'true' : 'false'} @click=${this.togglePause}>\n ${this.paused ? say('Play {name}', { name: this.label }) : say('Pause {name}', { name: this.label })}\n </button>`\n : nothing}\n </div>`;\n const stage = html`<div class=\"stage\" part=\"stage\"><slot name=\"stage\"></slot>${over ? controls : nothing}</div>`;\n return html`\n <div class=\"frame\" part=\"frame\" role=\"region\" aria-label=${this.label}>\n ${this.layout === 'split'\n ? html`<div class=\"content\" part=\"content\"><slot></slot></div>${stage}`\n : html`${stage}<div class=\"content\" part=\"content\"><slot></slot></div>`}\n </div>\n ${over ? nothing : controls}\n `;\n }\n}\n\ncustomElements.define('impakt-scene', ImpaktScene);\n\ndeclare global {\n interface HTMLElementTagNameMap { 'impakt-scene': ImpaktScene }\n}\n"],"mappings":";AAAA,SAAS,MAAM,KAAK,eAAyD;AAC7E,SAAS,KAAK,eAAe,UAAU,YAAY,OAAO,GAAG,aAAa;AAK1E,IAAM,QAAQ,CAAC,MAAc,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC;AAmChD,IAAM,cAAN,cAA0B,cAAc;AAAA,EAoD7C,cAAc;AACZ,UAAM;AAXR;AAAA;AAAA;AAAA;AAAA;AAAA,SAAQ,SAAS;AAEjB,SAAQ,QAAQ;AAChB,SAAQ,UAAU;AAClB,SAAQ,UAAU;AAClB,SAAQ,WAAW;AACnB,SAAQ,SAAS;AACjB,SAAQ,YAAY;AACpB,SAAQ,SAAS;AAgKjB,SAAQ,WAAW,MAAM;AACvB,UAAI,KAAK,UAAU,UAAU,KAAK,UAAU,OAAQ,MAAK,SAAS;AAAA,IACpE;AAMA,SAAQ,OAAO,CAAC,QAAgB;AAC9B,WAAK,QAAQ;AACb,UAAI,KAAK,QAAQ;AACf,YAAI,CAAC,KAAK,UAAW,MAAK,YAAY;AACtC,cAAM,IAAI,KAAK,IAAI,IAAI,MAAM,KAAK,aAAa,KAAK,MAAM;AAE1D,cAAM,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,IAAI,IAAI,KAAK,IAAI,KAAK,IAAI,GAAG,CAAC,IAAI;AAClE,aAAK,WAAW,KAAK,YAAY,KAAK,SAAS,KAAK,YAAY;AAChE,YAAI,IAAI,EAAG,MAAK,SAAS;AAAA,YACpB,MAAK,SAAS;AACnB;AAAA,MACF;AACA,UAAI,KAAK,UAAU,QAAQ;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