@spatial-elements/sveltekit 1.0.0-beta.15 → 1.0.0-beta.18

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.
Files changed (49) hide show
  1. package/README.md +1 -1
  2. package/dist/catalog/ScrollNavigationBridge.svelte +5 -1
  3. package/dist/catalog/ScrollNavigationBridge.svelte.d.ts +1 -1
  4. package/dist/catalog/stagedCatalogNavigation.d.ts +1 -1
  5. package/dist/spatial-element/BrandStageShell.svelte +27 -2
  6. package/dist/spatial-element/BrandStageShell.svelte.d.ts +2 -0
  7. package/dist/spatial-element/CarouselSpatialElement.svelte +7 -7
  8. package/dist/spatial-element/ContentPage.svelte +5 -2
  9. package/dist/spatial-element/ContentPage.svelte.d.ts +3 -0
  10. package/dist/spatial-element/OverflowControls.svelte +6 -6
  11. package/dist/spatial-element/PointerHint.svelte +5 -4
  12. package/dist/spatial-element/Section.svelte +1 -1
  13. package/dist/spatial-element/SpaceMouseControl.svelte +4 -4
  14. package/dist/spatial-element/SpatialCardGridSection.svelte +6 -9
  15. package/dist/spatial-element/SpatialCardPresentation.svelte +129 -33
  16. package/dist/spatial-element/SpatialCardPresentation.svelte.d.ts +2 -2
  17. package/dist/spatial-element/SpatialCardSlot.svelte +1 -1
  18. package/dist/spatial-element/SpatialCarouselSection.svelte +10 -2
  19. package/dist/spatial-element/SpatialElementCard.svelte +7 -13
  20. package/dist/spatial-element/SpatialElementCard.svelte.d.ts +2 -2
  21. package/dist/spatial-element/SpatialElementHelp.svelte +7 -5
  22. package/dist/spatial-element/SpatialElementMediaRail.svelte +2 -1
  23. package/dist/spatial-element/SpatialElementPage.svelte +1 -1
  24. package/dist/spatial-element/SpatialElementStickyHeader.svelte +29 -5
  25. package/dist/spatial-element/SpatialElementSummaryContent.svelte +16 -8
  26. package/dist/spatial-element/SpatialElementSummaryContent.svelte.d.ts +4 -0
  27. package/dist/spatial-element/SpatialElementSummaryPanel.svelte +2 -1
  28. package/dist/spatial-element/SpatialElementTabList.svelte +32 -10
  29. package/dist/spatial-element/SpatialIconButton.svelte +2 -0
  30. package/dist/spatial-element/SpatialListPage.svelte +2 -2
  31. package/dist/spatial-element/SpatialNavigationShell.svelte +10 -44
  32. package/dist/spatial-element/SpatialSummaryHost.svelte +1 -1
  33. package/dist/spatial-element/SpatialSummaryRoot.svelte +33 -10
  34. package/dist/spatial-element/SpatialSummarySlot.svelte +1 -1
  35. package/dist/spatial-element/cardAppearanceFreeze.js +1 -1
  36. package/dist/spatial-element/carouselTextHit.js +2 -1
  37. package/dist/spatial-element/contentSidebars.js +15 -7
  38. package/dist/spatial-element/index.d.ts +1 -2
  39. package/dist/spatial-element/layout.generated.css +41 -17
  40. package/dist/spatial-element/spatialCardGrid.d.ts +3 -3
  41. package/dist/spatial-element/spatialSummary.d.ts +4 -2
  42. package/dist/spatial-element/spatialThemeStyle.js +4 -4
  43. package/dist/stage/ButtonGroup.svelte +2 -0
  44. package/dist/stage/Panel.svelte +11 -3
  45. package/dist/stage/Panel.svelte.d.ts +2 -0
  46. package/dist/stage/Stage.svelte +6 -3
  47. package/dist/stage/panelShadowStyle.d.ts +3 -0
  48. package/dist/stage/panelShadowStyle.js +11 -0
  49. package/package.json +9 -9
package/README.md CHANGED
@@ -13,7 +13,7 @@ SvelteKit components for interactive 3D collections and detail pages, built on t
13
13
  ## Installation
14
14
 
15
15
  ```sh
16
- npm install @spatial-elements/sveltekit@beta three@^0.186.1
16
+ npm install @spatial-elements/sveltekit@beta three@^0.187.0
17
17
  ```
18
18
 
19
19
  Requires Node >=22.12 for tooling, Svelte ^5.56.4 and SvelteKit ^2.70.3. This is a beta package. Models and environments belong to your application and are not bundled.
@@ -16,7 +16,7 @@
16
16
  replaceState
17
17
  } from '$app/navigation';
18
18
  import { navigating, page } from '$app/state';
19
- import type { BeforeNavigate, OnNavigate } from '@sveltejs/kit';
19
+ import type { BeforeNavigate, OnNavigate } from '$app/navigation';
20
20
  import { getContext, onDestroy, onMount, tick } from 'svelte';
21
21
  import { CATALOG_ENDPOINTS, type CatalogEndpointRegistry } from '@spatial-elements/core/catalog/CatalogEndpointRegistry';
22
22
  import {
@@ -270,6 +270,9 @@
270
270
  }
271
271
 
272
272
  beforeNavigate((navigation) => {
273
+ // A history entry can carry shallow metadata while restoring another page.
274
+ // Kit calls these hooks for that full popstate navigation; keep its capture.
275
+ if (navigation.shallow && navigation.type !== 'popstate') return;
273
276
  // The single permitted replay continues the existing visual ownership.
274
277
  // It must not run stopActive, onSupersede, or the generic feedback again.
275
278
  if (navigation.to && earlyNavigation.acceptReplay(navigation.to.url.href)) {
@@ -360,6 +363,7 @@
360
363
  });
361
364
 
362
365
  onNavigate((navigation) => {
366
+ if (navigation.shallow && navigation.type !== 'popstate') return;
363
367
  const destination = navigation.to;
364
368
  if (!destination) return;
365
369
  const owner = controller;
@@ -1,5 +1,5 @@
1
1
  import { type EarlyNavigationCancelReason, type EarlyNavigationHandle } from '@spatial-elements/core/catalog/EarlyNavigationCoordinator';
2
- import type { BeforeNavigate, OnNavigate } from '@sveltejs/kit';
2
+ import type { BeforeNavigate, OnNavigate } from '$app/navigation';
3
3
  import type { VirtualScrollController } from '@spatial-elements/core/stage/VirtualScrollController';
4
4
  interface Props {
5
5
  controller?: VirtualScrollController;
@@ -1,4 +1,4 @@
1
- import type { BeforeNavigate } from '@sveltejs/kit';
1
+ import type { BeforeNavigate } from '$app/navigation';
2
2
  import type { StageExperience } from '@spatial-elements/core/stage/StageExperience';
3
3
  import type { CatalogEndpointRegistry } from '@spatial-elements/core/catalog/CatalogEndpointRegistry';
4
4
  import type { EarlyNavigationCancelReason } from '@spatial-elements/core/catalog/EarlyNavigationCoordinator';
@@ -1,6 +1,7 @@
1
1
  <script lang="ts">
2
2
  import type { MenuItem } from '@page-sections/core';
3
3
  import type { Snippet } from 'svelte';
4
+ import { STAGE_SCROLL_PRIORITY, subscribeStageScrollFrame } from '@spatial-elements/core/stage/scrollFrame';
4
5
  import { preventBrowserPinch } from '@spatial-elements/core/stage/browserPinch';
5
6
  import '@page-sections/svelte/styles.css';
6
7
  import { retainDeviceOrientationPermission } from '@spatial-elements/core/catalog/listDeviceOrientation';
@@ -31,6 +32,8 @@
31
32
  dracoDecoderPath?: string;
32
33
  /** Layout contents. ContentPage and SpatialElementPage register their own data. */
33
34
  children?: Snippet;
35
+ /** Document footer; scrolls over the stationary stage in every layout. */
36
+ footer?: Snippet;
34
37
  /** Persistent main-menu content. The shell owns its box and surface. */
35
38
  menu?: Snippet;
36
39
  /** Complete application navigation; the spatial shell supplies positioning and surfaces. */
@@ -46,7 +49,24 @@
46
49
  right?: Snippet;
47
50
  }
48
51
 
49
- let { theme, colorScheme, messages, renderSettings, dracoDecoderPath, children, menu, navigation, items, brand, tools, summary, left, right, deviceOrientation = false }: Props = $props();
52
+ let { theme, colorScheme, messages, renderSettings, dracoDecoderPath, children, footer, menu, navigation, items, brand, tools, summary, left, right, deviceOrientation = false }: Props = $props();
53
+ let shell = $state<HTMLDivElement>();
54
+ let footerHost = $state<HTMLDivElement>();
55
+ $effect(() => {
56
+ const stage = shell?.querySelector<HTMLElement>('.stage');
57
+ if (!stage || !footerHost) return;
58
+ const host = footerHost;
59
+ let previous = 0;
60
+ // Only the footer follows the existing visual wheel smoothing. No stage
61
+ // geometry reads, inherited style writes or canvas displacement are needed.
62
+ const stop = subscribeStageScrollFrame(frame => {
63
+ const offset = stage.classList.contains('stage-virtual-scroll-active') ? frame.targetScrollY - frame.scrollY : 0;
64
+ if (offset === previous) return;
65
+ previous = offset;
66
+ host.style.translate = offset ? `0 ${offset}px` : '';
67
+ }, STAGE_SCROLL_PRIORITY.virtualDocument);
68
+ return () => { stop(); host.style.removeProperty('translate'); };
69
+ });
50
70
  $effect(() => {
51
71
  if (deviceOrientation) return retainDeviceOrientationPermission();
52
72
  });
@@ -58,7 +78,7 @@
58
78
  function attachPinchPolicy(node: HTMLElement) { return { destroy: preventBrowserPinch(node) }; }
59
79
  </script>
60
80
 
61
- <div use:attachPinchPolicy class="brand-stage-shell" style={brandStyle} style:color-scheme={colorScheme} data-color-scheme={colorScheme}>
81
+ <div bind:this={shell} use:attachPinchPolicy class="brand-stage-shell" style={brandStyle} style:color-scheme={colorScheme} data-color-scheme={colorScheme}>
62
82
  <Stage
63
83
  {deviceOrientation}
64
84
  brandId={theme.id}
@@ -72,10 +92,15 @@
72
92
  {#if navigation || menu || items || brand || left || right}<SpatialNavigationShell {navigation} {menu} {items} {brand} {tools} {left} {right} />{/if}
73
93
  <SpatialSummaryHost {summary}>{@render children?.()}</SpatialSummaryHost>
74
94
  </Stage>
95
+ {#if footer}<div bind:this={footerHost} class="spatial-footer">{@render footer()}</div>{/if}
75
96
  <PointerHint />
76
97
  </div>
77
98
 
78
99
  <style>
100
+ :global(:where(.brand-stage-shell) a) { text-decoration: none; text-underline-offset: 0.2em; }
101
+ :global(:where(.brand-stage-shell) a:hover) { text-decoration: underline; }
102
+ :global(.brand-stage-shell .ps-navigation a:hover) { text-decoration: none; }
103
+ .spatial-footer { position: relative; z-index: 31; padding-top: 48px; }
79
104
  .brand-stage-shell {
80
105
  background: var(--spatial-element-background);
81
106
  --spatial-element-content-inline-inset: 192px;
@@ -20,6 +20,8 @@ interface Props {
20
20
  dracoDecoderPath?: string;
21
21
  /** Layout contents. ContentPage and SpatialElementPage register their own data. */
22
22
  children?: Snippet;
23
+ /** Document footer; scrolls over the stationary stage in every layout. */
24
+ footer?: Snippet;
23
25
  /** Persistent main-menu content. The shell owns its box and surface. */
24
26
  menu?: Snippet;
25
27
  /** Complete application navigation; the spatial shell supplies positioning and surfaces. */
@@ -4,7 +4,7 @@
4
4
  import { resolveSpatialThemeRadii } from '@spatial-elements/core/spatial-element/spatialTheme';
5
5
  import SpatialSummarySlot from './SpatialSummarySlot.svelte';
6
6
  import { getContext } from 'svelte';
7
- import { getCssPanelBoxShadow } from '@spatial-elements/core/stage/panelShadow';
7
+ import { getSharedPanelBoxShadow } from '@spatial-elements/core/stage/panelShadow';
8
8
  import { mouseHover } from '@spatial-elements/core/stage/mouseHover';
9
9
  import type { SpatialListItem } from '@spatial-elements/core/spatial-element/types';
10
10
  import { CATALOG_ITEMS, type CatalogItems } from '@spatial-elements/core/catalog/catalogItems';
@@ -190,7 +190,7 @@
190
190
  aria-hidden={interactive && !selected}
191
191
  style:--carousel-panel-opacity={(interactive ? pose.panelOpacity : 1) *
192
192
  (brand.panelTheme.opacity ?? 1)}
193
- style:--carousel-panel-shadow={getCssPanelBoxShadow(brand.panelTheme.shadowIntensity ?? 0.28)}
193
+ style:--carousel-panel-shadow={getSharedPanelBoxShadow(brand.panelTheme.shadowIntensity ?? 0.28, brand.panelTheme.shadowColor)}
194
194
  style:--carousel-panel-tint={typeof brand.panelTheme.tint === 'number'
195
195
  ? '#' + brand.panelTheme.tint.toString(16).padStart(6, '0')
196
196
  : typeof brand.panelTheme.tint === 'object'
@@ -207,7 +207,7 @@
207
207
  <SpatialSummarySlot instanceKey={`carousel:${brand.id}:${occurrence}`}
208
208
  context={{ spatialElement: { id: spatialElement.id, brandId: brand.id, eyebrow: spatialElement.eyebrow, title: spatialElement.title,
209
209
  features: spatialElement.summary?.features ?? spatialElement.features.map((label) => ({ label })), action: spatialElement.summary?.action },
210
- contentInset, heading: 'h3', mode: 'carousel', address,
210
+ contentInset, heading: 'h3', mode: 'carousel', detailHref: href(spatialElement.href), address,
211
211
  carousel: { item: spatialElement, occurrence, compact } }} />
212
212
  </div>
213
213
  </article>
@@ -217,7 +217,7 @@
217
217
  display: block;
218
218
  position: relative;
219
219
  min-width: 0;
220
- height: calc(var(--spatial-carousel-title-reserve) + var(--spatial-carousel-fit-height));
220
+ height: calc(var(--spatial-carousel-panel-reserve) + var(--spatial-carousel-fit-height));
221
221
  min-height: 0;
222
222
  padding: 0;
223
223
  box-sizing: border-box;
@@ -311,12 +311,12 @@
311
311
  .summary {
312
312
  position: absolute;
313
313
  left: var(--spatial-carousel-summary-left);
314
- top: calc(var(--spatial-carousel-title-reserve) - var(--spatial-carousel-compact-height));
314
+ top: calc(var(--spatial-carousel-fit-height) - var(--spatial-carousel-compact-overlap));
315
315
  width: var(--spatial-carousel-summary-width);
316
316
  height: var(--spatial-carousel-compact-height);
317
317
  min-height: 0;
318
318
  margin: 0;
319
- --spatial-carousel-compact-height: 40px;
319
+
320
320
  box-sizing: border-box;
321
321
 
322
322
  border-radius: var(--carousel-panel-radius, 14px);
@@ -329,7 +329,7 @@
329
329
  display: block;
330
330
  visibility: hidden;
331
331
  }
332
- .has-eyebrow { --spatial-carousel-compact-height: 66px; }
332
+
333
333
  [data-carousel-fit-anchor] { position: absolute; left: var(--spatial-carousel-fit-left); top: var(--spatial-carousel-title-reserve); width: var(--spatial-carousel-fit-width); height: var(--spatial-carousel-fit-height); pointer-events: none; }
334
334
  @media (min-width: 840px) {
335
335
  .summary { top: calc(var(--spatial-carousel-fit-height) / 2); height: auto; max-height: var(--spatial-carousel-fit-height); padding: 0; transform: translateY(-50%); }
@@ -20,11 +20,14 @@
20
20
  /** SpatialCardGridSection, SpatialCarouselSection and ordinary Section children. */
21
21
  children?: Snippet;
22
22
  leftSidebar?: Snippet;
23
+ /** Content after the sections, outside the sticky menu boundary. */
24
+ pageEnd?: Snippet;
25
+ /** @deprecated Use pageEnd. The site footer belongs to BrandStageShell. */
23
26
  footer?: Snippet;
24
27
  showContentMenu?: boolean;
25
28
  contentMenuLabel?: string;
26
29
  }
27
- let { page, hdr, background, children, leftSidebar, footer, showContentMenu = false, contentMenuLabel }: Props = $props();
30
+ let { page, hdr, background, children, leftSidebar, pageEnd, footer, showContentMenu = false, contentMenuLabel }: Props = $props();
28
31
  const backgroundId = $props.id();
29
32
  const backgroundScope = backgroundId.replace(/[^a-zA-Z0-9_-]/g, '_');
30
33
  onMount(() => {
@@ -45,7 +48,7 @@
45
48
  </script>
46
49
 
47
50
  {#if background}<svelte:element this={'style'}>{backgroundRules}</svelte:element>{/if}
48
- <PageContent {page} {leftSidebar} {footer} {showContentMenu} {contentMenuLabel} class="content-page" data-catalog-list data-brand-id={brand.id}
51
+ <PageContent {page} {leftSidebar} pageEnd={pageEnd ?? footer} {showContentMenu} {contentMenuLabel} class="content-page" data-catalog-list data-brand-id={brand.id}
49
52
  data-spatial-content-page={backgroundScope} data-spatial-page-background={background ? backgroundScope : undefined}>
50
53
  {@render children?.()}
51
54
  </PageContent>
@@ -11,6 +11,9 @@ interface Props {
11
11
  /** SpatialCardGridSection, SpatialCarouselSection and ordinary Section children. */
12
12
  children?: Snippet;
13
13
  leftSidebar?: Snippet;
14
+ /** Content after the sections, outside the sticky menu boundary. */
15
+ pageEnd?: Snippet;
16
+ /** @deprecated Use pageEnd. The site footer belongs to BrandStageShell. */
14
17
  footer?: Snippet;
15
18
  showContentMenu?: boolean;
16
19
  contentMenuLabel?: string;
@@ -1,8 +1,8 @@
1
1
  <script lang="ts">
2
- import ChevronUp from 'lucide-svelte/icons/chevron-up';
3
- import ChevronDown from 'lucide-svelte/icons/chevron-down';
4
- import ChevronLeft from 'lucide-svelte/icons/chevron-left';
5
- import ChevronRight from 'lucide-svelte/icons/chevron-right';
2
+ import ChevronUp from '@lucide/svelte/icons/chevron-up';
3
+ import ChevronDown from '@lucide/svelte/icons/chevron-down';
4
+ import ChevronLeft from '@lucide/svelte/icons/chevron-left';
5
+ import ChevronRight from '@lucide/svelte/icons/chevron-right';
6
6
  let {
7
7
  target,
8
8
  responsive = false,
@@ -52,7 +52,7 @@
52
52
  }
53
53
  </script>
54
54
 
55
- <div class="overflow-controls" class:vertical class:hidden data-overflow-controls={label}>
55
+ <div class="ps-shadow-navigation overflow-controls" class:vertical class:hidden data-overflow-controls={label}>
56
56
  {#if before}<button
57
57
  class="before"
58
58
  type="button"
@@ -95,7 +95,7 @@
95
95
  --scroll-button-radius: var(--spatial-element-control-radius, 12px);
96
96
  background: var(--ps-section-standard, #fff);
97
97
  color: var(--spatial-element-navigation-ink, var(--spatial-element-ink));
98
- box-shadow: 0 2px 8px #0003;
98
+ box-shadow: var(--ps-navigation-shadow, var(--ps-default-navigation-shadow));
99
99
  cursor: pointer;
100
100
  pointer-events: auto;
101
101
  }
@@ -1,8 +1,8 @@
1
1
  <script lang="ts">
2
2
  import { onMount } from 'svelte';
3
- import MoveHorizontal from 'lucide-svelte/icons/move-horizontal';
4
- import Search from 'lucide-svelte/icons/search';
5
- import Rotate3D from 'lucide-svelte/icons/rotate-3d';
3
+ import MoveHorizontal from '@lucide/svelte/icons/move-horizontal';
4
+ import Search from '@lucide/svelte/icons/search';
5
+ import Rotate3D from '@lucide/svelte/icons/rotate-3d';
6
6
  import { carouselTextHit } from './carouselTextHit.js';
7
7
  let badge: HTMLDivElement;
8
8
  let action = $state<'move' | 'details' | 'rotate' | undefined>();
@@ -23,7 +23,8 @@
23
23
  text = !dragging ? carouselTextHit(target, x, y) : undefined;
24
24
  text?.setAttribute('data-carousel-text-hit', '');
25
25
  const geometry = target.closest('.spatial-element-target');
26
- action = dragging ? 'move' : text || (buttons & 1) || (!geometry && target.closest('a, button, input, textarea, select, [contenteditable]'))
26
+ const summaryLink = target.closest('[data-spatial-summary-link], .compact-copy');
27
+ action = dragging ? 'move' : text || (buttons & 1) || (!geometry && !summaryLink && target.closest('a, button, input, textarea, select, [contenteditable]'))
27
28
  ? undefined : geometry?.closest('.selected') ? 'details' : 'move';
28
29
  } else {
29
30
  const cursor = target instanceof HTMLCanvasElement ? target.style.cursor : '';
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { Section as PageSection } from '@page-sections/svelte';
3
3
  import { getContext, onMount } from 'svelte';
4
- import { dev } from '$app/environment';
4
+ import { dev } from '$app/env';
5
5
  import './layout.generated.css';
6
6
  import { createSectionBackgroundNormalizer } from '@spatial-elements/core/spatial-element/sectionBackground';
7
7
  import type { Snippet } from 'svelte';
@@ -84,7 +84,7 @@
84
84
  >
85
85
  <SpaceMouseIcon />
86
86
  </SpatialIconButton>
87
- <dialog bind:this={dialog} aria-labelledby={`${id}-title`} aria-describedby={`${id}-description`}>
87
+ <dialog class="ps-shadow-popup" bind:this={dialog} aria-labelledby={`${id}-title`} aria-describedby={`${id}-description`}>
88
88
  <h2 id={`${id}-title`}>
89
89
  {failure === 'permission-required'
90
90
  ? copy.spaceMousePermissionTitle
@@ -109,7 +109,7 @@
109
109
  >{/if}
110
110
  </div>
111
111
  </dialog>
112
- <div bind:this={toast} popover="manual" role="status" class="connection-toast">
112
+ <div bind:this={toast} popover="manual" role="status" class="connection-toast ps-shadow-popup">
113
113
  {toastMessage}
114
114
  </div>
115
115
 
@@ -118,12 +118,12 @@
118
118
  .connection-toast {
119
119
  box-sizing: border-box;
120
120
  padding: 24px;
121
- border: 1px solid color-mix(in srgb, var(--spatial-element-ink) 15%, transparent);
121
+ border: 1px solid var(--ps-panel-border);
122
122
  border-radius: var(--spatial-element-panel-radius, 12px);
123
123
  color: var(--spatial-element-ink);
124
124
  background: var(--ps-section-standard, var(--ps-background, #fff));
125
125
  font: inherit;
126
- box-shadow: 0 8px 32px #0003;
126
+ box-shadow: var(--ps-popup-shadow, var(--ps-navigation-shadow, var(--ps-default-navigation-shadow)));
127
127
  max-width: min(440px, calc(100vw - 32px));
128
128
  }
129
129
  dialog::backdrop {
@@ -18,16 +18,15 @@
18
18
  section,
19
19
  list,
20
20
  cardSize = 'm',
21
- cardVariant = 'catalog',
22
- itemSpan = { xs: 4, s: 3, m: 4, l: 4 },
21
+ cardShadow = false,
22
+ itemSpan,
23
23
  textAlign = 'start',
24
24
  mediaAspect = '1/1',
25
- mediaFit = cardVariant === 'catalog' ? 'contain' : 'cover',
25
+ mediaFit = 'contain',
26
26
  cardTone = 'standard'
27
27
  }: Props = $props();
28
28
  const reserveEyebrow = $derived(
29
- (cardVariant !== 'catalog' || cardSize !== 's') &&
30
- list.some((item) => Boolean(item.eyebrow?.trim()))
29
+ cardSize !== 's' && list.some((item) => Boolean(item.eyebrow?.trim()))
31
30
  );
32
31
  let catalog: HTMLDivElement;
33
32
  $effect(() => {
@@ -48,7 +47,7 @@
48
47
  {#snippet card()}<SpatialElementCard
49
48
  {spatialElement}
50
49
  {cardSize}
51
- {cardVariant}
50
+ {cardShadow}
52
51
  {textAlign}
53
52
  {mediaAspect}
54
53
  {mediaFit}
@@ -57,9 +56,7 @@
57
56
  order={index}
58
57
  occurrence={JSON.stringify([section.id, spatialElement.itemKey ?? spatialElement.id])}
59
58
  />{/snippet}
60
- {#if cardVariant === 'editorial'}<ContentBlock span={itemSpan}
61
- >{@render card()}</ContentBlock
62
- >
59
+ {#if itemSpan !== undefined}<ContentBlock span={itemSpan}>{@render card()}</ContentBlock>
63
60
  {:else}{@render card()}{/if}
64
61
  {/each}
65
62
  </ContentGrid>
@@ -1,12 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { getContext } from 'svelte';
3
3
  import { Card, type CardElements } from '@page-sections/svelte';
4
- import type {
5
- CardMediaAspect,
6
- CardMediaFit,
7
- CardVariant,
8
- SurfaceTone
9
- } from '@page-sections/core';
4
+ import type { CardMediaAspect, CardMediaFit, SurfaceTone } from '@page-sections/core';
10
5
  import { mouseHover } from '@spatial-elements/core/stage/mouseHover';
11
6
  import { catalogViewLink } from '@spatial-elements/core/catalog/catalogViewLink';
12
7
  import {
@@ -34,7 +29,7 @@
34
29
  mediaFit = 'contain',
35
30
  reserveEyebrow = false,
36
31
  cardTone = 'standard',
37
- cardVariant = 'catalog'
32
+ cardShadow = false
38
33
  }: {
39
34
  spatialElement: SpatialListItem;
40
35
  occurrence: string;
@@ -46,7 +41,7 @@
46
41
  mediaFit?: CardMediaFit;
47
42
  reserveEyebrow?: boolean;
48
43
  cardTone?: SurfaceTone;
49
- cardVariant?: CardVariant;
44
+ cardShadow?: boolean;
50
45
  } = $props();
51
46
  const readTheme = useSpatialTheme();
52
47
  const brand = $derived(readTheme());
@@ -73,7 +68,6 @@
73
68
  const ready = $derived.by(() => {
74
69
  void reserveEyebrow;
75
70
  void cardSize;
76
- void cardVariant;
77
71
  const enabled = active,
78
72
  themeId = brand.id,
79
73
  current = spatialElement,
@@ -102,7 +96,9 @@
102
96
  bind(parts.root, 'container');
103
97
  bind(parts.surface, 'summary-surface', 'spatial-element-card-surface');
104
98
  bind(parts.media, 'geometry', 'spatial-element-card-geometry');
105
- bind(parts.title, 'title');
99
+ // Register the actual clipped label as the spatial text endpoint.
100
+ const titleLabel = parts.title.querySelector<HTMLElement>('.title-label') ?? parts.title;
101
+ bind(titleLabel, 'title');
106
102
  bind(
107
103
  parts.copy.querySelector('[data-ps-card-part="eyebrow"]'),
108
104
  'eyebrow',
@@ -113,10 +109,45 @@
113
109
  parts.media.dataset.catalogOccurrence = key;
114
110
  parts.media.dataset.catalogSlot = 'catalog.card';
115
111
  cleanups.push(mouseHover(parts.root).destroy);
116
- const link = parts.root.matches('a')
117
- ? (parts.root as HTMLAnchorElement)
118
- : parts.title.querySelector('a');
112
+ // The tilted card can briefly move behind its stationary presentation root.
113
+ // Keep that part of the card's hit area linked as well, without replaying
114
+ // events from the actual link or any nested interactive content.
115
+ const presentation = parts.root.closest<HTMLElement>('.spatial-card-root');
116
+ if (presentation) {
117
+ const activatePresentation = (event: MouseEvent) => {
118
+ if (event.target === presentation) activate(event);
119
+ };
120
+ presentation.addEventListener('click', activatePresentation);
121
+ cleanups.push(() => presentation.removeEventListener('click', activatePresentation));
122
+ }
123
+ const link = parts.title.querySelector('a');
119
124
  if (link) {
125
+ // preserve-3d creates containing blocks. Size the stretched hit area from
126
+ // untransformed layout offsets so it still covers the complete card.
127
+ parts.root.dataset.spatialCardLinkReady = '';
128
+ const sizeLink = () => {
129
+ let left = 0,
130
+ top = 0;
131
+ for (
132
+ let node: HTMLElement | null = link;
133
+ node && node !== parts.root;
134
+ node = node.offsetParent as HTMLElement | null
135
+ ) {
136
+ left += node.offsetLeft;
137
+ top += node.offsetTop;
138
+ }
139
+ link.style.setProperty('--spatial-card-link-left', -left + 'px');
140
+ link.style.setProperty('--spatial-card-link-top', -top + 'px');
141
+ link.style.setProperty('--spatial-card-link-width', parts.root.offsetWidth + 'px');
142
+ link.style.setProperty('--spatial-card-link-height', parts.root.offsetHeight + 'px');
143
+ };
144
+ const observer = new ResizeObserver(sizeLink);
145
+ for (const node of [parts.root, parts.copy, parts.title, link]) observer.observe(node);
146
+ sizeLink();
147
+ cleanups.push(() => {
148
+ observer.disconnect();
149
+ delete parts.root.dataset.spatialCardLinkReady;
150
+ });
120
151
  link.dataset.catalogFocusKey = 'catalog:' + JSON.stringify([themeId, current.id, key]);
121
152
  cleanups.push(
122
153
  catalogViewLink(link, {
@@ -126,7 +157,7 @@
126
157
  );
127
158
  }
128
159
  parts.title.removeAttribute('title');
129
- cleanups.push(truncatedTitle(parts.title, current.title).destroy);
160
+ cleanups.push(truncatedTitle(titleLabel, current.title).destroy);
130
161
  return () => cleanups.reverse().forEach((stop) => stop());
131
162
  };
132
163
  });
@@ -135,6 +166,40 @@
135
166
  event.preventDefault();
136
167
  return;
137
168
  }
169
+
170
+ const target = event.target as HTMLElement;
171
+ if (
172
+ !event.defaultPrevented &&
173
+ event.button === 0 &&
174
+ !target.closest('a, button, input, select, textarea')
175
+ ) {
176
+ // A tilted card can move its hit plane between pointerdown and pointerup.
177
+ // The browser then targets their common article instead of its stretched
178
+ // anchor. Replay through the native link, preserving modifier-key behavior.
179
+ const link = (event.currentTarget as HTMLElement).querySelector<HTMLAnchorElement>(
180
+ 'a.primary-link'
181
+ );
182
+ if (link) {
183
+ event.preventDefault();
184
+ event.stopPropagation();
185
+ link.dispatchEvent(
186
+ new MouseEvent('click', {
187
+ bubbles: true,
188
+ cancelable: true,
189
+ button: event.button,
190
+ detail: event.detail,
191
+ ctrlKey: event.ctrlKey,
192
+ metaKey: event.metaKey,
193
+ shiftKey: event.shiftKey,
194
+ altKey: event.altKey,
195
+ clientX: event.clientX,
196
+ clientY: event.clientY,
197
+ view: event.view
198
+ })
199
+ );
200
+ return;
201
+ }
202
+ }
138
203
  endpoints?.prefer(brand.id, spatialElement.id, occurrence);
139
204
  sections?.activate({
140
205
  brandId: brand.id,
@@ -155,7 +220,7 @@
155
220
  {mediaFit}
156
221
  {reserveEyebrow}
157
222
  tone={cardTone}
158
- variant={cardVariant}
223
+ shadow={cardShadow}
159
224
  headingLevel={3}
160
225
  class="spatial-element-card"
161
226
  onready={ready}
@@ -164,9 +229,6 @@
164
229
  data-catalog-order={order}
165
230
  data-catalog-occurrence={occurrence}
166
231
  data-spatial-element-id={spatialElement.id}
167
- data-catalog-focus-key={cardVariant === 'catalog'
168
- ? `catalog:${JSON.stringify([brand.id, spatialElement.id, occurrence])}`
169
- : undefined}
170
232
  aria-busy={busy || undefined}
171
233
  onclick={activate}
172
234
  onpointerenter={() => {
@@ -175,11 +237,8 @@
175
237
  onpointerdown={() => {
176
238
  if (active) prepare(spatialElement);
177
239
  }}
178
- onfocus={(event) => {
179
- if (
180
- active &&
181
- !(event.currentTarget as HTMLElement).hasAttribute('data-catalog-restoring-focus')
182
- )
240
+ onfocusin={(event) => {
241
+ if (active && !(event.target as HTMLElement).hasAttribute('data-catalog-restoring-focus'))
183
242
  prepare(spatialElement);
184
243
  }}
185
244
  >
@@ -198,6 +257,42 @@
198
257
  <span class="catalog-status" role="status">{busy ? 'Opening spatial element…' : ''}</span>
199
258
 
200
259
  <style>
260
+ :global(
261
+ .ps-card.spatial-element-card[data-catalog-card][data-spatial-card-link-ready]
262
+ [data-ps-card-part='copy']
263
+ ),
264
+ :global(
265
+ .ps-card.spatial-element-card[data-catalog-card][data-spatial-card-link-ready]
266
+ [data-ps-card-part='title']
267
+ ),
268
+ :global(
269
+ .ps-card.spatial-element-card[data-catalog-card][data-spatial-card-link-ready] .primary-link
270
+ ) {
271
+ transform-style: preserve-3d;
272
+ }
273
+ :global(
274
+ .ps-card.spatial-element-card[data-catalog-card][data-spatial-card-link-ready] .primary-link
275
+ ) {
276
+ display: block;
277
+ }
278
+ :global(
279
+ .ps-card.spatial-element-card[data-catalog-card][data-spatial-card-link-ready]
280
+ .primary-link::after
281
+ ) {
282
+ inset: auto;
283
+ left: var(--spatial-card-link-left);
284
+ top: var(--spatial-card-link-top);
285
+ width: var(--spatial-card-link-width);
286
+ height: var(--spatial-card-link-height);
287
+ }
288
+
289
+ :global(.ps-card.spatial-element-card[data-catalog-card]:has(.primary-link:focus-visible)) {
290
+ outline: 3px solid var(--ps-accent);
291
+ outline-offset: 4px;
292
+ }
293
+ :global(.ps-card.spatial-element-card[data-catalog-card] .primary-link:focus-visible::after) {
294
+ outline: none;
295
+ }
201
296
  :global(.ps-card.spatial-element-card[data-catalog-card]) {
202
297
  isolation: auto;
203
298
  --ps-radius: var(--spatial-element-control-radius);
@@ -208,18 +303,14 @@
208
303
  rotateX(var(--catalog-rotate-x, 0deg)) rotateY(var(--catalog-rotate-y, 0deg));
209
304
  }
210
305
  :global(.ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='media-frame']) {
306
+ pointer-events: none;
211
307
  overflow: visible;
212
308
  }
213
- :global(.ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='media']),
214
- :global(.ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='copy']) {
309
+ :global(.ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='media']) {
215
310
  transform-style: preserve-3d;
216
311
  }
217
- :global(.ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='surface']) {
218
- box-shadow: 0 12px 32px rgb(0 0 0 / 6%);
219
- transition: border-color 180ms ease;
220
- }
221
312
  :global(
222
- .ps-card.spatial-element-card[data-catalog-card]:is([data-mouse-hover], :focus-visible)
313
+ .ps-card.spatial-element-card[data-catalog-card]:is([data-mouse-hover], :has(:focus-visible))
223
314
  [data-ps-card-part='surface']
224
315
  ) {
225
316
  border-color: var(--ps-accent);
@@ -236,7 +327,7 @@
236
327
  transition: opacity 180ms ease;
237
328
  }
238
329
  :global(
239
- .ps-card.spatial-element-card[data-catalog-card]:is([data-mouse-hover], :focus-visible)
330
+ .ps-card.spatial-element-card[data-catalog-card]:is([data-mouse-hover], :has(:focus-visible))
240
331
  [data-ps-card-part='surface']::after
241
332
  ) {
242
333
  opacity: 1;
@@ -245,7 +336,9 @@
245
336
  opacity: var(--spatial-card-frozen-after-opacity) !important;
246
337
  transition-property: none !important;
247
338
  }
248
- :global(.ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='title']) {
339
+ :global(
340
+ .ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='title'] .title-label
341
+ ) {
249
342
  transform: translateZ(var(--card-title-depth, 0px));
250
343
  }
251
344
  :global(.ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='eyebrow']) {
@@ -258,7 +351,9 @@
258
351
  transform 260ms ease,
259
352
  text-shadow 260ms ease;
260
353
  }
261
- :global(.ps-card.spatial-element-card[data-catalog-card]:is([data-mouse-hover], :focus-visible)) {
354
+ :global(
355
+ .ps-card.spatial-element-card[data-catalog-card]:is([data-mouse-hover], :has(:focus-visible))
356
+ ) {
262
357
  --card-eyebrow-depth: 40px;
263
358
  --card-title-depth: 64px;
264
359
  --card-model-depth: 96px;
@@ -302,6 +397,7 @@
302
397
  @media (prefers-reduced-motion: reduce) {
303
398
  :global(.ps-card.spatial-element-card[data-catalog-card]),
304
399
  :global(.ps-card.spatial-element-card[data-catalog-card] [data-shared-role]),
400
+ :global(.ps-card.spatial-element-card[data-catalog-card] [data-ps-card-part='title'] .title-label),
305
401
  .catalog-poster {
306
402
  transform: none;
307
403
  transition: none;
@@ -1,4 +1,4 @@
1
- import type { CardMediaAspect, CardMediaFit, CardVariant, SurfaceTone } from '@page-sections/core';
1
+ import type { CardMediaAspect, CardMediaFit, SurfaceTone } from '@page-sections/core';
2
2
  import type { SpatialListItem } from '@spatial-elements/core/spatial-element/types';
3
3
  import type { SpatialCardSize } from '@spatial-elements/core/spatial-element/responsiveLayout';
4
4
  type $$ComponentProps = {
@@ -12,7 +12,7 @@ type $$ComponentProps = {
12
12
  mediaFit?: CardMediaFit;
13
13
  reserveEyebrow?: boolean;
14
14
  cardTone?: SurfaceTone;
15
- cardVariant?: CardVariant;
15
+ cardShadow?: boolean;
16
16
  };
17
17
  declare const SpatialCardPresentation: import("svelte").Component<$$ComponentProps, {}, "">;
18
18
  type SpatialCardPresentation = ReturnType<typeof SpatialCardPresentation>;