@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,15 +1,10 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type CarouselPresentation } from '@spatial-elements/core/catalog/catalogPose';
|
|
2
2
|
import type { SpatialListItem, SpatialElementSectionDefinition } from '@spatial-elements/core/spatial-element/types';
|
|
3
3
|
type $$ComponentProps = {
|
|
4
|
-
/** Unique page-local anchor, heading and optional CSS appearance overrides. */
|
|
5
4
|
section: SpatialElementSectionDefinition;
|
|
6
|
-
/** Project element documents with getSpatialListItems; assets register automatically. */
|
|
7
|
-
list: SpatialListItem[];
|
|
8
|
-
/** Arc radius (default 0.48 of width) and depth (default 700 CSS-world pixels). */
|
|
9
5
|
presentation?: CarouselPresentation;
|
|
10
|
-
|
|
6
|
+
list: SpatialListItem[];
|
|
11
7
|
initialItemKey?: string;
|
|
12
|
-
/** Reports selection changes; URL and application state remain host-owned. */
|
|
13
8
|
onselectionchange?: (selection: {
|
|
14
9
|
itemKey: string;
|
|
15
10
|
spatialElementId: string;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import SpatialElementSummaryContent from './SpatialElementSummaryContent.svelte';
|
|
3
3
|
import { getContext } from 'svelte';
|
|
4
4
|
import { getCssPanelBoxShadow } from '@spatial-elements/core/stage/panelShadow';
|
|
5
|
+
import { mouseHover } from '@spatial-elements/core/stage/mouseHover';
|
|
5
6
|
import type { SpatialListItem } from '@spatial-elements/core/spatial-element/types';
|
|
6
7
|
import { CATALOG_ITEMS, type CatalogItems } from '@spatial-elements/core/catalog/catalogItems';
|
|
7
8
|
import { carouselKey } from '@spatial-elements/core/catalog/carouselSelection';
|
|
8
9
|
import { carouselPose, carouselResident } from '@spatial-elements/core/catalog/catalogPose';
|
|
9
|
-
import type { CarouselPresentation } from '@spatial-elements/core/catalog/catalogPose';
|
|
10
|
+
import type { CarouselLayout, CarouselPresentation, CarouselEmphasis } from '@spatial-elements/core/catalog/catalogPose';
|
|
10
11
|
import { useCatalogNavigation } from '../catalog/catalogNavigation.js';
|
|
11
12
|
import { createCatalogEndpointAction } from '../catalog/catalogEndpointAction.js';
|
|
12
13
|
import {
|
|
@@ -20,30 +21,39 @@
|
|
|
20
21
|
spatialElement,
|
|
21
22
|
sectionId,
|
|
22
23
|
presentation,
|
|
24
|
+
layout,
|
|
23
25
|
index,
|
|
24
26
|
count,
|
|
25
27
|
phase,
|
|
28
|
+
emphasis,
|
|
29
|
+
focus,
|
|
26
30
|
windowPhase,
|
|
27
31
|
selected,
|
|
28
32
|
interactive,
|
|
29
|
-
onselect
|
|
33
|
+
onselect,
|
|
34
|
+
canActivate
|
|
30
35
|
}: {
|
|
31
36
|
spatialElement: SpatialListItem;
|
|
32
37
|
sectionId: string;
|
|
33
38
|
presentation?: CarouselPresentation;
|
|
39
|
+
layout: CarouselLayout;
|
|
34
40
|
index: number;
|
|
35
41
|
count: number;
|
|
36
42
|
phase: number;
|
|
43
|
+
emphasis?: CarouselEmphasis;
|
|
44
|
+
focus: number;
|
|
37
45
|
windowPhase: number;
|
|
38
46
|
selected: boolean;
|
|
39
47
|
interactive: boolean;
|
|
40
48
|
onselect: () => void;
|
|
49
|
+
canActivate: () => boolean;
|
|
41
50
|
} = $props();
|
|
42
51
|
const items = getContext<CatalogItems | undefined>(CATALOG_ITEMS);
|
|
43
52
|
const endpoints = getContext<CatalogEndpointRegistry | undefined>(CATALOG_ENDPOINTS);
|
|
44
53
|
const sections = getContext<CatalogSections | undefined>(CATALOG_SECTIONS);
|
|
45
54
|
const readTheme = useSpatialTheme();
|
|
46
55
|
const brand = $derived(readTheme());
|
|
56
|
+
const contentInset = $derived(brand.panelShape.contentInset ?? Math.max(16, Math.round(brand.panelShape.radius * 0.7)));
|
|
47
57
|
const catalogEndpoint = createCatalogEndpointAction();
|
|
48
58
|
function address(role: CatalogEndpointRole) {
|
|
49
59
|
return interactive &&
|
|
@@ -70,8 +80,9 @@
|
|
|
70
80
|
return () => clearTimeout(timer);
|
|
71
81
|
});
|
|
72
82
|
const occurrence = $derived(JSON.stringify([sectionId, carouselKey(spatialElement)]));
|
|
73
|
-
const
|
|
74
|
-
const
|
|
83
|
+
const tooltip = $derived(spatialElement.title);
|
|
84
|
+
const pose = $derived(carouselPose(index, phase, count, presentation, layout, emphasis, focus));
|
|
85
|
+
const resident = $derived(carouselResident(index, windowPhase, count, presentation, layout));
|
|
75
86
|
function activate(event: MouseEvent) {
|
|
76
87
|
endpoints?.prefer(brand.id, spatialElement.id, occurrence, 'carousel.front');
|
|
77
88
|
sections?.activate({
|
|
@@ -87,12 +98,13 @@
|
|
|
87
98
|
return items?.register({
|
|
88
99
|
...spatialElement,
|
|
89
100
|
occurrence,
|
|
90
|
-
pose: { kind: 'carousel', read: () => carouselPose(index, phase, count, presentation) }
|
|
101
|
+
pose: { kind: 'carousel', read: () => carouselPose(index, phase, count, presentation, layout, emphasis, focus) }
|
|
91
102
|
});
|
|
92
103
|
});
|
|
93
104
|
</script>
|
|
94
105
|
|
|
95
106
|
<article
|
|
107
|
+
id={`carousel-${sectionId}-${index}`}
|
|
96
108
|
use:catalogEndpoint={address('container')}
|
|
97
109
|
class="carousel-spatial-element"
|
|
98
110
|
class:selected
|
|
@@ -116,29 +128,54 @@
|
|
|
116
128
|
data-catalog-geometry
|
|
117
129
|
data-spatial-element-id={spatialElement.id}
|
|
118
130
|
data-catalog-occurrence={occurrence}
|
|
131
|
+
style={interactive
|
|
132
|
+
? `--carousel-poster-x:${(pose.x - 0.19) * 100}%;--carousel-poster-mobile-x:${pose.x * 100}%;--carousel-poster-y:${pose.y * 100}%;--carousel-poster-size:${pose.size};--carousel-poster-opacity:${pose.opacity}`
|
|
133
|
+
: undefined}
|
|
119
134
|
>
|
|
120
|
-
<
|
|
135
|
+
<a
|
|
136
|
+
use:mouseHover
|
|
121
137
|
draggable="false"
|
|
122
138
|
class="spatial-element-target"
|
|
139
|
+
title={tooltip}
|
|
123
140
|
hidden={interactive && !pose.visible}
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
141
|
+
href={href(spatialElement.href)}
|
|
142
|
+
role={interactive && !selected ? 'button' : undefined}
|
|
143
|
+
aria-label={interactive && !selected ? `Select ${tooltip}` : `More information: ${tooltip}`}
|
|
144
|
+
aria-pressed={interactive && !selected ? false : undefined}
|
|
145
|
+
aria-busy={selected && busy || undefined}
|
|
146
|
+
data-catalog-focus-key={`catalog-geometry:${occurrence}`}
|
|
147
|
+
onpointerenter={() => { if (selected) prepare(spatialElement); }}
|
|
148
|
+
onfocus={() => { if (selected) prepare(spatialElement); }}
|
|
149
|
+
onpointerdown={() => { if (selected) prepare(spatialElement); }}
|
|
150
|
+
onkeydown={(event) => {
|
|
151
|
+
if (interactive && !selected && event.key === ' ') {
|
|
152
|
+
event.preventDefault();
|
|
153
|
+
event.currentTarget.click();
|
|
154
|
+
}
|
|
155
|
+
}}
|
|
156
|
+
onclick={(event) => {
|
|
157
|
+
if (!canActivate()) { event.preventDefault(); return; }
|
|
158
|
+
if (interactive && !selected) { event.preventDefault(); onselect(); return; }
|
|
159
|
+
activate(event);
|
|
160
|
+
}}
|
|
161
|
+
style:z-index={interactive ? Math.max(1, Math.round(1200 / (1 + Math.max(0, -pose.depth) / 1000))) : undefined}
|
|
130
162
|
>
|
|
131
|
-
{#if spatialElement.fallbackImage}<
|
|
163
|
+
{#if !spatialElement.fallbackImage}<span>{spatialElement.eyebrow}</span>{/if}
|
|
164
|
+
</a>
|
|
165
|
+
{#if spatialElement.fallbackImage}<img
|
|
166
|
+
hidden={interactive && !pose.visible}
|
|
167
|
+
class="spatial-element-poster"
|
|
132
168
|
draggable="false"
|
|
133
169
|
src={spatialElement.fallbackImage}
|
|
134
170
|
alt={`${brand.name} ${spatialElement.title}`}
|
|
171
|
+
style:--carousel-depth-blur={interactive && pose.blur ? `blur(${pose.blur}px)` : 'blur(0px)'}
|
|
135
172
|
width="320"
|
|
136
173
|
height="320"
|
|
137
|
-
/>{
|
|
138
|
-
</button>
|
|
174
|
+
/>{/if}
|
|
139
175
|
</div>
|
|
140
176
|
<div
|
|
141
177
|
class="summary"
|
|
178
|
+
style:--summary-content-inset={`${contentInset}px`}
|
|
142
179
|
hidden={interactive && pose.panelOpacity < 0.001}
|
|
143
180
|
inert={interactive && !selected}
|
|
144
181
|
aria-hidden={interactive && !selected}
|
|
@@ -154,55 +191,20 @@
|
|
|
154
191
|
100 +
|
|
155
192
|
'%'}
|
|
156
193
|
style:--carousel-panel-blur={(brand.panelTheme.backdropBlur ?? 5) + 'px'}
|
|
194
|
+
style:--carousel-focus-blur={interactive && pose.panelOpacity < 1 ? `blur(${(1 - pose.panelOpacity) * 6}px)` : 'none'}
|
|
157
195
|
style:--carousel-panel-radius={brand.panelShape.radius + 'px'}
|
|
158
196
|
use:catalogEndpoint={address('summary-surface')}
|
|
159
197
|
>
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
spatialElement.summary?.features ?? spatialElement.features.map((label) => ({ label }))
|
|
167
|
-
)}
|
|
168
|
-
>
|
|
169
|
-
{#each spatialElement.summary?.features ?? spatialElement.features.map( (label) => ({ label }) ) as feature, index (index)}<li
|
|
170
|
-
>
|
|
171
|
-
{feature.label}
|
|
172
|
-
</li>{/each}
|
|
173
|
-
</ul>
|
|
174
|
-
{#if spatialElement.summary?.action}
|
|
175
|
-
{@const action = spatialElement.summary.action}
|
|
176
|
-
{#if action.href}<a
|
|
177
|
-
use:catalogEndpoint={address('primary-action')}
|
|
178
|
-
data-catalog-rich-shared="primary-action"
|
|
179
|
-
data-catalog-semantic={catalogActionSemantic(action)}
|
|
180
|
-
class="action"
|
|
181
|
-
href={action.href}
|
|
182
|
-
rel="external"
|
|
183
|
-
aria-label={action.ariaLabel}>{action.label}</a
|
|
184
|
-
>
|
|
185
|
-
{:else}<button
|
|
186
|
-
class="action"
|
|
187
|
-
aria-label={action.ariaLabel}
|
|
188
|
-
use:catalogEndpoint={address('primary-action')}
|
|
189
|
-
data-catalog-rich-shared="primary-action"
|
|
190
|
-
data-catalog-semantic={catalogActionSemantic(action)}>{action.label}</button
|
|
191
|
-
>{/if}
|
|
192
|
-
{/if}
|
|
198
|
+
<SpatialElementSummaryContent {address} {contentInset} spatialElement={{
|
|
199
|
+
id: spatialElement.id, eyebrow: spatialElement.eyebrow, title: spatialElement.title,
|
|
200
|
+
features: spatialElement.summary?.features ?? spatialElement.features.map((label) => ({ label })),
|
|
201
|
+
action: spatialElement.summary?.action
|
|
202
|
+
}} />
|
|
203
|
+
<div class="information-links">
|
|
193
204
|
<a
|
|
194
205
|
data-catalog-focus-key={`catalog:${JSON.stringify([brand.id, spatialElement.id, occurrence, 'carousel.front'])}`}
|
|
195
206
|
aria-busy={busy || undefined}
|
|
196
|
-
onclick={
|
|
197
|
-
endpoints?.prefer(brand.id, spatialElement.id, occurrence, 'carousel.front');
|
|
198
|
-
sections?.activate({
|
|
199
|
-
brandId: brand.id,
|
|
200
|
-
spatialElementId: spatialElement.id,
|
|
201
|
-
occurrence,
|
|
202
|
-
slot: 'carousel.front'
|
|
203
|
-
});
|
|
204
|
-
event.currentTarget.focus({ preventScroll: true });
|
|
205
|
-
}}
|
|
207
|
+
onclick={activate}
|
|
206
208
|
class="information"
|
|
207
209
|
href={href(spatialElement.href)}
|
|
208
210
|
onpointerenter={() => prepare(spatialElement)}
|
|
@@ -219,53 +221,63 @@
|
|
|
219
221
|
>{spatialElement.summary.sectionLink.label}</a
|
|
220
222
|
>
|
|
221
223
|
{/if}
|
|
224
|
+
</div>
|
|
222
225
|
</div>
|
|
223
226
|
</article>
|
|
224
227
|
|
|
225
228
|
<style>
|
|
226
229
|
.carousel-spatial-element {
|
|
227
230
|
display: grid;
|
|
228
|
-
grid-template-columns: minmax(0, 1fr)
|
|
229
|
-
|
|
231
|
+
grid-template-columns: minmax(0, 1fr);
|
|
232
|
+
grid-template-rows: 1fr;
|
|
230
233
|
align-items: center;
|
|
231
|
-
|
|
234
|
+
position: relative;
|
|
235
|
+
min-width: 0;
|
|
236
|
+
min-height: 600px;
|
|
237
|
+
padding: 32px 0 64px;
|
|
238
|
+
box-sizing: border-box;
|
|
239
|
+
scroll-snap-align: start;
|
|
240
|
+
scroll-snap-stop: always;
|
|
241
|
+
scroll-margin-top: 100px;
|
|
232
242
|
}
|
|
233
243
|
.interactive {
|
|
234
|
-
|
|
235
|
-
inset: 0;
|
|
244
|
+
grid-area: 1 / 1;
|
|
236
245
|
pointer-events: none;
|
|
237
246
|
}
|
|
238
247
|
.spatial-element-visual {
|
|
239
|
-
|
|
240
|
-
|
|
248
|
+
position: absolute;
|
|
249
|
+
inset: 0;
|
|
241
250
|
display: grid;
|
|
242
251
|
place-items: center;
|
|
243
252
|
touch-action: manipulation;
|
|
244
253
|
}
|
|
245
|
-
.interactive {
|
|
246
|
-
display: block;
|
|
247
|
-
margin: 0;
|
|
248
|
-
}
|
|
249
254
|
.interactive .spatial-element-visual {
|
|
250
|
-
/*
|
|
251
|
-
touch-action:
|
|
255
|
+
/* The native rail owns horizontal panning; vertical page scroll and zoom stay native. */
|
|
256
|
+
touch-action: manipulation;
|
|
252
257
|
}
|
|
253
258
|
.interactive[hidden] {
|
|
254
259
|
/* Keep known summary dimensions measurable without painting or registering GPU actors. */
|
|
255
|
-
display:
|
|
260
|
+
display: grid;
|
|
256
261
|
visibility: hidden;
|
|
257
262
|
}
|
|
258
263
|
.interactive .summary {
|
|
259
|
-
position: absolute;
|
|
260
|
-
left: 0;
|
|
261
|
-
top: 0;
|
|
262
|
-
width: 40%;
|
|
263
|
-
box-sizing: border-box;
|
|
264
264
|
z-index: 1400;
|
|
265
265
|
transform-origin: 0 0;
|
|
266
|
-
|
|
266
|
+
}
|
|
267
|
+
.spatial-element-target,
|
|
268
|
+
.spatial-element-poster {
|
|
269
|
+
position: absolute;
|
|
270
|
+
left: var(--carousel-poster-x, 31%);
|
|
271
|
+
top: var(--carousel-poster-y, 50%);
|
|
272
|
+
width: calc(var(--carousel-poster-size, 0.82) * 100cqw);
|
|
273
|
+
max-width: calc(var(--carousel-poster-size, 0.82) * 560px);
|
|
274
|
+
transform: translate(-50%, -50%);
|
|
275
|
+
aspect-ratio: 1;
|
|
267
276
|
}
|
|
268
277
|
.spatial-element-target {
|
|
278
|
+
display: block;
|
|
279
|
+
color: inherit;
|
|
280
|
+
text-decoration: none;
|
|
269
281
|
border: none;
|
|
270
282
|
background: transparent;
|
|
271
283
|
cursor: pointer;
|
|
@@ -273,10 +285,6 @@
|
|
|
273
285
|
padding: 0;
|
|
274
286
|
aspect-ratio: 1;
|
|
275
287
|
}
|
|
276
|
-
.interactive .spatial-element-target {
|
|
277
|
-
position: absolute;
|
|
278
|
-
transform: translate(-50%, -50%);
|
|
279
|
-
}
|
|
280
288
|
.spatial-element-target[hidden] {
|
|
281
289
|
display: none;
|
|
282
290
|
}
|
|
@@ -285,21 +293,41 @@
|
|
|
285
293
|
outline-offset: 4px;
|
|
286
294
|
border-radius: 12px;
|
|
287
295
|
}
|
|
296
|
+
/* Enhanced geometry already has a silhouette focus outline in the renderer. */
|
|
297
|
+
.interactive:global([data-catalog-model-ready]) .spatial-element-target:focus-visible {
|
|
298
|
+
outline: none;
|
|
299
|
+
}
|
|
288
300
|
img {
|
|
289
|
-
|
|
290
|
-
height:
|
|
301
|
+
opacity: var(--carousel-poster-opacity, 1);
|
|
302
|
+
height: auto;
|
|
303
|
+
pointer-events: none;
|
|
291
304
|
object-fit: contain;
|
|
305
|
+
filter: var(--carousel-hover-blur, var(--carousel-depth-blur, blur(0px))) var(--carousel-hover-shadow, drop-shadow(0 0 0 transparent));
|
|
306
|
+
transition: filter 180ms ease, opacity 240ms ease;
|
|
307
|
+
}
|
|
308
|
+
.spatial-element-target:global([data-mouse-hover]) + img,
|
|
309
|
+
.spatial-element-target:focus-visible + img {
|
|
310
|
+
--carousel-hover-blur: blur(0px);
|
|
311
|
+
--carousel-hover-shadow: drop-shadow(0 0 3px var(--spatial-element-accent));
|
|
292
312
|
}
|
|
293
|
-
.
|
|
313
|
+
.interactive:global([data-catalog-model-ready]) img {
|
|
294
314
|
opacity: 0;
|
|
315
|
+
/* The GPU replaces the poster in this frame. Fading it would draw a second
|
|
316
|
+
product beneath the moving model when a return transition releases it. */
|
|
317
|
+
transition: filter 180ms ease;
|
|
295
318
|
}
|
|
296
319
|
.summary {
|
|
297
320
|
position: relative;
|
|
321
|
+
width: min(494px, 100%);
|
|
322
|
+
min-height: 504px;
|
|
323
|
+
margin-left: 50%;
|
|
324
|
+
box-sizing: border-box;
|
|
325
|
+
filter: var(--carousel-focus-blur, none);
|
|
298
326
|
|
|
299
327
|
border-radius: var(--carousel-panel-radius, 14px);
|
|
300
|
-
padding:
|
|
328
|
+
padding: var(--summary-content-inset);
|
|
301
329
|
|
|
302
|
-
color: var(--spatial-element-ink);
|
|
330
|
+
color: color-mix(in srgb, var(--spatial-element-ink) 92%, transparent);
|
|
303
331
|
pointer-events: auto;
|
|
304
332
|
}
|
|
305
333
|
.summary::before {
|
|
@@ -329,37 +357,15 @@
|
|
|
329
357
|
display: block;
|
|
330
358
|
visibility: hidden;
|
|
331
359
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
ul {
|
|
342
|
-
padding-left: 20px;
|
|
343
|
-
line-height: 1.6;
|
|
344
|
-
}
|
|
345
|
-
li {
|
|
346
|
-
margin: 12px 0;
|
|
347
|
-
}
|
|
348
|
-
.action {
|
|
349
|
-
display: block;
|
|
350
|
-
width: 100%;
|
|
351
|
-
box-sizing: border-box;
|
|
352
|
-
padding: 14px;
|
|
353
|
-
margin-top: 24px;
|
|
354
|
-
border: 0;
|
|
355
|
-
border-radius: 8px;
|
|
356
|
-
background: var(--spatial-element-accent);
|
|
357
|
-
color: white;
|
|
358
|
-
text-align: center;
|
|
359
|
-
text-decoration: none;
|
|
360
|
-
font: inherit;
|
|
361
|
-
font-weight: 650;
|
|
362
|
-
}
|
|
360
|
+
.summary > .information-links {
|
|
361
|
+
position: absolute;
|
|
362
|
+
top: 100%;
|
|
363
|
+
left: 0;
|
|
364
|
+
width: 100%;
|
|
365
|
+
display: flex;
|
|
366
|
+
flex-wrap: wrap;
|
|
367
|
+
gap: 0 16px;
|
|
368
|
+
}
|
|
363
369
|
.information {
|
|
364
370
|
display: inline-block;
|
|
365
371
|
margin-top: 20px;
|
|
@@ -380,14 +386,22 @@
|
|
|
380
386
|
white-space: nowrap;
|
|
381
387
|
}
|
|
382
388
|
@container (max-width: 700px) {
|
|
383
|
-
.interactive .summary {
|
|
384
|
-
width: 92%;
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
@media (max-width: 850px) {
|
|
388
389
|
.carousel-spatial-element {
|
|
389
|
-
|
|
390
|
-
|
|
390
|
+
min-height: 0;
|
|
391
|
+
padding: 360px 0 80px;
|
|
392
|
+
align-items: start;
|
|
391
393
|
}
|
|
394
|
+
.summary {
|
|
395
|
+
margin-inline: auto;
|
|
396
|
+
}
|
|
397
|
+
.spatial-element-target,
|
|
398
|
+
.spatial-element-poster {
|
|
399
|
+
left: var(--carousel-poster-mobile-x, 50%);
|
|
400
|
+
top: 180px;
|
|
401
|
+
max-width: calc(var(--carousel-poster-size, 0.82) * 360px);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
@media (prefers-reduced-motion: reduce) {
|
|
405
|
+
img { transition: none; }
|
|
392
406
|
}
|
|
393
407
|
</style>
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import type { SpatialListItem } from '@spatial-elements/core/spatial-element/types';
|
|
2
|
-
import type { CarouselPresentation } from '@spatial-elements/core/catalog/catalogPose';
|
|
2
|
+
import type { CarouselLayout, CarouselPresentation, CarouselEmphasis } from '@spatial-elements/core/catalog/catalogPose';
|
|
3
3
|
type $$ComponentProps = {
|
|
4
4
|
spatialElement: SpatialListItem;
|
|
5
5
|
sectionId: string;
|
|
6
6
|
presentation?: CarouselPresentation;
|
|
7
|
+
layout: CarouselLayout;
|
|
7
8
|
index: number;
|
|
8
9
|
count: number;
|
|
9
10
|
phase: number;
|
|
11
|
+
emphasis?: CarouselEmphasis;
|
|
12
|
+
focus: number;
|
|
10
13
|
windowPhase: number;
|
|
11
14
|
selected: boolean;
|
|
12
15
|
interactive: boolean;
|
|
13
16
|
onselect: () => void;
|
|
17
|
+
canActivate: () => boolean;
|
|
14
18
|
};
|
|
15
19
|
declare const CarouselSpatialElement: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
16
20
|
type CarouselSpatialElement = ReturnType<typeof CarouselSpatialElement>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { retainListDeviceOrientation } from '@spatial-elements/core/catalog/listDeviceOrientation';
|
|
2
3
|
import Section from './Section.svelte';
|
|
3
4
|
import SpatialElementCard from './SpatialElementCard.svelte';
|
|
4
5
|
import type {
|
|
@@ -12,10 +13,15 @@
|
|
|
12
13
|
list: SpatialListItem[];
|
|
13
14
|
}
|
|
14
15
|
let { section, list }: Props = $props();
|
|
16
|
+
let catalog: HTMLDivElement;
|
|
17
|
+
$effect(() => {
|
|
18
|
+
if (catalog)
|
|
19
|
+
return retainListDeviceOrientation(catalog, () => {});
|
|
20
|
+
});
|
|
15
21
|
</script>
|
|
16
22
|
|
|
17
23
|
<Section {section} presentation="list">
|
|
18
|
-
<div class="catalog">
|
|
24
|
+
<div class="catalog" bind:this={catalog} data-device-orientation="">
|
|
19
25
|
{#each list as spatialElement, index (spatialElement.itemKey ?? spatialElement.id)}
|
|
20
26
|
<SpatialElementCard
|
|
21
27
|
{spatialElement}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import { MoveHorizontal, Search, Rotate3D } from 'lucide-svelte';
|
|
4
|
+
import { carouselTextHit } from './carouselTextHit.js';
|
|
5
|
+
let badge: HTMLDivElement;
|
|
6
|
+
let action = $state<'move' | 'details' | 'rotate' | undefined>();
|
|
7
|
+
onMount(() => {
|
|
8
|
+
let frame = 0, x = 0, y = 0, buttons = 0;
|
|
9
|
+
let text: HTMLElement | undefined;
|
|
10
|
+
const clearText = () => { text?.removeAttribute('data-carousel-text-hit'); text = undefined; };
|
|
11
|
+
const hide = () => { cancelAnimationFrame(frame); frame = 0; action = undefined; clearText(); };
|
|
12
|
+
const update = () => {
|
|
13
|
+
frame = 0;
|
|
14
|
+
clearText();
|
|
15
|
+
const target = document.elementFromPoint(x, y);
|
|
16
|
+
const shell = badge.closest('.brand-stage-shell');
|
|
17
|
+
if (!target || !shell?.contains(target) || target.closest('[data-catalog-transition]')) { action = undefined; return; }
|
|
18
|
+
const section = target.closest('.carousel-drag-section');
|
|
19
|
+
const dragging = section?.hasAttribute('data-carousel-dragging');
|
|
20
|
+
if (section?.querySelector('.carousel.interactive')) {
|
|
21
|
+
text = !dragging ? carouselTextHit(target, x, y) : undefined;
|
|
22
|
+
text?.setAttribute('data-carousel-text-hit', '');
|
|
23
|
+
const geometry = target.closest('.spatial-element-target');
|
|
24
|
+
action = dragging ? 'move' : text || (buttons & 1) || (!geometry && target.closest('a, button, input, textarea, select, [contenteditable]'))
|
|
25
|
+
? undefined : geometry?.closest('.selected') ? 'details' : 'move';
|
|
26
|
+
} else {
|
|
27
|
+
const cursor = target instanceof HTMLCanvasElement ? target.style.cursor : '';
|
|
28
|
+
action = cursor === 'grab' || cursor === 'grabbing' ? 'rotate' : undefined;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const move = (event: PointerEvent) => {
|
|
32
|
+
if (event.pointerType !== 'mouse') { hide(); return; }
|
|
33
|
+
x = event.clientX; y = event.clientY; buttons = event.buttons;
|
|
34
|
+
// Position immediately, independently of the frame-batched hit testing.
|
|
35
|
+
// No reactive update or interpolation between the pointer and its hint.
|
|
36
|
+
badge.style.transform = `translate3d(${Math.max(0, Math.min(x + 10, innerWidth - 22))}px, ${Math.max(0, Math.min(y + 14, innerHeight - 22))}px, 0)`;
|
|
37
|
+
if (!frame) frame = requestAnimationFrame(update);
|
|
38
|
+
};
|
|
39
|
+
window.addEventListener('pointermove', move);
|
|
40
|
+
window.addEventListener('pointerdown', move);
|
|
41
|
+
window.addEventListener('pointerup', move);
|
|
42
|
+
window.addEventListener('blur', hide);
|
|
43
|
+
window.addEventListener('pointercancel', hide);
|
|
44
|
+
window.addEventListener('keydown', hide);
|
|
45
|
+
window.addEventListener('scroll', hide, true);
|
|
46
|
+
document.documentElement.addEventListener('pointerleave', hide);
|
|
47
|
+
const observer = new MutationObserver(hide);
|
|
48
|
+
observer.observe(badge.closest('.brand-stage-shell')!, {subtree:true, attributes:true, attributeFilter:['data-catalog-transition']});
|
|
49
|
+
return () => {
|
|
50
|
+
hide();
|
|
51
|
+
observer.disconnect();
|
|
52
|
+
window.removeEventListener('pointermove', move);
|
|
53
|
+
window.removeEventListener('pointerdown', move);
|
|
54
|
+
window.removeEventListener('pointerup', move);
|
|
55
|
+
window.removeEventListener('blur', hide);
|
|
56
|
+
window.removeEventListener('pointercancel', hide);
|
|
57
|
+
window.removeEventListener('keydown', hide);
|
|
58
|
+
window.removeEventListener('scroll', hide, true);
|
|
59
|
+
document.documentElement.removeEventListener('pointerleave', hide);
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
</script>
|
|
63
|
+
|
|
64
|
+
<div bind:this={badge} class="pointer-hint" data-pointer-hint={action} hidden={!action} aria-hidden="true">
|
|
65
|
+
{#if action === 'move'}<MoveHorizontal size={20} strokeWidth={1.8} />
|
|
66
|
+
{:else if action === 'details'}<Search size={20} strokeWidth={1.8} />
|
|
67
|
+
{:else if action === 'rotate'}<Rotate3D size={20} strokeWidth={1.8} />{/if}
|
|
68
|
+
</div>
|
|
69
|
+
|
|
70
|
+
<style>
|
|
71
|
+
.pointer-hint { position: fixed; left: 0; top: 0; z-index: 2147483647; pointer-events: none;
|
|
72
|
+
display: grid; place-items: center; width: 20px; height: 20px;
|
|
73
|
+
color: var(--spatial-element-ink); will-change: transform;
|
|
74
|
+
/* Contrast follows the strokes only, without a button-like surface. */
|
|
75
|
+
filter: drop-shadow(0 0 1px var(--spatial-element-background))
|
|
76
|
+
drop-shadow(0 0 1px var(--spatial-element-background)); }
|
|
77
|
+
.pointer-hint[hidden] { display: none; }
|
|
78
|
+
</style>
|