@eldrajs/theme-cli 0.2.8 → 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 -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 +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 +622 -184
- package/template/blocks/navigation/__tests__/Block.spec.ts +406 -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/starter.spec.ts +31 -15
- package/template/test/storefront/gatewayPrerender.spec.ts +26 -0
- package/template/tokens.json +13 -13
|
@@ -28,6 +28,15 @@
|
|
|
28
28
|
* here would silently (and wrongly) resolve `localized: false` regardless of the manifest. See
|
|
29
29
|
* `blocks/faq/Block.vue`'s own comment for the full reasoning.
|
|
30
30
|
*
|
|
31
|
+
* **The theme's look** (the "makers" story): the image takes the wider `1.15fr` track and the
|
|
32
|
+
* text `1fr`, side by side from 961px of block width (stacked, image first, below that), with a
|
|
33
|
+
* 5:4 photo, the design's `h2`, the row text as a muted lead paragraph and the row link as an
|
|
34
|
+
* outline button. The block can carry a short `list`, shown under the first row's text — a round initial (`primary`,
|
|
35
|
+
* `accent` and `border-strong` in turn, `aria-hidden`: the name beside it says the same), a name,
|
|
36
|
+
* one line and a small link whose accessible name adds the entry's name ("Shop Harbour Pottery"),
|
|
37
|
+
* so three "Shop" links are never three identical names. `background` puts the whole block on
|
|
38
|
+
* `surface`.
|
|
39
|
+
*
|
|
31
40
|
* `useRichTextScrollRegions` is applied once, to a ref around the whole `<ol>`, rather than once per
|
|
32
41
|
* row: its own contract only needs a ref that *contains* every rendered rich-text root (it wraps
|
|
33
42
|
* every `<table>`/marks every `<pre>` under whatever element it is given — see that composable's
|
|
@@ -35,7 +44,15 @@
|
|
|
35
44
|
* call covers every row's rich text at once.
|
|
36
45
|
*/
|
|
37
46
|
import { computed, ref } from 'vue';
|
|
38
|
-
import {
|
|
47
|
+
import {
|
|
48
|
+
Button,
|
|
49
|
+
Container,
|
|
50
|
+
EditorPlaceholder,
|
|
51
|
+
Link,
|
|
52
|
+
Section,
|
|
53
|
+
VisuallyHidden,
|
|
54
|
+
type SectionBackground,
|
|
55
|
+
} from '@eldrajs/ui';
|
|
39
56
|
import { EldraRichText } from '@eldrajs/theme-vue';
|
|
40
57
|
import { DEFAULT_IMAGE_FRAMING, type ImageFraming } from '@eldrajs/theme-vue';
|
|
41
58
|
import { useBlockData } from '../../app/composables/useBlockData';
|
|
@@ -48,11 +65,19 @@ import { isInternalHref, safeHref } from '../../app/utils/links';
|
|
|
48
65
|
|
|
49
66
|
type Side = 'image-left' | 'image-right';
|
|
50
67
|
|
|
68
|
+
interface SplitContentEntry {
|
|
69
|
+
title?: string;
|
|
70
|
+
text?: string;
|
|
71
|
+
linkLabel?: string;
|
|
72
|
+
href?: string;
|
|
73
|
+
}
|
|
74
|
+
|
|
51
75
|
interface SplitContentRow {
|
|
52
76
|
image?: { url: string; altText?: string | null; framing?: ImageFraming | null } | null;
|
|
53
77
|
eyebrow?: string;
|
|
54
78
|
heading?: string;
|
|
55
79
|
text?: { content?: unknown[] } | null;
|
|
80
|
+
|
|
56
81
|
linkLabel?: string;
|
|
57
82
|
href?: string;
|
|
58
83
|
}
|
|
@@ -63,6 +88,7 @@ const editing = useEditing();
|
|
|
63
88
|
const { t } = useI18n();
|
|
64
89
|
|
|
65
90
|
const startWith = computed<Side>(() => data.value.startWith ?? 'image-left');
|
|
91
|
+
const background = computed<SectionBackground>(() => data.value.background ?? 'none');
|
|
66
92
|
const rows = computed<SplitContentRow[]>(() => data.value.rows ?? []);
|
|
67
93
|
|
|
68
94
|
function oppositeSide(side: Side): Side {
|
|
@@ -85,16 +111,42 @@ function rowFraming(row: SplitContentRow): ImageFraming | undefined {
|
|
|
85
111
|
/** The image's own column is always `7fr`, wherever it lands — see the module doc comment. */
|
|
86
112
|
function rowGridColsClass(index: number): string {
|
|
87
113
|
return rowSide(index) === 'image-left'
|
|
88
|
-
? '@
|
|
89
|
-
: '@
|
|
114
|
+
? '@min-[60.0625rem]:grid-cols-[minmax(0,1.15fr)_minmax(0,1fr)]'
|
|
115
|
+
: '@min-[60.0625rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.15fr)]';
|
|
90
116
|
}
|
|
91
117
|
/** The image is always first in the DOM (see the template); `order` only ever needs to move it —
|
|
92
118
|
* the text column's own class is just its mirror. */
|
|
93
119
|
function imageOrderClass(index: number): string {
|
|
94
|
-
return rowSide(index) === 'image-right' ? '@
|
|
120
|
+
return rowSide(index) === 'image-right' ? '@min-[60.0625rem]:order-2' : '';
|
|
95
121
|
}
|
|
96
122
|
function textOrderClass(index: number): string {
|
|
97
|
-
return rowSide(index) === 'image-right' ? '@
|
|
123
|
+
return rowSide(index) === 'image-right' ? '@min-[60.0625rem]:order-1' : '';
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** The round initials cycle through three theme colours, all dark enough for the light letter. */
|
|
127
|
+
const AVATAR_TONES = ['bg-primary', 'bg-accent', 'bg-border-strong'] as const;
|
|
128
|
+
function entryTone(index: number): string {
|
|
129
|
+
return AVATAR_TONES[index % AVATAR_TONES.length]!;
|
|
130
|
+
}
|
|
131
|
+
function entryInitial(entry: SplitContentEntry): string {
|
|
132
|
+
return Array.from((entry.title ?? '').trim())[0]?.toLocaleUpperCase() ?? '';
|
|
133
|
+
}
|
|
134
|
+
/** The block's `list` belongs to the first row (a block-level field, so adding it never changed
|
|
135
|
+
* the stored shape of `rows`). */
|
|
136
|
+
const entries = computed<SplitContentEntry[]>(() =>
|
|
137
|
+
((data.value.list ?? []) as SplitContentEntry[]).filter(
|
|
138
|
+
(entry) => (entry.title ?? '').trim() !== ''
|
|
139
|
+
)
|
|
140
|
+
);
|
|
141
|
+
function rowEntries(index: number): SplitContentEntry[] {
|
|
142
|
+
return index === 0 ? entries.value : [];
|
|
143
|
+
}
|
|
144
|
+
function entryHref(entry: SplitContentEntry): string | null {
|
|
145
|
+
return entry.linkLabel ? safeHref(entry.href) : null;
|
|
146
|
+
}
|
|
147
|
+
function entryLinkAs(entry: SplitContentEntry): typeof EldraRouterLink | undefined {
|
|
148
|
+
const href = entryHref(entry);
|
|
149
|
+
return href !== null && isInternalHref(href) ? EldraRouterLink : undefined;
|
|
98
150
|
}
|
|
99
151
|
|
|
100
152
|
function rowHref(row: SplitContentRow): string | null {
|
|
@@ -119,13 +171,13 @@ useRichTextScrollRegions(rowsRoot, (caption) => caption ?? t('splitContent.richT
|
|
|
119
171
|
</script>
|
|
120
172
|
|
|
121
173
|
<template>
|
|
122
|
-
<Section spacing="md" :aria-label="t('splitContent.label')">
|
|
174
|
+
<Section :background="background" spacing="md" :aria-label="t('splitContent.label')">
|
|
123
175
|
<Container width="wide">
|
|
124
|
-
<ol ref="rowsRoot" role="list" class="
|
|
176
|
+
<ol ref="rowsRoot" role="list" class="grid gap-16 @min-[60.0625rem]:gap-24">
|
|
125
177
|
<li
|
|
126
178
|
v-for="(row, index) in rows"
|
|
127
179
|
:key="index"
|
|
128
|
-
class="
|
|
180
|
+
class="grid items-center gap-8 @min-[60.0625rem]:gap-16"
|
|
129
181
|
:class="rowHasImage(row) ? rowGridColsClass(index) : ''"
|
|
130
182
|
>
|
|
131
183
|
<UiImage
|
|
@@ -135,7 +187,7 @@ useRichTextScrollRegions(rowsRoot, (caption) => caption ?? t('splitContent.richT
|
|
|
135
187
|
:framing="rowFraming(row)"
|
|
136
188
|
:entry-id="entryId"
|
|
137
189
|
:field-path="`rows.${index}.image`"
|
|
138
|
-
aspect="4
|
|
190
|
+
aspect="5/4"
|
|
139
191
|
rounded="xl"
|
|
140
192
|
:class="imageOrderClass(index)"
|
|
141
193
|
/>
|
|
@@ -143,17 +195,17 @@ useRichTextScrollRegions(rowsRoot, (caption) => caption ?? t('splitContent.richT
|
|
|
143
195
|
v-else-if="editing"
|
|
144
196
|
inline
|
|
145
197
|
:label="t('splitContent.imageHintLabel')"
|
|
146
|
-
:class="['bg-surface-strong aspect-[4
|
|
198
|
+
:class="['bg-surface-strong aspect-[5/4] w-full rounded-xl', imageOrderClass(index)]"
|
|
147
199
|
/>
|
|
148
200
|
|
|
149
201
|
<div
|
|
150
|
-
class="
|
|
151
|
-
:class="[rowHasImage(row) ? '
|
|
202
|
+
class="min-w-0"
|
|
203
|
+
:class="[rowHasImage(row) ? '' : 'max-w-[40rem]', textOrderClass(index)]"
|
|
152
204
|
>
|
|
153
|
-
<p v-if="row.eyebrow" class="text-overline text-accent">{{ row.eyebrow }}</p>
|
|
205
|
+
<p v-if="row.eyebrow" class="text-overline text-accent mb-2">{{ row.eyebrow }}</p>
|
|
154
206
|
<h2
|
|
155
207
|
v-if="row.heading"
|
|
156
|
-
class="font-heading text-text
|
|
208
|
+
class="font-heading text-text text-[1.75rem] leading-[1.1] font-medium tracking-[-0.01em] text-balance @min-[47.5625rem]:text-[2.25rem]"
|
|
157
209
|
>
|
|
158
210
|
{{ row.heading }}
|
|
159
211
|
</h2>
|
|
@@ -169,23 +221,49 @@ useRichTextScrollRegions(rowsRoot, (caption) => caption ?? t('splitContent.richT
|
|
|
169
221
|
floor costs nothing and survives a toolbar change.) -->
|
|
170
222
|
<EldraRichText
|
|
171
223
|
v-if="rowHasText(row)"
|
|
172
|
-
class="prose-eldra text-
|
|
224
|
+
class="prose-eldra text-muted mt-4 text-[1.125rem] leading-[1.6] [&>*+*]:mt-3"
|
|
173
225
|
:entry-id="entryId"
|
|
174
226
|
:field="`rows.${index}.text`"
|
|
175
227
|
:doc="row.text"
|
|
176
228
|
:min-heading-level="3"
|
|
177
229
|
/>
|
|
178
230
|
|
|
179
|
-
<
|
|
231
|
+
<ul v-if="rowEntries(index).length > 0" role="list" class="border-border mt-6 border-t">
|
|
232
|
+
<li
|
|
233
|
+
v-for="(entry, entryIndex) in rowEntries(index)"
|
|
234
|
+
:key="entryIndex"
|
|
235
|
+
class="border-border grid grid-cols-[3rem_minmax(0,1fr)_auto] items-center gap-4 border-b py-3.5"
|
|
236
|
+
>
|
|
237
|
+
<span
|
|
238
|
+
class="font-heading text-primary-contrast grid size-12 place-items-center rounded-full text-[1.125rem]"
|
|
239
|
+
:class="entryTone(entryIndex)"
|
|
240
|
+
aria-hidden="true"
|
|
241
|
+
>{{ entryInitial(entry) }}</span
|
|
242
|
+
>
|
|
243
|
+
<span class="min-w-0">
|
|
244
|
+
<span class="block font-semibold">{{ entry.title }}</span>
|
|
245
|
+
<span v-if="entry.text" class="text-muted block text-sm">{{ entry.text }}</span>
|
|
246
|
+
</span>
|
|
247
|
+
<Link
|
|
248
|
+
v-if="entryHref(entry) !== null"
|
|
249
|
+
:href="entryHref(entry)!"
|
|
250
|
+
:as="entryLinkAs(entry)"
|
|
251
|
+
class="text-[0.9375rem] font-semibold"
|
|
252
|
+
>
|
|
253
|
+
{{ entry.linkLabel }}<VisuallyHidden> {{ entry.title }}</VisuallyHidden>
|
|
254
|
+
</Link>
|
|
255
|
+
</li>
|
|
256
|
+
</ul>
|
|
257
|
+
|
|
258
|
+
<Button
|
|
180
259
|
v-if="rowHasLink(row)"
|
|
181
260
|
:href="rowHref(row)!"
|
|
182
261
|
:as="rowLinkAs(row)"
|
|
183
|
-
variant="
|
|
184
|
-
|
|
185
|
-
class="mt-1 text-lg"
|
|
262
|
+
variant="outline"
|
|
263
|
+
class="mt-7"
|
|
186
264
|
>
|
|
187
265
|
{{ row.linkLabel }}
|
|
188
|
-
</
|
|
266
|
+
</Button>
|
|
189
267
|
</div>
|
|
190
268
|
</li>
|
|
191
269
|
</ol>
|
|
@@ -73,7 +73,7 @@ describe('split-content block', () => {
|
|
|
73
73
|
it('renders rows as an ordered role=list, one h2 heading per row', () => {
|
|
74
74
|
const wrapper = mount(Block, mountOptions({ entry: { id: 'e1', data: withImage } }));
|
|
75
75
|
const list = wrapper.get('ol[role="list"]');
|
|
76
|
-
const items = list.findAll('li');
|
|
76
|
+
const items = list.findAll(':scope > li');
|
|
77
77
|
expect(items).toHaveLength(withImage.rows.length);
|
|
78
78
|
const headings = list.findAll('h2');
|
|
79
79
|
expect(headings).toHaveLength(withImage.rows.length);
|
|
@@ -89,7 +89,7 @@ describe('split-content block', () => {
|
|
|
89
89
|
Block,
|
|
90
90
|
mountOptions({ entry: { id: 'e1', data: { ...withImage, startWith } } })
|
|
91
91
|
);
|
|
92
|
-
const items = wrapper.findAll('li');
|
|
92
|
+
const items = wrapper.findAll('ol > li');
|
|
93
93
|
expect(items).toHaveLength(withImage.rows.length);
|
|
94
94
|
items.forEach((item) => {
|
|
95
95
|
const first = item.element.children[0] as HTMLElement;
|
|
@@ -103,14 +103,21 @@ describe('split-content block', () => {
|
|
|
103
103
|
Block,
|
|
104
104
|
mountOptions({ entry: { id: 'e1', data: { ...withImage, startWith: 'image-left' } } })
|
|
105
105
|
);
|
|
106
|
-
const items = wrapper.findAll('li');
|
|
107
|
-
// Row 1 (index 0, image-left): the image's own
|
|
108
|
-
|
|
109
|
-
expect(items[0]!.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
expect(items[
|
|
113
|
-
|
|
106
|
+
const items = wrapper.findAll('ol > li');
|
|
107
|
+
// Row 1 (index 0, image-left): the image's own wider 1.15fr column comes first, no order
|
|
108
|
+
// override; side by side from 961px of block width.
|
|
109
|
+
expect(items[0]!.classes()).toContain(
|
|
110
|
+
'@min-[60.0625rem]:grid-cols-[minmax(0,1.15fr)_minmax(0,1fr)]'
|
|
111
|
+
);
|
|
112
|
+
expect(items[0]!.get('[data-part="root"]').classes()).not.toContain(
|
|
113
|
+
'@min-[60.0625rem]:order-2'
|
|
114
|
+
);
|
|
115
|
+
// Row 2 (index 1, image-right): the text's 1fr column comes first; the image (still first in
|
|
116
|
+
// the DOM) is pushed to the second, wider track with `order`.
|
|
117
|
+
expect(items[1]!.classes()).toContain(
|
|
118
|
+
'@min-[60.0625rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.15fr)]'
|
|
119
|
+
);
|
|
120
|
+
expect(items[1]!.get('[data-part="root"]').classes()).toContain('@min-[60.0625rem]:order-2');
|
|
114
121
|
});
|
|
115
122
|
|
|
116
123
|
it('a row with no image renders no <img>, stays single column, and gives its text a 40rem max width', () => {
|
|
@@ -122,7 +129,7 @@ describe('split-content block', () => {
|
|
|
122
129
|
);
|
|
123
130
|
const item = wrapper.get('li');
|
|
124
131
|
expect(item.find('img').exists()).toBe(false);
|
|
125
|
-
expect(item.classes().some((c) => c.
|
|
132
|
+
expect(item.classes().some((c) => c.includes('grid-cols'))).toBe(false);
|
|
126
133
|
expect(item.element.children).toHaveLength(1);
|
|
127
134
|
expect((item.element.children[0] as HTMLElement).className).toContain('max-w-[40rem]');
|
|
128
135
|
});
|
|
@@ -136,18 +143,50 @@ describe('split-content block', () => {
|
|
|
136
143
|
Block,
|
|
137
144
|
mountOptions({ entry: { id: 'e1', data: { startWith: 'image-left', rows } } })
|
|
138
145
|
);
|
|
139
|
-
expect(wrapper.findAll('li')).toHaveLength(6);
|
|
146
|
+
expect(wrapper.findAll('ol > li')).toHaveLength(6);
|
|
140
147
|
});
|
|
141
148
|
|
|
142
|
-
it(
|
|
149
|
+
it("every link is reachable in source order: a row's list entries, then its button", () => {
|
|
143
150
|
const wrapper = mount(Block, mountOptions({ entry: { id: 'e1', data: withImage } }));
|
|
144
151
|
const links = wrapper.element.querySelectorAll('a[href]');
|
|
145
|
-
|
|
146
|
-
withImage.
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
152
|
+
const expected = withImage.rows.flatMap((row, index) => [
|
|
153
|
+
...(index === 0 ? withImage.list : []).map((entry) => ({
|
|
154
|
+
name: `${entry.linkLabel}\u00a0${entry.title}`,
|
|
155
|
+
href: entry.href,
|
|
156
|
+
})),
|
|
157
|
+
{ name: row.linkLabel, href: row.href },
|
|
158
|
+
]);
|
|
159
|
+
expect(
|
|
160
|
+
Array.from(links).map((link) => ({
|
|
161
|
+
name: link.textContent?.trim(),
|
|
162
|
+
href: link.getAttribute('href'),
|
|
163
|
+
}))
|
|
164
|
+
).toEqual(expected);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('renders a row list: hidden initials, a name and line per entry, links named with the entry, axe-clean', async () => {
|
|
168
|
+
const wrapper = mount(Block, mountOptions({ entry: { id: 'e1', data: withImage } }));
|
|
169
|
+
const entries = wrapper.findAll('ol > li:first-child ul > li');
|
|
170
|
+
expect(entries).toHaveLength(withImage.list.length);
|
|
171
|
+
expect(wrapper.findAll('ol > li:nth-child(2) ul > li')).toHaveLength(0);
|
|
172
|
+
entries.forEach((entry, index) => {
|
|
173
|
+
const source = withImage.list[index]!;
|
|
174
|
+
const initial = entry.get('span[aria-hidden="true"]');
|
|
175
|
+
expect(initial.text()).toBe(source.title.charAt(0));
|
|
176
|
+
expect(entry.text()).toContain(source.text);
|
|
177
|
+
expect(entry.get('a').text()).toContain(source.title);
|
|
178
|
+
});
|
|
179
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
it('puts the block on surface when background is surface, and on the page ground by default', () => {
|
|
183
|
+
const onSurface = mount(Block, mountOptions({ entry: { id: 'e1', data: withImage } }));
|
|
184
|
+
expect(onSurface.get('section').attributes('data-section-bg')).toBe('surface');
|
|
185
|
+
const plain = mount(
|
|
186
|
+
Block,
|
|
187
|
+
mountOptions({ entry: { id: 'e1', data: { ...withImage, background: undefined } } })
|
|
150
188
|
);
|
|
189
|
+
expect(plain.get('section').attributes('data-section-bg')).toBe('none');
|
|
151
190
|
});
|
|
152
191
|
|
|
153
192
|
it("a row link is a real <a href>, so Tab and Enter are the platform's own way to reach and activate it", () => {
|
|
@@ -11,8 +11,12 @@
|
|
|
11
11
|
"name": "Start with",
|
|
12
12
|
"type": "select",
|
|
13
13
|
"helpText": "image-left is the default. Only the first row's image side — rows then alternate.",
|
|
14
|
-
"metadata": {
|
|
15
|
-
|
|
14
|
+
"metadata": {
|
|
15
|
+
"options": ["image-left", "image-right"]
|
|
16
|
+
},
|
|
17
|
+
"validators": {
|
|
18
|
+
"required": true
|
|
19
|
+
}
|
|
16
20
|
},
|
|
17
21
|
{
|
|
18
22
|
"fieldId": "rows",
|
|
@@ -30,7 +34,10 @@
|
|
|
30
34
|
"fieldId": "image",
|
|
31
35
|
"name": "Image",
|
|
32
36
|
"type": "media",
|
|
33
|
-
"metadata": {
|
|
37
|
+
"metadata": {
|
|
38
|
+
"multiple": false,
|
|
39
|
+
"framing": true
|
|
40
|
+
}
|
|
34
41
|
},
|
|
35
42
|
{
|
|
36
43
|
"fieldId": "eyebrow",
|
|
@@ -43,7 +50,9 @@
|
|
|
43
50
|
"name": "Heading",
|
|
44
51
|
"type": "string",
|
|
45
52
|
"localized": true,
|
|
46
|
-
"validators": {
|
|
53
|
+
"validators": {
|
|
54
|
+
"required": true
|
|
55
|
+
}
|
|
47
56
|
},
|
|
48
57
|
{
|
|
49
58
|
"fieldId": "text",
|
|
@@ -56,15 +65,72 @@
|
|
|
56
65
|
},
|
|
57
66
|
{
|
|
58
67
|
"fieldId": "linkLabel",
|
|
59
|
-
"name": "
|
|
68
|
+
"name": "Button label",
|
|
60
69
|
"type": "string",
|
|
61
70
|
"localized": true
|
|
62
71
|
},
|
|
63
|
-
{
|
|
72
|
+
{
|
|
73
|
+
"fieldId": "href",
|
|
74
|
+
"name": "Button link",
|
|
75
|
+
"type": "string"
|
|
76
|
+
}
|
|
64
77
|
]
|
|
65
78
|
}
|
|
66
79
|
}
|
|
67
80
|
}
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"fieldId": "list",
|
|
84
|
+
"name": "List",
|
|
85
|
+
"type": "list",
|
|
86
|
+
"helpText": "Optional short entries under the first row's text, each with a round initial, a name, one line and a link, e.g. the makers you work with. 2-4 work best.",
|
|
87
|
+
"metadata": {
|
|
88
|
+
"item": {
|
|
89
|
+
"fieldId": "entry",
|
|
90
|
+
"name": "Entry",
|
|
91
|
+
"type": "composite",
|
|
92
|
+
"metadata": {
|
|
93
|
+
"fields": [
|
|
94
|
+
{
|
|
95
|
+
"fieldId": "title",
|
|
96
|
+
"name": "Name",
|
|
97
|
+
"type": "string",
|
|
98
|
+
"localized": true,
|
|
99
|
+
"validators": {
|
|
100
|
+
"required": true
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"fieldId": "text",
|
|
105
|
+
"name": "Line",
|
|
106
|
+
"type": "string",
|
|
107
|
+
"localized": true
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"fieldId": "linkLabel",
|
|
111
|
+
"name": "Link label",
|
|
112
|
+
"type": "string",
|
|
113
|
+
"localized": true,
|
|
114
|
+
"helpText": "Short, e.g. \"Shop\". Screen readers hear the name after it."
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"fieldId": "href",
|
|
118
|
+
"name": "Link",
|
|
119
|
+
"type": "string"
|
|
120
|
+
}
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"fieldId": "background",
|
|
128
|
+
"name": "Section background",
|
|
129
|
+
"type": "select",
|
|
130
|
+
"helpText": "none is the default.",
|
|
131
|
+
"metadata": {
|
|
132
|
+
"options": ["none", "surface"]
|
|
133
|
+
}
|
|
68
134
|
}
|
|
69
135
|
]
|
|
70
136
|
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
|
+
"background": "surface",
|
|
2
3
|
"rows": [
|
|
3
4
|
{
|
|
4
5
|
"image": {
|
|
5
6
|
"assetId": "demo-split-1",
|
|
6
|
-
"url": "/
|
|
7
|
-
"altText": "
|
|
8
|
-
"width":
|
|
9
|
-
"height":
|
|
7
|
+
"url": "/images/wheel.webp",
|
|
8
|
+
"altText": "Hands shaping clay on a potter's wheel",
|
|
9
|
+
"width": 1400,
|
|
10
|
+
"height": 933
|
|
10
11
|
},
|
|
11
|
-
"eyebrow": "The
|
|
12
|
-
"heading": "
|
|
12
|
+
"eyebrow": "The makers",
|
|
13
|
+
"heading": "Nine workshops, all within a day's drive",
|
|
13
14
|
"text": {
|
|
14
15
|
"type": "doc",
|
|
15
16
|
"content": [
|
|
@@ -18,22 +19,22 @@
|
|
|
18
19
|
"content": [
|
|
19
20
|
{
|
|
20
21
|
"type": "text",
|
|
21
|
-
"text": "
|
|
22
|
+
"text": "We visit every workshop we sell from. Here are three of them."
|
|
22
23
|
}
|
|
23
24
|
]
|
|
24
25
|
}
|
|
25
26
|
]
|
|
26
27
|
},
|
|
27
|
-
"linkLabel": "
|
|
28
|
-
"href": "/pages/
|
|
28
|
+
"linkLabel": "Read their stories",
|
|
29
|
+
"href": "/pages/makers"
|
|
29
30
|
},
|
|
30
31
|
{
|
|
31
32
|
"image": {
|
|
32
33
|
"assetId": "demo-split-2",
|
|
33
|
-
"url": "/
|
|
34
|
-
"altText": "
|
|
35
|
-
"width":
|
|
36
|
-
"height":
|
|
34
|
+
"url": "/images/clay-hands.webp",
|
|
35
|
+
"altText": "A potter's hands working wet clay",
|
|
36
|
+
"width": 1400,
|
|
37
|
+
"height": 933
|
|
37
38
|
},
|
|
38
39
|
"eyebrow": "The mill",
|
|
39
40
|
"heading": "Knitted slowly, so it lasts",
|
|
@@ -54,5 +55,25 @@
|
|
|
54
55
|
"linkLabel": "Visit the mill",
|
|
55
56
|
"href": "/pages/mill"
|
|
56
57
|
}
|
|
58
|
+
],
|
|
59
|
+
"list": [
|
|
60
|
+
{
|
|
61
|
+
"title": "Harbour Pottery",
|
|
62
|
+
"text": "Stoneware, thrown and glazed by hand",
|
|
63
|
+
"linkLabel": "Shop",
|
|
64
|
+
"href": "/collections/the-winter-edit"
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
"title": "Fell & Fleece",
|
|
68
|
+
"text": "Knitwear from their own flock",
|
|
69
|
+
"linkLabel": "Shop",
|
|
70
|
+
"href": "/collections/winter-knitwear"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"title": "Kiln Lane",
|
|
74
|
+
"text": "Small-batch vases and jugs",
|
|
75
|
+
"linkLabel": "Shop",
|
|
76
|
+
"href": "/collections/best-sellers"
|
|
77
|
+
}
|
|
57
78
|
]
|
|
58
79
|
}
|
|
Binary file
|
|
Binary file
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"href": "/collections/care",
|
|
63
63
|
"image": {
|
|
64
64
|
"assetId": "demo-feature-1",
|
|
65
|
-
"url": "/
|
|
66
|
-
"altText": "
|
|
67
|
-
"width":
|
|
68
|
-
"height":
|
|
65
|
+
"url": "/images/yarn-tools.webp",
|
|
66
|
+
"altText": "Yarn and knitting needles on a table",
|
|
67
|
+
"width": 1400,
|
|
68
|
+
"height": 933
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
{
|
|
@@ -89,10 +89,10 @@
|
|
|
89
89
|
"href": "/collections/ceramics",
|
|
90
90
|
"image": {
|
|
91
91
|
"assetId": "demo-feature-2",
|
|
92
|
-
"url": "/
|
|
93
|
-
"altText": "
|
|
94
|
-
"width":
|
|
95
|
-
"height":
|
|
92
|
+
"url": "/images/plates.webp",
|
|
93
|
+
"altText": "Stoneware plates set on a table",
|
|
94
|
+
"width": 1400,
|
|
95
|
+
"height": 933
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
{
|
|
@@ -116,10 +116,10 @@
|
|
|
116
116
|
"href": "/collections/kitchen",
|
|
117
117
|
"image": {
|
|
118
118
|
"assetId": "demo-feature-3",
|
|
119
|
-
"url": "/
|
|
120
|
-
"altText": "
|
|
121
|
-
"width":
|
|
122
|
-
"height":
|
|
119
|
+
"url": "/images/kitchen.webp",
|
|
120
|
+
"altText": "A laid kitchen table",
|
|
121
|
+
"width": 1400,
|
|
122
|
+
"height": 840
|
|
123
123
|
}
|
|
124
124
|
},
|
|
125
125
|
{
|
|
@@ -143,10 +143,10 @@
|
|
|
143
143
|
"href": "/collections/linen",
|
|
144
144
|
"image": {
|
|
145
145
|
"assetId": "demo-feature-4",
|
|
146
|
-
"url": "/
|
|
147
|
-
"altText": "
|
|
148
|
-
"width":
|
|
149
|
-
"height":
|
|
146
|
+
"url": "/images/enamel-cups.webp",
|
|
147
|
+
"altText": "Enamel cups on a wooden table",
|
|
148
|
+
"width": 1400,
|
|
149
|
+
"height": 933
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|