@eldrajs/theme-cli 0.2.7 → 0.2.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/package.json +3 -3
  3. package/template/.eldra/block-types.d.ts +28 -7
  4. package/template/.eldra/manifest.json +1152 -445
  5. package/template/.eldra/previews.json +35 -35
  6. package/template/README.md +32 -0
  7. package/template/app/assets/main.css +23 -0
  8. package/template/app/plugins/eldra-storefront.ts +3 -0
  9. package/template/app/storefront/demo.ts +75 -24
  10. package/template/app/storefront/gateway.ts +16 -2
  11. package/template/blocks/announcement-bar/preview.png +0 -0
  12. package/template/blocks/article/preview.json +4 -4
  13. package/template/blocks/article/preview.png +0 -0
  14. package/template/blocks/article-list/Block.vue +48 -19
  15. package/template/blocks/article-list/__tests__/Block.spec.ts +15 -0
  16. package/template/blocks/article-list/preview.json +43 -43
  17. package/template/blocks/article-list/preview.png +0 -0
  18. package/template/blocks/breadcrumbs/preview.png +0 -0
  19. package/template/blocks/cart/preview.png +0 -0
  20. package/template/blocks/collection-grid/Block.vue +260 -9
  21. package/template/blocks/collection-grid/__tests__/Block.spec.ts +202 -0
  22. package/template/blocks/collection-grid/block.json +3 -3
  23. package/template/blocks/collection-grid/preview.png +0 -0
  24. package/template/blocks/collection-header/Block.vue +65 -52
  25. package/template/blocks/collection-header/preview.json +4 -4
  26. package/template/blocks/collection-header/preview.png +0 -0
  27. package/template/blocks/contact/preview.png +0 -0
  28. package/template/blocks/cta/preview.json +4 -4
  29. package/template/blocks/cta/preview.png +0 -0
  30. package/template/blocks/faq/preview.png +0 -0
  31. package/template/blocks/feature-grid/Block.vue +73 -4
  32. package/template/blocks/feature-grid/__tests__/Block.spec.ts +43 -1
  33. package/template/blocks/feature-grid/block.json +2 -2
  34. package/template/blocks/feature-grid/preview.json +49 -24
  35. package/template/blocks/feature-grid/preview.png +0 -0
  36. package/template/blocks/footer/Block.vue +186 -71
  37. package/template/blocks/footer/__tests__/Block.spec.ts +127 -32
  38. package/template/blocks/footer/block.json +42 -4
  39. package/template/blocks/footer/mock.json +31 -34
  40. package/template/blocks/footer/preview.png +0 -0
  41. package/template/blocks/form/preview.png +0 -0
  42. package/template/blocks/gallery/preview.json +24 -24
  43. package/template/blocks/gallery/preview.png +0 -0
  44. package/template/blocks/hero/Block.vue +117 -19
  45. package/template/blocks/hero/__tests__/Block.spec.ts +46 -0
  46. package/template/blocks/hero/block.json +36 -1
  47. package/template/blocks/hero/preview.json +33 -25
  48. package/template/blocks/hero/preview.png +0 -0
  49. package/template/blocks/image/preview.json +4 -4
  50. package/template/blocks/image/preview.png +0 -0
  51. package/template/blocks/logo-cloud/preview.png +0 -0
  52. package/template/blocks/navigation/Block.vue +665 -184
  53. package/template/blocks/navigation/__tests__/Block.spec.ts +496 -75
  54. package/template/blocks/navigation/__tests__/fixtures/menu.json +182 -0
  55. package/template/blocks/navigation/block.json +110 -6
  56. package/template/blocks/navigation/mock.json +372 -140
  57. package/template/blocks/navigation/preview.json +311 -0
  58. package/template/blocks/navigation/preview.png +0 -0
  59. package/template/blocks/newsletter/Block.vue +248 -144
  60. package/template/blocks/newsletter/__tests__/Block.spec.ts +42 -0
  61. package/template/blocks/newsletter/block.json +61 -2
  62. package/template/blocks/newsletter/preview.json +35 -0
  63. package/template/blocks/newsletter/preview.png +0 -0
  64. package/template/blocks/order-status/preview.png +0 -0
  65. package/template/blocks/pricing-table/preview.png +0 -0
  66. package/template/blocks/product-carousel/Block.vue +272 -26
  67. package/template/blocks/product-carousel/__tests__/Block.spec.ts +90 -0
  68. package/template/blocks/product-carousel/block.json +61 -0
  69. package/template/blocks/product-carousel/preview.json +12 -0
  70. package/template/blocks/product-carousel/preview.png +0 -0
  71. package/template/blocks/product-detail/Block.vue +148 -96
  72. package/template/blocks/product-detail/__tests__/Block.spec.ts +98 -74
  73. package/template/blocks/product-detail/block.json +11 -4
  74. package/template/blocks/product-detail/mock.json +53 -22
  75. package/template/blocks/product-detail/parts/Gallery.vue +52 -103
  76. package/template/blocks/product-detail/preview.png +0 -0
  77. package/template/blocks/quote/preview.png +0 -0
  78. package/template/blocks/rich-text/preview.png +0 -0
  79. package/template/blocks/search/Block.vue +1 -0
  80. package/template/blocks/search/TypeSection.vue +1 -0
  81. package/template/blocks/search/__tests__/Block.spec.ts +23 -0
  82. package/template/blocks/search/preview.png +0 -0
  83. package/template/blocks/split-content/Block.vue +98 -20
  84. package/template/blocks/split-content/__tests__/Block.spec.ts +57 -18
  85. package/template/blocks/split-content/block.json +72 -6
  86. package/template/blocks/split-content/preview.json +34 -13
  87. package/template/blocks/split-content/preview.png +0 -0
  88. package/template/blocks/stats/preview.png +0 -0
  89. package/template/blocks/tabs/preview.json +16 -16
  90. package/template/blocks/tabs/preview.png +0 -0
  91. package/template/blocks/team/preview.png +0 -0
  92. package/template/blocks/testimonials/preview.png +0 -0
  93. package/template/blocks/timeline/preview.png +0 -0
  94. package/template/blocks/trust-strip/Block.vue +67 -1
  95. package/template/blocks/trust-strip/__tests__/Block.spec.ts +30 -1
  96. package/template/blocks/trust-strip/block.json +4 -4
  97. package/template/blocks/trust-strip/preview.json +21 -0
  98. package/template/blocks/trust-strip/preview.png +0 -0
  99. package/template/blocks/video-embed/preview.png +0 -0
  100. package/template/blocks/wishlist/preview.png +0 -0
  101. package/template/i18n/en-US.json +16 -9
  102. package/template/i18n/is-IS.json +16 -9
  103. package/template/package.json +1 -1
  104. package/template/pages/article.page.json +19 -18
  105. package/template/pages/cart.page.json +3 -13
  106. package/template/pages/category.page.json +15 -7
  107. package/template/pages/collection.page.json +15 -14
  108. package/template/pages/home.page.json +217 -182
  109. package/template/pages/product.page.json +46 -36
  110. package/template/pages/products.page.json +3 -13
  111. package/template/pages/search.page.json +3 -13
  112. package/template/pages/wishlist.page.json +3 -13
  113. package/template/public/images/CREDITS.md +28 -0
  114. package/template/public/images/bowl.webp +0 -0
  115. package/template/public/images/clay-hands.webp +0 -0
  116. package/template/public/images/coffee-table.webp +0 -0
  117. package/template/public/images/cup.webp +0 -0
  118. package/template/public/images/enamel-cups.webp +0 -0
  119. package/template/public/images/hero.webp +0 -0
  120. package/template/public/images/kitchen.webp +0 -0
  121. package/template/public/images/mug.webp +0 -0
  122. package/template/public/images/northwind-mark.svg +1 -0
  123. package/template/public/images/planters.webp +0 -0
  124. package/template/public/images/plates.webp +0 -0
  125. package/template/public/images/reading.webp +0 -0
  126. package/template/public/images/sweater.webp +0 -0
  127. package/template/public/images/terracotta.webp +0 -0
  128. package/template/public/images/throws.webp +0 -0
  129. package/template/public/images/vase.webp +0 -0
  130. package/template/public/images/wheel.webp +0 -0
  131. package/template/public/images/yarn-tools.webp +0 -0
  132. package/template/public/images/yarn.webp +0 -0
  133. package/template/stories/generated/collection-grid.stories.ts +6 -0
  134. package/template/stories/generated/feature-grid.stories.ts +6 -0
  135. package/template/stories/generated/footer.stories.ts +4 -4
  136. package/template/stories/generated/hero.stories.ts +6 -0
  137. package/template/stories/generated/navigation.stories.ts +14 -1
  138. package/template/stories/generated/newsletter.stories.ts +2 -1
  139. package/template/stories/generated/product-carousel.stories.ts +12 -0
  140. package/template/stories/generated/split-content.stories.ts +12 -0
  141. package/template/stories/generated/trust-strip.stories.ts +8 -1
  142. package/template/stories/pages/article.stories.ts +2 -1
  143. package/template/stories/pages/cart.stories.ts +2 -1
  144. package/template/stories/pages/category.stories.ts +2 -1
  145. package/template/stories/pages/collection.stories.ts +2 -1
  146. package/template/stories/pages/home.stories.ts +2 -1
  147. package/template/stories/pages/product.stories.ts +2 -1
  148. package/template/stories/pages/products.stories.ts +2 -1
  149. package/template/stories/pages/search.stories.ts +2 -1
  150. package/template/stories/pages/wishlist.stories.ts +2 -1
  151. package/template/stories/support/demoChrome.ts +32 -0
  152. package/template/stories/support/pageBlocks.ts +2 -4
  153. package/template/test/countPill.browser.spec.ts +21 -13
  154. package/template/test/localePrefix.spec.ts +11 -6
  155. package/template/test/pages/article.spec.ts +1 -1
  156. package/template/test/pages/category.spec.ts +34 -11
  157. package/template/test/pages/collection.spec.ts +182 -148
  158. package/template/test/pages/home.spec.ts +35 -40
  159. package/template/test/pages/hydration.spec.ts +4 -4
  160. package/template/test/pages/product.spec.ts +17 -14
  161. package/template/test/pages/seededPages.spec.ts +11 -6
  162. package/template/test/prerenderFailure.spec.ts +4 -3
  163. package/template/test/prerenderRefresh.browser.spec.ts +36 -15
  164. package/template/test/previewParity.browser.spec.ts +1152 -0
  165. package/template/test/starter.spec.ts +37 -16
  166. package/template/test/storefront/gatewayPrerender.spec.ts +26 -0
  167. package/template/test/support/previewParity.ts +302 -0
  168. package/template/test/support/previewParityContent.ts +726 -0
  169. package/template/tokens.json +13 -13
@@ -3161,3 +3161,205 @@ describe('collection-grid — card width on a phone', () => {
3161
3161
  wrapper.unmount();
3162
3162
  });
3163
3163
  });
3164
+
3165
+ /**
3166
+ * **`filter-bar`**: the same filters as the sidebar, laid out as one row of chips above the grid —
3167
+ * a chip per group opening that group's own panel in a popover, a pressed chip per on/off value, the
3168
+ * sort at the far end, and the applied values as removable tags under it. Only the layout differs,
3169
+ * so every change here goes through the sidebar's own live path (and its debounce): the URL write,
3170
+ * the request and the focus rules are asserted against the same contract the sidebar tests use.
3171
+ */
3172
+ describe('collection-grid — the filter-bar variant', () => {
3173
+ const barMock = { ...mock, variant: 'filter-bar' };
3174
+ const bar = (wrapper: VueWrapper) =>
3175
+ wrapper.get(`[role="group"][aria-label="${enUS.grid.filterAndSort}"]`);
3176
+ const barTrigger = (wrapper: VueWrapper, label: string) =>
3177
+ bar(wrapper)
3178
+ .findAll('button[aria-haspopup="dialog"]')
3179
+ .find((button) => button.text().startsWith(label))!;
3180
+ const panelOf = (trigger: Element) =>
3181
+ document.getElementById(`${trigger.getAttribute('aria-controls')!}`);
3182
+
3183
+ async function flush(): Promise<void> {
3184
+ for (let index = 0; index < 4; index += 1) {
3185
+ await nextTick();
3186
+ await new Promise((resolve) => setTimeout(resolve, 0));
3187
+ }
3188
+ }
3189
+
3190
+ /** What a browser does when `Enter` activates a focused `<button>`: keydown, then a `detail: 0`
3191
+ * click. */
3192
+ async function pressEnter(button: HTMLElement): Promise<void> {
3193
+ button.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
3194
+ button.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, detail: 0 }));
3195
+ await flush();
3196
+ }
3197
+
3198
+ afterEach(() => {
3199
+ document.body.innerHTML = '';
3200
+ });
3201
+
3202
+ it('draws a chip per group, a pressed chip per on/off value and the sort — no sidebar, no drawer', async () => {
3203
+ const wrapper = mountGrid(barMock);
3204
+ await wrapper.vm.$nextTick();
3205
+
3206
+ expect(wrapper.find('aside').exists()).toBe(false);
3207
+ expect(wrapper.find('dialog').exists()).toBe(false);
3208
+ const groups = bar(wrapper).findAll('button[aria-haspopup="dialog"]');
3209
+ // Category, Size, Colour, Price: every seeded group but the on/off Availability one.
3210
+ expect(groups.map((button) => button.text())).toEqual([
3211
+ enUS.grid.legendCategory,
3212
+ 'Size',
3213
+ 'Colour',
3214
+ PRICE_LEGEND,
3215
+ ]);
3216
+ const pressed = bar(wrapper).get('button[aria-pressed]');
3217
+ expect(pressed.text()).toBe(enUS.grid.availabilityInStock);
3218
+ expect(pressed.attributes('aria-pressed')).toBe('false');
3219
+ expect(comboboxes(wrapper)).toHaveLength(2); // Sort, and Columns from 64rem
3220
+ expect(countLine(wrapper).text()).toBe('48 products');
3221
+ });
3222
+
3223
+ it('is axe-clean closed, with a group open, and with filters applied', async () => {
3224
+ const wrapper = mountGrid(barMock, { attachTo: document.body });
3225
+ await wrapper.vm.$nextTick();
3226
+ expect(await axe(wrapper.element)).toHaveNoViolations();
3227
+
3228
+ const colour = barTrigger(wrapper, 'Colour').element as HTMLElement;
3229
+ await pressEnter(colour);
3230
+ const panel = panelOf(colour)!;
3231
+ expect(panel).not.toBeNull();
3232
+ expect(panel.getAttribute('role')).toBe('dialog');
3233
+ expect(panel.getAttribute('aria-label')).toBe('Colour');
3234
+ expect(await axe(panel)).toHaveNoViolations();
3235
+
3236
+ (panel.querySelector('input[type="checkbox"]') as HTMLInputElement).click();
3237
+ await flush();
3238
+ await bar(wrapper).get('button[aria-pressed]').trigger('click');
3239
+ await flush();
3240
+ expect(await axe(wrapper.element)).toHaveNoViolations();
3241
+ });
3242
+
3243
+ describe('keyboard', () => {
3244
+ it('Enter opens a group, a ticked value applies at once, Escape closes and returns focus', async () => {
3245
+ const source = createDemoStorefront();
3246
+ const patches: Array<Record<string, unknown>> = [];
3247
+ const route = {
3248
+ ...source.route,
3249
+ setQuery(patch: Record<string, string | string[] | null>) {
3250
+ patches.push(patch);
3251
+ },
3252
+ };
3253
+ const wrapper = mountGrid(barMock, {
3254
+ source: { ...source, route },
3255
+ attachTo: document.body,
3256
+ });
3257
+ await wrapper.vm.$nextTick();
3258
+
3259
+ const size = barTrigger(wrapper, 'Size').element as HTMLElement;
3260
+ size.focus();
3261
+ await pressEnter(size);
3262
+ expect(size.getAttribute('aria-expanded')).toBe('true');
3263
+
3264
+ const panel = panelOf(size)!;
3265
+ const box = panel.querySelectorAll<HTMLInputElement>('input[type="checkbox"]')[2]!;
3266
+ box.focus();
3267
+ box.click();
3268
+ await flush();
3269
+
3270
+ // The sidebar's own live path: the URL moves on the tick, the trigger counts it.
3271
+ expect(patches.at(-1)).toMatchObject({ page: null, size: ['m'] });
3272
+ expect(barTrigger(wrapper, 'Size').text()).toContain('1');
3273
+ expect(wrapper.get(`ul[aria-label="${enUS.grid.activeFilters}"]`).text()).toContain('M');
3274
+
3275
+ box.dispatchEvent(
3276
+ new KeyboardEvent('keydown', { key: 'Escape', bubbles: true, cancelable: true })
3277
+ );
3278
+ await flush();
3279
+ expect(panelOf(size)).toBeNull();
3280
+ expect(document.activeElement).toBe(size);
3281
+ });
3282
+
3283
+ it('Enter on an on/off chip presses it and adds its tag; removing the tag focuses the count', async () => {
3284
+ const wrapper = mountGrid(barMock, { attachTo: document.body });
3285
+ await wrapper.vm.$nextTick();
3286
+
3287
+ const chip = bar(wrapper).get('button[aria-pressed]');
3288
+ (chip.element as HTMLElement).focus();
3289
+ // A native button turns Enter into a click; jsdom does not, so the click is dispatched.
3290
+ await chip.trigger('click');
3291
+ await flush();
3292
+ expect(chip.attributes('aria-pressed')).toBe('true');
3293
+
3294
+ const tags = wrapper.get(`ul[aria-label="${enUS.grid.activeFilters}"]`);
3295
+ const remove = tags.get('[data-part="removeButton"]');
3296
+ expect(remove.attributes('aria-label')).toBe(
3297
+ `Remove filter ${enUS.grid.legendAvailability}: ${enUS.grid.availabilityInStock}`
3298
+ );
3299
+ await remove.trigger('click');
3300
+ await flush();
3301
+
3302
+ expect(chip.attributes('aria-pressed')).toBe('false');
3303
+ expect(wrapper.find(`ul[aria-label="${enUS.grid.activeFilters}"]`).exists()).toBe(false);
3304
+ expect(document.activeElement).toBe(countLine(wrapper).element);
3305
+ });
3306
+
3307
+ it('removing one of two tags moves focus to the next tag', async () => {
3308
+ const wrapper = mountGrid(barMock, { attachTo: document.body });
3309
+ await wrapper.vm.$nextTick();
3310
+ const size = barTrigger(wrapper, 'Size').element as HTMLElement;
3311
+ await pressEnter(size);
3312
+ const boxes = panelOf(size)!.querySelectorAll<HTMLInputElement>('input[type="checkbox"]');
3313
+ boxes[0]!.click();
3314
+ await flush();
3315
+ boxes[1]!.click();
3316
+ await flush();
3317
+
3318
+ const tags = () =>
3319
+ wrapper
3320
+ .get(`ul[aria-label="${enUS.grid.activeFilters}"]`)
3321
+ .findAll('[data-part="removeButton"]');
3322
+ expect(tags()).toHaveLength(2);
3323
+ await tags()[0]!.trigger('click');
3324
+ await flush();
3325
+ expect(tags()).toHaveLength(1);
3326
+ expect(document.activeElement).toBe(tags()[0]!.element);
3327
+ });
3328
+
3329
+ it('Clear all empties the selection and focuses the count', async () => {
3330
+ const wrapper = mountGrid(barMock, { attachTo: document.body });
3331
+ await wrapper.vm.$nextTick();
3332
+ await bar(wrapper).get('button[aria-pressed]').trigger('click');
3333
+ await flush();
3334
+
3335
+ const clearAll = wrapper
3336
+ .findAll('button')
3337
+ .find((button) => button.text() === enUS.grid.clearAll)!;
3338
+ (clearAll.element as HTMLElement).focus();
3339
+ await clearAll.trigger('click');
3340
+ await flush();
3341
+
3342
+ expect(bar(wrapper).get('button[aria-pressed]').attributes('aria-pressed')).toBe('false');
3343
+ expect(wrapper.find(`ul[aria-label="${enUS.grid.activeFilters}"]`).exists()).toBe(false);
3344
+ expect(document.activeElement).toBe(countLine(wrapper).element);
3345
+ });
3346
+ });
3347
+
3348
+ it('the bar’s requests are the sidebar’s: one debounced read for a run of changes', async () => {
3349
+ const stub = createStub(PRODUCTS, { filteredCount: 4 });
3350
+ const wrapper = mountGrid(barMock, { source: stub.source, attachTo: document.body });
3351
+ await wrapper.vm.$nextTick();
3352
+ const before = stub.requests.length;
3353
+
3354
+ useFilterTimers();
3355
+ await bar(wrapper).get('button[aria-pressed]').trigger('click');
3356
+ await bar(wrapper).get('button[aria-pressed]').trigger('click');
3357
+ await bar(wrapper).get('button[aria-pressed]').trigger('click');
3358
+ await settleFilterDebounce(wrapper);
3359
+ await flushPromises();
3360
+
3361
+ expect(stub.requests.length).toBe(before + 1);
3362
+ expect(stub.requests.at(-1)?.filters).toEqual({ availability: ['in_stock'] });
3363
+ expect(countLine(wrapper).text()).toBe('4 products');
3364
+ });
3365
+ });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "apiId": "collection-grid",
3
3
  "name": "Collection grid",
4
- "description": "A collection's products as a filterable, sortable card grid, with a filter sidebar on wide layouts and a filter drawer on narrow ones.",
4
+ "description": "A collection's products as a filterable, sortable card grid, with a filter sidebar on wide layouts and a filter drawer on narrow ones, or a horizontal filter bar above the grid.",
5
5
  "icon": "layout-grid",
6
6
  "category": "commerce",
7
7
  "version": 3,
@@ -24,8 +24,8 @@
24
24
  "fieldId": "variant",
25
25
  "name": "Variant",
26
26
  "type": "select",
27
- "helpText": "sidebar is the default. drawer-only gives the grid the full width at every size.",
28
- "metadata": { "options": ["sidebar", "drawer-only"] },
27
+ "helpText": "sidebar is the default. drawer-only gives the grid the full width at every size. filter-bar puts one row of filter chips above the grid, each opening its own group, with the applied filters as removable tags under it.",
28
+ "metadata": { "options": ["sidebar", "drawer-only", "filter-bar"] },
29
29
  "validators": { "required": true }
30
30
  },
31
31
  {
@@ -24,9 +24,10 @@
24
24
  * categories carry no count, and a curated collection chip beside a category chip would be two
25
25
  * different things in one strip.
26
26
  *
27
- * `variant: 'image'` renders two columns from `@tablet` (48rem: text left, a 3:2 image right,
28
- * vertically centred) and stacks image-first below it; `variant: 'text-only'` is a single column
29
- * capped at 48rem with a bottom rule. Neither field nor collection image resolves the `image`
27
+ * `variant: 'image'` is a banner: text left and a 26rem, 16:10 image right from 60rem of the
28
+ * block's width, vertically centred, and below that the text first with a wide 21:9 crop under it;
29
+ * `variant: 'text-only'` is a single column capped at 48rem. The chip strip (sub-collections, or a
30
+ * category's children) runs under either, full width, scrolling sideways on a narrow screen. Neither field nor collection image resolves the `image`
30
31
  * variant silently becomes `text-only` — `effectiveVariant` below, never an empty frame (spec
31
32
  * States, "No image"; Acceptance: "With no image and no collection image, the block renders as
32
33
  * text-only").
@@ -233,7 +234,7 @@ function onDescriptionKeydown(event: KeyboardEvent): void {
233
234
  }
234
235
 
235
236
  const descriptionClass = computed(() => [
236
- 'text-muted max-w-[60ch]',
237
+ 'text-muted max-w-[34rem] text-[1.125rem]',
237
238
  !expanded.value ? 'line-clamp-3' : '',
238
239
  ]);
239
240
 
@@ -384,38 +385,44 @@ const pillsLabel = computed(() =>
384
385
  categoryMode.value ? t('collection.subcategories') : t('collection.subcollections')
385
386
  );
386
387
 
388
+ /**
389
+ * The Northwind chip: a 2.5rem outlined pill, the current one filled with `text` on `background`
390
+ * (marked by `aria-current` and a heavier weight as well, so it never rests on colour alone).
391
+ * Exclusive branches, never a base class a variant overrides.
392
+ */
393
+ const PILL_BASE =
394
+ 'inline-flex min-h-10 items-center justify-center whitespace-nowrap rounded-full border px-4 ' +
395
+ 'text-[0.9375rem] motion-safe:transition-colors motion-safe:duration-fast';
387
396
  function pillClass(pill: ResolvedPill): string {
388
- const base =
389
- 'inline-flex h-11 items-center justify-center whitespace-nowrap rounded-full border px-4 ' +
390
- 'text-[0.875rem] font-medium @tablet:h-9 motion-safe:transition-colors motion-safe:duration-fast';
391
397
  if (pill.current) {
392
- return `${base} bg-primary text-primary-contrast border-transparent font-semibold`;
398
+ return `${PILL_BASE} bg-text text-background border-text font-semibold`;
393
399
  }
394
- return `${base} border-border-strong text-text hover:border-text hover:bg-[color-mix(in_oklab,var(--eldra-color-text),transparent_94%)]`;
400
+ return `${PILL_BASE} border-border-strong text-text font-medium hover:bg-surface`;
395
401
  }
396
402
 
397
403
  // ---------------------------------------------------------------------------------------------
398
404
  // Layout.
399
405
  // ---------------------------------------------------------------------------------------------
400
406
 
401
- /** Spec "Collection header" → Container/Section spacing: the shared `sm`/`md`/`lg` scale doesn't
402
- * carry these exact asymmetric steps, so `spacing="none"` on `Section` and the padding is written
403
- * here — the same pattern `footer`'s own `paddingClass` uses. */
404
- const PADDING_CLASS = 'pt-6 pb-8 @tablet:pt-8 @tablet:pb-12';
407
+ /**
408
+ * The banner: text beside a 26rem image from 60rem of the block's width (the design's own 960px
409
+ * edge, so a tablet gets the stacked layout), stacked below that with the text first and a wide
410
+ * 21:9 crop under it. The chip strip sits under the banner, full width, scrolling sideways rather
411
+ * than wrapping on a phone. `Section`'s shared spacing steps don't carry these asymmetric values,
412
+ * so `spacing="none"` and the padding is written here, the same pattern `footer` uses.
413
+ */
405
414
  const sectionClass = computed(() =>
406
- isImageVariant.value ? PADDING_CLASS : `${PADDING_CLASS} border-border border-b`
415
+ isImageVariant.value || hasPills.value ? 'pt-6 pb-6' : 'pt-6 pb-8 border-border border-b'
407
416
  );
408
417
 
409
418
  const rootClass = computed(() =>
410
419
  isImageVariant.value
411
- ? 'grid grid-cols-1 gap-6 @tablet:grid-cols-2 @tablet:items-center @tablet:gap-12'
420
+ ? 'grid grid-cols-1 gap-6 @min-[60rem]:grid-cols-[minmax(0,1fr)_26rem] @min-[60rem]:items-center @min-[60rem]:gap-12'
412
421
  : 'flex max-w-[48rem] flex-col'
413
422
  );
414
- const textColumnClass = computed(() =>
415
- isImageVariant.value
416
- ? 'flex flex-col gap-4 @tablet:order-1 @content:max-w-[40rem]'
417
- : 'flex flex-col gap-4'
418
- );
423
+ /** The 21:9 → 16:10 crop is the wrapper's, so `UiImage` fills it (`fill`) rather than reserving a
424
+ * single fixed ratio of its own. */
425
+ const IMAGE_FRAME_CLASS = 'relative aspect-[21/9] w-full @min-[60rem]:aspect-[16/10]';
419
426
  </script>
420
427
 
421
428
  <template>
@@ -428,20 +435,7 @@ const textColumnClass = computed(() =>
428
435
  >
429
436
  <Container width="wide">
430
437
  <div :class="rootClass">
431
- <div v-if="isImageVariant" class="@tablet:order-2">
432
- <UiImage
433
- :src="resolvedImage!.src"
434
- :alt="resolvedImage!.alt"
435
- :framing="resolvedImage!.framing"
436
- :entry-id="resolvedImage!.fromField ? entryId : undefined"
437
- :field-path="resolvedImage!.fromField ? 'image' : undefined"
438
- aspect="3/2"
439
- rounded="xl"
440
- class="w-full"
441
- />
442
- </div>
443
-
444
- <div :class="textColumnClass">
438
+ <div class="flex flex-col gap-4">
445
439
  <Breadcrumb
446
440
  v-if="showBreadcrumb && breadcrumbItems.length > 0"
447
441
  :items="breadcrumbItems"
@@ -451,7 +445,7 @@ const textColumnClass = computed(() =>
451
445
  <h1
452
446
  v-if="hasTitle"
453
447
  :id="headingId"
454
- class="font-heading @content:text-[2.75rem] text-[2.125rem] leading-[1.1] font-bold text-balance"
448
+ class="font-heading @tablet:text-[3.25rem] text-[2.25rem] leading-[1.05] font-medium tracking-[-0.015em] text-balance"
455
449
  >
456
450
  {{ resolvedTitle }}
457
451
  </h1>
@@ -475,7 +469,7 @@ const textColumnClass = computed(() =>
475
469
  collection page. A floor, never an offset: h2/h3 in the document stay put. -->
476
470
  <EldraRichText
477
471
  v-if="hasFieldDescription"
478
- class="prose-eldra text-muted"
472
+ class="prose-eldra text-muted text-[1.125rem]"
479
473
  :entry-id="entryId"
480
474
  field="description"
481
475
  api-id="collection-header"
@@ -510,24 +504,43 @@ const textColumnClass = computed(() =>
510
504
  </Button>
511
505
  </div>
512
506
 
513
- <div v-if="hasCount || hasPills" class="flex flex-wrap items-center gap-x-5 gap-y-3">
514
- <p v-if="hasCount" class="text-muted text-[0.875rem] tabular-nums">{{ countText }}</p>
515
- <ul v-if="hasPills" :aria-label="pillsLabel" class="flex flex-wrap gap-2">
516
- <li v-for="pill in pills" :key="pill.href">
517
- <Link
518
- :href="pill.href"
519
- :as="pill.as"
520
- :underline="false"
521
- :aria-current="pill.current ? 'page' : undefined"
522
- :class="pillClass(pill)"
523
- >
524
- {{ pill.label }}
525
- </Link>
526
- </li>
527
- </ul>
528
- </div>
507
+ <p v-if="hasCount" class="text-muted text-[0.875rem] tabular-nums">{{ countText }}</p>
508
+ </div>
509
+
510
+ <!-- Second in the DOM and on screen: beside the text from 60rem, under it below. -->
511
+ <div v-if="isImageVariant" :class="IMAGE_FRAME_CLASS">
512
+ <UiImage
513
+ :src="resolvedImage!.src"
514
+ :alt="resolvedImage!.alt"
515
+ :framing="resolvedImage!.framing"
516
+ :entry-id="resolvedImage!.fromField ? entryId : undefined"
517
+ :field-path="resolvedImage!.fromField ? 'image' : undefined"
518
+ fill
519
+ rounded="xl"
520
+ />
529
521
  </div>
530
522
  </div>
523
+
524
+ <!-- The chip strip scrolls sideways on a narrow screen rather than wrapping into a block of
525
+ pills; `py-1`/`px-1` with the matching negative margin keeps each link's focus ring
526
+ inside the scroll container, which would otherwise clip it. -->
527
+ <ul
528
+ v-if="hasPills"
529
+ :aria-label="pillsLabel"
530
+ class="scrollbar-hidden -mx-1 mt-4 flex gap-2 overflow-x-auto px-1 py-1"
531
+ >
532
+ <li v-for="pill in pills" :key="pill.href" class="shrink-0">
533
+ <Link
534
+ :href="pill.href"
535
+ :as="pill.as"
536
+ :underline="false"
537
+ :aria-current="pill.current ? 'page' : undefined"
538
+ :class="pillClass(pill)"
539
+ >
540
+ {{ pill.label }}
541
+ </Link>
542
+ </li>
543
+ </ul>
531
544
  </Container>
532
545
  </Section>
533
546
  </template>
@@ -6,9 +6,9 @@
6
6
  },
7
7
  "image": {
8
8
  "assetId": "demo-collection-1",
9
- "url": "/demo/collection-1.svg",
10
- "altText": "Folded winter knitwear in oat, charcoal and moss",
11
- "width": 1600,
12
- "height": 1067
9
+ "url": "/images/sweater.webp",
10
+ "altText": "A folded knitted sweater",
11
+ "width": 1400,
12
+ "height": 933
13
13
  }
14
14
  }
Binary file
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "image": {
3
3
  "assetId": "demo-cta-split",
4
- "url": "/demo/cta-split.svg",
5
- "altText": "Darned elbow of a sage wool sweater",
6
- "width": 1200,
7
- "height": 900
4
+ "url": "/images/planters.webp",
5
+ "altText": "Ceramic planters with green plants",
6
+ "width": 932,
7
+ "height": 1400
8
8
  }
9
9
  }
Binary file
Binary file
@@ -24,6 +24,15 @@
24
24
  * the link to the bottom of a stretched card so links line up across a row (spec → Sizes,
25
25
  * "pushed to the bottom of the item").
26
26
  *
27
+ * **`arched`** is the design's "shop by category" row: each item an arch-topped 3:4 photo (full
28
+ * radius on top, `radius-lg` below) with a centred serif title and a muted line, and the whole
29
+ * tile one link — the title and line are the link's text, the photo is decorative. One row of
30
+ * equal tiles from 1101px of block width; below that the same row keeps a 9rem minimum per tile
31
+ * and scrolls sideways, bleeding to the block edge so the next tile peeks in. Every tile is a
32
+ * link, so `Tab` walks the row and the browser scrolls each into view — no tab stop of its own is
33
+ * needed for the scroll area (axe's `scrollable-region-focusable` is satisfied by its links).
34
+ * `columns` and `mediaType` do not apply to it.
35
+ *
27
36
  * Spec States → Empty (freshly inserted): "two 'Add a feature' items ('Pick an icon or image,
28
37
  * then a title and a sentence')" — the same per-item editor hint shape `team`'s/`stats`' own
29
38
  * repeaters use. `isItemEmpty` treats an item with neither icon nor image nor title as empty;
@@ -49,6 +58,7 @@ import { useUiId } from '../../app/composables/useUiId';
49
58
  import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
50
59
  import UiImage from '../../app/components/ui/UiImage.vue';
51
60
  import { isInternalHref, safeHref } from '../../app/utils/links';
61
+ import { focusRing } from '../../app/utils/classes';
52
62
 
53
63
  const props = defineProps<{ entry: EldraBlockEntry<'feature-grid'> }>();
54
64
  const { data } = useBlockData(props, 'feature-grid');
@@ -77,7 +87,8 @@ const hasHead = computed(
77
87
  () => hasHeading.value || hasIntro.value || hasHeadLink.value || showHeadingHint.value
78
88
  );
79
89
 
80
- const isCards = computed(() => (data.value.variant ?? 'cards') !== 'plain');
90
+ const isArched = computed(() => data.value.variant === 'arched');
91
+ const isCards = computed(() => !isArched.value && (data.value.variant ?? 'cards') !== 'plain');
81
92
  const featureCardVariant = computed<FeatureCardVariant>(() =>
82
93
  isCards.value ? 'surface' : 'plain'
83
94
  );
@@ -136,6 +147,22 @@ const renderedItems = computed(() =>
136
147
  );
137
148
  const hasItems = computed(() => renderedItems.value.length > 0);
138
149
 
150
+ /** The arched row: equal tiles in one row from 1101px, a sideways-scrolling row below with the
151
+ * track bleeding to the block edge (the same negative-gutter recipe `trust-strip`'s scroll layout
152
+ * uses, matched to `Container`'s own gutter at each step). */
153
+ const ARCHED_LIST_CLASS =
154
+ 'grid grid-flow-col auto-cols-[minmax(9rem,1fr)] gap-6 overflow-x-auto eldra-scrollbar-hide ' +
155
+ 'snap-x pt-1 pb-2 scroll-px-[var(--eldra-gutter-mobile)] ' +
156
+ '-mx-[var(--eldra-gutter-mobile)] px-[var(--eldra-gutter-mobile)] ' +
157
+ '@tablet:-mx-[var(--eldra-gutter-tablet)] @tablet:px-[var(--eldra-gutter-tablet)] @tablet:scroll-px-[var(--eldra-gutter-tablet)] ' +
158
+ '@content:-mx-[var(--eldra-gutter-desktop)] @content:px-[var(--eldra-gutter-desktop)] @content:scroll-px-[var(--eldra-gutter-desktop)] ' +
159
+ '@min-[68.8125rem]:auto-cols-fr @min-[68.8125rem]:overflow-visible @min-[68.8125rem]:mx-0 ' +
160
+ '@min-[68.8125rem]:px-0 @min-[68.8125rem]:snap-none';
161
+ const ARCH_TILE_CLASS =
162
+ 'group grid justify-items-center gap-3.5 text-center text-text no-underline rounded-lg';
163
+ const ARCH_FRAME_CLASS =
164
+ 'relative block w-full overflow-hidden bg-surface rounded-t-full rounded-b-lg aspect-[3/4]';
165
+
139
166
  const items = computed(() =>
140
167
  renderedItems.value.map((item) => {
141
168
  const href = safeHref(item.href);
@@ -146,7 +173,7 @@ const items = computed(() =>
146
173
  showIconTile: hasIcon,
147
174
  hasImage: Boolean(item.image),
148
175
  image: item.image,
149
- title: item.title,
176
+ title: item.title ?? '',
150
177
  text: item.text ?? '',
151
178
  cue: item.linkLabel || undefined,
152
179
  href,
@@ -169,7 +196,7 @@ const items = computed(() =>
169
196
  <h2
170
197
  v-if="hasHeading"
171
198
  :id="headingId"
172
- class="font-heading text-text @tablet:text-h2 text-[1.625rem] leading-[1.15] font-bold tracking-[-0.015em]"
199
+ class="font-heading text-text text-[1.75rem] leading-[1.1] font-medium tracking-[-0.01em] text-balance @min-[47.5625rem]:text-[2.25rem]"
173
200
  >
174
201
  {{ data.heading }}
175
202
  </h2>
@@ -192,7 +219,49 @@ const items = computed(() =>
192
219
  </Link>
193
220
  </div>
194
221
 
195
- <ul role="list" :class="gridClass">
222
+ <ul v-if="isArched" role="list" :class="ARCHED_LIST_CLASS">
223
+ <li v-for="(item, index) in items" :key="index" class="snap-start">
224
+ <EditorPlaceholder
225
+ v-if="item.isEmpty"
226
+ inline
227
+ class="aspect-[3/4] h-auto rounded-t-full rounded-b-lg"
228
+ :label="t('featureGrid.itemHintLabel')"
229
+ :help="t('featureGrid.itemHintHelp')"
230
+ />
231
+ <component
232
+ :is="item.href ? (item.linkAs ?? 'a') : 'div'"
233
+ v-else
234
+ v-bind="item.href ? (item.linkAs ? { to: item.href } : { href: item.href }) : {}"
235
+ :class="[ARCH_TILE_CLASS, item.href ? focusRing : '']"
236
+ >
237
+ <span :class="ARCH_FRAME_CLASS">
238
+ <UiImage
239
+ v-if="item.hasImage"
240
+ :src="item.image!.url"
241
+ alt=""
242
+ :framing="item.image!.framing ?? null"
243
+ fill
244
+ class="motion-safe:transition-transform motion-safe:duration-[250ms] motion-safe:group-hover:scale-[1.04]"
245
+ />
246
+ <EditorPlaceholder
247
+ v-else-if="isEditing"
248
+ inline
249
+ class="h-full"
250
+ :label="t('featureGrid.imageHintLabel')"
251
+ />
252
+ </span>
253
+ <span class="grid gap-0.5">
254
+ <span
255
+ class="font-heading text-[1.25rem] leading-[1.3] font-medium group-hover:underline group-hover:underline-offset-[0.2em]"
256
+ >{{ item.title }}</span
257
+ >
258
+ <span v-if="item.text" class="text-muted text-sm">{{ item.text }}</span>
259
+ </span>
260
+ </component>
261
+ </li>
262
+ </ul>
263
+
264
+ <ul v-else role="list" :class="gridClass">
196
265
  <li v-for="(item, index) in items" :key="index" class="h-full">
197
266
  <EditorPlaceholder
198
267
  v-if="item.isEmpty"
@@ -59,7 +59,9 @@ describe('feature-grid block', () => {
59
59
  // future overlay edit that forgets `mediaType`/`columns` fails here rather than only showing up
60
60
  // as a wrong insert thumbnail in Studio.
61
61
  expect(preview.mediaType).toBe('image');
62
- expect(preview.columns).toBe(String(preview.items.length));
62
+ // Five category tiles (the arched variant's demo row) in the cards' three-column grid: the
63
+ // grid must never have more columns than items, which is what left blank cells before.
64
+ expect(Number(preview.columns)).toBeLessThanOrEqual(preview.items.length);
63
65
 
64
66
  const wrapper = mountBlock(withImages);
65
67
  const images = wrapper.findAll('img');
@@ -92,6 +94,46 @@ describe('feature-grid block', () => {
92
94
  }
93
95
  );
94
96
 
97
+ describe('arched variant', () => {
98
+ const arched = { ...withImages, variant: 'arched' };
99
+
100
+ it('renders the preview row axe-clean, one link per tile naming its title and line', async () => {
101
+ const wrapper = mountBlock(arched);
102
+ const tiles = wrapper.findAll('ul > li');
103
+ expect(tiles).toHaveLength(preview.items.length);
104
+ preview.items.forEach((tile, index) => {
105
+ const link = tiles[index]!.get('a');
106
+ expect(tiles[index]!.findAll('a')).toHaveLength(1);
107
+ expect(link.text()).toContain(tile.title);
108
+ expect(link.text()).toContain(tile.text);
109
+ // The photo is decorative: the link's text already names the destination.
110
+ expect(link.get('img').attributes('alt')).toBe('');
111
+ });
112
+ expect(await axe(wrapper.element)).toHaveNoViolations();
113
+ });
114
+
115
+ it('routes a same-site tile through the router and drops an unsafe one to plain text', () => {
116
+ const wrapper = mountBlock({
117
+ ...arched,
118
+ items: [
119
+ { ...preview.items[0], href: 'javascript:alert(1)' },
120
+ { ...preview.items[1], href: 'https://example.com/knitwear' },
121
+ ],
122
+ });
123
+ const tiles = wrapper.findAll('ul > li');
124
+ expect(tiles[0]!.find('a').exists()).toBe(false);
125
+ expect(tiles[0]!.text()).toContain(preview.items[0]!.title);
126
+ expect(tiles[1]!.get('a').attributes('href')).toBe('https://example.com/knitwear');
127
+ });
128
+
129
+ it('Tab walks the head link, then every tile, in order — no other tab stop', () => {
130
+ const wrapper = mountBlock(arched);
131
+ const hrefs = wrapper.findAll('a').map((a) => a.attributes('href'));
132
+ expect(hrefs).toEqual([preview.headLinkHref, ...preview.items.map((tile) => tile.href)]);
133
+ expect(wrapper.find('[tabindex]').exists()).toBe(false);
134
+ });
135
+ });
136
+
95
137
  it('renders the image media type with no axe violations', async () => {
96
138
  const wrapper = mountBlock({ ...withImages, mediaType: 'image' });
97
139
  expect(wrapper.findAll('img')).toHaveLength(withImages.items.length);
@@ -10,8 +10,8 @@
10
10
  "fieldId": "variant",
11
11
  "name": "Variant",
12
12
  "type": "select",
13
- "helpText": "cards is the default.",
14
- "metadata": { "options": ["cards", "plain"] },
13
+ "helpText": "cards is the default. arched shows each item as an arch-topped photo with its title and line under it, the whole tile one link, in a single row that scrolls sideways on smaller screens. Use it for category tiles; it always shows images and ignores columns and media type.",
14
+ "metadata": { "options": ["cards", "plain", "arched"] },
15
15
  "validators": { "required": true }
16
16
  },
17
17
  {