@eldrajs/theme-cli 0.2.7 → 0.2.9

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 +2 -0
  2. package/package.json +3 -3
  3. package/template/.eldra/block-types.d.ts +28 -7
  4. package/template/.eldra/manifest.json +1152 -445
  5. package/template/.eldra/previews.json +35 -35
  6. package/template/README.md +32 -0
  7. package/template/app/assets/main.css +23 -0
  8. package/template/app/plugins/eldra-storefront.ts +3 -0
  9. package/template/app/storefront/demo.ts +75 -24
  10. package/template/app/storefront/gateway.ts +16 -2
  11. package/template/blocks/announcement-bar/preview.png +0 -0
  12. package/template/blocks/article/preview.json +4 -4
  13. package/template/blocks/article/preview.png +0 -0
  14. package/template/blocks/article-list/Block.vue +48 -19
  15. package/template/blocks/article-list/__tests__/Block.spec.ts +15 -0
  16. package/template/blocks/article-list/preview.json +43 -43
  17. package/template/blocks/article-list/preview.png +0 -0
  18. package/template/blocks/breadcrumbs/preview.png +0 -0
  19. package/template/blocks/cart/preview.png +0 -0
  20. package/template/blocks/collection-grid/Block.vue +260 -9
  21. package/template/blocks/collection-grid/__tests__/Block.spec.ts +202 -0
  22. package/template/blocks/collection-grid/block.json +3 -3
  23. package/template/blocks/collection-grid/preview.png +0 -0
  24. package/template/blocks/collection-header/Block.vue +65 -52
  25. package/template/blocks/collection-header/preview.json +4 -4
  26. package/template/blocks/collection-header/preview.png +0 -0
  27. package/template/blocks/contact/preview.png +0 -0
  28. package/template/blocks/cta/preview.json +4 -4
  29. package/template/blocks/cta/preview.png +0 -0
  30. package/template/blocks/faq/preview.png +0 -0
  31. package/template/blocks/feature-grid/Block.vue +73 -4
  32. package/template/blocks/feature-grid/__tests__/Block.spec.ts +43 -1
  33. package/template/blocks/feature-grid/block.json +2 -2
  34. package/template/blocks/feature-grid/preview.json +49 -24
  35. package/template/blocks/feature-grid/preview.png +0 -0
  36. package/template/blocks/footer/Block.vue +186 -71
  37. package/template/blocks/footer/__tests__/Block.spec.ts +127 -32
  38. package/template/blocks/footer/block.json +42 -4
  39. package/template/blocks/footer/mock.json +31 -34
  40. package/template/blocks/footer/preview.png +0 -0
  41. package/template/blocks/form/preview.png +0 -0
  42. package/template/blocks/gallery/preview.json +24 -24
  43. package/template/blocks/gallery/preview.png +0 -0
  44. package/template/blocks/hero/Block.vue +117 -19
  45. package/template/blocks/hero/__tests__/Block.spec.ts +46 -0
  46. package/template/blocks/hero/block.json +36 -1
  47. package/template/blocks/hero/preview.json +33 -25
  48. package/template/blocks/hero/preview.png +0 -0
  49. package/template/blocks/image/preview.json +4 -4
  50. package/template/blocks/image/preview.png +0 -0
  51. package/template/blocks/logo-cloud/preview.png +0 -0
  52. package/template/blocks/navigation/Block.vue +665 -184
  53. package/template/blocks/navigation/__tests__/Block.spec.ts +496 -75
  54. package/template/blocks/navigation/__tests__/fixtures/menu.json +182 -0
  55. package/template/blocks/navigation/block.json +110 -6
  56. package/template/blocks/navigation/mock.json +372 -140
  57. package/template/blocks/navigation/preview.json +311 -0
  58. package/template/blocks/navigation/preview.png +0 -0
  59. package/template/blocks/newsletter/Block.vue +248 -144
  60. package/template/blocks/newsletter/__tests__/Block.spec.ts +42 -0
  61. package/template/blocks/newsletter/block.json +61 -2
  62. package/template/blocks/newsletter/preview.json +35 -0
  63. package/template/blocks/newsletter/preview.png +0 -0
  64. package/template/blocks/order-status/preview.png +0 -0
  65. package/template/blocks/pricing-table/preview.png +0 -0
  66. package/template/blocks/product-carousel/Block.vue +272 -26
  67. package/template/blocks/product-carousel/__tests__/Block.spec.ts +90 -0
  68. package/template/blocks/product-carousel/block.json +61 -0
  69. package/template/blocks/product-carousel/preview.json +12 -0
  70. package/template/blocks/product-carousel/preview.png +0 -0
  71. package/template/blocks/product-detail/Block.vue +148 -96
  72. package/template/blocks/product-detail/__tests__/Block.spec.ts +98 -74
  73. package/template/blocks/product-detail/block.json +11 -4
  74. package/template/blocks/product-detail/mock.json +53 -22
  75. package/template/blocks/product-detail/parts/Gallery.vue +52 -103
  76. package/template/blocks/product-detail/preview.png +0 -0
  77. package/template/blocks/quote/preview.png +0 -0
  78. package/template/blocks/rich-text/preview.png +0 -0
  79. package/template/blocks/search/Block.vue +1 -0
  80. package/template/blocks/search/TypeSection.vue +1 -0
  81. package/template/blocks/search/__tests__/Block.spec.ts +23 -0
  82. package/template/blocks/search/preview.png +0 -0
  83. package/template/blocks/split-content/Block.vue +98 -20
  84. package/template/blocks/split-content/__tests__/Block.spec.ts +57 -18
  85. package/template/blocks/split-content/block.json +72 -6
  86. package/template/blocks/split-content/preview.json +34 -13
  87. package/template/blocks/split-content/preview.png +0 -0
  88. package/template/blocks/stats/preview.png +0 -0
  89. package/template/blocks/tabs/preview.json +16 -16
  90. package/template/blocks/tabs/preview.png +0 -0
  91. package/template/blocks/team/preview.png +0 -0
  92. package/template/blocks/testimonials/preview.png +0 -0
  93. package/template/blocks/timeline/preview.png +0 -0
  94. package/template/blocks/trust-strip/Block.vue +67 -1
  95. package/template/blocks/trust-strip/__tests__/Block.spec.ts +30 -1
  96. package/template/blocks/trust-strip/block.json +4 -4
  97. package/template/blocks/trust-strip/preview.json +21 -0
  98. package/template/blocks/trust-strip/preview.png +0 -0
  99. package/template/blocks/video-embed/preview.png +0 -0
  100. package/template/blocks/wishlist/preview.png +0 -0
  101. package/template/i18n/en-US.json +16 -9
  102. package/template/i18n/is-IS.json +16 -9
  103. package/template/package.json +1 -1
  104. package/template/pages/article.page.json +19 -18
  105. package/template/pages/cart.page.json +3 -13
  106. package/template/pages/category.page.json +15 -7
  107. package/template/pages/collection.page.json +15 -14
  108. package/template/pages/home.page.json +217 -182
  109. package/template/pages/product.page.json +46 -36
  110. package/template/pages/products.page.json +3 -13
  111. package/template/pages/search.page.json +3 -13
  112. package/template/pages/wishlist.page.json +3 -13
  113. package/template/public/images/CREDITS.md +28 -0
  114. package/template/public/images/bowl.webp +0 -0
  115. package/template/public/images/clay-hands.webp +0 -0
  116. package/template/public/images/coffee-table.webp +0 -0
  117. package/template/public/images/cup.webp +0 -0
  118. package/template/public/images/enamel-cups.webp +0 -0
  119. package/template/public/images/hero.webp +0 -0
  120. package/template/public/images/kitchen.webp +0 -0
  121. package/template/public/images/mug.webp +0 -0
  122. package/template/public/images/northwind-mark.svg +1 -0
  123. package/template/public/images/planters.webp +0 -0
  124. package/template/public/images/plates.webp +0 -0
  125. package/template/public/images/reading.webp +0 -0
  126. package/template/public/images/sweater.webp +0 -0
  127. package/template/public/images/terracotta.webp +0 -0
  128. package/template/public/images/throws.webp +0 -0
  129. package/template/public/images/vase.webp +0 -0
  130. package/template/public/images/wheel.webp +0 -0
  131. package/template/public/images/yarn-tools.webp +0 -0
  132. package/template/public/images/yarn.webp +0 -0
  133. package/template/stories/generated/collection-grid.stories.ts +6 -0
  134. package/template/stories/generated/feature-grid.stories.ts +6 -0
  135. package/template/stories/generated/footer.stories.ts +4 -4
  136. package/template/stories/generated/hero.stories.ts +6 -0
  137. package/template/stories/generated/navigation.stories.ts +14 -1
  138. package/template/stories/generated/newsletter.stories.ts +2 -1
  139. package/template/stories/generated/product-carousel.stories.ts +12 -0
  140. package/template/stories/generated/split-content.stories.ts +12 -0
  141. package/template/stories/generated/trust-strip.stories.ts +8 -1
  142. package/template/stories/pages/article.stories.ts +2 -1
  143. package/template/stories/pages/cart.stories.ts +2 -1
  144. package/template/stories/pages/category.stories.ts +2 -1
  145. package/template/stories/pages/collection.stories.ts +2 -1
  146. package/template/stories/pages/home.stories.ts +2 -1
  147. package/template/stories/pages/product.stories.ts +2 -1
  148. package/template/stories/pages/products.stories.ts +2 -1
  149. package/template/stories/pages/search.stories.ts +2 -1
  150. package/template/stories/pages/wishlist.stories.ts +2 -1
  151. package/template/stories/support/demoChrome.ts +32 -0
  152. package/template/stories/support/pageBlocks.ts +2 -4
  153. package/template/test/countPill.browser.spec.ts +21 -13
  154. package/template/test/localePrefix.spec.ts +11 -6
  155. package/template/test/pages/article.spec.ts +1 -1
  156. package/template/test/pages/category.spec.ts +34 -11
  157. package/template/test/pages/collection.spec.ts +182 -148
  158. package/template/test/pages/home.spec.ts +35 -40
  159. package/template/test/pages/hydration.spec.ts +4 -4
  160. package/template/test/pages/product.spec.ts +17 -14
  161. package/template/test/pages/seededPages.spec.ts +11 -6
  162. package/template/test/prerenderFailure.spec.ts +4 -3
  163. package/template/test/prerenderRefresh.browser.spec.ts +36 -15
  164. package/template/test/previewParity.browser.spec.ts +1152 -0
  165. package/template/test/starter.spec.ts +37 -16
  166. package/template/test/storefront/gatewayPrerender.spec.ts +26 -0
  167. package/template/test/support/previewParity.ts +302 -0
  168. package/template/test/support/previewParityContent.ts +726 -0
  169. package/template/tokens.json +13 -13
@@ -15,6 +15,13 @@
15
15
  * - `centered`: centred copy above a wide image (4:3 → 21:9 → 3:1).
16
16
  * - `split-carousel`: copy in a `5fr` column beside `@eldrajs/ui`'s `Carousel` in `7fr`, one 4:5
17
17
  * slide per `slides[]` item.
18
+ * - `card`: one wide photo (21:9) with the copy on a `background` card overlapping its
19
+ * bottom-left corner, and an optional small caption link on the photo (`captionLabel`,
20
+ * `captionDetail`, `captionHref` — "Glazed milk jug $34", a shoppable caption). Below 1101px
21
+ * of block width the card leaves the photo and sits under it, pulled up over its bottom edge
22
+ * (16:10 photo; 4:5 below 761px), and the caption moves to the photo's top-right corner. The
23
+ * copy comes before the photo in the DOM, so the heading is still the first thing read; `order`
24
+ * puts the photo above it, and from 1101px the card is positioned over the photo.
18
25
  *
19
26
  * The copy (eyebrow, heading, subheading, buttons) is the same shape in every variant, so it is
20
27
  * written once below; only the surrounding grid/flex wrapper and the media alongside it differ per
@@ -35,6 +42,7 @@ import { useUiId } from '../../app/composables/useUiId';
35
42
  import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
36
43
  import { isInternalHref, safeHref } from '../../app/utils/links';
37
44
  import UiImage from '../../app/components/ui/UiImage.vue';
45
+ import EldraIcon from '../../app/components/EldraIcon.vue';
38
46
 
39
47
  const props = defineProps<{ entry: EldraBlockEntry<'hero'> }>();
40
48
  const { data, entryId } = useBlockData(props, 'hero');
@@ -50,6 +58,7 @@ const isImageColumnVariant = computed(
50
58
  const isImageBackground = computed(() => variant.value === 'image-background');
51
59
  const isCentered = computed(() => variant.value === 'centered');
52
60
  const isSplitCarousel = computed(() => variant.value === 'split-carousel');
61
+ const isCard = computed(() => variant.value === 'card');
53
62
 
54
63
  const hasImage = computed(() => Boolean(data.value.image));
55
64
  /** `image-background` only gets the scrim + inverted copy once there is an actual image to scrim
@@ -82,11 +91,16 @@ const sectionBackground = computed<SectionBackground>(() => {
82
91
  /** `image-background` sets its own padding (`outerClass` below) instead of the `spacing` field's
83
92
  * section padding. */
84
93
  const sectionSpacing = computed<SectionSpacing>(() =>
85
- isImageBackground.value ? 'none' : (data.value.spacing ?? 'md')
86
- );
87
- const sectionRootClass = computed(() =>
88
- isImageBackground.value ? 'relative overflow-hidden' : ''
94
+ isImageBackground.value || isCard.value ? 'none' : (data.value.spacing ?? 'md')
89
95
  );
96
+ /** `card` sits close under the header (1.5rem, 0.75rem below 761px) and keeps a `section-sm` step
97
+ * below it, so a following block on the same ground — whose top padding the package drops for
98
+ * adjacent same-ground sections — still starts a step clear of the photo. */
99
+ const sectionRootClass = computed(() => {
100
+ if (isImageBackground.value) return 'relative overflow-hidden';
101
+ if (isCard.value) return 'pt-3 @min-[47.5625rem]:pt-6 pb-[var(--eldra-section-sm)]';
102
+ return '';
103
+ });
90
104
  const containerWidth = computed(() => (isCentered.value ? 'content' : 'wide'));
91
105
 
92
106
  /**
@@ -123,13 +137,32 @@ const outerClass = computed(() => {
123
137
  'pt-[var(--eldra-section-md)] pb-12 @content:pt-[7rem] @content:pb-16'
124
138
  );
125
139
  }
140
+ if (isCard.value) {
141
+ // A column below 1101px (the photo, then the card pulled up over its bottom edge); from there
142
+ // a plain block, the photo in flow and the card positioned over it.
143
+ return hasImage.value ? 'relative flex flex-col @min-[68.8125rem]:block' : '';
144
+ }
126
145
  return ''; // centered
127
146
  });
128
147
 
129
148
  /** Copy column max-width: 36rem alongside media, 44rem when there is nothing beside it to share
130
149
  * the row with (spec "Hero" → States, "No image" row); `centered` always uses its own 44rem,
131
150
  * centred as a block. */
151
+ const CARD_COPY_CLASS =
152
+ 'bg-background rounded-lg shadow-float px-5 py-6 @min-[47.5625rem]:px-10 @min-[47.5625rem]:py-9';
153
+ /** Over the photo from 1101px: bottom-left, 3rem in, at most 30rem wide. Below that the card is in
154
+ * flow under the photo and pulled up over it (4rem, with 0.75rem sides, below 761px; 3rem with
155
+ * 1rem sides above). With no photo yet it is just the card. */
156
+ const CARD_PLACEMENT_CLASS =
157
+ 'relative z-[1] order-2 -mt-16 mx-3 @min-[47.5625rem]:-mt-12 @min-[47.5625rem]:mx-4 ' +
158
+ '@min-[68.8125rem]:absolute @min-[68.8125rem]:left-12 @min-[68.8125rem]:bottom-12 ' +
159
+ '@min-[68.8125rem]:m-0 @min-[68.8125rem]:max-w-[30rem]';
132
160
  const copyClass = computed(() => {
161
+ if (isCard.value) {
162
+ return hasImage.value
163
+ ? `${CARD_COPY_CLASS} ${CARD_PLACEMENT_CLASS}`
164
+ : `${CARD_COPY_CLASS} max-w-[36rem]`;
165
+ }
133
166
  if (isCentered.value) return 'mx-auto max-w-[44rem] text-center';
134
167
  if (isImageColumnVariant.value) return hasImage.value ? 'max-w-[36rem]' : 'max-w-[44rem]';
135
168
  return 'max-w-[36rem]';
@@ -143,11 +176,40 @@ const copyOrderClass = computed(() =>
143
176
  const imageOrderClass = computed(() =>
144
177
  isImageRight.value ? 'order-1 @content:order-2' : 'order-1'
145
178
  );
146
- const buttonsRowClass = computed(() =>
147
- isCentered.value
148
- ? 'flex flex-col items-center gap-3 @tablet:flex-row @tablet:justify-center'
149
- : 'flex flex-col gap-3 @tablet:flex-row @tablet:items-center'
179
+ const buttonsRowClass = computed(() => {
180
+ if (isCard.value) return 'mt-6 flex flex-wrap gap-3';
181
+ return isCentered.value
182
+ ? 'mt-3 flex flex-col items-center gap-3 @tablet:flex-row @tablet:justify-center'
183
+ : 'mt-3 flex flex-col gap-3 @tablet:flex-row @tablet:items-center';
184
+ });
185
+ /** `card` buttons keep their own width and wrap; full width only on the narrowest phones. */
186
+ const buttonWidthClass = computed(() =>
187
+ isCard.value ? '@min-[22.5rem]:w-auto w-full' : '@tablet:w-auto w-full'
188
+ );
189
+
190
+ /** `card`'s heading is the design's lighter display serif: 2rem on the narrowest phones, 2.25rem
191
+ * up to 760px, 3.25rem from there. */
192
+ const headingClass = computed(() =>
193
+ isCard.value
194
+ ? 'font-heading text-[2rem] @min-[22.5rem]:text-[2.25rem] @min-[47.5625rem]:text-[3.25rem] leading-[1.02] font-medium tracking-[-0.01em] text-balance'
195
+ : 'font-heading @tablet:text-[3.5rem] text-[2.5rem] leading-[1.05] font-bold tracking-[-0.02em] text-balance'
196
+ );
197
+ const eyebrowSpacingClass = computed(() => (isCard.value ? 'mb-2' : 'mb-4'));
198
+ const subheadingClass = computed(() =>
199
+ isCard.value
200
+ ? 'mt-3.5 text-[1.125rem] leading-[1.6] text-pretty'
201
+ : 'text-body-lg mt-5 max-w-[34rem] text-pretty'
202
+ );
203
+
204
+ const captionLabel = computed(() => (data.value.captionLabel ?? '').trim());
205
+ const captionDetail = computed(() => (data.value.captionDetail ?? '').trim());
206
+ const captionHref = computed(() => safeHref(data.value.captionHref));
207
+ /** The caption is a link or nothing: a label with no destination would be a pill that looks
208
+ * clickable and is not. */
209
+ const hasCaption = computed(
210
+ () => isCard.value && hasImage.value && captionLabel.value !== '' && captionHref.value !== null
150
211
  );
212
+ const captionLinkAs = computed(() => routerLinkAs(captionHref.value));
151
213
  const carouselAriaLabel = computed(() => data.value.heading || t('hero.carouselFallback'));
152
214
  /** Bound below as `:ariaLabel` (camelCase), not this file's usual `:aria-label`: Vue's template
153
215
  * compiler passes a bound attribute's name through unchanged (the kebab→camel prop match is a
@@ -214,14 +276,14 @@ function slideAlt(slide: { alt?: string; image?: { altText?: string | null } }):
214
276
  <Container :width="containerWidth">
215
277
  <div :class="outerClass">
216
278
  <div :class="[copyClass, copyOrderClass]">
217
- <p v-if="data.eyebrow" class="text-overline mb-4" :class="eyebrowColorClass">
279
+ <p
280
+ v-if="data.eyebrow"
281
+ class="text-overline"
282
+ :class="[eyebrowColorClass, eyebrowSpacingClass]"
283
+ >
218
284
  {{ data.eyebrow }}
219
285
  </p>
220
- <h1
221
- v-if="data.heading"
222
- :id="headingId"
223
- class="font-heading @tablet:text-[3.5rem] text-[2.5rem] leading-[1.05] font-bold tracking-[-0.02em] text-balance"
224
- >
286
+ <h1 v-if="data.heading" :id="headingId" :class="headingClass">
225
287
  {{ data.heading }}
226
288
  </h1>
227
289
  <EditorPlaceholder
@@ -233,8 +295,7 @@ function slideAlt(slide: { alt?: string; image?: { altText?: string | null } }):
233
295
 
234
296
  <p
235
297
  v-if="data.subheading"
236
- class="text-body-lg mt-5 max-w-[34rem] text-pretty"
237
- :class="[subheadingColorClass, isCentered ? 'mx-auto' : '']"
298
+ :class="[subheadingClass, subheadingColorClass, isCentered ? 'mx-auto' : '']"
238
299
  >
239
300
  {{ data.subheading }}
240
301
  </p>
@@ -245,7 +306,7 @@ function slideAlt(slide: { alt?: string; image?: { altText?: string | null } }):
245
306
  :label="t('hero.subheadingHintLabel')"
246
307
  />
247
308
 
248
- <div class="mt-3" :class="buttonsRowClass">
309
+ <div :class="buttonsRowClass">
249
310
  <slot name="actions">
250
311
  <Button
251
312
  v-if="hasPrimaryCta"
@@ -253,7 +314,7 @@ function slideAlt(slide: { alt?: string; image?: { altText?: string | null } }):
253
314
  :as="primaryLinkAs"
254
315
  size="lg"
255
316
  variant="primary"
256
- class="@tablet:w-auto w-full"
317
+ :class="buttonWidthClass"
257
318
  >
258
319
  {{ data.primaryCtaLabel }}
259
320
  </Button>
@@ -263,7 +324,7 @@ function slideAlt(slide: { alt?: string; image?: { altText?: string | null } }):
263
324
  :as="secondaryLinkAs"
264
325
  size="lg"
265
326
  variant="outline"
266
- class="@tablet:w-auto w-full"
327
+ :class="buttonWidthClass"
267
328
  >
268
329
  {{ data.secondaryCtaLabel }}
269
330
  </Button>
@@ -321,6 +382,43 @@ function slideAlt(slide: { alt?: string; image?: { altText?: string | null } }):
321
382
  />
322
383
  </template>
323
384
 
385
+ <!-- card: the photo (above the card below 1101px, behind it from there) and its caption -->
386
+ <template v-else-if="isCard">
387
+ <div v-if="hasImage" class="relative order-1">
388
+ <UiImage
389
+ :src="data.image!.url"
390
+ :alt="data.image!.altText ?? ''"
391
+ :framing="framing"
392
+ :entry-id="entryId"
393
+ field-path="image"
394
+ rounded="xl"
395
+ :classes="{
396
+ frame:
397
+ 'aspect-[4/5]! @min-[47.5625rem]:aspect-[16/10]! @min-[68.8125rem]:aspect-[21/9]!',
398
+ }"
399
+ class="w-full"
400
+ />
401
+ <Link
402
+ v-if="hasCaption"
403
+ :href="captionHref!"
404
+ :as="captionLinkAs"
405
+ :underline="false"
406
+ :classes="{ label: 'inline-flex min-w-0 items-center gap-2' }"
407
+ class="bg-background/90 text-text hover:bg-background absolute top-5 right-5 inline-flex max-w-[calc(100%-2.5rem)] items-center gap-2 rounded-full px-3.5 py-2 text-sm font-semibold @min-[68.8125rem]:top-auto @min-[68.8125rem]:bottom-5"
408
+ >
409
+ <span class="truncate">{{ captionLabel }}</span>
410
+ <span v-if="captionDetail" class="text-muted font-normal">{{ captionDetail }}</span>
411
+ <EldraIcon name="arrow-right" size="md" class="shrink-0" />
412
+ </Link>
413
+ </div>
414
+ <EditorPlaceholder
415
+ v-else-if="editing"
416
+ inline
417
+ :label="t('hero.imageHintLabel')"
418
+ class="bg-surface-strong mt-6 aspect-[4/5] w-full rounded-xl @min-[47.5625rem]:aspect-[16/10] @min-[68.8125rem]:aspect-[21/9]"
419
+ />
420
+ </template>
421
+
324
422
  <!-- split-carousel -->
325
423
  <template v-else-if="isSplitCarousel">
326
424
  <Carousel
@@ -19,6 +19,7 @@ const VARIANTS = [
19
19
  'image-background',
20
20
  'centered',
21
21
  'split-carousel',
22
+ 'card',
22
23
  ] as const;
23
24
 
24
25
  describe('hero block', () => {
@@ -77,6 +78,51 @@ describe('hero block', () => {
77
78
  }
78
79
  );
79
80
 
81
+ describe('card variant', () => {
82
+ const card = { ...withImage, variant: 'card' };
83
+
84
+ it('renders the heading before the photo in the DOM, and the photo as a 21:9 frame from 1101px', () => {
85
+ const wrapper = mount(Block, mountOptions({ entry: { id: 'e1', data: card } }));
86
+ const html = wrapper.html();
87
+ expect(html.indexOf('<h1')).toBeLessThan(html.indexOf('<img'));
88
+ const frame = wrapper.get('[data-part="frame"]');
89
+ expect(frame.classes()).toContain('@min-[68.8125rem]:aspect-[21/9]!');
90
+ });
91
+
92
+ it('renders the caption as one same-site link naming the item and its detail', () => {
93
+ const wrapper = mount(Block, mountOptions({ entry: { id: 'e1', data: card } }));
94
+ const caption = wrapper
95
+ .findAll('a')
96
+ .find((link) => link.text().includes(withImage.captionLabel));
97
+ expect(caption).toBeDefined();
98
+ expect(caption!.text()).toContain(withImage.captionDetail);
99
+ expect(caption!.attributes('href')).toBe(withImage.captionHref);
100
+ });
101
+
102
+ it('renders no caption without a link, and none in the other variants', () => {
103
+ const noHref = mount(
104
+ Block,
105
+ mountOptions({ entry: { id: 'e1', data: { ...card, captionHref: '' } } })
106
+ );
107
+ expect(noHref.text()).not.toContain(withImage.captionLabel);
108
+ const imageRight = mount(
109
+ Block,
110
+ mountOptions({ entry: { id: 'e1', data: { ...card, variant: 'image-right' } } })
111
+ );
112
+ expect(imageRight.text()).not.toContain(withImage.captionLabel);
113
+ });
114
+
115
+ it('drops an unsafe caption link', () => {
116
+ const wrapper = mount(
117
+ Block,
118
+ mountOptions({
119
+ entry: { id: 'e1', data: { ...card, captionHref: 'javascript:alert(1)' } },
120
+ })
121
+ );
122
+ expect(wrapper.text()).not.toContain(withImage.captionLabel);
123
+ });
124
+ });
125
+
80
126
  it('carries the framing marker attributes on the rendered image (image-right)', () => {
81
127
  const wrapper = mount(
82
128
  Block,
@@ -26,7 +26,14 @@
26
26
  "groupId": "content",
27
27
  "validators": { "required": true },
28
28
  "metadata": {
29
- "options": ["image-right", "image-left", "image-background", "centered", "split-carousel"]
29
+ "options": [
30
+ "image-right",
31
+ "image-left",
32
+ "image-background",
33
+ "centered",
34
+ "split-carousel",
35
+ "card"
36
+ ]
30
37
  }
31
38
  },
32
39
  {
@@ -100,6 +107,34 @@
100
107
  }
101
108
  }
102
109
  },
110
+ {
111
+ "fieldId": "captionLabel",
112
+ "name": "Image caption",
113
+ "type": "string",
114
+ "groupId": "content",
115
+ "localized": true,
116
+ "helpText": "A small link on the photo naming what is in it, e.g. \"Glazed milk jug\". Card variant only.",
117
+ "showWhen": { "field": "variant", "in": ["card"] },
118
+ "validators": { "maxLength": 60 }
119
+ },
120
+ {
121
+ "fieldId": "captionDetail",
122
+ "name": "Image caption detail",
123
+ "type": "string",
124
+ "groupId": "content",
125
+ "localized": true,
126
+ "helpText": "Shown after the caption in a lighter weight, e.g. the price.",
127
+ "showWhen": { "field": "variant", "in": ["card"] },
128
+ "validators": { "maxLength": 30 }
129
+ },
130
+ {
131
+ "fieldId": "captionHref",
132
+ "name": "Image caption link",
133
+ "type": "string",
134
+ "groupId": "content",
135
+ "helpText": "Where the caption goes, usually the product in the photo. No link, no caption.",
136
+ "showWhen": { "field": "variant", "in": ["card"] }
137
+ },
103
138
  {
104
139
  "fieldId": "spacing",
105
140
  "name": "Spacing",
@@ -1,55 +1,63 @@
1
1
  {
2
2
  "image": {
3
3
  "assetId": "demo-hero",
4
- "url": "/demo/hero.svg",
5
- "altText": "Speckled stoneware serving bowl on a linen cloth",
6
- "width": 1600,
7
- "height": 1000
4
+ "url": "/images/hero.webp",
5
+ "altText": "Rows of pale green and white ceramic bottles",
6
+ "width": 1400,
7
+ "height": 933
8
8
  },
9
9
  "slides": [
10
10
  {
11
11
  "image": {
12
12
  "assetId": "demo-hero-slide-1",
13
- "url": "/demo/hero-slide-1.svg",
14
- "altText": "Terracotta serving bowl",
15
- "width": 1200,
16
- "height": 1500
13
+ "url": "/images/bowl.webp",
14
+ "altText": "A dark stoneware serving bowl",
15
+ "width": 1120,
16
+ "height": 1400
17
17
  },
18
- "alt": "Terracotta serving bowl",
18
+ "alt": "A dark stoneware serving bowl",
19
19
  "href": "/products/serving-bowl"
20
20
  },
21
21
  {
22
22
  "image": {
23
23
  "assetId": "demo-hero-slide-2",
24
- "url": "/demo/hero-slide-2.svg",
25
- "altText": "Sage glazed mug",
26
- "width": 1200,
27
- "height": 1500
24
+ "url": "/images/mug.webp",
25
+ "altText": "A hand-painted stoneware mug",
26
+ "width": 1400,
27
+ "height": 934
28
28
  },
29
- "alt": "Sage glazed mug",
29
+ "alt": "A hand-painted stoneware mug",
30
30
  "href": "/products/latte-mug"
31
31
  },
32
32
  {
33
33
  "image": {
34
34
  "assetId": "demo-hero-slide-3",
35
- "url": "/demo/hero-slide-3.svg",
36
- "altText": "Folded linen napkins",
37
- "width": 1200,
38
- "height": 1500
35
+ "url": "/images/cup.webp",
36
+ "altText": "A gingham linen napkin under a teal mug",
37
+ "width": 1400,
38
+ "height": 952
39
39
  },
40
- "alt": "Folded linen napkins",
40
+ "alt": "A gingham linen napkin under a teal mug",
41
41
  "href": "/products/linen-napkins"
42
42
  },
43
43
  {
44
44
  "image": {
45
45
  "assetId": "demo-hero-slide-4",
46
- "url": "/demo/hero-slide-4.svg",
47
- "altText": "Grey stoneware plates",
48
- "width": 1200,
49
- "height": 1500
46
+ "url": "/images/plates.webp",
47
+ "altText": "Stoneware dinner plates set on a table",
48
+ "width": 1400,
49
+ "height": 933
50
50
  },
51
- "alt": "Grey stoneware plates",
51
+ "alt": "Stoneware dinner plates set on a table",
52
52
  "href": "/products/dinner-plates"
53
53
  }
54
- ]
54
+ ],
55
+ "captionLabel": "Glazed milk jug",
56
+ "captionDetail": "$34",
57
+ "captionHref": "/products/glazed-milk-jug",
58
+ "primaryCtaHref": "/collections/the-winter-edit",
59
+ "secondaryCtaLabel": "Meet the makers",
60
+ "secondaryCtaHref": "/pages/makers",
61
+ "subheading": "Stoneware, knitwear and kitchen goods from small workshops, chosen to be used every day and kept for years.",
62
+ "eyebrow": "New this season"
55
63
  }
Binary file
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "image": {
3
3
  "assetId": "demo-gallery-4",
4
- "url": "/demo/gallery-4.svg",
5
- "altText": "Linen tea towels drying on a line in the courtyard of the Porto mill",
6
- "width": 1600,
7
- "height": 1000
4
+ "url": "/images/coffee-table.webp",
5
+ "altText": "A polka-dot mug of coffee with biscuits",
6
+ "width": 1400,
7
+ "height": 933
8
8
  }
9
9
  }
Binary file