@spatial-elements/sveltekit 1.0.0-beta.7 → 1.0.0-beta.8
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/ScrollNavigationBridge.svelte +170 -45
- package/dist/catalog/ScrollNavigationBridge.svelte.d.ts +9 -2
- package/dist/catalog/catalogSummaryTransfer.d.ts +16 -0
- package/dist/catalog/catalogSummaryTransfer.js +79 -0
- package/dist/catalog/catalogTransition.css +46 -3
- package/dist/catalog/interruptedPresentation.d.ts +10 -0
- package/dist/catalog/interruptedPresentation.js +29 -0
- package/dist/catalog/presentationCleanup.d.ts +4 -0
- package/dist/catalog/presentationCleanup.js +20 -0
- package/dist/catalog/stagedCatalogNavigation.d.ts +44 -0
- package/dist/catalog/stagedCatalogNavigation.js +403 -0
- package/dist/catalog/stagedDomReveal.d.ts +8 -0
- package/dist/catalog/stagedDomReveal.js +76 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/spatial-element/BrandStageShell.svelte +13 -2
- package/dist/spatial-element/BrandStageShell.svelte.d.ts +8 -0
- package/dist/spatial-element/CarouselSection.svelte +35 -21
- package/dist/spatial-element/CarouselSpatialElement.svelte +49 -115
- package/dist/spatial-element/ContentBlock.svelte +53 -0
- package/dist/spatial-element/ContentBlock.svelte.d.ts +11 -0
- package/dist/spatial-element/ContentGrid.svelte +28 -0
- package/dist/spatial-element/ContentGrid.svelte.d.ts +10 -0
- package/dist/spatial-element/ContentPage.svelte +28 -20
- package/dist/spatial-element/ContentPage.svelte.d.ts +3 -0
- package/dist/spatial-element/ListSection.svelte +11 -5
- package/dist/spatial-element/ListSection.svelte.d.ts +5 -0
- package/dist/spatial-element/PointerHint.svelte +3 -1
- package/dist/spatial-element/Section.svelte +51 -40
- package/dist/spatial-element/Section.svelte.d.ts +1 -0
- package/dist/spatial-element/SectionSurfaceGroup.svelte +34 -0
- package/dist/spatial-element/SectionSurfaceGroup.svelte.d.ts +7 -0
- package/dist/spatial-element/SpatialCardPresentation.svelte +378 -0
- package/dist/spatial-element/SpatialCardPresentation.svelte.d.ts +13 -0
- package/dist/spatial-element/SpatialCardSlot.svelte +33 -0
- package/dist/spatial-element/SpatialCardSlot.svelte.d.ts +8 -0
- package/dist/spatial-element/SpatialElementBreadcrumbs.svelte +20 -12
- package/dist/spatial-element/SpatialElementBreadcrumbs.svelte.d.ts +1 -0
- package/dist/spatial-element/SpatialElementCard.svelte +19 -318
- package/dist/spatial-element/SpatialElementCard.svelte.d.ts +3 -0
- package/dist/spatial-element/SpatialElementHelp.svelte +21 -15
- package/dist/spatial-element/SpatialElementHelp.svelte.d.ts +4 -1
- package/dist/spatial-element/SpatialElementMediaRail.svelte +75 -21
- package/dist/spatial-element/SpatialElementMediaRail.svelte.d.ts +3 -0
- package/dist/spatial-element/SpatialElementNativeMedia.svelte +36 -0
- package/dist/spatial-element/SpatialElementNativeMedia.svelte.d.ts +9 -0
- package/dist/spatial-element/SpatialElementPage.svelte +127 -68
- package/dist/spatial-element/SpatialElementPage.svelte.d.ts +1 -0
- package/dist/spatial-element/SpatialElementStickyHeader.svelte +36 -69
- package/dist/spatial-element/SpatialElementStickyHeader.svelte.d.ts +1 -0
- package/dist/spatial-element/SpatialElementSummaryContent.svelte +14 -11
- package/dist/spatial-element/SpatialElementSummaryPanel.svelte +29 -20
- package/dist/spatial-element/SpatialElementSummaryPanel.svelte.d.ts +1 -0
- package/dist/spatial-element/SpatialElementTabList.svelte +19 -3
- package/dist/spatial-element/SpatialElementTabs.svelte +56 -16
- package/dist/spatial-element/SpatialElementTabs.svelte.d.ts +1 -0
- package/dist/spatial-element/SpatialElementViewToggle.svelte +5 -4
- package/dist/spatial-element/SpatialIconButton.svelte +4 -2
- package/dist/spatial-element/SpatialNavigationShell.svelte +129 -0
- package/dist/spatial-element/SpatialNavigationShell.svelte.d.ts +10 -0
- package/dist/spatial-element/SpatialSummaryHost.svelte +19 -0
- package/dist/spatial-element/SpatialSummaryHost.svelte.d.ts +9 -0
- package/dist/spatial-element/SpatialSummaryRoot.svelte +78 -0
- package/dist/spatial-element/SpatialSummaryRoot.svelte.d.ts +8 -0
- package/dist/spatial-element/SpatialSummarySlot.svelte +39 -0
- package/dist/spatial-element/SpatialSummarySlot.svelte.d.ts +9 -0
- package/dist/spatial-element/SpatialViewIcon.svelte +29 -0
- package/dist/spatial-element/SpatialViewIcon.svelte.d.ts +6 -0
- package/dist/spatial-element/cardAppearanceFreeze.d.ts +5 -0
- package/dist/spatial-element/cardAppearanceFreeze.js +72 -0
- package/dist/spatial-element/index.d.ts +6 -2
- package/dist/spatial-element/index.js +3 -1
- package/dist/spatial-element/layout.generated.css +455 -0
- package/dist/spatial-element/presentationBoxFreeze.d.ts +8 -0
- package/dist/spatial-element/presentationBoxFreeze.js +35 -0
- package/dist/spatial-element/spatialPresentationOwner.d.ts +6 -0
- package/dist/spatial-element/spatialPresentationOwner.js +2 -0
- package/dist/spatial-element/spatialSummary.d.ts +37 -0
- package/dist/spatial-element/spatialSummary.js +1 -0
- package/dist/spatial-element/spatialSummaryHost.svelte.d.ts +60 -0
- package/dist/spatial-element/spatialSummaryHost.svelte.js +233 -0
- package/dist/spatial-element/spatialThemeStyle.js +10 -4
- package/dist/stage/ButtonGroup.svelte +1 -1
- package/dist/stage/Panel.svelte +16 -4
- package/dist/stage/Stage.svelte +180 -26
- package/package.json +2 -2
|
@@ -1,11 +1,39 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import { onMount } from 'svelte';
|
|
3
|
+
import { STAGE_PANEL_LAYOUT_EVENT } from '@spatial-elements/core/stage/panelContext';
|
|
4
|
+
import { resolveSpatialThemeRadii } from '@spatial-elements/core/spatial-element/spatialTheme';
|
|
2
5
|
import Panel from '../stage/Panel.svelte';
|
|
3
6
|
import { useSpatialTheme } from './brandContext.js';
|
|
4
7
|
import type { ResolvedSpatialElementData as SpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
import type { SpatialElementMediaItem } from '@spatial-elements/core/spatial-element/types';
|
|
9
|
+
|
|
10
|
+
let { spatialElement, selectedId, onselect }: { spatialElement: SpatialElementData; selectedId?: string; onselect?: (media: SpatialElementMediaItem) => void } = $props();
|
|
11
|
+
let rail: HTMLElement;
|
|
12
|
+
let refreshFrame = 0;
|
|
13
|
+
function refreshProjection() {
|
|
14
|
+
if (!refreshFrame) refreshFrame = requestAnimationFrame(() => {
|
|
15
|
+
refreshFrame = 0; window.dispatchEvent(new Event(STAGE_PANEL_LAYOUT_EVENT));
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
$effect(() => {
|
|
19
|
+
const id = selectedId;
|
|
20
|
+
if (!rail || !id) return;
|
|
21
|
+
const anchor = Array.from(rail.querySelectorAll<HTMLElement>('[data-media-id]')).find(node => node.dataset.mediaId === id);
|
|
22
|
+
if (!anchor) return;
|
|
23
|
+
const left = anchor.offsetLeft, top = anchor.offsetTop;
|
|
24
|
+
if (left < rail.scrollLeft) rail.scrollLeft = left;
|
|
25
|
+
else if (left + anchor.offsetWidth > rail.scrollLeft + rail.clientWidth) rail.scrollLeft = left + anchor.offsetWidth - rail.clientWidth;
|
|
26
|
+
if (top < rail.scrollTop) rail.scrollTop = top;
|
|
27
|
+
else if (top + anchor.offsetHeight > rail.scrollTop + rail.clientHeight) rail.scrollTop = top + anchor.offsetHeight - rail.clientHeight;
|
|
28
|
+
});
|
|
29
|
+
onMount(() => {
|
|
30
|
+
const element = rail;
|
|
31
|
+
element.addEventListener('scroll', refreshProjection, { passive: true });
|
|
32
|
+
return () => { element.removeEventListener('scroll', refreshProjection); cancelAnimationFrame(refreshFrame); };
|
|
33
|
+
});
|
|
7
34
|
const readTheme = useSpatialTheme();
|
|
8
35
|
const theme = $derived(readTheme());
|
|
36
|
+
const radii = $derived(resolveSpatialThemeRadii(theme));
|
|
9
37
|
const minimap = $derived({
|
|
10
38
|
...spatialElement.minimap,
|
|
11
39
|
...theme.minimapTheme,
|
|
@@ -13,10 +41,12 @@
|
|
|
13
41
|
});
|
|
14
42
|
</script>
|
|
15
43
|
|
|
16
|
-
<aside class="spatial-element-rail" aria-label="SpatialElement images">
|
|
44
|
+
<aside bind:this={rail} class="spatial-element-rail" aria-label="SpatialElement images">
|
|
17
45
|
{#each spatialElement.media as media (media.id)}
|
|
46
|
+
{@const active = selectedId ? selectedId === media.id : media.kind === 'minimap'}
|
|
18
47
|
<div
|
|
19
48
|
class="spatial-element-media-anchor"
|
|
49
|
+
data-media-id={media.id}
|
|
20
50
|
data-spatial-element-dock-minimap-anchor={media.kind === 'minimap' ? '' : undefined}
|
|
21
51
|
>
|
|
22
52
|
<Panel
|
|
@@ -24,27 +54,31 @@
|
|
|
24
54
|
? { brandId: theme.id, spatialElementId: spatialElement.id, slot: 'detail.dock', role: 'geometry' }
|
|
25
55
|
: undefined}
|
|
26
56
|
transitionGroup="enter"
|
|
27
|
-
class={`thumbnail-panel ${
|
|
28
|
-
shape={{ ...theme.panelShape, contentInset: 0 }}
|
|
57
|
+
class={`thumbnail-panel ${active ? 'active' : ''}`}
|
|
58
|
+
shape={{ ...theme.panelShape, radius: radii.control, contentInset: 0 }}
|
|
29
59
|
theme={theme.panelTheme}
|
|
30
60
|
contentClass="thumbnail-panel-content"
|
|
31
61
|
minimap={media.kind === 'minimap' ? minimap : false}
|
|
32
62
|
data-spatial-element-departing-media-content={media.kind === 'minimap' ? undefined : ''}
|
|
33
63
|
>
|
|
34
64
|
{#if media.kind === 'minimap'}
|
|
35
|
-
<button type="button" aria-label={media.label} class="thumb thumb-minimap active
|
|
65
|
+
<button type="button" aria-label={media.label} aria-pressed={active} onclick={() => onselect?.(media)} class="thumb thumb-minimap" class:active>
|
|
36
66
|
{#if spatialElement.fallbackImage}
|
|
37
67
|
<img class="minimap-poster" src={spatialElement.fallbackImage} alt="" />
|
|
38
68
|
{/if}
|
|
39
69
|
</button>
|
|
40
70
|
{:else if media.kind === 'drawing'}
|
|
41
|
-
<button type="button" aria-label={media.label} class="thumb thumb-drawing">
|
|
71
|
+
<button type="button" aria-label={media.label} aria-pressed={active} onclick={() => onselect?.(media)} class="thumb thumb-drawing" class:active>
|
|
42
72
|
<span class="drawing-sheet" aria-hidden="true"></span>
|
|
43
73
|
</button>
|
|
44
|
-
{:else}
|
|
45
|
-
<button type="button" aria-label={media.label} class="thumb thumb-image">
|
|
74
|
+
{:else if media.kind === 'image'}
|
|
75
|
+
<button type="button" aria-label={media.label} aria-pressed={active} onclick={() => onselect?.(media)} class="thumb thumb-image" class:active>
|
|
46
76
|
<img src={media.src} alt={media.alt} />
|
|
47
77
|
</button>
|
|
78
|
+
{:else}
|
|
79
|
+
<button type="button" aria-label={media.label} aria-pressed={active} onclick={() => onselect?.(media)} class="thumb thumb-image" class:active>
|
|
80
|
+
{#if media.poster}<img src={media.poster} alt="" />{:else}<span aria-hidden="true">▶</span>{/if}
|
|
81
|
+
</button>
|
|
48
82
|
{/if}
|
|
49
83
|
</Panel>
|
|
50
84
|
</div>
|
|
@@ -53,18 +87,30 @@
|
|
|
53
87
|
|
|
54
88
|
<style>
|
|
55
89
|
.spatial-element-rail {
|
|
56
|
-
position:
|
|
57
|
-
|
|
58
|
-
|
|
90
|
+
position: relative;
|
|
91
|
+
flex: none;
|
|
92
|
+
width: calc(100% - var(--spatial-detail-media-left) * 2);
|
|
93
|
+
height: var(--spatial-detail-media-size);
|
|
94
|
+
margin-top: var(--spatial-detail-media-stage-gap);
|
|
95
|
+
margin-left: var(--spatial-detail-media-left);
|
|
59
96
|
display: grid;
|
|
60
|
-
|
|
97
|
+
grid-auto-flow: column;
|
|
98
|
+
grid-auto-columns: var(--spatial-detail-media-size);
|
|
99
|
+
gap: var(--spatial-detail-media-gap);
|
|
100
|
+
justify-content: start;
|
|
61
101
|
justify-items: start;
|
|
102
|
+
overflow-x: auto;
|
|
103
|
+
overflow-y: hidden;
|
|
104
|
+
/* Keep horizontal swipes in the rail, but let vertical gestures scroll
|
|
105
|
+
* the document, including when this rail has no vertical overflow. */
|
|
106
|
+
overscroll-behavior-x: contain;
|
|
107
|
+
overscroll-behavior-y: auto;
|
|
62
108
|
pointer-events: auto;
|
|
63
109
|
}
|
|
64
110
|
|
|
65
111
|
.spatial-element-media-anchor {
|
|
66
|
-
width:
|
|
67
|
-
|
|
112
|
+
width: 100%;
|
|
113
|
+
aspect-ratio: 1;
|
|
68
114
|
}
|
|
69
115
|
|
|
70
116
|
:global(.thumbnail-panel) {
|
|
@@ -85,7 +131,7 @@
|
|
|
85
131
|
width: 100%;
|
|
86
132
|
height: 100%;
|
|
87
133
|
border: 0;
|
|
88
|
-
border-radius: var(--spatial-element-
|
|
134
|
+
border-radius: var(--spatial-element-control-radius);
|
|
89
135
|
background: transparent;
|
|
90
136
|
cursor: pointer;
|
|
91
137
|
}
|
|
@@ -152,12 +198,20 @@
|
|
|
152
198
|
content: '100 mm';
|
|
153
199
|
}
|
|
154
200
|
|
|
155
|
-
@media (
|
|
201
|
+
@media (min-width: 840px) {
|
|
156
202
|
.spatial-element-rail {
|
|
157
|
-
position:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
203
|
+
position: absolute;
|
|
204
|
+
top: 0;
|
|
205
|
+
left: var(--spatial-detail-media-left);
|
|
206
|
+
width: var(--spatial-detail-media-size);
|
|
207
|
+
height: var(--spatial-detail-fit-height);
|
|
208
|
+
margin: 0;
|
|
209
|
+
grid-auto-flow: row;
|
|
210
|
+
grid-auto-columns: 100%;
|
|
211
|
+
grid-auto-rows: max-content;
|
|
212
|
+
align-content: start;
|
|
213
|
+
overflow-x: hidden;
|
|
214
|
+
overflow-y: auto;
|
|
161
215
|
}
|
|
162
216
|
}
|
|
163
217
|
</style>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { ResolvedSpatialElementData as SpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
|
|
2
|
+
import type { SpatialElementMediaItem } from '@spatial-elements/core/spatial-element/types';
|
|
2
3
|
type $$ComponentProps = {
|
|
3
4
|
spatialElement: SpatialElementData;
|
|
5
|
+
selectedId?: string;
|
|
6
|
+
onselect?: (media: SpatialElementMediaItem) => void;
|
|
4
7
|
};
|
|
5
8
|
declare const SpatialElementMediaRail: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
6
9
|
type SpatialElementMediaRail = ReturnType<typeof SpatialElementMediaRail>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { SpatialElementMediaItem } from '@spatial-elements/core/spatial-element/types';
|
|
3
|
+
import { spatialYoutubeEmbedUrl } from '@spatial-elements/core/spatial-element/spatialElementMedia';
|
|
4
|
+
let { media }: { media: Exclude<SpatialElementMediaItem, { kind: 'minimap' }> } = $props();
|
|
5
|
+
let failed = $state(false);
|
|
6
|
+
const embedUrl = $derived(media.kind === 'youtube' ? spatialYoutubeEmbedUrl(media.videoId) : undefined);
|
|
7
|
+
$effect(() => { media.id; failed = false; });
|
|
8
|
+
function releaseVideo(video: HTMLVideoElement) {
|
|
9
|
+
return { destroy() { video.pause(); video.removeAttribute('src'); video.load(); } };
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<div class="spatial-native-media" data-spatial-native-media={media.kind} data-stage-ui>
|
|
14
|
+
{#if failed || media.kind === 'drawing' || (media.kind === 'youtube' && !embedUrl)}
|
|
15
|
+
<p role="status">{media.label}: media unavailable.</p>
|
|
16
|
+
{:else if media.kind === 'image'}
|
|
17
|
+
<img src={media.src} alt={media.alt} onerror={() => failed = true} />
|
|
18
|
+
{:else if media.kind === 'video'}
|
|
19
|
+
<!-- Captions are supplied through the typed media track collection below. -->
|
|
20
|
+
<!-- svelte-ignore a11y_media_has_caption -->
|
|
21
|
+
<video use:releaseVideo src={media.src} poster={media.poster} controls playsinline preload="metadata" aria-label={media.label} onerror={() => failed = true}>
|
|
22
|
+
{#each media.captions ?? [] as track}
|
|
23
|
+
<track kind="captions" src={track.src} srclang={track.language} label={track.label} default={track.default} />
|
|
24
|
+
{/each}
|
|
25
|
+
</video>
|
|
26
|
+
{:else if media.kind === 'youtube' && embedUrl}
|
|
27
|
+
<iframe src={embedUrl} title={media.label} allow="fullscreen; picture-in-picture" allowfullscreen referrerpolicy="strict-origin-when-cross-origin"></iframe>
|
|
28
|
+
{/if}
|
|
29
|
+
</div>
|
|
30
|
+
|
|
31
|
+
<style>
|
|
32
|
+
.spatial-native-media { display: grid; place-items: center; width: 100%; height: 100%; min-width: 0; min-height: 0; pointer-events: auto; }
|
|
33
|
+
img, video { display: block; width: 100%; height: 100%; object-fit: contain; }
|
|
34
|
+
iframe { border: 0; width: 100%; height: 100%; }
|
|
35
|
+
p { max-width: 32rem; padding: 24px; text-align: center; }
|
|
36
|
+
</style>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { SpatialElementMediaItem } from '@spatial-elements/core/spatial-element/types';
|
|
2
|
+
type $$ComponentProps = {
|
|
3
|
+
media: Exclude<SpatialElementMediaItem, {
|
|
4
|
+
kind: 'minimap';
|
|
5
|
+
}>;
|
|
6
|
+
};
|
|
7
|
+
declare const SpatialElementNativeMedia: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
8
|
+
type SpatialElementNativeMedia = ReturnType<typeof SpatialElementNativeMedia>;
|
|
9
|
+
export default SpatialElementNativeMedia;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { getContext, onMount, setContext } from 'svelte';
|
|
3
|
+
import ShoppingCart from 'lucide-svelte/icons/shopping-cart';
|
|
4
|
+
import { SpatialElementPaneController } from '@spatial-elements/core/spatial-element/SpatialElementPaneController';
|
|
5
|
+
import { resolveActiveDetailSection } from '@spatial-elements/core/spatial-element/activeDetailSection';
|
|
6
|
+
import { resolveDetailLayout } from '@spatial-elements/core/spatial-element/responsiveLayout';
|
|
3
7
|
import {
|
|
4
8
|
CATALOG_ENDPOINTS,
|
|
5
9
|
type CatalogEndpointRegistry
|
|
@@ -11,26 +15,29 @@
|
|
|
11
15
|
STAGE_ANCHOR_NAVIGATION_EVENT,
|
|
12
16
|
type StageAnchorNavigationDetail
|
|
13
17
|
} from '@spatial-elements/core/stage/scrollAnimation';
|
|
14
|
-
import { STAGE_SCROLL_PRIORITY, subscribeStageScrollFrame } from '@spatial-elements/core/stage/scrollFrame';
|
|
18
|
+
import { getStageVisualScrollPosition, STAGE_SCROLL_PRIORITY, subscribeStageScrollFrame } from '@spatial-elements/core/stage/scrollFrame';
|
|
15
19
|
import SpatialElementBreadcrumbs from './SpatialElementBreadcrumbs.svelte';
|
|
16
20
|
import { useSpatialTheme } from './brandContext.js';
|
|
17
21
|
import SpatialElementMediaRail from './SpatialElementMediaRail.svelte';
|
|
22
|
+
import SpatialElementNativeMedia from './SpatialElementNativeMedia.svelte';
|
|
23
|
+
import { resolveSpatialElementMedia } from '@spatial-elements/core/spatial-element/spatialElementMedia';
|
|
18
24
|
import SpatialElementSummaryPanel from './SpatialElementSummaryPanel.svelte';
|
|
19
25
|
import SpatialElementHelp from './SpatialElementHelp.svelte';
|
|
20
26
|
import SpatialElementStickyHeader from './SpatialElementStickyHeader.svelte';
|
|
21
27
|
import SpatialElementTabs from './SpatialElementTabs.svelte';
|
|
28
|
+
import SectionSurfaceGroup from './SectionSurfaceGroup.svelte';
|
|
29
|
+
import './layout.generated.css';
|
|
22
30
|
import { SpatialElementDockController } from '@spatial-elements/core/spatial-element/SpatialElementDockController';
|
|
23
31
|
import { SPATIAL_ELEMENT_SECTION_REGISTRY_KEY, SpatialElementSectionRegistry } from '@spatial-elements/core/spatial-element/spatialElementSectionRegistry';
|
|
24
|
-
import type { SpatialElementData, SpatialElementSectionNavigationItem } from '@spatial-elements/core/spatial-element/types';
|
|
32
|
+
import type { SpatialElementData, SpatialElementMediaItem, SpatialElementSectionNavigationItem } from '@spatial-elements/core/spatial-element/types';
|
|
25
33
|
import { resolveSpatialElementData } from '@spatial-elements/core/spatial-element/spatialElement';
|
|
26
34
|
import { registerSpatialPage } from './spatialPageContext.js';
|
|
35
|
+
import { STAGE_CONTEXT_KEY, type StageContext } from '@spatial-elements/core/stage/panelContext';
|
|
27
36
|
|
|
28
37
|
const SPATIAL_ELEMENT_OVERVIEW_SECTION = {
|
|
29
38
|
id: 'overview',
|
|
30
39
|
title: 'Übersicht'
|
|
31
40
|
} satisfies SpatialElementSectionNavigationItem;
|
|
32
|
-
// Switch while the next panel enters the upper reading area, before it reaches the sticky tabs.
|
|
33
|
-
const SPATIAL_ELEMENT_SECTION_ACTIVATION_VIEWPORT_RATIO = 0.25;
|
|
34
41
|
|
|
35
42
|
interface Props {
|
|
36
43
|
/** Complete element document from this page's load function. Registers assets with the enclosing shell. */
|
|
@@ -41,14 +48,31 @@
|
|
|
41
48
|
let { spatialElement: element, children }: Props = $props();
|
|
42
49
|
const readTheme = useSpatialTheme();
|
|
43
50
|
const brand = $derived(readTheme());
|
|
44
|
-
const spatialElement = $derived(
|
|
51
|
+
const spatialElement = $derived.by(() => {
|
|
52
|
+
const resolved = resolveSpatialElementData(element, brand.id);
|
|
53
|
+
return { ...resolved, media: resolveSpatialElementMedia(resolved.media) };
|
|
54
|
+
});
|
|
55
|
+
let mediaSelection = $state<{ elementId: string; mediaId: string }>();
|
|
56
|
+
const selectedMedia = $derived(spatialElement.media.find(media =>
|
|
57
|
+
mediaSelection?.elementId === spatialElement.id && media.id === mediaSelection.mediaId) ?? spatialElement.media[0]);
|
|
58
|
+
function selectMedia(media: SpatialElementMediaItem) {
|
|
59
|
+
mediaSelection = { elementId: spatialElement.id, mediaId: media.id };
|
|
60
|
+
}
|
|
61
|
+
$effect(() => { if (mediaSelection?.elementId !== element?.id) mediaSelection = undefined; });
|
|
45
62
|
// During route teardown Kit can clear the outgoing page's data before unmount.
|
|
46
63
|
// Read raw assets here, so the parent stage never evaluates outgoing DOM-derived content.
|
|
47
64
|
registerSpatialPage(() => element ? { kind: 'detail', element } : { kind: 'content', hdr: '' });
|
|
48
65
|
const endpoints = getContext<CatalogEndpointRegistry | undefined>(CATALOG_ENDPOINTS);
|
|
66
|
+
const stageContext = getContext<StageContext | undefined>(STAGE_CONTEXT_KEY);
|
|
49
67
|
let sections = $state<SpatialElementSectionNavigationItem[]>([]);
|
|
50
68
|
let activeSectionId = $state<string | undefined>(SPATIAL_ELEMENT_OVERVIEW_SECTION.id);
|
|
51
69
|
let mainElement: HTMLElement;
|
|
70
|
+
let splitPane = $state(false);
|
|
71
|
+
let paneController = $state.raw<SpatialElementPaneController>();
|
|
72
|
+
const paneTint = $derived(typeof brand.panelTheme.tint === 'number'
|
|
73
|
+
? `#${brand.panelTheme.tint.toString(16).padStart(6, '0')}`
|
|
74
|
+
: typeof brand.panelTheme.tint === 'object' ? brand.panelTheme.tint.getStyle()
|
|
75
|
+
: brand.panelTheme.tint ?? '#ffffff');
|
|
52
76
|
let navigationTargetId: string | undefined;
|
|
53
77
|
let scrollSpyFrame = 0;
|
|
54
78
|
const navigationSections = $derived([SPATIAL_ELEMENT_OVERVIEW_SECTION, ...sections]);
|
|
@@ -63,23 +87,32 @@
|
|
|
63
87
|
activeSectionId = SPATIAL_ELEMENT_OVERVIEW_SECTION.id;
|
|
64
88
|
}
|
|
65
89
|
});
|
|
90
|
+
$effect(() => {
|
|
91
|
+
paneController?.setFocus(stageContext?.getZoomUiFocus?.() ?? stageContext?.getZoomFocus?.() ?? 0,
|
|
92
|
+
Boolean(stageContext?.isFullscreen?.()));
|
|
93
|
+
});
|
|
94
|
+
function invokePaneAction() {
|
|
95
|
+
mainElement.querySelector<HTMLElement>('[data-spatial-detail-pane-body] [data-catalog-rich-shared="primary-action"]')?.click();
|
|
96
|
+
}
|
|
66
97
|
|
|
67
98
|
function updateActiveSection() {
|
|
68
99
|
if (navigationTargetId || !mainElement?.isConnected) return;
|
|
69
|
-
const
|
|
100
|
+
const metrics = stageContext?.getLayoutMetrics?.('stable');
|
|
101
|
+
const pane = metrics ? resolveDetailLayout(metrics).pane : undefined;
|
|
102
|
+
const offset = pane?.body.y ?? (
|
|
70
103
|
Number.parseFloat(
|
|
71
104
|
getComputedStyle(mainElement).getPropertyValue('--spatial-element-section-scroll-offset')
|
|
72
|
-
) || 24;
|
|
73
|
-
const
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
105
|
+
) || 24);
|
|
106
|
+
const readingBottom = pane ? pane.body.y + pane.body.height : window.innerHeight;
|
|
107
|
+
const bounds = sections.flatMap(section => {
|
|
108
|
+
const rect = document.getElementById(section.id)?.getBoundingClientRect();
|
|
109
|
+
return rect ? [{ id: section.id, top: rect.top, bottom: rect.bottom }] : [];
|
|
110
|
+
});
|
|
111
|
+
const scrollOwner = document.scrollingElement ?? document.documentElement;
|
|
112
|
+
const nextActiveId = resolveActiveDetailSection(bounds, offset, readingBottom,
|
|
113
|
+
getStageVisualScrollPosition().scrollY,
|
|
114
|
+
Math.max(0, scrollOwner.scrollHeight - scrollOwner.clientHeight),
|
|
115
|
+
SPATIAL_ELEMENT_OVERVIEW_SECTION.id);
|
|
83
116
|
if (nextActiveId !== activeSectionId) activeSectionId = nextActiveId;
|
|
84
117
|
}
|
|
85
118
|
|
|
@@ -102,7 +135,11 @@
|
|
|
102
135
|
}
|
|
103
136
|
|
|
104
137
|
onMount(() => {
|
|
105
|
-
const
|
|
138
|
+
const unregisterMedia = stageContext?.registerDetailMedia?.(() => element ? selectedMedia.kind : 'minimap');
|
|
139
|
+
paneController = new SpatialElementPaneController(mainElement,
|
|
140
|
+
() => stageContext?.getLayoutMetrics?.('stable'), (split) => { splitPane = split; });
|
|
141
|
+
paneController.start();
|
|
142
|
+
const dock = new SpatialElementDockController(mainElement, () => stageContext?.getLayoutMetrics?.('stable'));
|
|
106
143
|
dock.start();
|
|
107
144
|
const unregisterPresentation = endpoints?.registerPresentation(
|
|
108
145
|
{ brandId: brand.id, spatialElementId: spatialElement.id },
|
|
@@ -128,6 +165,8 @@
|
|
|
128
165
|
scheduleScrollSpy();
|
|
129
166
|
|
|
130
167
|
return () => {
|
|
168
|
+
unregisterMedia?.();
|
|
169
|
+
paneController?.destroy();
|
|
131
170
|
cancelAnimationFrame(scrollSpyFrame);
|
|
132
171
|
window.removeEventListener(STAGE_ANCHOR_NAVIGATION_EVENT, handleAnchorNavigation);
|
|
133
172
|
window.removeEventListener(STAGE_ANCHOR_NAVIGATION_END_EVENT, handleAnchorNavigationEnd);
|
|
@@ -149,20 +188,39 @@
|
|
|
149
188
|
data-spatial-element-root
|
|
150
189
|
data-spatial-element-id={spatialElement.id}
|
|
151
190
|
data-brand-id={spatialElement.brandId}
|
|
191
|
+
data-spatial-selected-media={selectedMedia.kind}
|
|
192
|
+
style:--spatial-pane-tint={paneTint}
|
|
193
|
+
style:--spatial-pane-tint-opacity={`${Math.min(1, Math.max(0, brand.panelTheme.tintOpacity ?? 0.28)) * 100}%`}
|
|
194
|
+
style:--spatial-pane-blur={`${Math.min(100, Math.max(0, brand.panelTheme.backdropBlur ?? 5))}px`}
|
|
152
195
|
>
|
|
153
|
-
<
|
|
154
|
-
items={spatialElement.breadcrumbs}
|
|
155
|
-
|
|
196
|
+
<div class="spatial-element-pane-heading" data-spatial-detail-pane-header data-spatial-detail-fixed>
|
|
197
|
+
<SpatialElementBreadcrumbs items={spatialElement.breadcrumbs} />
|
|
198
|
+
<div class="spatial-element-pane-title-row">
|
|
199
|
+
<p class="spatial-element-pane-title">{spatialElement.title}</p>
|
|
200
|
+
{#if spatialElement.eyebrow}<p class="spatial-element-pane-eyebrow">{spatialElement.eyebrow}</p>{/if}
|
|
201
|
+
{#if spatialElement.action}
|
|
202
|
+
<button type="button" class="spatial-element-pane-action" onclick={invokePaneAction}
|
|
203
|
+
aria-label={spatialElement.action.ariaLabel ?? spatialElement.action.label}>
|
|
204
|
+
<ShoppingCart size={24} aria-hidden="true" />
|
|
205
|
+
</button>
|
|
206
|
+
{/if}
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
156
209
|
<SpatialElementStickyHeader {activeSectionId} {spatialElement} sections={navigationSections} />
|
|
157
|
-
|
|
210
|
+
<div class="spatial-element-pane-surface" data-spatial-detail-pane-surface data-spatial-detail-fixed aria-hidden="true"></div>
|
|
211
|
+
<div class="spatial-element-pane-cover spatial-element-pane-cover-top" data-spatial-detail-fixed aria-hidden="true"></div>
|
|
212
|
+
<div class="spatial-element-pane-cover spatial-element-pane-cover-bottom" data-spatial-detail-fixed aria-hidden="true"></div>
|
|
213
|
+
<div class="spatial-element-presentation">
|
|
158
214
|
<section
|
|
159
215
|
id={SPATIAL_ELEMENT_OVERVIEW_SECTION.id}
|
|
160
216
|
class="spatial-element-hero"
|
|
161
217
|
data-spatial-element-tab-target
|
|
162
218
|
data-stage-scroll-top
|
|
163
219
|
aria-labelledby="spatial-element-title"
|
|
220
|
+
data-spatial-detail-media-region
|
|
221
|
+
data-spatial-detail-fixed
|
|
164
222
|
>
|
|
165
|
-
<SpatialElementMediaRail {spatialElement} />
|
|
223
|
+
<SpatialElementMediaRail {spatialElement} selectedId={selectedMedia.id} onselect={selectMedia} />
|
|
166
224
|
|
|
167
225
|
<StageViewport
|
|
168
226
|
catalogEndpoint={{
|
|
@@ -175,56 +233,61 @@
|
|
|
175
233
|
data-catalog-geometry
|
|
176
234
|
data-spatial-element-id={spatialElement.id}
|
|
177
235
|
data-catalog-slot="detail.hero"
|
|
178
|
-
fallbackSrc={spatialElement.fallbackImage}
|
|
236
|
+
fallbackSrc={selectedMedia.kind === 'minimap' ? spatialElement.fallbackImage : undefined}
|
|
179
237
|
fallbackAlt={`${brand.name} ${spatialElement.title}`}
|
|
180
|
-
aria-hidden={spatialElement.fallbackImage ?
|
|
181
|
-
|
|
238
|
+
aria-hidden={selectedMedia.kind === 'minimap' && !spatialElement.fallbackImage ? 'true' : undefined}
|
|
239
|
+
>
|
|
240
|
+
{#if selectedMedia.kind !== 'minimap'}
|
|
241
|
+
{#key `${spatialElement.id}:${selectedMedia.id}`}<SpatialElementNativeMedia media={selectedMedia} />{/key}
|
|
242
|
+
{/if}
|
|
243
|
+
</StageViewport>
|
|
182
244
|
|
|
183
|
-
{#key spatialElement.id}<SpatialElementHelp />{/key}
|
|
184
|
-
<SpatialElementSummaryPanel {spatialElement} />
|
|
245
|
+
{#key spatialElement.id}<SpatialElementHelp active={selectedMedia.kind === 'minimap'} />{/key}
|
|
185
246
|
</section>
|
|
186
|
-
|
|
247
|
+
<div class="spatial-element-pane-body" data-spatial-detail-pane-body data-stage-scroll-viewport>
|
|
248
|
+
{#key spatialElement.id}<SpatialElementSummaryPanel {spatialElement} nativeContent={splitPane} />{/key}
|
|
187
249
|
<div class="spatial-element-content">
|
|
188
|
-
<div class="spatial-element-section-list" data-catalog-transition-dom="enter">
|
|
189
|
-
{@render children?.()}
|
|
250
|
+
<div class="spatial-element-section-list spatial-content-width spatial-content-container" data-catalog-transition-dom="enter">
|
|
251
|
+
<SectionSurfaceGroup>{@render children?.()}</SectionSurfaceGroup>
|
|
190
252
|
</div>
|
|
191
253
|
<!-- Read after the section snippet has registered its metadata during SSR. -->
|
|
192
254
|
<SpatialElementTabs {activeSectionId} sections={[SPATIAL_ELEMENT_OVERVIEW_SECTION, ...sections]} />
|
|
193
255
|
</div>
|
|
256
|
+
</div>
|
|
257
|
+
</div>
|
|
258
|
+
<div class="spatial-element-pane-submenu-shell" data-spatial-detail-pane-submenu-shell data-spatial-detail-fixed>
|
|
259
|
+
<div class="spatial-element-pane-submenu" data-spatial-detail-pane-submenu aria-hidden="true" inert></div>
|
|
260
|
+
</div>
|
|
194
261
|
</main>
|
|
195
262
|
|
|
196
263
|
<style>
|
|
197
264
|
.spatial-element-main {
|
|
198
265
|
--spatial-element-section-scroll-offset: 150px;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
width: min(1550px, calc(100vw - 120px), 100%);
|
|
202
|
-
margin: 0 auto;
|
|
266
|
+
width: 100%;
|
|
267
|
+
margin: 0;
|
|
203
268
|
}
|
|
269
|
+
.spatial-element-presentation { position: relative; }
|
|
270
|
+
.spatial-element-pane-heading { display: contents; }
|
|
271
|
+
.spatial-element-pane-title-row, .spatial-element-pane-surface,
|
|
272
|
+
.spatial-element-pane-cover, .spatial-element-pane-submenu-shell { display: none; }
|
|
204
273
|
|
|
205
274
|
.spatial-element-hero {
|
|
206
|
-
--spatial-element-hero-column-gap: clamp(28px, 4vw, 70px);
|
|
207
275
|
position: relative;
|
|
208
276
|
box-sizing: border-box;
|
|
209
|
-
display:
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
align-items: start;
|
|
213
|
-
width: calc(100vw - var(--spatial-element-hero-edge-gap) - var(--spatial-element-hero-edge-gap));
|
|
214
|
-
min-height: clamp(610px, calc(100vh - 230px), 760px);
|
|
215
|
-
margin-left: calc(50% - 50vw + var(--spatial-element-hero-edge-gap));
|
|
216
|
-
padding-left: max(0px, calc(50vw - 50% - var(--spatial-element-hero-edge-gap)));
|
|
277
|
+
display: flex;
|
|
278
|
+
flex-direction: column;
|
|
279
|
+
width: 100%;
|
|
217
280
|
}
|
|
218
281
|
|
|
219
282
|
.spatial-element-content {
|
|
220
283
|
display: flex;
|
|
221
284
|
flex-direction: column;
|
|
222
|
-
width:
|
|
223
|
-
margin-left: calc(50% - 50vw + var(--spatial-element-content-inline-inset));
|
|
285
|
+
width: 100%;
|
|
224
286
|
}
|
|
225
287
|
|
|
226
288
|
.spatial-element-section-list {
|
|
227
289
|
order: 2;
|
|
290
|
+
margin-top: var(--spatial-detail-submenu-after-gap, 0px);
|
|
228
291
|
}
|
|
229
292
|
|
|
230
293
|
.spatial-element-content :global(.spatial-element-tabs-anchor) {
|
|
@@ -232,33 +295,29 @@
|
|
|
232
295
|
}
|
|
233
296
|
|
|
234
297
|
.spatial-element-section-list :global(.content-section:first-child) {
|
|
235
|
-
margin-top:
|
|
298
|
+
margin-top: 0;
|
|
236
299
|
}
|
|
237
300
|
|
|
238
301
|
.spatial-element-hero :global(.spatial-element-visual) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
302
|
+
order: -1;
|
|
303
|
+
flex: none;
|
|
304
|
+
margin-left: var(--spatial-detail-fit-left);
|
|
305
|
+
width: calc(100% - var(--spatial-detail-fit-left) - var(--spatial-detail-fit-right));
|
|
306
|
+
height: var(--spatial-detail-fit-height);
|
|
307
|
+
min-height: 0;
|
|
243
308
|
background: transparent;
|
|
244
309
|
pointer-events: none;
|
|
245
310
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
.spatial-element-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
.spatial-element-content {
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
.spatial-element-hero {
|
|
258
|
-
grid-template-columns: 1fr;
|
|
259
|
-
width: 100%;
|
|
260
|
-
margin-left: 0;
|
|
261
|
-
padding-left: 0;
|
|
262
|
-
}
|
|
311
|
+
@media (min-width: 840px) {
|
|
312
|
+
.spatial-element-hero { height: var(--spatial-detail-fit-height); }
|
|
313
|
+
.spatial-element-content { padding-top: 8px; }
|
|
314
|
+
.spatial-element-content :global(.spatial-element-tabs-anchor) { margin-left: 8px; max-width: calc(100% - 16px); }
|
|
315
|
+
}
|
|
316
|
+
@media (min-width: 1200px) {
|
|
317
|
+
.spatial-element-content :global(.spatial-element-tabs-anchor) { max-width: calc(100% - 32px); }
|
|
318
|
+
}
|
|
319
|
+
@media (min-width: 1600px) {
|
|
320
|
+
.spatial-element-content { padding-top: 12px; }
|
|
321
|
+
.spatial-element-content :global(.spatial-element-tabs-anchor) { margin-left: calc((100% - var(--spatial-detail-content-width)) / 2); max-width: var(--spatial-detail-content-width); }
|
|
263
322
|
}
|
|
264
323
|
</style>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import './layout.generated.css';
|
|
2
3
|
import type { SpatialElementData } from '@spatial-elements/core/spatial-element/types';
|
|
3
4
|
interface Props {
|
|
4
5
|
/** Complete element document from this page's load function. Registers assets with the enclosing shell. */
|