@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.
Files changed (165) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/package.json +1 -1
  3. package/template/.eldra/block-types.d.ts +28 -7
  4. package/template/.eldra/manifest.json +1034 -355
  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 +82 -58
  25. package/template/blocks/collection-header/__tests__/Block.spec.ts +77 -1
  26. package/template/blocks/collection-header/preview.json +4 -4
  27. package/template/blocks/collection-header/preview.png +0 -0
  28. package/template/blocks/contact/preview.png +0 -0
  29. package/template/blocks/cta/preview.json +4 -4
  30. package/template/blocks/cta/preview.png +0 -0
  31. package/template/blocks/faq/preview.png +0 -0
  32. package/template/blocks/feature-grid/Block.vue +73 -4
  33. package/template/blocks/feature-grid/__tests__/Block.spec.ts +43 -1
  34. package/template/blocks/feature-grid/block.json +2 -2
  35. package/template/blocks/feature-grid/preview.json +49 -24
  36. package/template/blocks/feature-grid/preview.png +0 -0
  37. package/template/blocks/footer/Block.vue +186 -71
  38. package/template/blocks/footer/__tests__/Block.spec.ts +127 -32
  39. package/template/blocks/footer/block.json +42 -4
  40. package/template/blocks/footer/mock.json +31 -34
  41. package/template/blocks/footer/preview.png +0 -0
  42. package/template/blocks/form/preview.png +0 -0
  43. package/template/blocks/gallery/preview.json +24 -24
  44. package/template/blocks/gallery/preview.png +0 -0
  45. package/template/blocks/hero/Block.vue +117 -19
  46. package/template/blocks/hero/__tests__/Block.spec.ts +46 -0
  47. package/template/blocks/hero/block.json +36 -1
  48. package/template/blocks/hero/preview.json +33 -25
  49. package/template/blocks/hero/preview.png +0 -0
  50. package/template/blocks/image/preview.json +4 -4
  51. package/template/blocks/image/preview.png +0 -0
  52. package/template/blocks/logo-cloud/preview.png +0 -0
  53. package/template/blocks/navigation/Block.vue +623 -184
  54. package/template/blocks/navigation/__tests__/Block.spec.ts +416 -68
  55. package/template/blocks/navigation/__tests__/fixtures/menu.json +182 -0
  56. package/template/blocks/navigation/block.json +102 -6
  57. package/template/blocks/navigation/mock.json +279 -52
  58. package/template/blocks/navigation/preview.json +311 -0
  59. package/template/blocks/navigation/preview.png +0 -0
  60. package/template/blocks/newsletter/Block.vue +248 -144
  61. package/template/blocks/newsletter/__tests__/Block.spec.ts +42 -0
  62. package/template/blocks/newsletter/block.json +61 -2
  63. package/template/blocks/newsletter/preview.json +35 -0
  64. package/template/blocks/newsletter/preview.png +0 -0
  65. package/template/blocks/order-status/preview.png +0 -0
  66. package/template/blocks/pricing-table/preview.png +0 -0
  67. package/template/blocks/product-carousel/Block.vue +272 -26
  68. package/template/blocks/product-carousel/__tests__/Block.spec.ts +90 -0
  69. package/template/blocks/product-carousel/block.json +61 -0
  70. package/template/blocks/product-carousel/preview.json +12 -0
  71. package/template/blocks/product-carousel/preview.png +0 -0
  72. package/template/blocks/product-detail/Block.vue +148 -96
  73. package/template/blocks/product-detail/__tests__/Block.spec.ts +98 -74
  74. package/template/blocks/product-detail/block.json +11 -4
  75. package/template/blocks/product-detail/mock.json +53 -22
  76. package/template/blocks/product-detail/parts/Gallery.vue +52 -103
  77. package/template/blocks/product-detail/preview.png +0 -0
  78. package/template/blocks/quote/preview.png +0 -0
  79. package/template/blocks/rich-text/preview.png +0 -0
  80. package/template/blocks/search/Block.vue +1 -0
  81. package/template/blocks/search/TypeSection.vue +1 -0
  82. package/template/blocks/search/__tests__/Block.spec.ts +23 -0
  83. package/template/blocks/search/preview.png +0 -0
  84. package/template/blocks/split-content/Block.vue +98 -20
  85. package/template/blocks/split-content/__tests__/Block.spec.ts +57 -18
  86. package/template/blocks/split-content/block.json +72 -6
  87. package/template/blocks/split-content/preview.json +34 -13
  88. package/template/blocks/split-content/preview.png +0 -0
  89. package/template/blocks/stats/preview.png +0 -0
  90. package/template/blocks/tabs/preview.json +16 -16
  91. package/template/blocks/tabs/preview.png +0 -0
  92. package/template/blocks/team/preview.png +0 -0
  93. package/template/blocks/testimonials/preview.png +0 -0
  94. package/template/blocks/timeline/preview.png +0 -0
  95. package/template/blocks/trust-strip/Block.vue +67 -1
  96. package/template/blocks/trust-strip/__tests__/Block.spec.ts +30 -1
  97. package/template/blocks/trust-strip/block.json +4 -4
  98. package/template/blocks/trust-strip/preview.json +21 -0
  99. package/template/blocks/trust-strip/preview.png +0 -0
  100. package/template/blocks/video-embed/preview.png +0 -0
  101. package/template/blocks/wishlist/preview.png +0 -0
  102. package/template/i18n/en-US.json +16 -9
  103. package/template/i18n/is-IS.json +16 -9
  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/clay-hands.webp +0 -0
  115. package/template/public/images/coffee-table.webp +0 -0
  116. package/template/public/images/cup.webp +0 -0
  117. package/template/public/images/enamel-cups.webp +0 -0
  118. package/template/public/images/hero.webp +0 -0
  119. package/template/public/images/kitchen.webp +0 -0
  120. package/template/public/images/mug.webp +0 -0
  121. package/template/public/images/northwind-mark.svg +1 -0
  122. package/template/public/images/planters.webp +0 -0
  123. package/template/public/images/plates.webp +0 -0
  124. package/template/public/images/reading.webp +0 -0
  125. package/template/public/images/sweater.webp +0 -0
  126. package/template/public/images/terracotta.webp +0 -0
  127. package/template/public/images/throws.webp +0 -0
  128. package/template/public/images/vase.webp +0 -0
  129. package/template/public/images/wheel.webp +0 -0
  130. package/template/public/images/yarn-tools.webp +0 -0
  131. package/template/public/images/yarn.webp +0 -0
  132. package/template/stories/generated/collection-grid.stories.ts +6 -0
  133. package/template/stories/generated/feature-grid.stories.ts +6 -0
  134. package/template/stories/generated/footer.stories.ts +4 -4
  135. package/template/stories/generated/hero.stories.ts +6 -0
  136. package/template/stories/generated/navigation.stories.ts +14 -1
  137. package/template/stories/generated/newsletter.stories.ts +2 -1
  138. package/template/stories/generated/product-carousel.stories.ts +12 -0
  139. package/template/stories/generated/split-content.stories.ts +12 -0
  140. package/template/stories/generated/trust-strip.stories.ts +8 -1
  141. package/template/stories/pages/article.stories.ts +2 -1
  142. package/template/stories/pages/cart.stories.ts +2 -1
  143. package/template/stories/pages/category.stories.ts +2 -1
  144. package/template/stories/pages/collection.stories.ts +2 -1
  145. package/template/stories/pages/home.stories.ts +2 -1
  146. package/template/stories/pages/product.stories.ts +2 -1
  147. package/template/stories/pages/products.stories.ts +2 -1
  148. package/template/stories/pages/search.stories.ts +2 -1
  149. package/template/stories/pages/wishlist.stories.ts +2 -1
  150. package/template/stories/support/demoChrome.ts +32 -0
  151. package/template/stories/support/pageBlocks.ts +2 -4
  152. package/template/test/countPill.browser.spec.ts +21 -13
  153. package/template/test/localePrefix.spec.ts +11 -6
  154. package/template/test/pages/article.spec.ts +1 -1
  155. package/template/test/pages/category.spec.ts +34 -11
  156. package/template/test/pages/collection.spec.ts +182 -148
  157. package/template/test/pages/home.spec.ts +35 -40
  158. package/template/test/pages/hydration.spec.ts +4 -4
  159. package/template/test/pages/product.spec.ts +17 -14
  160. package/template/test/pages/seededPages.spec.ts +11 -6
  161. package/template/test/prerenderRefresh.browser.spec.ts +36 -15
  162. package/template/test/previewParity.browser.spec.ts +36 -2
  163. package/template/test/starter.spec.ts +31 -15
  164. package/template/test/storefront/gatewayPrerender.spec.ts +26 -0
  165. 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`: from `@content` (64rem) block width, copy left / form right (`1fr 1fr`, 4rem gap,
8
- * vertically centred). Below that it stacks like `centered`, left-aligned, full container width.
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
- const isInverted = computed(
113
- () => sectionBackground.value === 'primary' || sectionBackground.value === 'accent'
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 (sectionBackground.value === 'primary') return 'text-primary-contrast';
139
- if (sectionBackground.value === 'accent') return 'text-accent-contrast';
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 (sectionBackground.value === 'primary') return 'text-primary-contrast/90';
144
- if (sectionBackground.value === 'accent') return 'text-accent-contrast/90';
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 (sectionBackground.value === 'primary') {
191
+ if (formGround.value === 'primary') {
149
192
  return 'text-primary-contrast/90 [&_a]:text-primary-contrast';
150
193
  }
151
- if (sectionBackground.value === 'accent') {
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
- ? '@content:grid @content:grid-cols-2 @content:items-center @content:gap-16'
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
- const copyClass = computed(() => (isSplit.value ? 'grid gap-3 text-left' : 'grid gap-3'));
173
- const formColumnClass = computed(() =>
174
- isSplit.value ? 'mt-6 @content:mt-0 text-left' : 'mt-6 text-left'
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="copyClass">
310
- <h2
311
- v-if="heading"
312
- :id="headingId"
313
- class="@tablet:text-[2rem] text-[1.625rem] leading-tight font-semibold text-balance"
314
- >
315
- {{ heading }}
316
- </h2>
317
- <EditorPlaceholder
318
- v-else-if="showHeadingHint"
319
- :id="headingId"
320
- inline
321
- :label="t('newsletter.headingHintLabel')"
322
- />
323
- <p v-if="text" class="text-base leading-[1.6]" :class="mutedToneClass">{{ text }}</p>
324
- <EditorPlaceholder
325
- v-else-if="showTextHint"
326
- inline
327
- :label="t('newsletter.textHintLabel')"
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="formColumnClass">
332
- <FormLayout
333
- v-if="!succeeded"
334
- novalidate
335
- :submitting="isSubmitting"
336
- :classes="{ fields: 'grid gap-3 @two-col:grid-cols-[1fr_auto] @two-col:items-end' }"
337
- @submit="onSubmit"
338
- @invalid="onInvalid"
339
- >
340
- <div ref="emailFieldRoot" class="contents">
341
- <FieldWrapper
342
- :label="fieldLabelText"
343
- :error="emailError ?? undefined"
344
- :classes="fieldWrapperClasses"
345
- >
346
- <Input
347
- v-model="email"
348
- type="email"
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
- <div
361
- v-if="requireConsentCheckbox"
362
- ref="checkboxFieldRoot"
363
- class="@two-col:col-span-2 order-2 grid gap-1"
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
- <Checkbox
366
- v-model="consentChecked"
367
- name="consent"
368
- :invalid="consentError !== null"
369
- :described-by="consentError ? consentErrorId : undefined"
370
- :classes="checkboxClasses"
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
- {{ consentCheckboxLabelText }}
373
- </Checkbox>
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="consentError"
376
- :id="consentErrorId"
377
- class="text-field-note text-danger flex items-start gap-1.25 font-medium"
378
- :class="errorChipClass"
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
- <EldraIcon
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
- <Button
391
- type="submit"
392
- variant="primary"
393
- size="lg"
394
- class="@two-col:w-auto w-full"
395
- :label="t('newsletter.subscribing')"
396
- :aria-describedby="consentSentence ? consentSentenceId : undefined"
397
- >
398
- {{ buttonLabelText }}
399
- </Button>
400
-
401
- <p
402
- v-if="consentSentence"
403
- :id="consentSentenceId"
404
- data-part="consent-sentence"
405
- class="text-body-sm @two-col:col-span-2 order-3"
406
- :class="consentToneClass"
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
- {{ consentSentence }}
409
- </p>
410
-
411
- <div ref="consentRoot" class="@two-col:col-span-2 order-3">
412
- <!-- Under this block's own `h2`, so any heading in the consent copy starts at `h3`. -->
413
- <EldraRichText
414
- v-if="hasConsent"
415
- class="prose-eldra text-body-sm"
416
- :class="consentToneClass"
417
- :entry-id="entryId"
418
- field="consent"
419
- :doc="data.consent"
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
+ }