@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.
- package/CHANGELOG.md +2 -0
- package/package.json +3 -3
- package/template/.eldra/block-types.d.ts +28 -7
- package/template/.eldra/manifest.json +1152 -445
- 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 +65 -52
- 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 +665 -184
- package/template/blocks/navigation/__tests__/Block.spec.ts +496 -75
- package/template/blocks/navigation/__tests__/fixtures/menu.json +182 -0
- package/template/blocks/navigation/block.json +110 -6
- package/template/blocks/navigation/mock.json +372 -140
- 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/package.json +1 -1
- 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/bowl.webp +0 -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/prerenderFailure.spec.ts +4 -3
- package/template/test/prerenderRefresh.browser.spec.ts +36 -15
- package/template/test/previewParity.browser.spec.ts +1152 -0
- package/template/test/starter.spec.ts +37 -16
- package/template/test/storefront/gatewayPrerender.spec.ts +26 -0
- package/template/test/support/previewParity.ts +302 -0
- package/template/test/support/previewParityContent.ts +726 -0
- package/template/tokens.json +13 -13
|
@@ -4,8 +4,15 @@
|
|
|
4
4
|
* states (spec `02-blocks.md` "Newsletter", lines 1645–1762). Use it once per page. `variant`:
|
|
5
5
|
* - `centered` (default): everything centred in a 36rem column; the form's own text (label,
|
|
6
6
|
* error, consent) stays left-aligned so it lines up with the field.
|
|
7
|
-
* - `split`:
|
|
8
|
-
*
|
|
7
|
+
* - `split`: a rounded band (`radius-xl`) of two equal panels from 961px of block width, stacked
|
|
8
|
+
* below that. The right panel is the sign-up on `primary` — it carries `data-section="primary"`,
|
|
9
|
+
* the package's own inversion signal, so `Button` and links invert exactly as on a primary
|
|
10
|
+
* `Section` — and the left panel, on `surface-strong`, is either a **help panel**
|
|
11
|
+
* (`helpHeading`, `helpText` and up to four `contacts` lines: an icon, a label that may be a
|
|
12
|
+
* link, and a note in `success` green such as opening hours) when `helpHeading` is set, or the
|
|
13
|
+
* block's own heading and text, with the form alone on the right. The help panel comes first in
|
|
14
|
+
* the DOM, so its heading is the first one read; the block's `<section>` stays labelled by the
|
|
15
|
+
* newsletter heading. Unset, the section ground is `none` here (the band brings its own colours).
|
|
9
16
|
*
|
|
10
17
|
* **The field-row / checkbox / button / consent order** is one CSS grid (`@two-col`, the package's
|
|
11
18
|
* own 36rem container-query token — the same breakpoint `FormLayout`'s own two-column layout uses)
|
|
@@ -65,6 +72,7 @@ import {
|
|
|
65
72
|
FieldWrapper,
|
|
66
73
|
FormLayout,
|
|
67
74
|
Input,
|
|
75
|
+
Link,
|
|
68
76
|
Section,
|
|
69
77
|
type FormLayoutSubmitPayload,
|
|
70
78
|
type SectionBackground,
|
|
@@ -78,6 +86,8 @@ import { useStorefront } from '../../app/composables/useStorefront';
|
|
|
78
86
|
import { useI18n } from 'vue-i18n';
|
|
79
87
|
import { useUiId } from '../../app/composables/useUiId';
|
|
80
88
|
import EldraIcon from '../../app/components/EldraIcon.vue';
|
|
89
|
+
import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
|
|
90
|
+
import { isInternalHref, safeHref } from '../../app/utils/links';
|
|
81
91
|
import FormHoneypot from '../../app/components/FormHoneypot.vue';
|
|
82
92
|
|
|
83
93
|
const props = defineProps<{ entry: EldraBlockEntry<'newsletter'> }>();
|
|
@@ -107,12 +117,45 @@ const variant = computed<Variant>(() => data.value.variant ?? 'centered');
|
|
|
107
117
|
const isSplit = computed(() => variant.value === 'split');
|
|
108
118
|
|
|
109
119
|
const sectionBackground = computed<SectionBackground>(
|
|
110
|
-
() => data.value.sectionBackground ?? 'surface'
|
|
120
|
+
() => data.value.sectionBackground ?? (isSplit.value ? 'none' : 'surface')
|
|
111
121
|
);
|
|
112
|
-
|
|
113
|
-
|
|
122
|
+
|
|
123
|
+
/* ---------------------------------------------------------------------- */
|
|
124
|
+
/* The split band's help panel */
|
|
125
|
+
/* ---------------------------------------------------------------------- */
|
|
126
|
+
|
|
127
|
+
const helpHeading = computed(() => (isSplit.value ? (data.value.helpHeading ?? '').trim() : ''));
|
|
128
|
+
const hasHelp = computed(() => helpHeading.value !== '');
|
|
129
|
+
const helpText = computed(() => (data.value.helpText ?? '').trim());
|
|
130
|
+
const helpHeadingId = `newsletter-help-heading-${useUiId()}`;
|
|
131
|
+
const contacts = computed(() =>
|
|
132
|
+
(data.value.contacts ?? [])
|
|
133
|
+
.map((line) => {
|
|
134
|
+
const href = safeHref(line.href);
|
|
135
|
+
return {
|
|
136
|
+
icon: line.icon || undefined,
|
|
137
|
+
label: (line.label ?? '').trim(),
|
|
138
|
+
note: (line.note ?? '').trim(),
|
|
139
|
+
href,
|
|
140
|
+
linkAs: href !== null && isInternalHref(href) ? EldraRouterLink : undefined,
|
|
141
|
+
};
|
|
142
|
+
})
|
|
143
|
+
.filter((line) => line.label !== '')
|
|
144
|
+
.slice(0, 4)
|
|
114
145
|
);
|
|
115
146
|
|
|
147
|
+
/** Which ground each part sits on: the copy and the form follow the section's own background,
|
|
148
|
+
* except in `split`, where the band's panels decide — the form is always on `primary`, the copy on
|
|
149
|
+
* `primary` beside a help panel and on `surface-strong` without one. */
|
|
150
|
+
const formGround = computed<SectionBackground>(() =>
|
|
151
|
+
isSplit.value ? 'primary' : sectionBackground.value
|
|
152
|
+
);
|
|
153
|
+
const copyGround = computed<SectionBackground>(() => {
|
|
154
|
+
if (!isSplit.value) return sectionBackground.value;
|
|
155
|
+
return hasHelp.value ? 'primary' : 'surface-strong';
|
|
156
|
+
});
|
|
157
|
+
const isInverted = computed(() => formGround.value === 'primary' || formGround.value === 'accent');
|
|
158
|
+
|
|
116
159
|
const heading = computed(() => (data.value.heading ?? '').trim());
|
|
117
160
|
const text = computed(() => (data.value.text ?? '').trim());
|
|
118
161
|
const fieldLabelText = computed(() => data.value.fieldLabel || t('newsletter.emailLabel'));
|
|
@@ -135,20 +178,20 @@ const showTextHint = computed(() => isEditing.value && text.value === '');
|
|
|
135
178
|
* reads `muted` on those two backgrounds. `undefined` on every other ground leaves the package's
|
|
136
179
|
* own default (`text-text`) in place. */
|
|
137
180
|
const contrastTextClass = computed<string | undefined>(() => {
|
|
138
|
-
if (
|
|
139
|
-
if (
|
|
181
|
+
if (formGround.value === 'primary') return 'text-primary-contrast';
|
|
182
|
+
if (formGround.value === 'accent') return 'text-accent-contrast';
|
|
140
183
|
return undefined;
|
|
141
184
|
});
|
|
142
185
|
const mutedToneClass = computed(() => {
|
|
143
|
-
if (
|
|
144
|
-
if (
|
|
186
|
+
if (copyGround.value === 'primary') return 'text-primary-contrast/90';
|
|
187
|
+
if (copyGround.value === 'accent') return 'text-accent-contrast/90';
|
|
145
188
|
return 'text-muted';
|
|
146
189
|
});
|
|
147
190
|
const consentToneClass = computed(() => {
|
|
148
|
-
if (
|
|
191
|
+
if (formGround.value === 'primary') {
|
|
149
192
|
return 'text-primary-contrast/90 [&_a]:text-primary-contrast';
|
|
150
193
|
}
|
|
151
|
-
if (
|
|
194
|
+
if (formGround.value === 'accent') {
|
|
152
195
|
return 'text-accent-contrast/90 [&_a]:text-accent-contrast';
|
|
153
196
|
}
|
|
154
197
|
return 'text-muted [&_a]:text-muted';
|
|
@@ -164,14 +207,47 @@ const fieldWrapperClasses = computed(() => ({
|
|
|
164
207
|
}));
|
|
165
208
|
const checkboxClasses = computed(() => ({ label: contrastTextClass.value }));
|
|
166
209
|
|
|
210
|
+
/** One band panel: 3rem in, 2rem/1.25rem below 761px of block width. */
|
|
211
|
+
const PANEL_CLASS = 'px-5 py-8 @min-[47.5625rem]:p-12';
|
|
212
|
+
const PRIMARY_PANEL_CLASS = `${PANEL_CLASS} bg-primary text-primary-contrast`;
|
|
167
213
|
const outerClass = computed(() =>
|
|
168
214
|
isSplit.value
|
|
169
|
-
? '
|
|
215
|
+
? 'bg-surface-strong grid overflow-hidden rounded-xl @min-[60.0625rem]:grid-cols-2'
|
|
170
216
|
: 'mx-auto max-w-[36rem] text-center'
|
|
171
217
|
);
|
|
172
|
-
|
|
173
|
-
const
|
|
174
|
-
isSplit.value
|
|
218
|
+
/** `split` with a help panel: the copy and the form share the primary panel. */
|
|
219
|
+
const sharedPanelClass = computed(() =>
|
|
220
|
+
isSplit.value && hasHelp.value ? PRIMARY_PANEL_CLASS : 'contents'
|
|
221
|
+
);
|
|
222
|
+
const copyClass = computed(() => {
|
|
223
|
+
if (!isSplit.value) return 'grid gap-3';
|
|
224
|
+
return hasHelp.value ? 'grid gap-3 text-left' : `${PANEL_CLASS} grid content-center gap-3`;
|
|
225
|
+
});
|
|
226
|
+
const formColumnClass = computed(() => {
|
|
227
|
+
if (!isSplit.value) return 'mt-6 text-left';
|
|
228
|
+
return hasHelp.value ? 'mt-5 text-left' : `${PRIMARY_PANEL_CLASS} grid content-center`;
|
|
229
|
+
});
|
|
230
|
+
/** `data-section="primary"` on whichever element is the primary panel. */
|
|
231
|
+
const sharedPanelSection = computed(() => (isSplit.value && hasHelp.value ? 'primary' : undefined));
|
|
232
|
+
const formColumnSection = computed(() => (isSplit.value && !hasHelp.value ? 'primary' : undefined));
|
|
233
|
+
const headingClass = computed(() =>
|
|
234
|
+
isSplit.value
|
|
235
|
+
? 'font-heading text-[1.875rem] leading-[1.15] font-medium text-balance'
|
|
236
|
+
: '@tablet:text-[2rem] text-[1.625rem] leading-tight font-semibold text-balance'
|
|
237
|
+
);
|
|
238
|
+
/** `FormLayout` is its own width container, so these measure the form, not the block. In the band
|
|
239
|
+
* (a half-width panel) the field and button share a row once the form is 24rem wide — on a phone
|
|
240
|
+
* they stack, as the design's narrow band does. */
|
|
241
|
+
const fieldsClass = computed(() =>
|
|
242
|
+
isSplit.value
|
|
243
|
+
? 'grid gap-3 @min-[24rem]:grid-cols-[1fr_auto] @min-[24rem]:items-end'
|
|
244
|
+
: 'grid gap-3 @two-col:grid-cols-[1fr_auto] @two-col:items-end'
|
|
245
|
+
);
|
|
246
|
+
const spanAllClass = computed(() =>
|
|
247
|
+
isSplit.value ? '@min-[24rem]:col-span-2' : '@two-col:col-span-2'
|
|
248
|
+
);
|
|
249
|
+
const submitWidthClass = computed(() =>
|
|
250
|
+
isSplit.value ? '@min-[24rem]:w-auto w-full' : '@two-col:w-auto w-full'
|
|
175
251
|
);
|
|
176
252
|
|
|
177
253
|
/* ---------------------------------------------------------------------- */
|
|
@@ -304,147 +380,175 @@ async function onSubmit(payload: FormLayoutSubmitPayload): Promise<void> {
|
|
|
304
380
|
|
|
305
381
|
<template>
|
|
306
382
|
<Section :background="sectionBackground" spacing="md" :labelled-by="headingId">
|
|
307
|
-
<Container width="content">
|
|
383
|
+
<Container :width="isSplit ? 'wide' : 'content'">
|
|
308
384
|
<div :class="outerClass">
|
|
309
|
-
<div :class="
|
|
310
|
-
<h2
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
385
|
+
<div v-if="hasHelp" :class="PANEL_CLASS">
|
|
386
|
+
<h2 :id="helpHeadingId" :class="headingClass">{{ helpHeading }}</h2>
|
|
387
|
+
<p v-if="helpText" class="text-muted mt-3">{{ helpText }}</p>
|
|
388
|
+
<ul v-if="contacts.length > 0" role="list" class="mt-5 grid gap-3">
|
|
389
|
+
<li v-for="(line, index) in contacts" :key="index" class="flex items-center gap-3">
|
|
390
|
+
<EldraIcon
|
|
391
|
+
v-if="line.icon"
|
|
392
|
+
:name="line.icon"
|
|
393
|
+
size="md"
|
|
394
|
+
class="text-primary shrink-0"
|
|
395
|
+
/>
|
|
396
|
+
<span>
|
|
397
|
+
<Link
|
|
398
|
+
v-if="line.href !== null"
|
|
399
|
+
:href="line.href"
|
|
400
|
+
:as="line.linkAs"
|
|
401
|
+
class="text-text font-semibold"
|
|
402
|
+
>{{ line.label }}</Link
|
|
403
|
+
>
|
|
404
|
+
<template v-else>{{ line.label }}</template>
|
|
405
|
+
<template v-if="line.note">
|
|
406
|
+
·
|
|
407
|
+
<span class="text-success font-semibold">{{ line.note }}</span>
|
|
408
|
+
</template>
|
|
409
|
+
</span>
|
|
410
|
+
</li>
|
|
411
|
+
</ul>
|
|
329
412
|
</div>
|
|
330
413
|
|
|
331
|
-
<div :class="
|
|
332
|
-
<
|
|
333
|
-
v-if="
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
name="email"
|
|
350
|
-
autocomplete="email"
|
|
351
|
-
size="lg"
|
|
352
|
-
:placeholder="placeholderText"
|
|
353
|
-
/>
|
|
354
|
-
</FieldWrapper>
|
|
355
|
-
</div>
|
|
356
|
-
|
|
357
|
-
<FormHoneypot v-model="honeypot" :name="honeypotField" />
|
|
358
|
-
<div v-if="siteKey" ref="turnstileRoot" class="@two-col:col-span-2 order-2" />
|
|
414
|
+
<div :class="sharedPanelClass" :data-section="sharedPanelSection">
|
|
415
|
+
<div :class="copyClass">
|
|
416
|
+
<h2 v-if="heading" :id="headingId" :class="headingClass">
|
|
417
|
+
{{ heading }}
|
|
418
|
+
</h2>
|
|
419
|
+
<EditorPlaceholder
|
|
420
|
+
v-else-if="showHeadingHint"
|
|
421
|
+
:id="headingId"
|
|
422
|
+
inline
|
|
423
|
+
:label="t('newsletter.headingHintLabel')"
|
|
424
|
+
/>
|
|
425
|
+
<p v-if="text" class="text-base leading-[1.6]" :class="mutedToneClass">{{ text }}</p>
|
|
426
|
+
<EditorPlaceholder
|
|
427
|
+
v-else-if="showTextHint"
|
|
428
|
+
inline
|
|
429
|
+
:label="t('newsletter.textHintLabel')"
|
|
430
|
+
/>
|
|
431
|
+
</div>
|
|
359
432
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
433
|
+
<div :class="formColumnClass" :data-section="formColumnSection">
|
|
434
|
+
<FormLayout
|
|
435
|
+
v-if="!succeeded"
|
|
436
|
+
novalidate
|
|
437
|
+
:submitting="isSubmitting"
|
|
438
|
+
:classes="{ fields: fieldsClass }"
|
|
439
|
+
@submit="onSubmit"
|
|
440
|
+
@invalid="onInvalid"
|
|
364
441
|
>
|
|
365
|
-
<
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
442
|
+
<div ref="emailFieldRoot" class="contents">
|
|
443
|
+
<FieldWrapper
|
|
444
|
+
:label="fieldLabelText"
|
|
445
|
+
:error="emailError ?? undefined"
|
|
446
|
+
:classes="fieldWrapperClasses"
|
|
447
|
+
>
|
|
448
|
+
<Input
|
|
449
|
+
v-model="email"
|
|
450
|
+
type="email"
|
|
451
|
+
name="email"
|
|
452
|
+
autocomplete="email"
|
|
453
|
+
size="lg"
|
|
454
|
+
:placeholder="placeholderText"
|
|
455
|
+
/>
|
|
456
|
+
</FieldWrapper>
|
|
457
|
+
</div>
|
|
458
|
+
|
|
459
|
+
<FormHoneypot v-model="honeypot" :name="honeypotField" />
|
|
460
|
+
<div v-if="siteKey" ref="turnstileRoot" class="order-2" :class="spanAllClass" />
|
|
461
|
+
|
|
462
|
+
<div
|
|
463
|
+
v-if="requireConsentCheckbox"
|
|
464
|
+
ref="checkboxFieldRoot"
|
|
465
|
+
class="order-2 grid gap-1"
|
|
466
|
+
:class="spanAllClass"
|
|
371
467
|
>
|
|
372
|
-
|
|
373
|
-
|
|
468
|
+
<Checkbox
|
|
469
|
+
v-model="consentChecked"
|
|
470
|
+
name="consent"
|
|
471
|
+
:invalid="consentError !== null"
|
|
472
|
+
:described-by="consentError ? consentErrorId : undefined"
|
|
473
|
+
:classes="checkboxClasses"
|
|
474
|
+
>
|
|
475
|
+
{{ consentCheckboxLabelText }}
|
|
476
|
+
</Checkbox>
|
|
477
|
+
<p
|
|
478
|
+
v-if="consentError"
|
|
479
|
+
:id="consentErrorId"
|
|
480
|
+
class="text-field-note text-danger flex items-start gap-1.25 font-medium"
|
|
481
|
+
:class="errorChipClass"
|
|
482
|
+
>
|
|
483
|
+
<EldraIcon
|
|
484
|
+
name="alert-circle"
|
|
485
|
+
size="sm"
|
|
486
|
+
class="size-4 shrink-0 translate-y-[0.1em]"
|
|
487
|
+
aria-hidden="true"
|
|
488
|
+
/>
|
|
489
|
+
<span>{{ consentError }}</span>
|
|
490
|
+
</p>
|
|
491
|
+
</div>
|
|
492
|
+
|
|
493
|
+
<Button
|
|
494
|
+
type="submit"
|
|
495
|
+
variant="primary"
|
|
496
|
+
size="lg"
|
|
497
|
+
:class="submitWidthClass"
|
|
498
|
+
:label="t('newsletter.subscribing')"
|
|
499
|
+
:aria-describedby="consentSentence ? consentSentenceId : undefined"
|
|
500
|
+
>
|
|
501
|
+
{{ buttonLabelText }}
|
|
502
|
+
</Button>
|
|
503
|
+
|
|
374
504
|
<p
|
|
375
|
-
v-if="
|
|
376
|
-
:id="
|
|
377
|
-
|
|
378
|
-
|
|
505
|
+
v-if="consentSentence"
|
|
506
|
+
:id="consentSentenceId"
|
|
507
|
+
data-part="consent-sentence"
|
|
508
|
+
class="text-body-sm order-3"
|
|
509
|
+
:class="[consentToneClass, spanAllClass]"
|
|
379
510
|
>
|
|
380
|
-
|
|
381
|
-
name="alert-circle"
|
|
382
|
-
size="sm"
|
|
383
|
-
class="size-4 shrink-0 translate-y-[0.1em]"
|
|
384
|
-
aria-hidden="true"
|
|
385
|
-
/>
|
|
386
|
-
<span>{{ consentError }}</span>
|
|
511
|
+
{{ consentSentence }}
|
|
387
512
|
</p>
|
|
388
|
-
</div>
|
|
389
513
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
514
|
+
<div ref="consentRoot" class="order-3" :class="spanAllClass">
|
|
515
|
+
<!-- Under this block's own `h2`, so any heading in the consent copy starts at `h3`. -->
|
|
516
|
+
<EldraRichText
|
|
517
|
+
v-if="hasConsent"
|
|
518
|
+
class="prose-eldra text-body-sm"
|
|
519
|
+
:class="consentToneClass"
|
|
520
|
+
:entry-id="entryId"
|
|
521
|
+
field="consent"
|
|
522
|
+
:doc="data.consent"
|
|
523
|
+
api-id="newsletter"
|
|
524
|
+
:min-heading-level="3"
|
|
525
|
+
/>
|
|
526
|
+
</div>
|
|
527
|
+
</FormLayout>
|
|
528
|
+
|
|
529
|
+
<div
|
|
530
|
+
ref="statusRoot"
|
|
531
|
+
role="status"
|
|
532
|
+
tabindex="-1"
|
|
533
|
+
:class="
|
|
534
|
+
succeeded
|
|
535
|
+
? 'border-border bg-background text-text mt-3 flex items-start gap-3 rounded-lg border p-5'
|
|
536
|
+
: ''
|
|
537
|
+
"
|
|
407
538
|
>
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
class="
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
api-id="newsletter"
|
|
421
|
-
:min-heading-level="3"
|
|
422
|
-
/>
|
|
539
|
+
<template v-if="succeeded">
|
|
540
|
+
<EldraIcon
|
|
541
|
+
name="circle-check"
|
|
542
|
+
size="lg"
|
|
543
|
+
class="text-success shrink-0"
|
|
544
|
+
aria-hidden="true"
|
|
545
|
+
/>
|
|
546
|
+
<div class="grid gap-1">
|
|
547
|
+
<p class="font-semibold">{{ successTitleText }}</p>
|
|
548
|
+
<p v-if="successTextValue" class="text-muted">{{ successTextValue }}</p>
|
|
549
|
+
</div>
|
|
550
|
+
</template>
|
|
423
551
|
</div>
|
|
424
|
-
</FormLayout>
|
|
425
|
-
|
|
426
|
-
<div
|
|
427
|
-
ref="statusRoot"
|
|
428
|
-
role="status"
|
|
429
|
-
tabindex="-1"
|
|
430
|
-
:class="
|
|
431
|
-
succeeded
|
|
432
|
-
? 'border-border bg-background text-text mt-3 flex items-start gap-3 rounded-lg border p-5'
|
|
433
|
-
: ''
|
|
434
|
-
"
|
|
435
|
-
>
|
|
436
|
-
<template v-if="succeeded">
|
|
437
|
-
<EldraIcon
|
|
438
|
-
name="circle-check"
|
|
439
|
-
size="lg"
|
|
440
|
-
class="text-success shrink-0"
|
|
441
|
-
aria-hidden="true"
|
|
442
|
-
/>
|
|
443
|
-
<div class="grid gap-1">
|
|
444
|
-
<p class="font-semibold">{{ successTitleText }}</p>
|
|
445
|
-
<p v-if="successTextValue" class="text-muted">{{ successTextValue }}</p>
|
|
446
|
-
</div>
|
|
447
|
-
</template>
|
|
448
552
|
</div>
|
|
449
553
|
</div>
|
|
450
554
|
</div>
|
|
@@ -4,6 +4,7 @@ import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
|
4
4
|
import { axe } from '../../../test/support/axe';
|
|
5
5
|
import Block from '../Block.vue';
|
|
6
6
|
import mock from '../mock.json';
|
|
7
|
+
import preview from '../preview.json';
|
|
7
8
|
import { mountOptions } from '../../../test/support/mountBlock';
|
|
8
9
|
import { STOREFRONT_KEY } from '../../../app/storefront/types';
|
|
9
10
|
import type {
|
|
@@ -413,11 +414,52 @@ describe('newsletter block', () => {
|
|
|
413
414
|
});
|
|
414
415
|
|
|
415
416
|
describe('split variant', () => {
|
|
417
|
+
const band = { ...mock, ...preview };
|
|
418
|
+
|
|
416
419
|
it('renders the same field and button as centered', () => {
|
|
417
420
|
const wrapper = mountNewsletter({ ...mock, variant: 'split' });
|
|
418
421
|
expect(wrapper.find('input[type="email"]').exists()).toBe(true);
|
|
419
422
|
expect(wrapper.find('button[type="submit"]').exists()).toBe(true);
|
|
420
423
|
expect(wrapper.text()).toContain(mock.heading);
|
|
421
424
|
});
|
|
425
|
+
|
|
426
|
+
it('renders the help panel first, then the sign-up on a primary panel, with no axe violations', async () => {
|
|
427
|
+
const wrapper = mountNewsletter(band);
|
|
428
|
+
const headings = wrapper.findAll('h2').map((h) => h.text());
|
|
429
|
+
expect(headings).toEqual([preview.helpHeading, preview.heading]);
|
|
430
|
+
// The section stays named by the newsletter heading.
|
|
431
|
+
const section = wrapper.get('section');
|
|
432
|
+
expect(wrapper.get(`#${section.attributes('aria-labelledby')}`).text()).toBe(preview.heading);
|
|
433
|
+
// The form sits inside the panel that carries the package's inversion signal.
|
|
434
|
+
const panel = wrapper.get('[data-section="primary"]');
|
|
435
|
+
expect(panel.find('form').exists()).toBe(true);
|
|
436
|
+
expect(panel.text()).toContain(preview.heading);
|
|
437
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
it('lists the contact lines: a link where there is one, plain text and a note where not', () => {
|
|
441
|
+
const wrapper = mountNewsletter(band);
|
|
442
|
+
const lines = wrapper.findAll('ul[role="list"] > li');
|
|
443
|
+
expect(lines).toHaveLength(preview.contacts.length);
|
|
444
|
+
expect(lines[0]!.get('a').attributes('href')).toBe('tel:+15550142290');
|
|
445
|
+
expect(lines[1]!.get('a').attributes('href')).toBe('mailto:hello@northwind.example');
|
|
446
|
+
expect(lines[2]!.find('a').exists()).toBe(false);
|
|
447
|
+
expect(lines[2]!.text()).toContain(preview.contacts[2]!.note!);
|
|
448
|
+
});
|
|
449
|
+
|
|
450
|
+
it('without a help heading, the heading and text take the left panel and the form the right', () => {
|
|
451
|
+
const wrapper = mountNewsletter({ ...band, helpHeading: '' });
|
|
452
|
+
expect(wrapper.findAll('h2')).toHaveLength(1);
|
|
453
|
+
const panel = wrapper.get('[data-section="primary"]');
|
|
454
|
+
expect(panel.find('form').exists()).toBe(true);
|
|
455
|
+
expect(panel.text()).not.toContain(preview.heading);
|
|
456
|
+
});
|
|
457
|
+
|
|
458
|
+
it('shows no help panel in the centered variant, and defaults the split ground to none', () => {
|
|
459
|
+
const centered = mountNewsletter({ ...band, variant: 'centered' });
|
|
460
|
+
expect(centered.text()).not.toContain(preview.helpHeading);
|
|
461
|
+
const { sectionBackground: _omit, ...unset } = band;
|
|
462
|
+
expect(mountNewsletter(unset).get('section').attributes('data-section-bg')).toBe('none');
|
|
463
|
+
});
|
|
422
464
|
});
|
|
423
465
|
});
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"fieldId": "variant",
|
|
11
11
|
"name": "Variant",
|
|
12
12
|
"type": "select",
|
|
13
|
-
"helpText": "centered is the default.",
|
|
13
|
+
"helpText": "centered is the default. split is a rounded band of two panels: the sign-up on the primary colour on the right, and on the left either the help panel below (when it has a heading) or the heading and text.",
|
|
14
14
|
"metadata": { "options": ["centered", "split"] },
|
|
15
15
|
"validators": { "required": true }
|
|
16
16
|
},
|
|
@@ -93,11 +93,70 @@
|
|
|
93
93
|
"type": "string",
|
|
94
94
|
"helpText": "The key of the sign-up form on the Forms page. Defaults to \"newsletter\" when unset."
|
|
95
95
|
},
|
|
96
|
+
{
|
|
97
|
+
"fieldId": "helpHeading",
|
|
98
|
+
"name": "Help heading",
|
|
99
|
+
"type": "string",
|
|
100
|
+
"localized": true,
|
|
101
|
+
"helpText": "Split variant only. A heading for a panel beside the sign-up, e.g. \"Questions before you buy?\". No heading, no panel.",
|
|
102
|
+
"showWhen": { "field": "variant", "in": ["split"] }
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"fieldId": "helpText",
|
|
106
|
+
"name": "Help text",
|
|
107
|
+
"type": "text",
|
|
108
|
+
"localized": true,
|
|
109
|
+
"showWhen": { "field": "variant", "in": ["split"] }
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"fieldId": "contacts",
|
|
113
|
+
"name": "Contact lines",
|
|
114
|
+
"type": "list",
|
|
115
|
+
"helpText": "Up to 4 lines in the help panel: phone, email, address. Each an icon, a label, an optional link and an optional highlighted note such as opening hours.",
|
|
116
|
+
"showWhen": { "field": "variant", "in": ["split"] },
|
|
117
|
+
"metadata": {
|
|
118
|
+
"item": {
|
|
119
|
+
"fieldId": "item",
|
|
120
|
+
"name": "Contact line",
|
|
121
|
+
"type": "composite",
|
|
122
|
+
"metadata": {
|
|
123
|
+
"fields": [
|
|
124
|
+
{
|
|
125
|
+
"fieldId": "icon",
|
|
126
|
+
"name": "Icon",
|
|
127
|
+
"type": "tabler-icon",
|
|
128
|
+
"helpText": "For example phone, mail or map-pin."
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"fieldId": "label",
|
|
132
|
+
"name": "Label",
|
|
133
|
+
"type": "string",
|
|
134
|
+
"localized": true,
|
|
135
|
+
"validators": { "required": true }
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"fieldId": "href",
|
|
139
|
+
"name": "Link",
|
|
140
|
+
"type": "string",
|
|
141
|
+
"helpText": "tel:, mailto: or a page. Optional."
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"fieldId": "note",
|
|
145
|
+
"name": "Note",
|
|
146
|
+
"type": "string",
|
|
147
|
+
"localized": true,
|
|
148
|
+
"helpText": "Shown after the label in green, e.g. \"open today until 18:00\"."
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
},
|
|
96
155
|
{
|
|
97
156
|
"fieldId": "sectionBackground",
|
|
98
157
|
"name": "Section background",
|
|
99
158
|
"type": "select",
|
|
100
|
-
"helpText": "Defaults to \"surface\" when unset.",
|
|
159
|
+
"helpText": "Defaults to \"surface\" when unset (\"none\" in the split variant, whose band brings its own colours).",
|
|
101
160
|
"metadata": { "options": ["none", "surface", "surface-strong", "primary", "accent"] }
|
|
102
161
|
}
|
|
103
162
|
]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"variant": "split",
|
|
3
|
+
"heading": "Letters from the workshop",
|
|
4
|
+
"text": "New pieces and small-batch restocks, once a month.",
|
|
5
|
+
"placeholder": "you@example.com",
|
|
6
|
+
"consent": {
|
|
7
|
+
"type": "doc",
|
|
8
|
+
"content": [
|
|
9
|
+
{
|
|
10
|
+
"type": "paragraph",
|
|
11
|
+
"content": [
|
|
12
|
+
{ "type": "text", "text": "Unsubscribe at any time. Read our " },
|
|
13
|
+
{
|
|
14
|
+
"type": "text",
|
|
15
|
+
"marks": [{ "type": "link", "attrs": { "href": "/pages/privacy" } }],
|
|
16
|
+
"text": "privacy policy"
|
|
17
|
+
},
|
|
18
|
+
{ "type": "text", "text": "." }
|
|
19
|
+
]
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
},
|
|
23
|
+
"helpHeading": "Questions before you buy?",
|
|
24
|
+
"helpText": "Sizes, glazes, gift ideas: we know every piece in the shop.",
|
|
25
|
+
"contacts": [
|
|
26
|
+
{ "icon": "phone", "label": "(555) 014-2290", "href": "tel:+15550142290" },
|
|
27
|
+
{
|
|
28
|
+
"icon": "mail",
|
|
29
|
+
"label": "hello@northwind.example",
|
|
30
|
+
"href": "mailto:hello@northwind.example"
|
|
31
|
+
},
|
|
32
|
+
{ "icon": "map-pin", "label": "14 Harbour Street", "note": "open today until 18:00" }
|
|
33
|
+
],
|
|
34
|
+
"sectionBackground": "none"
|
|
35
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|