@eldrajs/theme-cli 0.2.8 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -1
- package/package.json +1 -1
- package/template/.eldra/block-types.d.ts +28 -7
- package/template/.eldra/manifest.json +1034 -355
- package/template/.eldra/previews.json +35 -35
- package/template/README.md +32 -0
- package/template/app/assets/main.css +23 -0
- package/template/app/plugins/eldra-storefront.ts +3 -0
- package/template/app/storefront/demo.ts +75 -24
- package/template/app/storefront/gateway.ts +16 -2
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/preview.json +4 -4
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/Block.vue +48 -19
- package/template/blocks/article-list/__tests__/Block.spec.ts +15 -0
- package/template/blocks/article-list/preview.json +43 -43
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/preview.png +0 -0
- package/template/blocks/collection-grid/Block.vue +260 -9
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +202 -0
- package/template/blocks/collection-grid/block.json +3 -3
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/Block.vue +82 -58
- package/template/blocks/collection-header/__tests__/Block.spec.ts +77 -1
- package/template/blocks/collection-header/preview.json +4 -4
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/preview.json +4 -4
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/Block.vue +73 -4
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +43 -1
- package/template/blocks/feature-grid/block.json +2 -2
- package/template/blocks/feature-grid/preview.json +49 -24
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +186 -71
- package/template/blocks/footer/__tests__/Block.spec.ts +127 -32
- package/template/blocks/footer/block.json +42 -4
- package/template/blocks/footer/mock.json +31 -34
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/preview.png +0 -0
- package/template/blocks/gallery/preview.json +24 -24
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +117 -19
- package/template/blocks/hero/__tests__/Block.spec.ts +46 -0
- package/template/blocks/hero/block.json +36 -1
- package/template/blocks/hero/preview.json +33 -25
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/preview.json +4 -4
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +623 -184
- package/template/blocks/navigation/__tests__/Block.spec.ts +416 -68
- package/template/blocks/navigation/__tests__/fixtures/menu.json +182 -0
- package/template/blocks/navigation/block.json +102 -6
- package/template/blocks/navigation/mock.json +279 -52
- package/template/blocks/navigation/preview.json +311 -0
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/Block.vue +248 -144
- package/template/blocks/newsletter/__tests__/Block.spec.ts +42 -0
- package/template/blocks/newsletter/block.json +61 -2
- package/template/blocks/newsletter/preview.json +35 -0
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/Block.vue +272 -26
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +90 -0
- package/template/blocks/product-carousel/block.json +61 -0
- package/template/blocks/product-carousel/preview.json +12 -0
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +148 -96
- package/template/blocks/product-detail/__tests__/Block.spec.ts +98 -74
- package/template/blocks/product-detail/block.json +11 -4
- package/template/blocks/product-detail/mock.json +53 -22
- package/template/blocks/product-detail/parts/Gallery.vue +52 -103
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/quote/preview.png +0 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/Block.vue +1 -0
- package/template/blocks/search/TypeSection.vue +1 -0
- package/template/blocks/search/__tests__/Block.spec.ts +23 -0
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/split-content/Block.vue +98 -20
- package/template/blocks/split-content/__tests__/Block.spec.ts +57 -18
- package/template/blocks/split-content/block.json +72 -6
- package/template/blocks/split-content/preview.json +34 -13
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/preview.json +16 -16
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/Block.vue +67 -1
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +30 -1
- package/template/blocks/trust-strip/block.json +4 -4
- package/template/blocks/trust-strip/preview.json +21 -0
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/i18n/en-US.json +16 -9
- package/template/i18n/is-IS.json +16 -9
- package/template/pages/article.page.json +19 -18
- package/template/pages/cart.page.json +3 -13
- package/template/pages/category.page.json +15 -7
- package/template/pages/collection.page.json +15 -14
- package/template/pages/home.page.json +217 -182
- package/template/pages/product.page.json +46 -36
- package/template/pages/products.page.json +3 -13
- package/template/pages/search.page.json +3 -13
- package/template/pages/wishlist.page.json +3 -13
- package/template/public/images/CREDITS.md +28 -0
- package/template/public/images/clay-hands.webp +0 -0
- package/template/public/images/coffee-table.webp +0 -0
- package/template/public/images/cup.webp +0 -0
- package/template/public/images/enamel-cups.webp +0 -0
- package/template/public/images/hero.webp +0 -0
- package/template/public/images/kitchen.webp +0 -0
- package/template/public/images/mug.webp +0 -0
- package/template/public/images/northwind-mark.svg +1 -0
- package/template/public/images/planters.webp +0 -0
- package/template/public/images/plates.webp +0 -0
- package/template/public/images/reading.webp +0 -0
- package/template/public/images/sweater.webp +0 -0
- package/template/public/images/terracotta.webp +0 -0
- package/template/public/images/throws.webp +0 -0
- package/template/public/images/vase.webp +0 -0
- package/template/public/images/wheel.webp +0 -0
- package/template/public/images/yarn-tools.webp +0 -0
- package/template/public/images/yarn.webp +0 -0
- package/template/stories/generated/collection-grid.stories.ts +6 -0
- package/template/stories/generated/feature-grid.stories.ts +6 -0
- package/template/stories/generated/footer.stories.ts +4 -4
- package/template/stories/generated/hero.stories.ts +6 -0
- package/template/stories/generated/navigation.stories.ts +14 -1
- package/template/stories/generated/newsletter.stories.ts +2 -1
- package/template/stories/generated/product-carousel.stories.ts +12 -0
- package/template/stories/generated/split-content.stories.ts +12 -0
- package/template/stories/generated/trust-strip.stories.ts +8 -1
- package/template/stories/pages/article.stories.ts +2 -1
- package/template/stories/pages/cart.stories.ts +2 -1
- package/template/stories/pages/category.stories.ts +2 -1
- package/template/stories/pages/collection.stories.ts +2 -1
- package/template/stories/pages/home.stories.ts +2 -1
- package/template/stories/pages/product.stories.ts +2 -1
- package/template/stories/pages/products.stories.ts +2 -1
- package/template/stories/pages/search.stories.ts +2 -1
- package/template/stories/pages/wishlist.stories.ts +2 -1
- package/template/stories/support/demoChrome.ts +32 -0
- package/template/stories/support/pageBlocks.ts +2 -4
- package/template/test/countPill.browser.spec.ts +21 -13
- package/template/test/localePrefix.spec.ts +11 -6
- package/template/test/pages/article.spec.ts +1 -1
- package/template/test/pages/category.spec.ts +34 -11
- package/template/test/pages/collection.spec.ts +182 -148
- package/template/test/pages/home.spec.ts +35 -40
- package/template/test/pages/hydration.spec.ts +4 -4
- package/template/test/pages/product.spec.ts +17 -14
- package/template/test/pages/seededPages.spec.ts +11 -6
- package/template/test/prerenderRefresh.browser.spec.ts +36 -15
- package/template/test/previewParity.browser.spec.ts +36 -2
- package/template/test/starter.spec.ts +31 -15
- package/template/test/storefront/gatewayPrerender.spec.ts +26 -0
- 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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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
|
|
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="
|
|
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
|
|
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="
|
|
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="
|
|
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": [
|
|
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": "/
|
|
5
|
-
"altText": "
|
|
6
|
-
"width":
|
|
7
|
-
"height":
|
|
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": "/
|
|
14
|
-
"altText": "
|
|
15
|
-
"width":
|
|
16
|
-
"height":
|
|
13
|
+
"url": "/images/bowl.webp",
|
|
14
|
+
"altText": "A dark stoneware serving bowl",
|
|
15
|
+
"width": 1120,
|
|
16
|
+
"height": 1400
|
|
17
17
|
},
|
|
18
|
-
"alt": "
|
|
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": "/
|
|
25
|
-
"altText": "
|
|
26
|
-
"width":
|
|
27
|
-
"height":
|
|
24
|
+
"url": "/images/mug.webp",
|
|
25
|
+
"altText": "A hand-painted stoneware mug",
|
|
26
|
+
"width": 1400,
|
|
27
|
+
"height": 934
|
|
28
28
|
},
|
|
29
|
-
"alt": "
|
|
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": "/
|
|
36
|
-
"altText": "
|
|
37
|
-
"width":
|
|
38
|
-
"height":
|
|
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": "
|
|
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": "/
|
|
47
|
-
"altText": "
|
|
48
|
-
"width":
|
|
49
|
-
"height":
|
|
46
|
+
"url": "/images/plates.webp",
|
|
47
|
+
"altText": "Stoneware dinner plates set on a table",
|
|
48
|
+
"width": 1400,
|
|
49
|
+
"height": 933
|
|
50
50
|
},
|
|
51
|
-
"alt": "
|
|
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": "/
|
|
5
|
-
"altText": "
|
|
6
|
-
"width":
|
|
7
|
-
"height":
|
|
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
|
|
Binary file
|