@eldrajs/theme-cli 0.2.10 → 0.2.11

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 (168) hide show
  1. package/CHANGELOG.md +11 -1
  2. package/package.json +3 -3
  3. package/template/.eldra/block-types.d.ts +4 -6
  4. package/template/.eldra/manifest.json +228 -246
  5. package/template/.eldra/previews.json +35 -35
  6. package/template/.storybook/eldra.ts +7 -2
  7. package/template/app/assets/main.css +5 -0
  8. package/template/app/composables/useBlockData.ts +9 -2
  9. package/template/app/composables/usePriceTokens.ts +150 -0
  10. package/template/app/composables/useQuickAdd.ts +95 -0
  11. package/template/app/composables/useRegionalFormat.ts +94 -0
  12. package/template/app/icons.ts +4 -0
  13. package/template/app/plugins/eldra-storefront.ts +2 -0
  14. package/template/app/plugins/eldra-ui-messages.ts +22 -8
  15. package/template/app/storefront/demo.ts +188 -16
  16. package/template/app/storefront/gateway.ts +19 -0
  17. package/template/app/storefront/productCardLook.ts +76 -0
  18. package/template/app/storefront/productReference.ts +17 -0
  19. package/template/app/storefront/toProductCard.ts +12 -8
  20. package/template/app/storefront/types.ts +17 -0
  21. package/template/blocks/announcement-bar/__tests__/Block.spec.ts +19 -7
  22. package/template/blocks/announcement-bar/block.json +2 -1
  23. package/template/blocks/announcement-bar/mock.json +1 -1
  24. package/template/blocks/announcement-bar/preview.png +0 -0
  25. package/template/blocks/article/Block.vue +8 -18
  26. package/template/blocks/article/block.json +3 -1
  27. package/template/blocks/article/preview.png +0 -0
  28. package/template/blocks/article-list/block.json +10 -1
  29. package/template/blocks/article-list/preview.png +0 -0
  30. package/template/blocks/breadcrumbs/Block.vue +15 -3
  31. package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +13 -0
  32. package/template/blocks/breadcrumbs/block.json +1 -0
  33. package/template/blocks/breadcrumbs/preview.png +0 -0
  34. package/template/blocks/cart/Block.vue +15 -5
  35. package/template/blocks/cart/__tests__/Block.spec.ts +53 -10
  36. package/template/blocks/cart/__tests__/ShippingBar.spec.ts +10 -8
  37. package/template/blocks/cart/block.json +8 -5
  38. package/template/blocks/cart/mock.json +2 -2
  39. package/template/blocks/cart/parts/ShippingBar.vue +24 -30
  40. package/template/blocks/cart/parts/notSold.ts +4 -3
  41. package/template/blocks/collection-grid/Block.vue +168 -85
  42. package/template/blocks/collection-grid/__tests__/Block.spec.ts +101 -23
  43. package/template/blocks/collection-grid/preview.png +0 -0
  44. package/template/blocks/collection-header/Block.vue +34 -11
  45. package/template/blocks/collection-header/__tests__/Block.spec.ts +3 -3
  46. package/template/blocks/collection-header/block.json +2 -0
  47. package/template/blocks/collection-header/preview.png +0 -0
  48. package/template/blocks/contact/block.json +4 -0
  49. package/template/blocks/contact/preview.png +0 -0
  50. package/template/blocks/cta/block.json +2 -0
  51. package/template/blocks/faq/Block.vue +5 -10
  52. package/template/blocks/faq/block.json +2 -1
  53. package/template/blocks/faq/mock.json +12 -1
  54. package/template/blocks/faq/preview.png +0 -0
  55. package/template/blocks/feature-grid/__tests__/Block.spec.ts +30 -7
  56. package/template/blocks/feature-grid/block.json +3 -2
  57. package/template/blocks/feature-grid/mock.json +1 -1
  58. package/template/blocks/feature-grid/preview.png +0 -0
  59. package/template/blocks/footer/Block.vue +64 -21
  60. package/template/blocks/footer/__tests__/Block.spec.ts +97 -1
  61. package/template/blocks/footer/block.json +5 -2
  62. package/template/blocks/footer/mock.json +1 -1
  63. package/template/blocks/footer/preview.png +0 -0
  64. package/template/blocks/form/block.json +1 -0
  65. package/template/blocks/gallery/preview.png +0 -0
  66. package/template/blocks/hero/Block.vue +38 -9
  67. package/template/blocks/hero/__tests__/Block.spec.ts +71 -19
  68. package/template/blocks/hero/block.json +16 -22
  69. package/template/blocks/hero/preview.json +1 -3
  70. package/template/blocks/hero/preview.png +0 -0
  71. package/template/blocks/image/block.json +2 -1
  72. package/template/blocks/image/preview.png +0 -0
  73. package/template/blocks/logo-cloud/block.json +1 -0
  74. package/template/blocks/logo-cloud/preview.png +0 -0
  75. package/template/blocks/navigation/Block.vue +404 -159
  76. package/template/blocks/navigation/__tests__/Block.spec.ts +806 -172
  77. package/template/blocks/navigation/__tests__/currentItem.spec.ts +90 -0
  78. package/template/blocks/navigation/block.json +2 -11
  79. package/template/blocks/navigation/mock.json +3 -3
  80. package/template/blocks/navigation/parts/LocalePicker.vue +103 -0
  81. package/template/blocks/navigation/parts/currentItem.ts +82 -0
  82. package/template/blocks/navigation/preview.json +7 -1
  83. package/template/blocks/navigation/preview.png +0 -0
  84. package/template/blocks/newsletter/Block.vue +6 -2
  85. package/template/blocks/newsletter/block.json +2 -0
  86. package/template/blocks/newsletter/preview.png +0 -0
  87. package/template/blocks/order-status/Block.vue +8 -17
  88. package/template/blocks/order-status/block.json +3 -0
  89. package/template/blocks/order-status/preview.png +0 -0
  90. package/template/blocks/pricing-table/__tests__/Block.spec.ts +12 -4
  91. package/template/blocks/pricing-table/block.json +2 -0
  92. package/template/blocks/pricing-table/mock.json +6 -6
  93. package/template/blocks/pricing-table/preview.png +0 -0
  94. package/template/blocks/product-carousel/Block.vue +36 -126
  95. package/template/blocks/product-carousel/__tests__/Block.spec.ts +88 -0
  96. package/template/blocks/product-carousel/block.json +1 -0
  97. package/template/blocks/product-carousel/preview.png +0 -0
  98. package/template/blocks/product-detail/Block.vue +84 -31
  99. package/template/blocks/product-detail/__tests__/Block.spec.ts +86 -0
  100. package/template/blocks/product-detail/__tests__/specs.spec.ts +79 -0
  101. package/template/blocks/product-detail/block.json +3 -1
  102. package/template/blocks/product-detail/mock.json +54 -4
  103. package/template/blocks/product-detail/parts/Gallery.vue +8 -2
  104. package/template/blocks/product-detail/preview.png +0 -0
  105. package/template/blocks/product-detail/specs.ts +75 -0
  106. package/template/blocks/quote/block.json +1 -0
  107. package/template/blocks/rich-text/preview.png +0 -0
  108. package/template/blocks/search/Block.vue +6 -1
  109. package/template/blocks/search/TypeSection.vue +8 -1
  110. package/template/blocks/search/__tests__/Block.spec.ts +24 -1
  111. package/template/blocks/search/block.json +1 -0
  112. package/template/blocks/search/preview.png +0 -0
  113. package/template/blocks/split-content/Block.vue +12 -5
  114. package/template/blocks/split-content/__tests__/Block.spec.ts +13 -0
  115. package/template/blocks/split-content/block.json +4 -2
  116. package/template/blocks/split-content/preview.png +0 -0
  117. package/template/blocks/stats/preview.png +0 -0
  118. package/template/blocks/tabs/Block.vue +3 -4
  119. package/template/blocks/tabs/block.json +1 -1
  120. package/template/blocks/tabs/preview.png +0 -0
  121. package/template/blocks/team/block.json +3 -1
  122. package/template/blocks/team/preview.png +0 -0
  123. package/template/blocks/testimonials/block.json +2 -0
  124. package/template/blocks/testimonials/preview.png +0 -0
  125. package/template/blocks/timeline/block.json +2 -1
  126. package/template/blocks/timeline/preview.png +0 -0
  127. package/template/blocks/trust-strip/Block.vue +2 -2
  128. package/template/blocks/trust-strip/__tests__/Block.spec.ts +38 -9
  129. package/template/blocks/trust-strip/block.json +1 -1
  130. package/template/blocks/trust-strip/mock.json +1 -1
  131. package/template/blocks/trust-strip/preview.json +1 -1
  132. package/template/blocks/trust-strip/preview.png +0 -0
  133. package/template/blocks/video-embed/block.json +2 -0
  134. package/template/blocks/video-embed/preview.png +0 -0
  135. package/template/blocks/wishlist/Block.vue +2 -2
  136. package/template/blocks/wishlist/preview.png +0 -0
  137. package/template/i18n/en-US.json +13 -5
  138. package/template/i18n/is-IS.json +12 -4
  139. package/template/pages/article.page.json +1 -3
  140. package/template/pages/cart.page.json +1 -3
  141. package/template/pages/category.page.json +2 -4
  142. package/template/pages/collection.page.json +1 -3
  143. package/template/pages/home.page.json +7 -18
  144. package/template/pages/product.page.json +62 -131
  145. package/template/pages/products.page.json +1 -3
  146. package/template/pages/search.page.json +1 -3
  147. package/template/pages/wishlist.page.json +1 -3
  148. package/template/stories/generated/footer.stories.ts +6 -0
  149. package/template/stories/generated/navigation.stories.ts +0 -18
  150. package/template/test/inlineEditable.spec.ts +10 -2
  151. package/template/test/localePrefix.spec.ts +2 -19
  152. package/template/test/pages/article.spec.ts +0 -2
  153. package/template/test/pages/category.spec.ts +35 -13
  154. package/template/test/pages/home.spec.ts +33 -17
  155. package/template/test/pages/product.spec.ts +64 -44
  156. package/template/test/pages/ssr.spec.ts +3 -1
  157. package/template/test/prerenderRefresh.browser.spec.ts +30 -25
  158. package/template/test/priceTokens.spec.ts +309 -0
  159. package/template/test/regionalFormat.spec.ts +80 -0
  160. package/template/test/starter.spec.ts +23 -7
  161. package/template/test/storefront/demo.spec.ts +19 -18
  162. package/template/test/storefront/toProductCard.spec.ts +17 -2
  163. package/template/test/structuredData.generate.spec.ts +4 -2
  164. package/template/test/support/mockGateway.ts +21 -1
  165. package/template/test/support/mountBlock.ts +25 -4
  166. package/template/test/support/priceTokens.ts +20 -0
  167. package/template/test/uiMessagesPlugin.spec.ts +34 -1
  168. package/template/tokens.json +8 -8
@@ -50,12 +50,11 @@
50
50
  * products" floor is about whether the block is worth showing at all, not about a shopper's own
51
51
  * narrowing.
52
52
  *
53
- * Cards are restyled through `ProductCard`'s `classes`, never forked: the title is not underlined
54
- * until hover, the price sits beside the title from 761px, and the quick-add pill shares the
55
- * photo's grid cell (the card root becomes a one-column grid so the pill can sit on the media
56
- * without knowing its height).
53
+ * Cards are drawn the theme's one way, `productCardLook()` (`app/storefront/productCardLook.ts`),
54
+ * shared with `collection-grid` and `search`: the maker under the title, plain colour dots, "New"/
55
+ * "Sale" chips and a "+ Add" pill on the photo.
57
56
  */
58
- import { computed, inject, nextTick, ref, toValue, watch } from 'vue';
57
+ import { computed, inject, ref, toValue, watch } from 'vue';
59
58
  import {
60
59
  Button,
61
60
  Carousel,
@@ -67,13 +66,10 @@ import {
67
66
  ProductCard,
68
67
  Section,
69
68
  Skeleton,
70
- useToast,
71
69
  VisuallyHidden,
72
70
  } from '@eldrajs/ui';
73
- import type { CarouselPart, ProductCardPart, SectionBackground } from '@eldrajs/ui';
74
- import { useEldraLocale } from '@eldrajs/theme-vue';
75
- import { useStorefrontFeedback } from '../../app/composables/useStorefrontFeedback';
76
- import { CART_ADD_TOAST_ID } from '../../app/storefront/feedback';
71
+ import type { CarouselPart, SectionBackground } from '@eldrajs/ui';
72
+ import { useQuickAdd } from '../../app/composables/useQuickAdd';
77
73
  import { useBlockData } from '../../app/composables/useBlockData';
78
74
  import { useEditing } from '../../app/composables/useEditing';
79
75
  import { useRevalidating } from '../../app/composables/useRevalidating';
@@ -84,7 +80,6 @@ import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
84
80
  import { isInternalHref, safeHref } from '../../app/utils/links';
85
81
  import type {
86
82
  StorefrontCollectionSelector,
87
- StorefrontProduct,
88
83
  StorefrontProductListItem,
89
84
  } from '../../app/storefront/types';
90
85
  import {
@@ -93,6 +88,7 @@ import {
93
88
  selectorSlug,
94
89
  } from '../../app/storefront/collectionSelector';
95
90
  import { toProductCardEntries } from '../../app/storefront/toProductCard';
91
+ import { productCardLook } from '../../app/storefront/productCardLook';
96
92
  import { useMoney } from '../../app/storefront/money';
97
93
 
98
94
  const props = defineProps<{ entry: EldraBlockEntry<'product-carousel'> }>();
@@ -417,103 +413,16 @@ const showFilteredEmpty = computed(
417
413
  /* ---------------------------------------------------------------------------------------------- */
418
414
 
419
415
  const showQuickAdd = computed(() => (data.value.quickAdd ?? false) && !isRecentlyViewed.value);
420
- /** `null` until a pill is pressed, so the read asks for nothing on the server or on load. */
421
- const quickAddHandle = ref<string | null>(null);
422
- const quickAddResult = storefront.catalog.product(quickAddHandle);
423
- const quickAddBusy = ref(false);
424
- const toast = useToast();
425
- const feedback = useStorefrontFeedback();
426
- const activeLocale = useEldraLocale();
427
-
428
- /** Resolves once the product read for `handle` has settled: the product, or `null` when the read
429
- * failed or answered nothing. */
430
- async function readProduct(handle: string): Promise<StorefrontProduct | null> {
431
- quickAddHandle.value = handle;
432
- await nextTick();
433
- const settled = (): boolean =>
434
- !quickAddResult.loading.value &&
435
- (quickAddResult.data.value?.handle === handle || quickAddResult.error.value !== null);
436
- if (!settled()) {
437
- await new Promise<void>((resolve) => {
438
- const stop = watch(
439
- () => [quickAddResult.loading.value, quickAddResult.data.value, quickAddResult.error.value],
440
- () => {
441
- if (!settled()) return;
442
- stop();
443
- resolve();
444
- }
445
- );
446
- });
447
- }
448
- const product = quickAddResult.data.value;
449
- return product !== null && product.handle === handle ? product : null;
450
- }
451
-
452
- async function onQuickAdd(item: { handle: string }): Promise<void> {
453
- if (quickAddBusy.value) return;
454
- quickAddBusy.value = true;
455
- try {
456
- const product = await readProduct(item.handle);
457
- if (product === null || product.variantId === '') {
458
- feedback.report(null, { id: CART_ADD_TOAST_ID });
459
- return;
460
- }
461
- const cart = storefront.cart;
462
- const failure = await cart.add({
463
- productId: product.productId,
464
- variantId: product.variantId,
465
- quantity: 1,
466
- });
467
- if (failure !== null) {
468
- feedback.report(failure, { id: CART_ADD_TOAST_ID });
469
- return;
470
- }
471
- toast.show({
472
- id: CART_ADD_TOAST_ID,
473
- title: t('cart.added'),
474
- action: cart.drawerAvailable.value
475
- ? {
476
- label: t('cart.viewCart'),
477
- onActivate: () => {
478
- cart.drawerOpen.value = true;
479
- },
480
- }
481
- : { label: t('cart.viewCart'), href: activeLocale.path('/cart') },
482
- });
483
- } finally {
484
- quickAddBusy.value = false;
485
- }
486
- }
416
+ /** The shared "+ Add" (`app/composables/useQuickAdd.ts`): read, add one, toast. */
417
+ const quickAdd = useQuickAdd();
418
+ const onQuickAdd = quickAdd.add;
487
419
 
488
420
  /* ---------------------------------------------------------------------------------------------- */
489
421
  /* Card and grid styling */
490
422
  /* ---------------------------------------------------------------------------------------------- */
491
423
 
492
- /** The card's own parts, restyled to the theme (see the module doc comment). The root is a
493
- * one-column grid so the quick-add pill can share the photo's cell; from 761px of block width
494
- * the price moves beside the title. */
495
- const CARD_ROOT_CLASS = 'grid grid-cols-1 grid-rows-[auto_1fr] content-start';
496
- const cardClasses = computed<Partial<Record<ProductCardPart, string>>>(() => ({
497
- media: '[grid-area:1/1]',
498
- body:
499
- '[grid-area:2/1] @min-[47.5625rem]:grid @min-[47.5625rem]:grid-cols-[minmax(0,1fr)_auto] ' +
500
- '@min-[47.5625rem]:items-baseline @min-[47.5625rem]:content-start @min-[47.5625rem]:gap-x-3',
501
- title: 'leading-[1.35]',
502
- link:
503
- 'no-underline hover:underline hover:decoration-1 hover:decoration-current ' +
504
- 'hover:underline-offset-[0.2em]',
505
- price: 'whitespace-nowrap',
506
- rating: '@min-[47.5625rem]:col-span-2',
507
- stockLine: '@min-[47.5625rem]:col-span-2',
508
- swatches: 'mt-1 @min-[47.5625rem]:col-span-2',
509
- quickAdd:
510
- '[grid-area:1/1] z-10 m-3 mt-0 self-end justify-self-end w-auto h-10 min-h-10 rounded-full ' +
511
- 'border-0 bg-background px-3.5 text-sm font-semibold text-text shadow-sm ' +
512
- 'hover:bg-text hover:text-background disabled:opacity-90',
513
- }));
514
-
515
424
  const GRID_CLASS =
516
- 'grid grid-cols-2 gap-x-3 gap-y-8 @min-[47.5625rem]:grid-cols-3 @min-[47.5625rem]:gap-x-5 ' +
425
+ 'grid grid-cols-1 @min-[23.25rem]:grid-cols-2 gap-x-3 gap-y-8 @min-[47.5625rem]:grid-cols-3 @min-[47.5625rem]:gap-x-5 ' +
517
426
  '@min-[47.5625rem]:gap-y-10 @min-[68.8125rem]:grid-cols-4';
518
427
 
519
428
  function chipClass(active: boolean): string {
@@ -568,24 +477,11 @@ const showBlock = computed(() =>
568
477
  />
569
478
 
570
479
  <template v-else-if="showCarousel && isGrid">
571
- <div class="mb-8 flex flex-wrap items-end justify-between gap-x-8 gap-y-4">
572
- <div>
573
- <p v-if="data.eyebrow" class="text-overline text-accent mb-2">{{ data.eyebrow }}</p>
574
- <h2 :id="headingId" :class="HEADING_CLASSES">
575
- <Link
576
- v-if="hasViewAll"
577
- :href="viewAllHref!"
578
- :as="viewAllLinkAs"
579
- variant="standalone"
580
- arrow
581
- :aria-label="`${heading} — ${data.viewAllLabel}${t('productCarousel.viewAllContext')}`"
582
- :class="`${HEADING_CLASSES} text-inherit`"
583
- >
584
- {{ heading }}
585
- </Link>
586
- <template v-else>{{ heading }}</template>
587
- </h2>
588
- </div>
480
+ <!-- The eyebrow sits above the row, so the chips and the link centre on the heading
481
+ itself, not on the eyebrow and heading together. -->
482
+ <p v-if="data.eyebrow" class="text-overline text-accent mb-2">{{ data.eyebrow }}</p>
483
+ <div class="mb-8 flex flex-wrap items-center justify-between gap-x-8 gap-y-4">
484
+ <h2 :id="headingId" :class="HEADING_CLASSES">{{ heading }}</h2>
589
485
  <ul
590
486
  v-if="hasFilterChips"
591
487
  class="eldra-scrollbar-hide flex max-w-full gap-2 overflow-x-auto px-0.5 py-1"
@@ -606,6 +502,22 @@ const showBlock = computed(() =>
606
502
  </button>
607
503
  </li>
608
504
  </ul>
505
+ <!-- The grid's head row is the design's section head: a plain heading on the left and
506
+ the "view all" link on its own at the right ("Shop all knitwear →"), named by its
507
+ own text, underlined on hover only (the design's standalone shape, the opt-out `Link` keeps for
508
+ it). The carousel keeps the heading-as-link below, where a separate link beside
509
+ the arrows read as a third control; the grid has no arrows. -->
510
+ <Link
511
+ v-if="hasViewAll"
512
+ :href="viewAllHref!"
513
+ :as="viewAllLinkAs"
514
+ variant="standalone"
515
+ arrow
516
+ :underline="false"
517
+ data-view-all
518
+ >
519
+ {{ data.viewAllLabel }}
520
+ </Link>
609
521
  </div>
610
522
 
611
523
  <ul v-if="showSkeletons" role="list" :class="GRID_CLASS">
@@ -616,10 +528,9 @@ const showBlock = computed(() =>
616
528
  <ProductCard
617
529
  :product="entry.product"
618
530
  :ratio="cardRatio"
619
- :class="[CARD_CLASS, CARD_ROOT_CLASS]"
620
- :classes="cardClasses"
531
+ v-bind="productCardLook(t, entry.product.title)"
532
+ :class="CARD_CLASS"
621
533
  :show-swatches="showSwatchesField"
622
- :show-rating="true"
623
534
  :quick-add="showQuickAdd"
624
535
  :heading-level="3"
625
536
  :revalidating="entry.revalidating"
@@ -687,10 +598,9 @@ const showBlock = computed(() =>
687
598
  <ProductCard
688
599
  :product="entry.product"
689
600
  :ratio="cardRatio"
690
- :class="[CARD_CLASS, CARD_ROOT_CLASS]"
691
- :classes="cardClasses"
601
+ v-bind="productCardLook(t, entry.product.title)"
602
+ :class="CARD_CLASS"
692
603
  :show-swatches="!isRecentlyViewed && showSwatchesField"
693
- :show-rating="!isRecentlyViewed"
694
604
  :quick-add="showQuickAdd"
695
605
  :heading-level="3"
696
606
  :revalidating="entry.revalidating"
@@ -577,6 +577,10 @@ describe('product-carousel block', () => {
577
577
  'stoneware-dinner-plates-set-of-4',
578
578
  'hand-thrown-serving-bowl',
579
579
  'glazed-milk-jug',
580
+ 'tall-bud-vase',
581
+ 'celadon-tea-cup',
582
+ 'terracotta-planters',
583
+ 'enamel-camp-cups-set-of-6',
580
584
  ]);
581
585
  const ceramicTitles = PRODUCTS.filter((p) => ceramicHandles.has(p.handle)).map(
582
586
  (p) => p.title
@@ -624,6 +628,70 @@ describe('product-carousel block', () => {
624
628
  });
625
629
  });
626
630
 
631
+ /** The theme's card (`app/storefront/productCardLook.ts`), as the design draws it. */
632
+ describe('the theme card', () => {
633
+ const design = { ...mock, ...preview };
634
+
635
+ async function cardFor(handle: string) {
636
+ const wrapper = mountBlock({ ...design, layout: 'carousel' });
637
+ await flushPromises();
638
+ const product = PRODUCTS.find((item) => item.handle === handle)!;
639
+ const card = wrapper
640
+ .findAllComponents(ProductCard)
641
+ .find((c) => (c.props('product') as { title: string }).title === product.title);
642
+ expect(card, handle).toBeDefined();
643
+ return { wrapper, card: card!, product };
644
+ }
645
+
646
+ it('reads title, price, then the maker under them, with no rating and no stock line', async () => {
647
+ const { card, product } = await cardFor('merino-crew-sweater');
648
+ const parts = card
649
+ .findAll('[data-part="body"] > [data-part]')
650
+ .map((node) => node.attributes('data-part'));
651
+ // (The swatch count's visually hidden line follows the dots.)
652
+ expect(parts.slice(0, 4)).toEqual(['title', 'price', 'vendor', 'swatches']);
653
+ expect(card.get('[data-part="vendor"]').text()).toBe(product.vendor);
654
+ expect(card.find('[data-part="rating"]').exists()).toBe(false);
655
+ expect(card.find('[data-part="stockLine"]').exists()).toBe(false);
656
+ });
657
+
658
+ it('draws every colour as a plain dot, no "+N"', async () => {
659
+ const { card, product } = await cardFor('merino-crew-sweater');
660
+ expect(card.findAll('[data-part="swatch"]')).toHaveLength(product.colours!.length);
661
+ expect(card.find('[data-part="swatchOverflow"]').exists()).toBe(false);
662
+ });
663
+
664
+ it('labels a sale "Sale" and a new product "New"', async () => {
665
+ const sale = await cardFor('merino-crew-sweater');
666
+ expect(sale.card.get('[data-part="badges"]').text()).toBe(enUS.productCard.sale);
667
+ const fresh = await cardFor('fisherman-rib-cardigan');
668
+ const badge = fresh.card.get('[data-part="badges"] [data-part="root"]');
669
+ expect(badge.text()).toBe('New');
670
+ expect(badge.classes()).toContain('bg-background');
671
+ });
672
+
673
+ it('words quick add "Add" with a plus, named "Add <title> to cart", the word hidden on phones', async () => {
674
+ const { card, product } = await cardFor('fisherman-rib-cardigan');
675
+ const button = card.get('button[data-part="quickAdd"]');
676
+ expect(button.attributes('aria-label')).toBe(`Add ${product.title} to cart`);
677
+ expect(button.get('[data-part="label"]').text()).toBe(enUS.productCard.add);
678
+ expect(button.get('[data-part="label"]').classes()).toContain('@max-[47.5rem]:hidden');
679
+ expect(button.find('[data-part="leadingIcon"] svg').exists()).toBe(true);
680
+ });
681
+
682
+ it('leaves the title un-underlined until hover', async () => {
683
+ const { card } = await cardFor('fisherman-rib-cardigan');
684
+ const link = card.get('[data-part="link"]');
685
+ expect(link.classes()).toContain('no-underline');
686
+ expect(link.classes()).toContain('hover:underline');
687
+ });
688
+
689
+ it('has no axe violations', async () => {
690
+ const { wrapper } = await cardFor('fisherman-rib-cardigan');
691
+ expect(await axe(wrapper.element)).toHaveNoViolations();
692
+ });
693
+ });
694
+
627
695
  describe('the collection variant\u2019s source', () => {
628
696
  const WINTER = demoCollectionId('winter-knitwear')!;
629
697
  const BEST_SELLERS = demoCollectionId('best-sellers')!;
@@ -798,6 +866,26 @@ describe('product-carousel block', () => {
798
866
  const wrapper = await mountVariant({ variant: 'recently-viewed' });
799
867
  expect(wrapper.find('h2 a').exists()).toBe(false);
800
868
  });
869
+
870
+ it('in the grid layout, keeps the heading plain and draws the link on its own, by its label', async () => {
871
+ const wrapper = await mountVariant({
872
+ variant: 'related',
873
+ layout: 'grid',
874
+ viewAllLabel: 'Shop all knitwear',
875
+ viewAllHref: '/collections/knitwear',
876
+ });
877
+ expect(wrapper.find('h2 a').exists()).toBe(false);
878
+ expect(wrapper.get('h2').text()).toBe(mock.heading);
879
+ const link = wrapper.get('a[data-view-all]');
880
+ expect(link.text()).toBe('Shop all knitwear');
881
+ expect(link.attributes('href')).toBe('/collections/knitwear');
882
+ // After the heading in reading order, as it sits after it on the row.
883
+ expect(
884
+ wrapper.get('h2').element.compareDocumentPosition(link.element) &
885
+ Node.DOCUMENT_POSITION_FOLLOWING
886
+ ).toBeTruthy();
887
+ expect(await axe(wrapper.element)).toHaveNoViolations();
888
+ });
801
889
  });
802
890
 
803
891
  /**
@@ -57,6 +57,7 @@
57
57
  "fieldId": "viewAllHref",
58
58
  "name": "View all link",
59
59
  "type": "string",
60
+ "allowPrices": false,
60
61
  "helpText": "Where the heading links to. The collection variant links to the collection you picked instead.",
61
62
  "showWhen": { "field": "variant", "in": ["related"] }
62
63
  },
@@ -79,6 +79,7 @@ import { isInternalHref, safeHref } from '../../app/utils/links';
79
79
  import Gallery from './parts/Gallery.vue';
80
80
  import StickyBuyBar from './parts/StickyBuyBar.vue';
81
81
  import { deriveStockLine, type LowStockThreshold } from './stock';
82
+ import { specsFromBody, type TabSpec } from './specs';
82
83
 
83
84
  interface PerkItem {
84
85
  icon?: string;
@@ -212,6 +213,16 @@ const tabs = computed<TabItem[]>(() =>
212
213
  (data.value.tabs ?? []).filter((tab: TabItem) => Boolean(tab.label))
213
214
  );
214
215
 
216
+ /**
217
+ * A tab whose body is a list of facts ("**Material** Merino wool", one per bullet) as label/value
218
+ * pairs, for the design's two-column definition list — `null` for any other body, which renders as
219
+ * the rich text it is (`specs.ts` has the rule). In the editor the body is always the rich text, so
220
+ * the author edits the list in place; the published page and every preview draw the `<dl>`.
221
+ */
222
+ function tabSpecs(tab: TabItem): TabSpec[] | null {
223
+ return editing.value ? null : specsFromBody(tab.body);
224
+ }
225
+
215
226
  const sizeGuideHref = computed(() => safeHref(data.value.sizeGuideHref));
216
227
  const sizeGuideLabel = computed(() => data.value.sizeGuideLabel?.trim() || t('product.sizeGuide'));
217
228
  const sizeGuideAs = computed(() =>
@@ -233,6 +244,17 @@ const sizeGuideAs = computed(() =>
233
244
  * through the same `safeHref` gate every author-supplied destination in this theme passes; a
234
245
  * destination that does not survive it drops the label rather than rendering a broken link.
235
246
  */
247
+ /**
248
+ * **The maker line above the title** — the product's brand (`vendor`), linked to a search for it:
249
+ * the one page this theme has that lists a maker's other products. Absent when the catalogue names
250
+ * no brand, never the shop's own name in its place.
251
+ */
252
+ const maker = computed<{ label: string; href: string } | null>(() => {
253
+ const vendor = product.value?.vendor?.trim() ?? '';
254
+ if (vendor === '') return null;
255
+ return { label: vendor, href: `/search?q=${encodeURIComponent(vendor)}` };
256
+ });
257
+
236
258
  const categoryLeaf = computed<{ label: string; href: string } | null>(() => {
237
259
  const leaf = (product.value?.categoryTrail ?? []).at(-1);
238
260
  if (leaf === undefined || !leaf.label) return null;
@@ -414,8 +436,13 @@ const isBackorder = computed(() => stockLine.value.state === 'backorder');
414
436
  * draws the clock in `muted` (it serves a quieter product-card context too), so the block asks for
415
437
  * the spec's colour through its `class`, never by patching it. */
416
438
  const stockClass = computed(() =>
417
- isBackorder.value ? 'text-warning font-semibold' : 'font-semibold'
439
+ isBackorder.value ? 'text-warning text-[1rem] font-semibold' : 'text-[1rem] font-semibold'
418
440
  );
441
+ /** The design's stock line is body-sized (1rem, the 1.25rem icon), not the card lists' caption. */
442
+ const STOCK_ICON_CLASS = 'size-5';
443
+ /** Through a constant, so `test/themeIcons.spec.ts` (which reads `icon: '…'` as an icon name)
444
+ * does not take the class for one. */
445
+ const STOCK_CLASSES = { icon: STOCK_ICON_CLASS };
419
446
 
420
447
  /* ------------------------------------------------------------------------- */
421
448
  /* Quantity, cart, wishlist */
@@ -663,13 +690,15 @@ const QUANTITY_STEPPER_CLASS = '[--eldra-stepper-radius:var(--eldra-radius-full)
663
690
  */
664
691
  const SWATCH_PILL_CLASSES = {
665
692
  radio:
666
- 'size-auto h-11 justify-start gap-2 ps-1.5 pe-4 ' +
693
+ 'size-auto h-11 justify-start gap-2 ps-[calc(0.5rem-1px)] pe-[calc(1rem-1px)] ' +
667
694
  'not-has-checked:[--eldra-variant-swatch-ring-width:1px] not-has-checked:border-border-strong ' +
668
- 'not-has-checked:ps-[calc(0.375rem+1px)] not-has-checked:pe-[calc(1rem+1px)]',
695
+ 'not-has-checked:ps-2 not-has-checked:pe-4',
669
696
  swatch: 'size-7 shrink-0',
670
697
  // The sold-out stroke crosses the disc only, never the name beside it.
671
- soldOutLine: 'inset-auto start-[calc(0.375rem+1px)] top-1/2 size-7 -translate-y-1/2',
672
- label: 'not-sr-only text-[0.9375rem] font-medium whitespace-nowrap',
698
+ soldOutLine: 'inset-auto start-2 top-1/2 size-7 -translate-y-1/2',
699
+ // Regular at rest, semibold once chosen — the design's own weight step for the checked pill.
700
+ label:
701
+ 'not-sr-only text-[0.9375rem] font-normal whitespace-nowrap [:has(>input:checked)>&]:font-semibold',
673
702
  };
674
703
  const PILL_CLASSES = { radio: 'rounded-full min-h-11 px-5' };
675
704
 
@@ -718,6 +747,14 @@ useRichTextScrollRegions(detailsRoot, (caption) => caption ?? t('product.tabsLab
718
747
  </Link>
719
748
  </p>
720
749
 
750
+ <!-- The maker, muted and underlined, set tight above the title (the title's own
751
+ negative top margin in the design, here the line's). -->
752
+ <p v-if="maker !== null" class="-mb-3 text-[0.875rem]" data-product-maker>
753
+ <Link :href="maker.href" :as="EldraRouterLink" tone="muted" class="underline">
754
+ {{ maker.label }}
755
+ </Link>
756
+ </p>
757
+
721
758
  <h1 :id="titleId" :class="TITLE_CLASS">{{ product.title }}</h1>
722
759
 
723
760
  <div class="flex flex-col gap-2">
@@ -806,16 +843,21 @@ useRichTextScrollRegions(detailsRoot, (caption) => caption ?? t('product.tabsLab
806
843
  :message="t(stockLine.key, stockLine.params)"
807
844
  :revalidating="stockRevalidating"
808
845
  :class="stockClass"
846
+ :classes="STOCK_CLASSES"
809
847
  />
810
- <span v-if="stockLine.noteKey" class="text-muted mt-1 block pl-6 text-[0.875rem]">{{
811
- t(stockLine.noteKey)
812
- }}</span>
848
+ <span
849
+ v-if="stockLine.noteKey"
850
+ class="text-muted mt-1 block pl-[1.625rem] text-[0.875rem]"
851
+ >{{ t(stockLine.noteKey) }}</span
852
+ >
813
853
  </p>
814
854
 
815
- <!-- Stepper, Add to cart and the heart on one row; below 48rem the button takes a row
816
- of its own under the other two (`order`, visual only: the DOM keeps quantity →
817
- add → save, the order a keyboard walks). -->
818
- <div class="@tablet:flex-nowrap flex flex-wrap items-center gap-3">
855
+ <!-- Stepper, the heart and Add to cart on one row, the button taking what is left. It
856
+ wraps onto a line of its own only when its label no longer fits beside the other
857
+ two (`min-w-max`), at any width rather than below a fixed breakpoint, and the
858
+ heart stays beside the stepper. The DOM is in the same order, so a keyboard walks
859
+ it as it reads. -->
860
+ <div data-eldra-product-actions class="flex flex-wrap items-center gap-3">
819
861
  <FieldWrapper
820
862
  v-if="showQuantity && !soldOut && !notSold"
821
863
  :label="t('product.quantity')"
@@ -830,10 +872,22 @@ useRichTextScrollRegions(detailsRoot, (caption) => caption ?? t('product.tabsLab
830
872
  :classes="quantityStepperClasses"
831
873
  />
832
874
  </FieldWrapper>
833
- <div
834
- ref="addToCartEl"
835
- class="@tablet:order-none @tablet:basis-auto order-last min-w-0 flex-1 basis-full"
875
+ <Button
876
+ v-if="showWishlist"
877
+ type="button"
878
+ icon-only
879
+ variant="outline"
880
+ size="lg"
881
+ class="shrink-0 rounded-full"
882
+ :pressed="wishlisted"
883
+ :label="wishlistLabel"
884
+ @click="toggleWishlist"
836
885
  >
886
+ <template #leadingIcon>
887
+ <EldraIcon name="heart" size="md" />
888
+ </template>
889
+ </Button>
890
+ <div ref="addToCartEl" class="min-w-max flex-1">
837
891
  <Button
838
892
  type="submit"
839
893
  variant="primary"
@@ -850,21 +904,6 @@ useRichTextScrollRegions(detailsRoot, (caption) => caption ?? t('product.tabsLab
850
904
  {{ addToCartLabel }}
851
905
  </Button>
852
906
  </div>
853
- <Button
854
- v-if="showWishlist"
855
- type="button"
856
- icon-only
857
- variant="outline"
858
- size="lg"
859
- class="shrink-0 rounded-full"
860
- :pressed="wishlisted"
861
- :label="wishlistLabel"
862
- @click="toggleWishlist"
863
- >
864
- <template #leadingIcon>
865
- <EldraIcon name="heart" size="md" />
866
- </template>
867
- </Button>
868
907
  </div>
869
908
  <p v-if="cartWillSwitch" class="text-muted text-body-sm -mt-2">
870
909
  {{ t('currency.cartWillSwitch', { currency: defaultCurrency }) }}
@@ -905,16 +944,30 @@ useRichTextScrollRegions(detailsRoot, (caption) => caption ?? t('product.tabsLab
905
944
  :title="tab.label!"
906
945
  :heading-level="2"
907
946
  :classes="{
908
- summary: 'min-h-13 px-0',
947
+ summary: 'min-h-13 px-0 py-0',
909
948
  title: 'text-body font-semibold font-body',
949
+ chevron: 'size-4',
910
950
  panel: 'px-0 pb-5 text-muted',
911
951
  }"
912
952
  >
953
+ <!-- Label/value facts as a two-column definition list: the term in `text`,
954
+ semibold, the value muted beside it. -->
955
+ <dl
956
+ v-if="tabSpecs(tab) !== null"
957
+ class="grid grid-cols-[auto_1fr] gap-x-6 gap-y-1.5"
958
+ >
959
+ <template v-for="(spec, specIndex) in tabSpecs(tab)" :key="specIndex">
960
+ <dt class="text-text font-semibold">{{ spec.label }}</dt>
961
+ <dd>{{ spec.value }}</dd>
962
+ </template>
963
+ </dl>
913
964
  <!-- Under this row's own `h2`, so the body's headings start at `h3`. -->
914
965
  <EldraRichText
966
+ v-else
915
967
  class="prose-eldra [&>*+*]:mt-3"
916
968
  :entry-id="entryId"
917
969
  :field="`tabs.${index}.body`"
970
+ api-id="product-detail"
918
971
  :doc="tab.body"
919
972
  :min-heading-level="3"
920
973
  />