@eldrajs/theme-cli 0.2.9 → 0.2.11

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 (169) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/package.json +3 -3
  3. package/template/.eldra/block-types.d.ts +4 -6
  4. package/template/.eldra/manifest.json +228 -246
  5. package/template/.eldra/previews.json +35 -35
  6. package/template/.storybook/eldra.ts +7 -2
  7. package/template/app/assets/main.css +5 -0
  8. package/template/app/composables/useBlockData.ts +9 -2
  9. package/template/app/composables/usePriceTokens.ts +150 -0
  10. package/template/app/composables/useQuickAdd.ts +95 -0
  11. package/template/app/composables/useRegionalFormat.ts +94 -0
  12. package/template/app/icons.ts +4 -0
  13. package/template/app/plugins/eldra-storefront.ts +2 -0
  14. package/template/app/plugins/eldra-ui-messages.ts +22 -8
  15. package/template/app/storefront/demo.ts +188 -16
  16. package/template/app/storefront/gateway.ts +19 -0
  17. package/template/app/storefront/productCardLook.ts +76 -0
  18. package/template/app/storefront/productReference.ts +17 -0
  19. package/template/app/storefront/toProductCard.ts +12 -8
  20. package/template/app/storefront/types.ts +17 -0
  21. package/template/blocks/announcement-bar/__tests__/Block.spec.ts +19 -7
  22. package/template/blocks/announcement-bar/block.json +2 -1
  23. package/template/blocks/announcement-bar/mock.json +1 -1
  24. package/template/blocks/announcement-bar/preview.png +0 -0
  25. package/template/blocks/article/Block.vue +8 -18
  26. package/template/blocks/article/block.json +3 -1
  27. package/template/blocks/article/preview.png +0 -0
  28. package/template/blocks/article-list/block.json +10 -1
  29. package/template/blocks/article-list/preview.png +0 -0
  30. package/template/blocks/breadcrumbs/Block.vue +15 -3
  31. package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +13 -0
  32. package/template/blocks/breadcrumbs/block.json +1 -0
  33. package/template/blocks/breadcrumbs/preview.png +0 -0
  34. package/template/blocks/cart/Block.vue +15 -5
  35. package/template/blocks/cart/__tests__/Block.spec.ts +53 -10
  36. package/template/blocks/cart/__tests__/ShippingBar.spec.ts +10 -8
  37. package/template/blocks/cart/block.json +8 -5
  38. package/template/blocks/cart/mock.json +2 -2
  39. package/template/blocks/cart/parts/ShippingBar.vue +24 -30
  40. package/template/blocks/cart/parts/notSold.ts +4 -3
  41. package/template/blocks/collection-grid/Block.vue +168 -85
  42. package/template/blocks/collection-grid/__tests__/Block.spec.ts +101 -23
  43. package/template/blocks/collection-grid/preview.png +0 -0
  44. package/template/blocks/collection-header/Block.vue +51 -17
  45. package/template/blocks/collection-header/__tests__/Block.spec.ts +80 -4
  46. package/template/blocks/collection-header/block.json +2 -0
  47. package/template/blocks/collection-header/preview.png +0 -0
  48. package/template/blocks/contact/block.json +4 -0
  49. package/template/blocks/contact/preview.png +0 -0
  50. package/template/blocks/cta/block.json +2 -0
  51. package/template/blocks/faq/Block.vue +5 -10
  52. package/template/blocks/faq/block.json +2 -1
  53. package/template/blocks/faq/mock.json +12 -1
  54. package/template/blocks/faq/preview.png +0 -0
  55. package/template/blocks/feature-grid/__tests__/Block.spec.ts +30 -7
  56. package/template/blocks/feature-grid/block.json +3 -2
  57. package/template/blocks/feature-grid/mock.json +1 -1
  58. package/template/blocks/feature-grid/preview.png +0 -0
  59. package/template/blocks/footer/Block.vue +64 -21
  60. package/template/blocks/footer/__tests__/Block.spec.ts +97 -1
  61. package/template/blocks/footer/block.json +5 -2
  62. package/template/blocks/footer/mock.json +1 -1
  63. package/template/blocks/footer/preview.png +0 -0
  64. package/template/blocks/form/block.json +1 -0
  65. package/template/blocks/gallery/preview.png +0 -0
  66. package/template/blocks/hero/Block.vue +38 -9
  67. package/template/blocks/hero/__tests__/Block.spec.ts +71 -19
  68. package/template/blocks/hero/block.json +16 -22
  69. package/template/blocks/hero/preview.json +1 -3
  70. package/template/blocks/hero/preview.png +0 -0
  71. package/template/blocks/image/block.json +2 -1
  72. package/template/blocks/image/preview.png +0 -0
  73. package/template/blocks/logo-cloud/block.json +1 -0
  74. package/template/blocks/logo-cloud/preview.png +0 -0
  75. package/template/blocks/navigation/Block.vue +405 -159
  76. package/template/blocks/navigation/__tests__/Block.spec.ts +816 -172
  77. package/template/blocks/navigation/__tests__/currentItem.spec.ts +90 -0
  78. package/template/blocks/navigation/block.json +2 -11
  79. package/template/blocks/navigation/mock.json +3 -3
  80. package/template/blocks/navigation/parts/LocalePicker.vue +103 -0
  81. package/template/blocks/navigation/parts/currentItem.ts +82 -0
  82. package/template/blocks/navigation/preview.json +7 -1
  83. package/template/blocks/navigation/preview.png +0 -0
  84. package/template/blocks/newsletter/Block.vue +6 -2
  85. package/template/blocks/newsletter/block.json +2 -0
  86. package/template/blocks/newsletter/preview.png +0 -0
  87. package/template/blocks/order-status/Block.vue +8 -17
  88. package/template/blocks/order-status/block.json +3 -0
  89. package/template/blocks/order-status/preview.png +0 -0
  90. package/template/blocks/pricing-table/__tests__/Block.spec.ts +12 -4
  91. package/template/blocks/pricing-table/block.json +2 -0
  92. package/template/blocks/pricing-table/mock.json +6 -6
  93. package/template/blocks/pricing-table/preview.png +0 -0
  94. package/template/blocks/product-carousel/Block.vue +36 -126
  95. package/template/blocks/product-carousel/__tests__/Block.spec.ts +88 -0
  96. package/template/blocks/product-carousel/block.json +1 -0
  97. package/template/blocks/product-carousel/preview.png +0 -0
  98. package/template/blocks/product-detail/Block.vue +84 -31
  99. package/template/blocks/product-detail/__tests__/Block.spec.ts +86 -0
  100. package/template/blocks/product-detail/__tests__/specs.spec.ts +79 -0
  101. package/template/blocks/product-detail/block.json +3 -1
  102. package/template/blocks/product-detail/mock.json +54 -4
  103. package/template/blocks/product-detail/parts/Gallery.vue +8 -2
  104. package/template/blocks/product-detail/preview.png +0 -0
  105. package/template/blocks/product-detail/specs.ts +75 -0
  106. package/template/blocks/quote/block.json +1 -0
  107. package/template/blocks/rich-text/preview.png +0 -0
  108. package/template/blocks/search/Block.vue +6 -1
  109. package/template/blocks/search/TypeSection.vue +8 -1
  110. package/template/blocks/search/__tests__/Block.spec.ts +24 -1
  111. package/template/blocks/search/block.json +1 -0
  112. package/template/blocks/search/preview.png +0 -0
  113. package/template/blocks/split-content/Block.vue +12 -5
  114. package/template/blocks/split-content/__tests__/Block.spec.ts +13 -0
  115. package/template/blocks/split-content/block.json +4 -2
  116. package/template/blocks/split-content/preview.png +0 -0
  117. package/template/blocks/stats/preview.png +0 -0
  118. package/template/blocks/tabs/Block.vue +3 -4
  119. package/template/blocks/tabs/block.json +1 -1
  120. package/template/blocks/tabs/preview.png +0 -0
  121. package/template/blocks/team/block.json +3 -1
  122. package/template/blocks/team/preview.png +0 -0
  123. package/template/blocks/testimonials/block.json +2 -0
  124. package/template/blocks/testimonials/preview.png +0 -0
  125. package/template/blocks/timeline/block.json +2 -1
  126. package/template/blocks/timeline/preview.png +0 -0
  127. package/template/blocks/trust-strip/Block.vue +2 -2
  128. package/template/blocks/trust-strip/__tests__/Block.spec.ts +38 -9
  129. package/template/blocks/trust-strip/block.json +1 -1
  130. package/template/blocks/trust-strip/mock.json +1 -1
  131. package/template/blocks/trust-strip/preview.json +1 -1
  132. package/template/blocks/trust-strip/preview.png +0 -0
  133. package/template/blocks/video-embed/block.json +2 -0
  134. package/template/blocks/video-embed/preview.png +0 -0
  135. package/template/blocks/wishlist/Block.vue +2 -2
  136. package/template/blocks/wishlist/preview.png +0 -0
  137. package/template/i18n/en-US.json +13 -5
  138. package/template/i18n/is-IS.json +12 -4
  139. package/template/pages/article.page.json +1 -3
  140. package/template/pages/cart.page.json +1 -3
  141. package/template/pages/category.page.json +2 -4
  142. package/template/pages/collection.page.json +1 -3
  143. package/template/pages/home.page.json +7 -18
  144. package/template/pages/product.page.json +62 -131
  145. package/template/pages/products.page.json +1 -3
  146. package/template/pages/search.page.json +1 -3
  147. package/template/pages/wishlist.page.json +1 -3
  148. package/template/stories/generated/footer.stories.ts +6 -0
  149. package/template/stories/generated/navigation.stories.ts +0 -18
  150. package/template/test/inlineEditable.spec.ts +10 -2
  151. package/template/test/localePrefix.spec.ts +2 -19
  152. package/template/test/pages/article.spec.ts +0 -2
  153. package/template/test/pages/category.spec.ts +35 -13
  154. package/template/test/pages/home.spec.ts +33 -17
  155. package/template/test/pages/product.spec.ts +64 -44
  156. package/template/test/pages/ssr.spec.ts +3 -1
  157. package/template/test/prerenderRefresh.browser.spec.ts +30 -25
  158. package/template/test/previewParity.browser.spec.ts +36 -2
  159. package/template/test/priceTokens.spec.ts +309 -0
  160. package/template/test/regionalFormat.spec.ts +80 -0
  161. package/template/test/starter.spec.ts +23 -7
  162. package/template/test/storefront/demo.spec.ts +19 -18
  163. package/template/test/storefront/toProductCard.spec.ts +17 -2
  164. package/template/test/structuredData.generate.spec.ts +4 -2
  165. package/template/test/support/mockGateway.ts +21 -1
  166. package/template/test/support/mountBlock.ts +25 -4
  167. package/template/test/support/priceTokens.ts +20 -0
  168. package/template/test/uiMessagesPlugin.spec.ts +34 -1
  169. package/template/tokens.json +8 -8
@@ -3,6 +3,7 @@ import { starterFormSeeds } from '../formSeeds';
3
3
  import { localizeFormDefinition } from './forms';
4
4
  import { createCartStore, type CartOps, type CartSnapshot } from './cart';
5
5
  import { createCurrencyStore } from './currency';
6
+ import type { StoreAmounts } from '@eldrajs/sdk/tokens';
6
7
  import { createHistoryStore, createWishlistStore } from './history';
7
8
  import { roundMoney } from './money';
8
9
  import { optionDisplayType } from './options';
@@ -107,6 +108,10 @@ const PRODUCT_PHOTOS: Record<string, readonly [DemoPhoto, DemoPhoto, DemoPhoto]>
107
108
  'glazed-milk-jug': ['hero', 'terracotta', 'vase'],
108
109
  'linen-napkins-set-of-4': ['cup', 'enamel-cups', 'kitchen'],
109
110
  'stonewashed-linen-throw': ['reading', 'throws', 'yarn'],
111
+ 'tall-bud-vase': ['vase', 'terracotta', 'coffee-table'],
112
+ 'celadon-tea-cup': ['cup', 'enamel-cups', 'kitchen'],
113
+ 'terracotta-planters': ['planters', 'terracotta', 'clay-hands'],
114
+ 'enamel-camp-cups-set-of-6': ['enamel-cups', 'kitchen', 'cup'],
110
115
  };
111
116
 
112
117
  function productPhotos(handle: string): readonly [DemoPhoto, DemoPhoto, DemoPhoto] {
@@ -136,6 +141,10 @@ interface DemoProductDef {
136
141
  variantId: string;
137
142
  rating?: { value: number; count: number } | null;
138
143
  colours?: Array<{ name: string; swatch: string }>;
144
+ /** The maker, as a real catalogue's brand would name it. */
145
+ vendor?: string;
146
+ /** New in: the card's "New" badge (`StorefrontProductListItem.isNew`). */
147
+ isNew?: boolean;
139
148
  /**
140
149
  * Which `category` facet value this product sits under, and which `size` values it is made in
141
150
  * (apparel only). Neither is part of `StorefrontProductListItem` — a product *card* never shows
@@ -149,6 +158,7 @@ interface DemoProductDef {
149
158
  const PRODUCT_DEFS: DemoProductDef[] = [
150
159
  {
151
160
  handle: 'merino-crew-sweater',
161
+ vendor: 'Fell & Fleece',
152
162
  category: 'knitwear',
153
163
  sizes: ['xs', 's', 'm', 'l', 'xl'],
154
164
  title: 'Merino crew sweater',
@@ -167,6 +177,8 @@ const PRODUCT_DEFS: DemoProductDef[] = [
167
177
  },
168
178
  {
169
179
  handle: 'fisherman-rib-cardigan',
180
+ isNew: true,
181
+ vendor: 'Fell & Fleece',
170
182
  category: 'knitwear',
171
183
  sizes: ['xs', 's', 'm', 'l', 'xl'],
172
184
  title: 'Fisherman rib cardigan',
@@ -177,6 +189,8 @@ const PRODUCT_DEFS: DemoProductDef[] = [
177
189
  },
178
190
  {
179
191
  handle: 'lambswool-throw-blanket',
192
+ isNew: true,
193
+ vendor: 'Fell & Fleece',
180
194
  category: 'knitwear',
181
195
  title: 'Lambswool throw blanket',
182
196
  amount: 148,
@@ -186,6 +200,7 @@ const PRODUCT_DEFS: DemoProductDef[] = [
186
200
  },
187
201
  {
188
202
  handle: 'ribbed-lambswool-beanie',
203
+ vendor: 'Fell & Fleece',
189
204
  category: 'knitwear',
190
205
  sizes: ['s', 'm', 'l'],
191
206
  title: 'Ribbed lambswool beanie',
@@ -196,6 +211,7 @@ const PRODUCT_DEFS: DemoProductDef[] = [
196
211
  },
197
212
  {
198
213
  handle: 'linen-tea-towels-pair',
214
+ vendor: 'Linen Loft',
199
215
  category: 'kitchen',
200
216
  title: 'Linen tea towels, pair',
201
217
  amount: 24,
@@ -205,6 +221,8 @@ const PRODUCT_DEFS: DemoProductDef[] = [
205
221
  },
206
222
  {
207
223
  handle: 'speckled-latte-mug',
224
+ isNew: true,
225
+ vendor: 'Kiln Lane',
208
226
  category: 'ceramics',
209
227
  title: 'Speckled latte mug',
210
228
  amount: 28,
@@ -215,6 +233,7 @@ const PRODUCT_DEFS: DemoProductDef[] = [
215
233
  },
216
234
  {
217
235
  handle: 'stoneware-dinner-plates-set-of-4',
236
+ vendor: 'Studio Ash',
218
237
  category: 'ceramics',
219
238
  title: 'Stoneware dinner plates, set of 4',
220
239
  amount: 72,
@@ -224,6 +243,7 @@ const PRODUCT_DEFS: DemoProductDef[] = [
224
243
  },
225
244
  {
226
245
  handle: 'walnut-serving-board',
246
+ vendor: 'Alder & Oak',
227
247
  category: 'kitchen',
228
248
  title: 'Walnut serving board',
229
249
  amount: 58,
@@ -233,6 +253,7 @@ const PRODUCT_DEFS: DemoProductDef[] = [
233
253
  },
234
254
  {
235
255
  handle: 'hand-thrown-serving-bowl',
256
+ vendor: 'Harbour Pottery',
236
257
  category: 'ceramics',
237
258
  title: 'Hand-thrown serving bowl',
238
259
  amount: 64,
@@ -242,6 +263,7 @@ const PRODUCT_DEFS: DemoProductDef[] = [
242
263
  },
243
264
  {
244
265
  handle: 'glazed-milk-jug',
266
+ vendor: 'Harbour Pottery',
245
267
  category: 'ceramics',
246
268
  title: 'Glazed milk jug',
247
269
  amount: 34,
@@ -251,6 +273,7 @@ const PRODUCT_DEFS: DemoProductDef[] = [
251
273
  },
252
274
  {
253
275
  handle: 'linen-napkins-set-of-4',
276
+ vendor: 'Linen Loft',
254
277
  category: 'kitchen',
255
278
  title: 'Linen napkins, set of 4',
256
279
  amount: 40,
@@ -260,6 +283,7 @@ const PRODUCT_DEFS: DemoProductDef[] = [
260
283
  },
261
284
  {
262
285
  handle: 'stonewashed-linen-throw',
286
+ vendor: 'Linen Loft',
263
287
  category: 'knitwear',
264
288
  title: 'Stonewashed linen throw',
265
289
  amount: 118,
@@ -267,6 +291,54 @@ const PRODUCT_DEFS: DemoProductDef[] = [
267
291
  available: true,
268
292
  variantId: 'stonewashed-linen-throw::default',
269
293
  },
294
+ // Four more ceramics, so a ceramics page shows eight different pieces as the design does rather
295
+ // than four repeated. Appended, so every index above keeps its product.
296
+ {
297
+ handle: 'tall-bud-vase',
298
+ vendor: 'Kiln Lane',
299
+ category: 'ceramics',
300
+ title: 'Tall bud vase',
301
+ amount: 42,
302
+ stock: 'in',
303
+ available: true,
304
+ variantId: 'tall-bud-vase::white',
305
+ colours: [
306
+ { name: 'White', swatch: '#f7f4ee' },
307
+ { name: 'Spruce', swatch: '#1e4646' },
308
+ ],
309
+ },
310
+ {
311
+ handle: 'celadon-tea-cup',
312
+ vendor: 'Kiln Lane',
313
+ category: 'ceramics',
314
+ title: 'Celadon tea cup',
315
+ amount: 24,
316
+ compareAt: 32,
317
+ stock: 'in',
318
+ available: true,
319
+ variantId: 'celadon-tea-cup::celadon',
320
+ colours: [{ name: 'Celadon', swatch: '#8fc4b1' }],
321
+ },
322
+ {
323
+ handle: 'terracotta-planters',
324
+ vendor: 'Harbour Pottery',
325
+ category: 'ceramics',
326
+ title: 'Terracotta planters',
327
+ amount: 36,
328
+ stock: 'in',
329
+ available: true,
330
+ variantId: 'terracotta-planters::default',
331
+ },
332
+ {
333
+ handle: 'enamel-camp-cups-set-of-6',
334
+ vendor: 'Studio Ash',
335
+ category: 'ceramics',
336
+ title: 'Enamel camp cups, set of 6',
337
+ amount: 48,
338
+ stock: 'out',
339
+ available: false,
340
+ variantId: 'enamel-camp-cups-set-of-6::default',
341
+ },
270
342
  ];
271
343
 
272
344
  /**
@@ -280,9 +352,10 @@ const PRODUCT_DEFS: DemoProductDef[] = [
280
352
  * **The fixture's category tree**, in the shape `GET /catalog/v1/categories` answers: one row per
281
353
  * category, a tree by `parentId`.
282
354
  *
283
- * Two levels and one shallow branch on purpose, because that is the shape a real store has and the
284
- * shape both features need to be exercised at all: `Homeware` holds `Ceramics` and `Kitchen`, while
285
- * `Knitwear` is a root with nothing under it. So a product page's trail is two crumbs for a mug
355
+ * Three levels and one shallow branch on purpose, because that is the shape a real store has and
356
+ * the shape every feature needs to be exercised at all: `Homeware` holds `Ceramics` and `Kitchen`,
357
+ * `Ceramics` holds five empty children (its page's strip), while `Knitwear` is a root with nothing
358
+ * under it. So a product page's trail is two crumbs for a mug
286
359
  * (`Homeware / Ceramics`) and one for a sweater (`Knitwear`), and the collection grid's category
287
360
  * group draws one parent row with two indented children beside one plain row — with `Homeware`
288
361
  * itself counting nothing directly, which is exactly the parent a flat facet never names.
@@ -302,6 +375,29 @@ const DEMO_CATEGORIES: readonly CategoryRow[] = [
302
375
  { id: 'knitwear', slug: 'knitwear', title: 'Knitwear', parentId: null },
303
376
  { id: 'ceramics', slug: 'ceramics', title: 'Ceramics', parentId: 'home' },
304
377
  { id: 'kitchen', slug: 'kitchen', title: 'Kitchen', parentId: 'home' },
378
+ // Ceramics' own children, so the category page's strip under the title has something to show
379
+ // (the design's "All ceramics · Mugs and cups · …" row). No product is filed under them: every
380
+ // ceramic piece sits on `ceramics` itself, so they count nothing and the facet never names them.
381
+ {
382
+ id: 'mugs-and-cups',
383
+ slug: 'mugs-and-cups',
384
+ title: 'Mugs and cups',
385
+ parentId: 'ceramics',
386
+ },
387
+ { id: 'bowls', slug: 'bowls', title: 'Bowls', parentId: 'ceramics' },
388
+ {
389
+ id: 'plates-and-platters',
390
+ slug: 'plates-and-platters',
391
+ title: 'Plates and platters',
392
+ parentId: 'ceramics',
393
+ },
394
+ { id: 'vases', slug: 'vases', title: 'Vases', parentId: 'ceramics' },
395
+ {
396
+ id: 'gift-sets',
397
+ slug: 'gift-sets',
398
+ title: 'Gift sets',
399
+ parentId: 'ceramics',
400
+ },
305
401
  ];
306
402
 
307
403
  /** The tree indexed both ways, for the trail and for placing the facet's own terms. */
@@ -331,9 +427,16 @@ function registerAttributes(handle: string, def: DemoProductDef): void {
331
427
  PRODUCT_ATTRIBUTES.set(handle, {
332
428
  // The `id` is what a parent clause is resolved through — `matchesClause` walks a product's own
333
429
  // category up the tree — and what `categoryTermsOf` places the facet's own terms by.
334
- category: { id: def.category, slug: def.category, title: CATEGORY_TITLES[def.category] },
430
+ category: {
431
+ id: def.category,
432
+ slug: def.category,
433
+ title: CATEGORY_TITLES[def.category],
434
+ },
335
435
  options: {
336
- size: (def.sizes ?? []).map((size) => ({ value: size, label: size.toUpperCase() })),
436
+ size: (def.sizes ?? []).map((size) => ({
437
+ value: size,
438
+ label: size.toUpperCase(),
439
+ })),
337
440
  colour: (def.colours ?? []).map((colour) => ({
338
441
  value: colour.name.toLowerCase(),
339
442
  label: colour.name,
@@ -353,6 +456,8 @@ function buildListItem(def: DemoProductDef): StorefrontProductListItem {
353
456
  price: { amount: def.amount, compareAt: def.compareAt ?? null },
354
457
  rating: def.rating ?? null,
355
458
  colours: def.colours,
459
+ ...(def.vendor === undefined ? {} : { vendor: def.vendor }),
460
+ ...(def.isNew === true ? { isNew: true } : {}),
356
461
  stock: def.stock,
357
462
  available: def.available,
358
463
  productId: def.handle,
@@ -388,7 +493,12 @@ const MERINO_OPTIONS: StorefrontProduct['options'] = [
388
493
  kind: 'color',
389
494
  values: [
390
495
  { value: 'oat', label: 'Oat', swatch: '#d8cbb0', available: true },
391
- { value: 'charcoal', label: 'Charcoal', swatch: '#3a3a3a', available: true },
496
+ {
497
+ value: 'charcoal',
498
+ label: 'Charcoal',
499
+ swatch: '#3a3a3a',
500
+ available: true,
501
+ },
392
502
  { value: 'clay', label: 'Clay', swatch: '#b5651d', available: true },
393
503
  { value: 'moss', label: 'Moss', swatch: '#6b7a4f', available: false },
394
504
  ],
@@ -761,19 +871,34 @@ function buildOrderSteps(status: StorefrontOrderStatus): StorefrontOrder['steps'
761
871
  { key: 'ordered', label: 'Ordered', date: '2026-09-18', state: 'done' },
762
872
  { key: 'packed', label: 'Packed', date: '2026-09-19', state: 'done' },
763
873
  { key: 'shipped', label: 'Shipped', date: '2026-09-20', state: 'done' },
764
- { key: 'delivered', label: 'Delivered', date: '2026-09-24', state: 'done' },
874
+ {
875
+ key: 'delivered',
876
+ label: 'Delivered',
877
+ date: '2026-09-24',
878
+ state: 'done',
879
+ },
765
880
  ];
766
881
  case 'delayed':
767
882
  return [
768
883
  { key: 'ordered', label: 'Ordered', date: '2026-09-18', state: 'done' },
769
884
  { key: 'packed', label: 'Packed', date: '2026-09-19', state: 'done' },
770
885
  { key: 'shipped', label: 'Shipped', date: '2026-09-20', state: 'done' },
771
- { key: 'delivered', label: 'Delivered', date: '2026-09-30', state: 'warning' },
886
+ {
887
+ key: 'delivered',
888
+ label: 'Delivered',
889
+ date: '2026-09-30',
890
+ state: 'warning',
891
+ },
772
892
  ];
773
893
  case 'cancelled':
774
894
  return [
775
895
  { key: 'ordered', label: 'Ordered', date: '2026-09-18', state: 'done' },
776
- { key: 'packed', label: 'Packed', date: '2026-09-19', state: 'warning' },
896
+ {
897
+ key: 'packed',
898
+ label: 'Packed',
899
+ date: '2026-09-19',
900
+ state: 'warning',
901
+ },
777
902
  { key: 'shipped', label: 'Shipped', date: null, state: 'upcoming' },
778
903
  { key: 'delivered', label: 'Delivered', date: null, state: 'upcoming' },
779
904
  ];
@@ -782,8 +907,18 @@ function buildOrderSteps(status: StorefrontOrderStatus): StorefrontOrder['steps'
782
907
  return [
783
908
  { key: 'ordered', label: 'Ordered', date: '2026-09-18', state: 'done' },
784
909
  { key: 'packed', label: 'Packed', date: '2026-09-19', state: 'done' },
785
- { key: 'shipped', label: 'Shipped', date: '2026-09-20', state: 'current' },
786
- { key: 'delivered', label: 'Delivered', date: '2026-09-26', state: 'upcoming' },
910
+ {
911
+ key: 'shipped',
912
+ label: 'Shipped',
913
+ date: '2026-09-20',
914
+ state: 'current',
915
+ },
916
+ {
917
+ key: 'delivered',
918
+ label: 'Delivered',
919
+ date: '2026-09-26',
920
+ state: 'upcoming',
921
+ },
787
922
  ];
788
923
  }
789
924
  }
@@ -945,7 +1080,14 @@ function suggestionFor(query: string): string | null {
945
1080
  function buildSearchResponse(query: string): StorefrontSearchResponse {
946
1081
  const q = normalise(query);
947
1082
  if (q === '') {
948
- return { query, total: 0, products: [], articles: [], pages: [], suggestion: null };
1083
+ return {
1084
+ query,
1085
+ total: 0,
1086
+ products: [],
1087
+ articles: [],
1088
+ pages: [],
1089
+ suggestion: null,
1090
+ };
949
1091
  }
950
1092
  const products = PRODUCTS.filter((product) => includesQuery(product.title, q));
951
1093
  const articles = JOURNAL_ARTICLES.filter(
@@ -1074,7 +1216,11 @@ function createDemoCartOps(seedLines: StorefrontCartLine[]): CartOps {
1074
1216
  async setQuantity(lineId, quantity) {
1075
1217
  lines = lines.map((line) =>
1076
1218
  line.id === lineId
1077
- ? { ...line, quantity, lineTotal: roundMoney(line.unitPrice * quantity) }
1219
+ ? {
1220
+ ...line,
1221
+ quantity,
1222
+ lineTotal: roundMoney(line.unitPrice * quantity),
1223
+ }
1078
1224
  : line
1079
1225
  );
1080
1226
  return snapshot();
@@ -1175,6 +1321,15 @@ export const DEMO_COMMERCE: StorefrontCommerce = {
1175
1321
  defaultTaxRate: 0.08,
1176
1322
  };
1177
1323
 
1324
+ /**
1325
+ * The demo store's own amounts for `⟦store …⟧` price tokens (`app/composables/usePriceTokens.ts`),
1326
+ * minor units per currency: free shipping over $80, the threshold the Northwind copy has always
1327
+ * quoted, with an amount of its own in each other currency a story might switch to.
1328
+ */
1329
+ export const DEMO_STORE_AMOUNTS: StoreAmounts = {
1330
+ freeShippingThreshold: { USD: 8000, EUR: 7500, ISK: 15000 },
1331
+ };
1332
+
1178
1333
  export interface DemoStorefrontOptions {
1179
1334
  orderStatus?: StorefrontOrderStatus;
1180
1335
  /** What the demo store sells in; `DEMO_COMMERCE` by default, `null` for a store that publishes
@@ -1203,6 +1358,8 @@ export interface DemoStorefrontOptions {
1203
1358
  * mode and `breadcrumbs`' `fromCategory` each draw nothing, exactly as they do on a product page.
1204
1359
  */
1205
1360
  categoryPath?: string;
1361
+ /** Seeds `route.path`, which a spec then changes to navigate; empty (the default) is no router. */
1362
+ path?: string;
1206
1363
  }
1207
1364
 
1208
1365
  /** Northwind fixtures in the theme's own view types — the "knobs" are exactly what a block spec
@@ -1212,6 +1369,7 @@ export function createDemoStorefront(options: DemoStorefrontOptions = {}): Store
1212
1369
 
1213
1370
  const categoryPath = options.categoryPath ?? null;
1214
1371
  const route: StorefrontRoute = reactive({
1372
+ path: options.path ?? '',
1215
1373
  productHandle: options.productHandle ?? 'merino-crew-sweater',
1216
1374
  collectionHandle: options.collectionHandle ?? 'winter-knitwear',
1217
1375
  categorySlug: categoryPath === null ? null : (categoryPath.split('/').at(-1) ?? null) || null,
@@ -1296,7 +1454,11 @@ export function createDemoStorefront(options: DemoStorefrontOptions = {}): Store
1296
1454
  // than over one fetched page: the vocabulary is every value the collection holds, and
1297
1455
  // each family's counts leave that family's own filter out (`deriveFacets`), so ticking
1298
1456
  // one colour narrows the sizes and leaves the other colours countable.
1299
- facets: deriveFacets(all, { filters, attributesFor, categories: CATEGORY_INDEX }),
1457
+ facets: deriveFacets(all, {
1458
+ filters,
1459
+ attributesFor,
1460
+ categories: CATEGORY_INDEX,
1461
+ }),
1300
1462
  };
1301
1463
  }),
1302
1464
  /**
@@ -1326,11 +1488,21 @@ export function createDemoStorefront(options: DemoStorefrontOptions = {}): Store
1326
1488
  total: ordered.length,
1327
1489
  // Counted over the **scope**, not the whole catalogue: on a category page the `category`
1328
1490
  // group lists that category's children with the counts they have inside it.
1329
- facets: deriveFacets(scope, { filters, attributesFor, categories: CATEGORY_INDEX }),
1491
+ facets: deriveFacets(scope, {
1492
+ filters,
1493
+ attributesFor,
1494
+ categories: CATEGORY_INDEX,
1495
+ }),
1330
1496
  };
1331
1497
  }),
1498
+ // The product itself is never one of its own related products — the gateway drops it before
1499
+ // taking `limit` (`relatedProducts`), so a row asked for 4 shows 4, here as there.
1332
1500
  related: (handle, limit) =>
1333
- createDemoResult([handle], () => (handle.value ? RELATED_ITEMS.slice(0, limit) : [])),
1501
+ createDemoResult([handle], () =>
1502
+ handle.value
1503
+ ? RELATED_ITEMS.filter((item) => item.handle !== handle.value).slice(0, limit)
1504
+ : []
1505
+ ),
1334
1506
  byHandles: (handles) =>
1335
1507
  createDemoResult([handles], () =>
1336
1508
  handles.value
@@ -104,6 +104,21 @@ interface RawProductListItem {
104
104
  * here; see its own comment for why the dots are gated on the option's `kind`.
105
105
  */
106
106
  options?: RawProductOption[] | null;
107
+ /** The product's brand; absent for a product without one. */
108
+ brand?: RawProductBrand | null;
109
+ }
110
+
111
+ /** `catalogweb_WebProductBrand`: only the name is read, as the product's `vendor`. */
112
+ interface RawProductBrand {
113
+ id: string;
114
+ name: string;
115
+ slug: string;
116
+ }
117
+
118
+ /** `vendor` from a raw brand: the trimmed name, or nothing at all. */
119
+ function vendorField(brand: RawProductBrand | null | undefined): { vendor?: string } {
120
+ const name = brand?.name?.trim() ?? '';
121
+ return name === '' ? {} : { vendor: name };
107
122
  }
108
123
 
109
124
  /**
@@ -250,6 +265,8 @@ interface RawProductDetails {
250
265
  mediaLinks?: RawMediaItem[] | null;
251
266
  options?: RawProductOption[] | null;
252
267
  variants?: RawProductVariant[] | null;
268
+ /** The product's brand; absent for a product without one. */
269
+ brand?: RawProductBrand | null;
253
270
  }
254
271
 
255
272
  /** One row of `POST /inventory/v1/stock/availability`'s answer. */
@@ -439,6 +456,7 @@ function mapProductListItem(raw: RawProductListItem): StorefrontProductListItem
439
456
  ...currencyFields(raw),
440
457
  },
441
458
  ...(colours === undefined ? {} : { colours }),
459
+ ...vendorField(raw.brand),
442
460
  // A card stays on the product's published status, not on inventory: the availability read is
443
461
  // per *variant*, and a list row carries no variant at all (see `StorefrontProductListItem`), so
444
462
  // answering a grid from inventory would mean one product detail read per card. The product page
@@ -560,6 +578,7 @@ function mapProductDetails(
560
578
  url: `/products/${raw.slug}`,
561
579
  featuredImage: images[0] ?? null,
562
580
  images,
581
+ ...vendorField(raw.brand),
563
582
  price: {
564
583
  amount: firstAvailable?.price ?? minPrice,
565
584
  compareAt: firstAvailable?.compareAtPrice ?? null,
@@ -0,0 +1,76 @@
1
+ import type { Component } from 'vue';
2
+ import type { ProductCardPart } from '@eldrajs/ui';
3
+ import { iconComponent } from '../composables/iconComponent';
4
+
5
+ /**
6
+ * The theme's product card: how `collection-grid`, `product-carousel` and `search` all draw
7
+ * `@eldrajs/ui`'s `ProductCard`, restyled through its props and `classes`, never forked. One place,
8
+ * so the three blocks cannot drift apart the way three copies of a class map would.
9
+ *
10
+ * What it draws: the photo with a "New" (white) or "Sale" (accent) chip top-left and a "+ Add" pill
11
+ * bottom-right on it; under the photo the title and the price on one row (price right) once the
12
+ * block is wider than 760px, stacked on a phone; the maker in muted text; then a plain row of
13
+ * colour dots. No rating and no stock line. On a phone the pill is a round "+" alone, still named
14
+ * "Add <title> to cart". The title is not underlined until hover.
15
+ *
16
+ * The card root becomes a one-column grid so the pill can share the photo's grid cell without
17
+ * knowing its height. The `@min-[47.5625rem]` / `@max-[47.5rem]` breakpoints are container
18
+ * queries against the block, the same 760px line the rest of the theme switches at.
19
+ */
20
+
21
+ /** The card root: a one-column grid, photo in the first row. */
22
+ export const PRODUCT_CARD_CLASS = 'min-w-0 grid grid-cols-1 grid-rows-[auto_1fr] content-start';
23
+
24
+ /* Every class is written out in full, never assembled from pieces: Tailwind finds classes by
25
+ reading the source text, so a class put together from parts is a class it never generates. */
26
+
27
+ export const PRODUCT_CARD_CLASSES: Partial<Record<ProductCardPart, string>> = {
28
+ media: '[grid-area:1/1]',
29
+ // The design's badges have 0.25rem corners (`.nw-pc__badge`), tighter than the theme's `radius-sm`.
30
+ newBadge:
31
+ 'rounded-[0.25rem] border-transparent text-xs font-bold tracking-[0.04em] bg-background text-text',
32
+ saleBadge: 'rounded-[0.25rem] border-transparent text-xs font-bold tracking-[0.04em]',
33
+ soldOutBadge: 'rounded-[0.25rem] text-xs font-bold tracking-[0.04em]',
34
+ body:
35
+ '[grid-area:2/1] mt-3 grid grid-cols-1 content-start gap-0 ' +
36
+ '@min-[47.5625rem]:grid-cols-[minmax(0,1fr)_auto] @min-[47.5625rem]:items-baseline @min-[47.5625rem]:gap-x-3',
37
+ title: 'leading-[1.35] tracking-normal',
38
+ link:
39
+ 'no-underline hover:underline hover:decoration-1 hover:decoration-current ' +
40
+ 'hover:underline-offset-[0.2em]',
41
+ price: 'whitespace-nowrap [&>[data-part=root]]:text-base',
42
+ vendor: 'mt-1 text-sm leading-[1.6] tracking-normal @min-[47.5625rem]:col-span-2',
43
+ swatches: 'mt-3 @min-[47.5625rem]:col-span-2',
44
+ quickAdd:
45
+ '[grid-area:1/1] z-10 m-3 mt-0 self-end justify-self-end w-auto h-10 min-h-10 gap-1.5 [&_svg]:size-4 ' +
46
+ 'rounded-full border-0 bg-background px-3.5 text-sm font-semibold text-text ' +
47
+ 'shadow-[0_2px_8px_rgb(29_27_24/0.15)] hover:bg-text hover:text-background disabled:opacity-90 ' +
48
+ '@max-[47.5rem]:enabled:w-10 @max-[47.5rem]:enabled:min-w-10 @max-[47.5rem]:enabled:px-0 @max-[47.5rem]:enabled:justify-center',
49
+ quickAddLabel: '@max-[47.5rem]:hidden',
50
+ };
51
+
52
+ /** The pill's "+". */
53
+ const PlusIcon: Component = iconComponent('plus');
54
+
55
+ /** `vue-i18n`'s `t`, as much of it as this needs. */
56
+ type Translate = (key: string, values?: Record<string, unknown>) => string;
57
+
58
+ /**
59
+ * Every prop the theme sets on a `<ProductCard>`, for `v-bind`. The block still passes the
60
+ * product, ratio, heading level, link component, currency, locale and refresh state itself, and
61
+ * `showSwatches`/`quickAdd` where its own fields decide them.
62
+ */
63
+ export function productCardLook(t: Translate, title: string) {
64
+ return {
65
+ class: PRODUCT_CARD_CLASS,
66
+ classes: PRODUCT_CARD_CLASSES,
67
+ showVendor: true,
68
+ vendorPlacement: 'below' as const,
69
+ showRating: false,
70
+ maxSwatches: 6,
71
+ saleBadgeLabel: t('productCard.sale'),
72
+ quickAddLabel: t('productCard.add'),
73
+ quickAddName: t('productCard.addName', { title }),
74
+ quickAddIcon: PlusIcon,
75
+ };
76
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The handle a block's product `reference` field names, or `null`.
3
+ *
4
+ * Like a collection reference (`collectionSelector.ts`), the value takes three shapes: the public
5
+ * read resolves a stored `{ _type: 'product', id }` into the product, `slug` included; a theme's own
6
+ * seed is `{ _type: 'product', slug }`, which Core resolves on deploy; and at depth 0, or while the
7
+ * page builder shows an unsaved draft, it is the bare stub `{ _type: 'product', id }`. Only a slug is
8
+ * something every storefront can look up, so the stub names nothing yet. Field data is
9
+ * CMS-authored, so no key is assumed to be present.
10
+ */
11
+ export function productReferenceSlug(reference: unknown): string | null {
12
+ if (reference === null || typeof reference !== 'object') return null;
13
+ const { _type: type, slug } = reference as { _type?: unknown; slug?: unknown };
14
+ if (type !== undefined && type !== 'product') return null;
15
+ const trimmed = typeof slug === 'string' ? slug.trim() : '';
16
+ return trimmed === '' ? null : trimmed;
17
+ }
@@ -15,12 +15,16 @@ export type ProductCardSource = StorefrontProductListItem | StorefrontSearchProd
15
15
  * agree pixel for pixel — `ProductCard` is the shared cell every commerce block renders a product
16
16
  * with, always built by `toProductCard()`.
17
17
  *
18
- * `badge` is never read off the input — `ProductCardProduct.badge` is deliberately the caller's
19
- * own sale/new *decision*, not something the card re-derives, so this is the one place that
20
- * decision gets made for every commerce block: `{ variant: 'sale' }` exactly when
21
- * `compareAt > amount`, matching `Price`'s own sale rule verbatim. A future "New" tag (the spec's
22
- * `dto_ProductListItem` carries no such flag today) is a decision for whoever adds it, not this
23
- * function.
18
+ * `badge` is `ProductCardProduct.badge`, the caller's own sale/new *decision*, not something the
19
+ * card re-derives, so this is the one place that decision gets made for every commerce block:
20
+ * `{ variant: 'sale' }` exactly when `compareAt > amount`, matching `Price`'s own sale rule
21
+ * verbatim, else `{ variant: 'new' }` when the source marks the item `isNew` (the demo does; the
22
+ * platform's list read carries no such flag today).
23
+ *
24
+ * `vendor` (the brand) rides along for the maker line under the title. `stock` does not: the
25
+ * theme's card draws no stock line (the design shows none, and a list row's stock is only the
26
+ * published status anyway — see `gateway.ts`'s `mapProductListItem`); a sold-out product still
27
+ * reads as one through `available`.
24
28
  *
25
29
  * **Units.** Storefront money is major units (`types.ts`) and `ProductCardProduct.price` is minor
26
30
  * units, like every other `@eldrajs/ui` money input, so the two prices are converted on the way in.
@@ -81,10 +85,10 @@ export function toProductCard(
81
85
  from,
82
86
  },
83
87
  ...(notSoldIn === null ? {} : { notSoldIn }),
88
+ ...(item.vendor ? { vendor: item.vendor } : {}),
84
89
  rating: item.rating,
85
90
  colours: item.colours,
86
- badge: isSale ? { variant: 'sale' } : null,
87
- stock: item.stock,
91
+ badge: isSale ? { variant: 'sale' } : item.isNew === true ? { variant: 'new' } : null,
88
92
  available: item.available,
89
93
  };
90
94
  }
@@ -70,6 +70,11 @@ export interface StorefrontProductListItem {
70
70
  featuredImage?: StorefrontMedia | null;
71
71
  price: StorefrontPrice;
72
72
  rating?: { value: number; count: number } | null;
73
+ /**
74
+ * The product is new in: the card's "New" badge. The platform's list read carries no such flag
75
+ * today, so only the demo source sets it; absent reads as not new. A sale badge wins over it.
76
+ */
77
+ isNew?: boolean;
73
78
  /**
74
79
  * The dots a card shows under its image, in the store's own order.
75
80
  *
@@ -83,6 +88,12 @@ export interface StorefrontProductListItem {
83
88
  colours?: Array<{ name: string; swatch: string }>;
84
89
  stock: 'in' | 'low' | 'out' | 'preorder';
85
90
  available: boolean;
91
+ /**
92
+ * **Who made it** — the product's brand as the catalogue names it (the maker line above a product
93
+ * page's title, and under a card's). Absent when the product has no brand; never the shop's own
94
+ * name standing in for one.
95
+ */
96
+ vendor?: string;
86
97
  /**
87
98
  * The **catalog product's** id — what a volatile refresh addresses this row by
88
99
  * (`app/storefront/volatile.ts`) and what a cart add has to send as its `productId`.
@@ -632,6 +643,12 @@ export interface StorefrontResult<T> {
632
643
 
633
644
  /** A `reactive()` object: a block reads it, only the app layer writes it. */
634
645
  export interface StorefrontRoute {
646
+ /**
647
+ * The committed route's path, reactive across client-side navigations (the header marks its
648
+ * current entry from it). Absent or empty where there is no router (Storybook, a block spec); the
649
+ * header then reads `window.location`.
650
+ */
651
+ path?: string;
635
652
  productHandle: string | null;
636
653
  collectionHandle: string | null;
637
654
  /**