@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.
@@ -1,5 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { getContext } from 'svelte';
3
+ import { mouseHover } from '@spatial-elements/core/stage/mouseHover';
4
+ import { truncatedTitle } from './truncatedTitle.js';
3
5
  import { useSpatialTheme } from './brandContext.js';
4
6
  import type { SpatialListItem } from '@spatial-elements/core/spatial-element/types';
5
7
  import { createCatalogEndpointAction } from '../catalog/catalogEndpointAction.js';
@@ -35,6 +37,7 @@
35
37
  </script>
36
38
 
37
39
  <a
40
+ use:mouseHover
38
41
  use:catalogEndpoint={{
39
42
  brandId: brand.id,
40
43
  spatialElementId: spatialElement.id,
@@ -136,6 +139,7 @@
136
139
  {spatialElement.eyebrow}
137
140
  </p>
138
141
  <h3
142
+ use:truncatedTitle={spatialElement.title}
139
143
  use:catalogEndpoint={{
140
144
  brandId: brand.id,
141
145
  spatialElementId: spatialElement.id,
@@ -161,6 +165,12 @@
161
165
  font-weight: 720;
162
166
  letter-spacing: 0.04em;
163
167
  text-transform: uppercase;
168
+ line-height: 1.4;
169
+ height: 1lh;
170
+ overflow: hidden;
171
+ white-space: nowrap;
172
+ text-overflow: ellipsis;
173
+ transform: translateZ(var(--card-eyebrow-depth, 0px));
164
174
  }
165
175
  .catalog-loading {
166
176
  position: absolute;
@@ -196,6 +206,7 @@
196
206
  color: var(--spatial-element-ink);
197
207
  text-decoration: none;
198
208
  transform-origin: center;
209
+ transform-style: preserve-3d;
199
210
  transform: perspective(1000px) translate3d(0, var(--catalog-lift, 0px), 0)
200
211
  rotateX(var(--catalog-rotate-x, 0deg)) rotateY(var(--catalog-rotate-y, 0deg));
201
212
  }
@@ -217,11 +228,31 @@
217
228
  transparent
218
229
  );
219
230
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.06);
231
+ transition: border-color 180ms ease;
220
232
  pointer-events: none;
221
233
  }
234
+ .spatial-element-card:global([data-mouse-hover]) .spatial-element-card-surface,
235
+ .spatial-element-card:focus-visible .spatial-element-card-surface {
236
+ border-color: var(--spatial-element-accent);
237
+ }
238
+ .spatial-element-card-surface::after {
239
+ content: '';
240
+ position: absolute;
241
+ inset: -1px;
242
+ border-radius: inherit;
243
+ box-shadow: 0 0 0 1px color-mix(in srgb, var(--spatial-element-accent) 25%, transparent),
244
+ 0 0 18px color-mix(in srgb, var(--spatial-element-accent) 18%, transparent);
245
+ opacity: 0;
246
+ transition: opacity 180ms ease;
247
+ }
248
+ .spatial-element-card:global([data-mouse-hover]) .spatial-element-card-surface::after,
249
+ .spatial-element-card:focus-visible .spatial-element-card-surface::after {
250
+ opacity: 1;
251
+ }
222
252
 
223
253
  .spatial-element-card-geometry {
224
254
  position: relative;
255
+ transform-style: preserve-3d;
225
256
  height: 228px;
226
257
  margin: 12px 12px 0;
227
258
  pointer-events: none;
@@ -232,6 +263,8 @@
232
263
  width: 100%;
233
264
  height: 100%;
234
265
  object-fit: contain;
266
+ transform: translateZ(var(--card-model-depth, 0px)) scale(var(--card-model-scale, 1));
267
+ transition: transform 260ms cubic-bezier(0.22, 0.75, 0.25, 1), opacity 240ms ease;
235
268
  }
236
269
 
237
270
  .spatial-element-card:global([data-catalog-model-ready]) .catalog-poster {
@@ -239,19 +272,51 @@
239
272
  }
240
273
 
241
274
  .spatial-element-card-copy {
275
+ position: relative;
242
276
  padding: 14px 22px 24px;
277
+ transform-style: preserve-3d;
243
278
  }
244
279
 
280
+ .spatial-element-card-eyebrow,
245
281
  h3 {
282
+ text-shadow: var(--card-text-shadow, 0 0 0 transparent);
283
+ transition: transform 260ms cubic-bezier(0.22, 0.75, 0.25, 1),
284
+ text-shadow 260ms cubic-bezier(0.22, 0.75, 0.25, 1);
285
+ }
286
+
287
+ .spatial-element-card:global([data-mouse-hover]),
288
+ .spatial-element-card:focus-visible {
289
+ --card-eyebrow-depth: 40px;
290
+ --card-title-depth: 64px;
291
+ --card-model-depth: 96px;
292
+ --card-model-scale: 1.12;
293
+ --card-text-shadow: 0 4px 10px rgb(0 0 0 / 0.16);
294
+ }
295
+
296
+ h3 {
297
+ display: -webkit-box;
298
+ -webkit-box-orient: vertical;
299
+ -webkit-line-clamp: 2;
300
+ line-clamp: 2;
301
+ height: 2lh;
302
+ overflow: hidden;
303
+ text-overflow: ellipsis;
304
+ overflow-wrap: anywhere;
246
305
  margin: 8px 0 0;
247
306
  font-size: 21px;
248
307
  font-weight: 720;
249
308
  line-height: 1.24;
309
+ transform: translateZ(var(--card-title-depth, 0px));
250
310
  }
251
311
 
252
312
  @media (prefers-reduced-motion: reduce) {
253
- .spatial-element-card {
313
+ .spatial-element-card,
314
+ .spatial-element-card-eyebrow,
315
+ .catalog-poster,
316
+ h3 {
254
317
  transform: none;
318
+ transition: none;
319
+ text-shadow: none;
255
320
  }
256
321
  }
257
322
  </style>
@@ -32,8 +32,11 @@
32
32
  data-spatial-element-departing-media-content={media.kind === 'minimap' ? undefined : ''}
33
33
  >
34
34
  {#if media.kind === 'minimap'}
35
- <button type="button" aria-label={media.label} class="thumb thumb-minimap active"
36
- ></button>
35
+ <button type="button" aria-label={media.label} class="thumb thumb-minimap active">
36
+ {#if spatialElement.fallbackImage}
37
+ <img class="minimap-poster" src={spatialElement.fallbackImage} alt="" />
38
+ {/if}
39
+ </button>
37
40
  {:else if media.kind === 'drawing'}
38
41
  <button type="button" aria-label={media.label} class="thumb thumb-drawing">
39
42
  <span class="drawing-sheet" aria-hidden="true"></span>
@@ -96,6 +99,21 @@
96
99
  overflow: hidden;
97
100
  }
98
101
 
102
+ .minimap-poster {
103
+ position: absolute;
104
+ inset: 10%;
105
+ width: 80%;
106
+ height: 80%;
107
+ object-fit: contain;
108
+ transition: opacity 240ms ease;
109
+ }
110
+
111
+ :global(.stage-enhanced) .minimap-poster { opacity: 0; }
112
+
113
+ @media (prefers-reduced-motion: reduce) {
114
+ .minimap-poster { transition: none; }
115
+ }
116
+
99
117
  .thumb-image img {
100
118
  display: block;
101
119
  max-width: calc(100% - 18px);
@@ -238,9 +238,6 @@
238
238
  .spatial-element-hero :global(.spatial-element-visual) {
239
239
  grid-column: 1;
240
240
  grid-row: 1;
241
- }
242
-
243
- :global(.spatial-element-visual) {
244
241
  min-height: clamp(540px, calc(100vh - 300px), 680px);
245
242
  border-radius: 28px;
246
243
  background: transparent;
@@ -0,0 +1,182 @@
1
+ <script lang="ts">
2
+ import { catalogActionSemantic } from '@spatial-elements/core/catalog/catalogAction';
3
+ import type { CatalogEndpointAddress, CatalogEndpointRole } from '@spatial-elements/core/catalog/CatalogEndpointRegistry';
4
+ import type { SpatialElementFeature, SpatialElementAction } from '@spatial-elements/core/spatial-element/types';
5
+ import { ShoppingCart } from 'lucide-svelte';
6
+ import { createCatalogEndpointAction } from '../catalog/catalogEndpointAction.js';
7
+ let { spatialElement, address, contentInset, heading = 'h3', element = $bindable() }: {
8
+ spatialElement: { id: string; eyebrow: string; title: string; features: SpatialElementFeature[]; action?: SpatialElementAction };
9
+ address: (role: CatalogEndpointRole) => CatalogEndpointAddress | undefined;
10
+ contentInset: number;
11
+ heading?: 'h1' | 'h3';
12
+ element?: HTMLDivElement;
13
+ } = $props();
14
+ const catalogEndpoint = createCatalogEndpointAction();
15
+ </script>
16
+ <div bind:this={element} class="summary-presentation" style:min-height={`${Math.max(504 - contentInset * 2, 0)}px`}>
17
+ <div class="panel-copy">
18
+ <p
19
+ class="panel-kicker"
20
+ data-shared-role="eyebrow"
21
+ data-spatial-element-id={spatialElement.id}
22
+ use:catalogEndpoint={address('eyebrow')}
23
+ >
24
+ {spatialElement.eyebrow}
25
+ </p>
26
+ <svelte:element this={heading} class="summary-title"
27
+ id={heading === 'h1' ? 'spatial-element-title' : undefined}
28
+ tabindex={heading === 'h1' ? -1 : undefined}
29
+ data-shared-role="title"
30
+ data-spatial-element-id={spatialElement.id}
31
+ use:catalogEndpoint={address('title')}
32
+ >
33
+ {spatialElement.title}
34
+ </svelte:element>
35
+ </div>
36
+
37
+ <ul
38
+ class="feature-list"
39
+ aria-label="SpatialElement highlights"
40
+ use:catalogEndpoint={address('features')}
41
+ data-catalog-rich-shared="features"
42
+ data-catalog-semantic={JSON.stringify(spatialElement.features)}
43
+ >
44
+ {#each spatialElement.features as feature (feature.label)}
45
+ <li>
46
+ <span class="feature-content" data-catalog-secondary>
47
+ <span class="feature-marker" aria-hidden="true">{feature.marker ?? 'Link'}</span>
48
+ <span>{feature.label}</span>
49
+ </span>
50
+ </li>
51
+ {/each}
52
+ </ul>
53
+
54
+ {#if spatialElement.action}
55
+ {#if spatialElement.action.href}
56
+ <a
57
+ use:catalogEndpoint={address('primary-action')}
58
+ data-catalog-rich-shared="primary-action"
59
+ data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
60
+ class="spatial-element-action spatial-element-action-expanded"
61
+ href={spatialElement.action.href}
62
+ rel="external"
63
+ aria-label={spatialElement.action.ariaLabel}
64
+ >
65
+ <span class="spatial-element-action-surface" data-catalog-secondary>
66
+ <ShoppingCart
67
+ class="spatial-element-action-icon"
68
+ size={27}
69
+ strokeWidth={2}
70
+ aria-hidden="true"
71
+ />
72
+ <span class="spatial-element-action-label">{spatialElement.action.label}</span>
73
+ </span>
74
+ </a>
75
+ {:else}
76
+ <button
77
+ use:catalogEndpoint={address('primary-action')}
78
+ data-catalog-rich-shared="primary-action"
79
+ data-catalog-semantic={catalogActionSemantic(spatialElement.action)}
80
+ class="spatial-element-action spatial-element-action-expanded"
81
+ type="button"
82
+ aria-label={spatialElement.action.ariaLabel}
83
+ >
84
+ <span class="spatial-element-action-surface" data-catalog-secondary>
85
+ <ShoppingCart
86
+ class="spatial-element-action-icon"
87
+ size={27}
88
+ strokeWidth={2}
89
+ aria-hidden="true"
90
+ />
91
+ <span class="spatial-element-action-label">{spatialElement.action.label}</span>
92
+ </span>
93
+ </button>
94
+ {/if}
95
+ {/if}
96
+ </div>
97
+ <style>
98
+ .summary-presentation {
99
+ position: relative;
100
+ box-sizing: border-box;
101
+ display: flex;
102
+ flex-direction: column;
103
+ justify-content: space-between;
104
+ gap: 24px;
105
+ pointer-events: auto;
106
+ }
107
+
108
+ .summary-title {
109
+ max-width: 390px;
110
+ margin: 10px 0 0;
111
+ font-size: clamp(30px, 3vw, 40px);
112
+ font-weight: 780;
113
+ line-height: 1.16;
114
+ }
115
+
116
+ .panel-kicker {
117
+ margin: 0;
118
+ font-size: 14px;
119
+ font-weight: 720;
120
+ letter-spacing: 0.05em;
121
+ text-transform: uppercase;
122
+ }
123
+
124
+ .feature-list {
125
+ display: grid;
126
+ gap: 20px;
127
+ margin: 0;
128
+ padding: 0;
129
+ color: var(--spatial-element-body);
130
+ font-size: 18px;
131
+ list-style: none;
132
+ }
133
+
134
+ .feature-content {
135
+ display: flex;
136
+ align-items: baseline;
137
+ gap: 14px;
138
+ }
139
+
140
+ .feature-marker {
141
+ color: var(--spatial-element-accent);
142
+ font-weight: 800;
143
+ }
144
+
145
+ .spatial-element-action {
146
+ display: block;
147
+ box-sizing: border-box;
148
+ width: 100%;
149
+ min-height: 62px;
150
+ border: 0;
151
+ padding: 0;
152
+ color: inherit;
153
+ background: transparent;
154
+ text-decoration: none;
155
+ cursor: pointer;
156
+ }
157
+
158
+ .spatial-element-action-surface {
159
+ display: flex;
160
+ align-items: center;
161
+ justify-content: center;
162
+ gap: 10px;
163
+ box-sizing: border-box;
164
+ width: 100%;
165
+ min-height: 62px;
166
+ border-radius: 7px;
167
+ color: var(--spatial-element-on-accent);
168
+ background: var(--spatial-element-accent);
169
+ font:
170
+ 760 22px/1 system-ui,
171
+ sans-serif;
172
+ }
173
+
174
+ :global(.spatial-element-action-icon) {
175
+ flex: none;
176
+ }
177
+
178
+ .spatial-element-action-label {
179
+ white-space: nowrap;
180
+ }
181
+
182
+ </style>
@@ -0,0 +1,18 @@
1
+ import type { CatalogEndpointAddress, CatalogEndpointRole } from '@spatial-elements/core/catalog/CatalogEndpointRegistry';
2
+ import type { SpatialElementFeature, SpatialElementAction } from '@spatial-elements/core/spatial-element/types';
3
+ type $$ComponentProps = {
4
+ spatialElement: {
5
+ id: string;
6
+ eyebrow: string;
7
+ title: string;
8
+ features: SpatialElementFeature[];
9
+ action?: SpatialElementAction;
10
+ };
11
+ address: (role: CatalogEndpointRole) => CatalogEndpointAddress | undefined;
12
+ contentInset: number;
13
+ heading?: 'h1' | 'h3';
14
+ element?: HTMLDivElement;
15
+ };
16
+ declare const SpatialElementSummaryContent: import("svelte").Component<$$ComponentProps, {}, "element">;
17
+ type SpatialElementSummaryContent = ReturnType<typeof SpatialElementSummaryContent>;
18
+ export default SpatialElementSummaryContent;