@spatial-elements/sveltekit 1.0.0-beta.5 → 1.0.0-beta.7
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/dist/catalog/catalogTransition.css +12 -0
- package/dist/spatial-element/BrandStageShell.svelte +10 -1
- package/dist/spatial-element/BrandStageShell.svelte.d.ts +2 -0
- package/dist/spatial-element/CarouselSection.svelte +341 -322
- package/dist/spatial-element/CarouselSection.svelte.d.ts +2 -7
- package/dist/spatial-element/CarouselSpatialElement.svelte +140 -126
- package/dist/spatial-element/CarouselSpatialElement.svelte.d.ts +5 -1
- package/dist/spatial-element/ListSection.svelte +7 -1
- package/dist/spatial-element/PointerHint.svelte +78 -0
- package/dist/spatial-element/PointerHint.svelte.d.ts +3 -0
- package/dist/spatial-element/SpatialElementCard.svelte +66 -1
- package/dist/spatial-element/SpatialElementMediaRail.svelte +20 -2
- package/dist/spatial-element/SpatialElementPage.svelte +0 -3
- package/dist/spatial-element/SpatialElementSummaryContent.svelte +182 -0
- package/dist/spatial-element/SpatialElementSummaryContent.svelte.d.ts +18 -0
- package/dist/spatial-element/SpatialElementSummaryPanel.svelte +5 -370
- package/dist/spatial-element/carouselTextHit.d.ts +2 -0
- package/dist/spatial-element/carouselTextHit.js +17 -0
- package/dist/spatial-element/truncatedTitle.d.ts +5 -0
- package/dist/spatial-element/truncatedTitle.js +28 -0
- package/dist/stage/Stage.svelte +42 -2
- package/dist/stage/Stage.svelte.d.ts +1 -0
- package/dist/stage/StageViewport.svelte +7 -1
- package/package.json +2 -2
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { onMount } from 'svelte';
|
|
3
|
-
import
|
|
4
|
-
import { mouseHover } from '@spatial-elements/core/stage/mouseHover';
|
|
5
|
-
import { ShoppingCart } from 'lucide-svelte';
|
|
3
|
+
import SpatialElementSummaryContent from './SpatialElementSummaryContent.svelte';
|
|
6
4
|
import Panel from '../stage/Panel.svelte';
|
|
7
5
|
import { useSpatialTheme } from './brandContext.js';
|
|
8
6
|
import type { ResolvedSpatialElementData as SpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
|
|
9
|
-
import { createCatalogEndpointAction } from '../catalog/catalogEndpointAction.js';
|
|
10
7
|
|
|
11
8
|
let { spatialElement }: { spatialElement: SpatialElementData } = $props();
|
|
12
9
|
const readTheme = useSpatialTheme();
|
|
13
10
|
const theme = $derived(readTheme());
|
|
14
|
-
const catalogEndpoint = createCatalogEndpointAction();
|
|
15
11
|
const contentInset = $derived(theme.panelShape.contentInset ?? Math.max(16, Math.round(theme.panelShape.radius * 0.7)));
|
|
16
|
-
let presentation
|
|
12
|
+
let presentation = $state<HTMLDivElement>(null!);
|
|
17
13
|
let panelHeight = $state<number>();
|
|
18
14
|
|
|
19
15
|
onMount(() => {
|
|
@@ -37,6 +33,7 @@
|
|
|
37
33
|
slot: 'detail.summary',
|
|
38
34
|
role: 'summary-surface'
|
|
39
35
|
}}
|
|
36
|
+
pointerReactive={false}
|
|
40
37
|
transitionGroup="shared"
|
|
41
38
|
class="spatial-element-panel"
|
|
42
39
|
shape={theme.panelShape}
|
|
@@ -47,128 +44,12 @@
|
|
|
47
44
|
data-shared-role="summary-surface"
|
|
48
45
|
data-spatial-element-id={spatialElement.id}
|
|
49
46
|
>
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
<p
|
|
53
|
-
class="panel-kicker"
|
|
54
|
-
data-shared-role="eyebrow"
|
|
55
|
-
data-spatial-element-id={spatialElement.id}
|
|
56
|
-
use:catalogEndpoint={{
|
|
57
|
-
brandId: theme.id,
|
|
58
|
-
spatialElementId: spatialElement.id,
|
|
59
|
-
slot: 'detail.summary',
|
|
60
|
-
role: 'eyebrow'
|
|
61
|
-
}}
|
|
62
|
-
>
|
|
63
|
-
{spatialElement.eyebrow}
|
|
64
|
-
</p>
|
|
65
|
-
<h1
|
|
66
|
-
id="spatial-element-title"
|
|
67
|
-
tabindex="-1"
|
|
68
|
-
data-shared-role="title"
|
|
69
|
-
data-spatial-element-id={spatialElement.id}
|
|
70
|
-
use:catalogEndpoint={{
|
|
71
|
-
brandId: theme.id,
|
|
72
|
-
spatialElementId: spatialElement.id,
|
|
73
|
-
slot: 'detail.summary',
|
|
74
|
-
role: 'title'
|
|
75
|
-
}}
|
|
76
|
-
>
|
|
77
|
-
{spatialElement.title}
|
|
78
|
-
</h1>
|
|
79
|
-
</div>
|
|
80
|
-
|
|
81
|
-
<ul
|
|
82
|
-
class="feature-list"
|
|
83
|
-
aria-label="SpatialElement highlights"
|
|
84
|
-
use:catalogEndpoint={{
|
|
85
|
-
brandId: theme.id,
|
|
86
|
-
spatialElementId: spatialElement.id,
|
|
87
|
-
slot: 'detail.summary',
|
|
88
|
-
role: 'features'
|
|
89
|
-
}}
|
|
90
|
-
data-catalog-rich-shared="features"
|
|
91
|
-
data-catalog-semantic={JSON.stringify(spatialElement.features)}
|
|
92
|
-
>
|
|
93
|
-
{#each spatialElement.features as feature (feature.label)}
|
|
94
|
-
<li>
|
|
95
|
-
<span class="feature-content" data-catalog-secondary>
|
|
96
|
-
<span class="feature-marker" aria-hidden="true">{feature.marker ?? 'Link'}</span>
|
|
97
|
-
<span>{feature.label}</span>
|
|
98
|
-
</span>
|
|
99
|
-
</li>
|
|
100
|
-
{/each}
|
|
101
|
-
</ul>
|
|
102
|
-
|
|
103
|
-
{#if spatialElement.action}
|
|
104
|
-
{#if spatialElement.action.href}
|
|
105
|
-
<a
|
|
106
|
-
use:catalogEndpoint={{
|
|
107
|
-
brandId: theme.id,
|
|
108
|
-
spatialElementId: spatialElement.id,
|
|
109
|
-
slot: 'detail.summary',
|
|
110
|
-
role: 'primary-action'
|
|
111
|
-
}}
|
|
112
|
-
data-catalog-rich-shared="primary-action"
|
|
113
|
-
data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
|
|
114
|
-
class="spatial-element-action spatial-element-action-expanded"
|
|
115
|
-
href={spatialElement.action.href}
|
|
116
|
-
rel="external"
|
|
117
|
-
aria-label={spatialElement.action.ariaLabel}
|
|
118
|
-
>
|
|
119
|
-
<span class="spatial-element-action-surface" data-catalog-secondary>
|
|
120
|
-
<ShoppingCart
|
|
121
|
-
class="spatial-element-action-icon"
|
|
122
|
-
size={27}
|
|
123
|
-
strokeWidth={2}
|
|
124
|
-
aria-hidden="true"
|
|
125
|
-
/>
|
|
126
|
-
<span class="spatial-element-action-label">{spatialElement.action.label}</span>
|
|
127
|
-
</span>
|
|
128
|
-
</a>
|
|
129
|
-
{:else}
|
|
130
|
-
<button
|
|
131
|
-
use:catalogEndpoint={{
|
|
132
|
-
brandId: theme.id,
|
|
133
|
-
spatialElementId: spatialElement.id,
|
|
134
|
-
slot: 'detail.summary',
|
|
135
|
-
role: 'primary-action'
|
|
136
|
-
}}
|
|
137
|
-
data-catalog-rich-shared="primary-action"
|
|
138
|
-
data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
|
|
139
|
-
class="spatial-element-action spatial-element-action-expanded"
|
|
140
|
-
type="button"
|
|
141
|
-
aria-label={spatialElement.action.ariaLabel}
|
|
142
|
-
>
|
|
143
|
-
<span class="spatial-element-action-surface" data-catalog-secondary>
|
|
144
|
-
<ShoppingCart
|
|
145
|
-
class="spatial-element-action-icon"
|
|
146
|
-
size={27}
|
|
147
|
-
strokeWidth={2}
|
|
148
|
-
aria-hidden="true"
|
|
149
|
-
/>
|
|
150
|
-
<span class="spatial-element-action-label">{spatialElement.action.label}</span>
|
|
151
|
-
</span>
|
|
152
|
-
</button>
|
|
153
|
-
{/if}
|
|
154
|
-
{/if}
|
|
155
|
-
</div>
|
|
47
|
+
<SpatialElementSummaryContent {spatialElement} {contentInset} heading="h1" bind:element={presentation}
|
|
48
|
+
address={(role) => ({ brandId: theme.id, spatialElementId: spatialElement.id, slot: 'detail.summary', role })} />
|
|
156
49
|
</Panel>
|
|
157
50
|
</div>
|
|
158
51
|
|
|
159
52
|
<style>
|
|
160
|
-
@property --summary-feature-hover-progress {
|
|
161
|
-
syntax: '<number>';
|
|
162
|
-
inherits: false;
|
|
163
|
-
initial-value: 0;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
@property --summary-action-hover-progress {
|
|
167
|
-
syntax: '<number>';
|
|
168
|
-
inherits: false;
|
|
169
|
-
initial-value: 0;
|
|
170
|
-
}
|
|
171
|
-
|
|
172
53
|
.spatial-element-aside {
|
|
173
54
|
position: relative;
|
|
174
55
|
min-height: inherit;
|
|
@@ -188,254 +69,8 @@
|
|
|
188
69
|
display: block;
|
|
189
70
|
overflow: visible;
|
|
190
71
|
color: color-mix(in srgb, var(--spatial-element-ink) 92%, transparent);
|
|
191
|
-
transform-style: preserve-3d;
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
.summary-presentation {
|
|
195
|
-
--summary-depth-progress: var(--stage-panel-pointer-proximity, 0);
|
|
196
|
-
--summary-shadow-strength: var(--stage-panel-shadow-strength, 0.18);
|
|
197
|
-
--summary-feature-depth: 40;
|
|
198
|
-
--summary-feature-hover-depth: 48;
|
|
199
|
-
--summary-eyebrow-depth: 60;
|
|
200
|
-
--summary-title-depth: 96;
|
|
201
|
-
--summary-action-depth: 76;
|
|
202
|
-
--summary-action-hover-depth: 24;
|
|
203
|
-
|
|
204
|
-
position: relative;
|
|
205
|
-
box-sizing: border-box;
|
|
206
|
-
display: flex;
|
|
207
|
-
flex-direction: column;
|
|
208
|
-
justify-content: space-between;
|
|
209
|
-
gap: 24px;
|
|
210
|
-
pointer-events: auto;
|
|
211
|
-
transform-style: preserve-3d;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
.panel-copy {
|
|
215
|
-
transform-style: preserve-3d;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
.summary-presentation h1 {
|
|
219
|
-
max-width: 390px;
|
|
220
|
-
margin: 10px 0 0;
|
|
221
|
-
font-size: clamp(30px, 3vw, 40px);
|
|
222
|
-
font-weight: 780;
|
|
223
|
-
line-height: 1.16;
|
|
224
|
-
transform-origin: left center;
|
|
225
|
-
will-change: transform;
|
|
226
72
|
}
|
|
227
73
|
|
|
228
|
-
.panel-kicker {
|
|
229
|
-
margin: 0;
|
|
230
|
-
font-size: 14px;
|
|
231
|
-
font-weight: 720;
|
|
232
|
-
letter-spacing: 0.05em;
|
|
233
|
-
text-transform: uppercase;
|
|
234
|
-
transform-origin: left center;
|
|
235
|
-
will-change: transform;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
.feature-list {
|
|
239
|
-
display: grid;
|
|
240
|
-
gap: 20px;
|
|
241
|
-
margin: 0;
|
|
242
|
-
padding: 0;
|
|
243
|
-
color: var(--spatial-element-body);
|
|
244
|
-
font-size: 18px;
|
|
245
|
-
list-style: none;
|
|
246
|
-
transform-style: preserve-3d;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
.feature-list li {
|
|
250
|
-
transform-style: preserve-3d;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
.feature-content {
|
|
254
|
-
--summary-feature-hover-progress: 0;
|
|
255
|
-
--summary-feature-effective-depth: calc(
|
|
256
|
-
var(--summary-feature-depth) * var(--summary-depth-progress) +
|
|
257
|
-
var(--summary-feature-hover-depth) * var(--summary-feature-hover-progress)
|
|
258
|
-
);
|
|
259
|
-
--summary-feature-shadow-depth: calc(
|
|
260
|
-
var(--summary-feature-depth) * var(--summary-depth-progress)
|
|
261
|
-
);
|
|
262
|
-
|
|
263
|
-
display: flex;
|
|
264
|
-
align-items: baseline;
|
|
265
|
-
gap: 14px;
|
|
266
|
-
text-shadow:
|
|
267
|
-
0 calc(0.055px * var(--summary-feature-shadow-depth))
|
|
268
|
-
calc(0.055px * var(--summary-feature-shadow-depth))
|
|
269
|
-
rgb(
|
|
270
|
-
0 0 0 /
|
|
271
|
-
calc(0.0168 * var(--summary-shadow-strength) * var(--summary-feature-shadow-depth))
|
|
272
|
-
),
|
|
273
|
-
0 calc(0.194px * var(--summary-feature-shadow-depth))
|
|
274
|
-
calc(0.278px * var(--summary-feature-shadow-depth))
|
|
275
|
-
rgb(
|
|
276
|
-
0 0 0 /
|
|
277
|
-
calc(0.00936 * var(--summary-shadow-strength) * var(--summary-feature-shadow-depth))
|
|
278
|
-
);
|
|
279
|
-
transform: translateZ(calc(1px * var(--summary-feature-effective-depth)));
|
|
280
|
-
transform-origin: left center;
|
|
281
|
-
transition: --summary-feature-hover-progress 260ms cubic-bezier(0.22, 0.75, 0.25, 1);
|
|
282
|
-
will-change: transform;
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
.summary-presentation:global([data-mouse-hover]) .feature-list li:hover .feature-content {
|
|
286
|
-
--summary-feature-hover-progress: 1;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
.feature-marker {
|
|
290
|
-
color: var(--spatial-element-accent);
|
|
291
|
-
font-weight: 800;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
.spatial-element-action {
|
|
295
|
-
display: block;
|
|
296
|
-
box-sizing: border-box;
|
|
297
|
-
width: 100%;
|
|
298
|
-
min-height: 62px;
|
|
299
|
-
border: 0;
|
|
300
|
-
padding: 0;
|
|
301
|
-
color: inherit;
|
|
302
|
-
background: transparent;
|
|
303
|
-
text-decoration: none;
|
|
304
|
-
cursor: pointer;
|
|
305
|
-
transform-style: preserve-3d;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
.summary-presentation:global([data-mouse-hover]) .spatial-element-action:hover .spatial-element-action-surface,
|
|
309
|
-
.spatial-element-action:focus-visible .spatial-element-action-surface {
|
|
310
|
-
--summary-action-hover-progress: 1;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
.spatial-element-action-surface {
|
|
314
|
-
--summary-action-hover-progress: 0;
|
|
315
|
-
|
|
316
|
-
display: flex;
|
|
317
|
-
align-items: center;
|
|
318
|
-
justify-content: center;
|
|
319
|
-
gap: 10px;
|
|
320
|
-
box-sizing: border-box;
|
|
321
|
-
width: 100%;
|
|
322
|
-
min-height: 62px;
|
|
323
|
-
border-radius: 7px;
|
|
324
|
-
color: var(--spatial-element-on-accent);
|
|
325
|
-
background: var(--spatial-element-accent);
|
|
326
|
-
font:
|
|
327
|
-
760 22px/1 system-ui,
|
|
328
|
-
sans-serif;
|
|
329
|
-
transform-origin: center;
|
|
330
|
-
transition: --summary-action-hover-progress 260ms cubic-bezier(0.22, 0.75, 0.25, 1);
|
|
331
|
-
will-change: transform;
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
.panel-kicker {
|
|
335
|
-
--summary-eyebrow-effective-depth: calc(
|
|
336
|
-
var(--summary-eyebrow-depth) * var(--summary-depth-progress)
|
|
337
|
-
);
|
|
338
|
-
|
|
339
|
-
text-shadow:
|
|
340
|
-
0 calc(0.055px * var(--summary-eyebrow-effective-depth))
|
|
341
|
-
calc(0.04px * var(--summary-eyebrow-effective-depth))
|
|
342
|
-
rgb(
|
|
343
|
-
0 0 0 /
|
|
344
|
-
calc(0.0134 * var(--summary-shadow-strength) * var(--summary-eyebrow-effective-depth))
|
|
345
|
-
),
|
|
346
|
-
0 calc(0.117px * var(--summary-eyebrow-effective-depth))
|
|
347
|
-
calc(0.167px * var(--summary-eyebrow-effective-depth))
|
|
348
|
-
rgb(
|
|
349
|
-
0 0 0 /
|
|
350
|
-
calc(0.0074 * var(--summary-shadow-strength) * var(--summary-eyebrow-effective-depth))
|
|
351
|
-
);
|
|
352
|
-
transform: translateZ(calc(1px * var(--summary-eyebrow-effective-depth)));
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
.summary-presentation h1 {
|
|
356
|
-
--summary-title-effective-depth: calc(
|
|
357
|
-
var(--summary-title-depth) * var(--summary-depth-progress)
|
|
358
|
-
);
|
|
359
|
-
|
|
360
|
-
text-shadow:
|
|
361
|
-
0 calc(0.055px * var(--summary-title-effective-depth))
|
|
362
|
-
calc(0.04px * var(--summary-title-effective-depth))
|
|
363
|
-
rgb(
|
|
364
|
-
0 0 0 /
|
|
365
|
-
calc(0.007 * var(--summary-shadow-strength) * var(--summary-title-effective-depth))
|
|
366
|
-
),
|
|
367
|
-
0 calc(0.156px * var(--summary-title-effective-depth))
|
|
368
|
-
calc(0.203px * var(--summary-title-effective-depth))
|
|
369
|
-
rgb(
|
|
370
|
-
0 0 0 /
|
|
371
|
-
calc(0.0039 * var(--summary-shadow-strength) * var(--summary-title-effective-depth))
|
|
372
|
-
);
|
|
373
|
-
transform: translateZ(calc(1px * var(--summary-title-effective-depth)));
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
.spatial-element-action-surface {
|
|
377
|
-
--summary-action-effective-depth: calc(
|
|
378
|
-
var(--summary-action-depth) * var(--summary-depth-progress) +
|
|
379
|
-
var(--summary-action-hover-depth) * var(--summary-action-hover-progress)
|
|
380
|
-
);
|
|
381
|
-
|
|
382
|
-
box-shadow:
|
|
383
|
-
0 calc(0.078px * var(--summary-action-effective-depth))
|
|
384
|
-
calc(0.094px * var(--summary-action-effective-depth))
|
|
385
|
-
rgb(
|
|
386
|
-
0 0 0 /
|
|
387
|
-
calc(0.0105 * var(--summary-shadow-strength) * var(--summary-action-effective-depth))
|
|
388
|
-
),
|
|
389
|
-
0 calc(0.237px * var(--summary-action-effective-depth))
|
|
390
|
-
calc(0.316px * var(--summary-action-effective-depth))
|
|
391
|
-
rgb(
|
|
392
|
-
0 0 0 /
|
|
393
|
-
calc(0.0068 * var(--summary-shadow-strength) * var(--summary-action-effective-depth))
|
|
394
|
-
);
|
|
395
|
-
transform: translateZ(calc(1px * var(--summary-action-effective-depth)));
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
:global(.spatial-element-action-icon) {
|
|
399
|
-
flex: none;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
.spatial-element-action-label {
|
|
403
|
-
white-space: nowrap;
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/* Zero-depth transforms still promote text to composited layers in Chromium.
|
|
407
|
-
* Remove those layers while the complete panel is in its native DOM rest mode. */
|
|
408
|
-
:global([data-stage-panel-render-mode='native']) .summary-presentation,
|
|
409
|
-
:global([data-stage-panel-render-mode='native']) .panel-copy,
|
|
410
|
-
:global([data-stage-panel-render-mode='native']) .feature-list,
|
|
411
|
-
:global([data-stage-panel-render-mode='native']) .feature-list li,
|
|
412
|
-
:global([data-stage-panel-render-mode='native']) .spatial-element-action {
|
|
413
|
-
transform-style: flat;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
:global([data-stage-panel-render-mode='native']) .panel-kicker,
|
|
417
|
-
:global([data-stage-panel-render-mode='native']) .summary-presentation h1,
|
|
418
|
-
:global([data-stage-panel-render-mode='native']) .feature-content,
|
|
419
|
-
:global([data-stage-panel-render-mode='native']) .spatial-element-action-surface {
|
|
420
|
-
transform: none;
|
|
421
|
-
will-change: auto;
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
@media (prefers-reduced-motion: reduce) {
|
|
425
|
-
.summary-presentation {
|
|
426
|
-
--summary-depth-progress: 0;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
.feature-content,
|
|
430
|
-
.summary-presentation:global([data-mouse-hover]) .feature-list li:hover .feature-content,
|
|
431
|
-
.spatial-element-action-surface,
|
|
432
|
-
.summary-presentation:global([data-mouse-hover]) .spatial-element-action:hover .spatial-element-action-surface,
|
|
433
|
-
.spatial-element-action:focus-visible .spatial-element-action-surface {
|
|
434
|
-
--summary-feature-hover-progress: 0;
|
|
435
|
-
--summary-action-hover-progress: 0;
|
|
436
|
-
transition: none;
|
|
437
|
-
}
|
|
438
|
-
}
|
|
439
74
|
|
|
440
75
|
@media (max-width: 1100px) {
|
|
441
76
|
.spatial-element-aside { min-height: 0; }
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Test rendered text fragments, not the full width of their block container. */
|
|
2
|
+
export function carouselTextHit(target, x, y) {
|
|
3
|
+
if (!(target instanceof HTMLElement) || !target.closest('.summary') ||
|
|
4
|
+
target.closest('a, button, input, textarea, select, [contenteditable]'))
|
|
5
|
+
return;
|
|
6
|
+
const walker = document.createTreeWalker(target, NodeFilter.SHOW_TEXT);
|
|
7
|
+
const range = document.createRange();
|
|
8
|
+
for (let node = walker.nextNode(); node; node = walker.nextNode()) {
|
|
9
|
+
if (!node.textContent?.trim())
|
|
10
|
+
continue;
|
|
11
|
+
range.selectNodeContents(node);
|
|
12
|
+
for (const rect of range.getClientRects()) {
|
|
13
|
+
if (x >= rect.left && x <= rect.right && y >= rect.top && y <= rect.bottom)
|
|
14
|
+
return target;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/** Native tooltips only for clipped text; measurements never run on pointer movement. */
|
|
2
|
+
export function truncatedTitle(node, text) {
|
|
3
|
+
const target = node.closest('[data-catalog-card]') ?? node;
|
|
4
|
+
let frame = 0;
|
|
5
|
+
const measure = () => {
|
|
6
|
+
frame = 0;
|
|
7
|
+
if (node.scrollHeight > node.clientHeight + 1 || node.scrollWidth > node.clientWidth + 1)
|
|
8
|
+
target.title = node.textContent?.trim() || text;
|
|
9
|
+
else
|
|
10
|
+
target.removeAttribute('title');
|
|
11
|
+
};
|
|
12
|
+
const schedule = () => {
|
|
13
|
+
if (!frame)
|
|
14
|
+
frame = requestAnimationFrame(measure);
|
|
15
|
+
};
|
|
16
|
+
const observer = new ResizeObserver(schedule);
|
|
17
|
+
observer.observe(node);
|
|
18
|
+
document.fonts?.addEventListener('loadingdone', schedule);
|
|
19
|
+
schedule();
|
|
20
|
+
return {
|
|
21
|
+
update(value) { text = value; schedule(); },
|
|
22
|
+
destroy() {
|
|
23
|
+
cancelAnimationFrame(frame);
|
|
24
|
+
observer.disconnect();
|
|
25
|
+
document.fonts?.removeEventListener('loadingdone', schedule);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
package/dist/stage/Stage.svelte
CHANGED
|
@@ -55,6 +55,7 @@
|
|
|
55
55
|
} from '@spatial-elements/core/stage/panelContext';
|
|
56
56
|
|
|
57
57
|
interface Props {
|
|
58
|
+
deviceOrientation?: boolean;
|
|
58
59
|
/** Namespace for automatic ContentPage/SpatialElementPage registration. Supplied by BrandStageShell. */
|
|
59
60
|
brandId?: string;
|
|
60
61
|
renderSettings?: StageRenderSettings;
|
|
@@ -76,6 +77,7 @@
|
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
let {
|
|
80
|
+
deviceOrientation = false,
|
|
79
81
|
brandId,
|
|
80
82
|
ariaLabel = 'WebGPU 3D stage',
|
|
81
83
|
renderSettings,
|
|
@@ -137,7 +139,7 @@
|
|
|
137
139
|
let virtualScrollSpacer: HTMLDivElement;
|
|
138
140
|
let domLayer: HTMLDivElement;
|
|
139
141
|
let status = $state('Loading stage');
|
|
140
|
-
let showStatus = $state(
|
|
142
|
+
let showStatus = $state(false);
|
|
141
143
|
let isEnhanced = $state(false);
|
|
142
144
|
let fullscreen = $state(false);
|
|
143
145
|
let fullscreenController: StageFullscreenController | undefined;
|
|
@@ -183,6 +185,7 @@
|
|
|
183
185
|
};
|
|
184
186
|
|
|
185
187
|
setContext<StageContext>(STAGE_CONTEXT_KEY, {
|
|
188
|
+
isEnhanced: () => isEnhanced,
|
|
186
189
|
updatePanelAppearance: scheduleAppearanceUpdate,
|
|
187
190
|
prefetchSpatialElement: (config) => experience?.prefetchSpatialElement(config),
|
|
188
191
|
registerPanel(panel) {
|
|
@@ -209,6 +212,10 @@
|
|
|
209
212
|
});
|
|
210
213
|
|
|
211
214
|
onMount(() => {
|
|
215
|
+
// The semantic page is already usable. Only announce unusually slow enhancement.
|
|
216
|
+
const statusTimer = window.setTimeout(() => {
|
|
217
|
+
if (stageState === 'loading') showStatus = true;
|
|
218
|
+
}, 1000);
|
|
212
219
|
fullscreenController = new StageFullscreenController(stage, (active) => {
|
|
213
220
|
fullscreen = active;
|
|
214
221
|
experience?.setFullscreen(active);
|
|
@@ -216,7 +223,8 @@
|
|
|
216
223
|
document.documentElement.classList.add('stage-route');
|
|
217
224
|
document.body.classList.add('stage-route');
|
|
218
225
|
virtualScroll = new VirtualScrollController(stage, domLayer, virtualScrollSpacer);
|
|
219
|
-
|
|
226
|
+
// Native fallback pages keep native document scrolling and browser anchor behavior.
|
|
227
|
+
if (navigator.gpu) virtualScroll.start();
|
|
220
228
|
transition = new CatalogTransition(stage, catalogEndpoints, {
|
|
221
229
|
captureContentGeometry: (endpoint, secondary) =>
|
|
222
230
|
experience?.captureContentGeometry(endpoint.spatialElementId, secondary) ?? false,
|
|
@@ -262,6 +270,7 @@
|
|
|
262
270
|
const panels = getPanelTargets();
|
|
263
271
|
const viewport = getViewportTarget();
|
|
264
272
|
const instance = new StageExperience(stage, {
|
|
273
|
+
deviceOrientation,
|
|
265
274
|
renderSettings,
|
|
266
275
|
dracoDecoderPath,
|
|
267
276
|
catalog: Boolean(catalog),
|
|
@@ -294,6 +303,7 @@
|
|
|
294
303
|
setZoomFocusState(restingZoomFocus);
|
|
295
304
|
isEnhanced = false;
|
|
296
305
|
isFallback = true;
|
|
306
|
+
virtualScroll?.destroy();
|
|
297
307
|
stageState = 'fallback';
|
|
298
308
|
showStatus = false;
|
|
299
309
|
}
|
|
@@ -311,6 +321,8 @@
|
|
|
311
321
|
return;
|
|
312
322
|
}
|
|
313
323
|
|
|
324
|
+
// Paint the prepared scene before posters and fallback surfaces start fading.
|
|
325
|
+
instance.flushCatalogFrame();
|
|
314
326
|
isEnhanced = true;
|
|
315
327
|
isFallback = false;
|
|
316
328
|
showStatus = false;
|
|
@@ -330,6 +342,7 @@
|
|
|
330
342
|
experience?.dispose();
|
|
331
343
|
experience = null;
|
|
332
344
|
status = error instanceof Error ? error.message : 'Unable to initialize WebGPU stage';
|
|
345
|
+
virtualScroll?.destroy();
|
|
333
346
|
isEnhanced = false;
|
|
334
347
|
isFallback = true;
|
|
335
348
|
stageState = 'fallback';
|
|
@@ -338,6 +351,7 @@
|
|
|
338
351
|
});
|
|
339
352
|
|
|
340
353
|
return () => {
|
|
354
|
+
window.clearTimeout(statusTimer);
|
|
341
355
|
fullscreenController?.dispose();
|
|
342
356
|
fullscreenController = undefined;
|
|
343
357
|
virtualScroll?.destroy();
|
|
@@ -714,6 +728,10 @@
|
|
|
714
728
|
</div>
|
|
715
729
|
|
|
716
730
|
<style>
|
|
731
|
+
/* Apply the same document metrics before hydration; the class remains useful
|
|
732
|
+
* to hosts that do not support :has(). */
|
|
733
|
+
:global(html:has(.stage)),
|
|
734
|
+
:global(body:has(.stage)),
|
|
717
735
|
:global(html.stage-route),
|
|
718
736
|
:global(body.stage-route) {
|
|
719
737
|
margin: 0;
|
|
@@ -722,6 +740,7 @@
|
|
|
722
740
|
background: #ffffff;
|
|
723
741
|
}
|
|
724
742
|
|
|
743
|
+
:global(body:has(.stage)),
|
|
725
744
|
:global(body.stage-route) {
|
|
726
745
|
overflow-x: hidden;
|
|
727
746
|
}
|
|
@@ -791,6 +810,19 @@
|
|
|
791
810
|
pointer-events: none;
|
|
792
811
|
}
|
|
793
812
|
|
|
813
|
+
.stage :global(.stage-webgpu-background),
|
|
814
|
+
.stage :global(.stage-webgpu-carousel-rear),
|
|
815
|
+
.stage :global(.stage-webgpu-foreground) {
|
|
816
|
+
opacity: 0;
|
|
817
|
+
transition: opacity 240ms ease;
|
|
818
|
+
}
|
|
819
|
+
|
|
820
|
+
.stage.stage-enhanced :global(.stage-webgpu-background),
|
|
821
|
+
.stage.stage-enhanced :global(.stage-webgpu-carousel-rear),
|
|
822
|
+
.stage.stage-enhanced :global(.stage-webgpu-foreground) {
|
|
823
|
+
opacity: 1;
|
|
824
|
+
}
|
|
825
|
+
|
|
794
826
|
.stage :global(.stage-webgpu-foreground) {
|
|
795
827
|
/* Keep rendered minimaps above the fixed element header (z-index 20). */
|
|
796
828
|
z-index: 21;
|
|
@@ -873,4 +905,12 @@
|
|
|
873
905
|
13px/1.35 system-ui,
|
|
874
906
|
sans-serif;
|
|
875
907
|
}
|
|
908
|
+
|
|
909
|
+
@media (prefers-reduced-motion: reduce) {
|
|
910
|
+
.stage :global(.stage-webgpu-background),
|
|
911
|
+
.stage :global(.stage-webgpu-carousel-rear),
|
|
912
|
+
.stage :global(.stage-webgpu-foreground) {
|
|
913
|
+
transition: none;
|
|
914
|
+
}
|
|
915
|
+
}
|
|
876
916
|
</style>
|
|
@@ -4,6 +4,7 @@ import type { BackgroundSettings, StageCameraSettings, StageInteractionTheme, St
|
|
|
4
4
|
import '../catalog/catalogTransition.css';
|
|
5
5
|
import type { CatalogPage } from '@spatial-elements/core/catalog/catalogPage';
|
|
6
6
|
interface Props {
|
|
7
|
+
deviceOrientation?: boolean;
|
|
7
8
|
/** Namespace for automatic ContentPage/SpatialElementPage registration. Supplied by BrandStageShell. */
|
|
8
9
|
brandId?: string;
|
|
9
10
|
renderSettings?: StageRenderSettings;
|
|
@@ -65,9 +65,15 @@
|
|
|
65
65
|
width: 100%;
|
|
66
66
|
height: 100%;
|
|
67
67
|
object-fit: contain;
|
|
68
|
+
opacity: 1;
|
|
69
|
+
transition: opacity 240ms ease;
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
:global(.stage-enhanced) .stage-viewport-fallback-image {
|
|
71
|
-
|
|
73
|
+
opacity: 0;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@media (prefers-reduced-motion: reduce) {
|
|
77
|
+
.stage-viewport-fallback-image { transition: none; }
|
|
72
78
|
}
|
|
73
79
|
</style>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spatial-elements/sveltekit",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.7",
|
|
4
4
|
"description": "SvelteKit components and navigation for Spatial Elements.",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"prepack": "npm run build"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@spatial-elements/core": "1.0.0-beta.
|
|
42
|
+
"@spatial-elements/core": "1.0.0-beta.7",
|
|
43
43
|
"lucide-svelte": "^1.0.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|