@eldrajs/theme-cli 0.2.8 → 0.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. package/CHANGELOG.md +3 -1
  2. package/package.json +1 -1
  3. package/template/.eldra/block-types.d.ts +28 -7
  4. package/template/.eldra/manifest.json +1034 -355
  5. package/template/.eldra/previews.json +35 -35
  6. package/template/README.md +32 -0
  7. package/template/app/assets/main.css +23 -0
  8. package/template/app/plugins/eldra-storefront.ts +3 -0
  9. package/template/app/storefront/demo.ts +75 -24
  10. package/template/app/storefront/gateway.ts +16 -2
  11. package/template/blocks/announcement-bar/preview.png +0 -0
  12. package/template/blocks/article/preview.json +4 -4
  13. package/template/blocks/article/preview.png +0 -0
  14. package/template/blocks/article-list/Block.vue +48 -19
  15. package/template/blocks/article-list/__tests__/Block.spec.ts +15 -0
  16. package/template/blocks/article-list/preview.json +43 -43
  17. package/template/blocks/article-list/preview.png +0 -0
  18. package/template/blocks/breadcrumbs/preview.png +0 -0
  19. package/template/blocks/cart/preview.png +0 -0
  20. package/template/blocks/collection-grid/Block.vue +260 -9
  21. package/template/blocks/collection-grid/__tests__/Block.spec.ts +202 -0
  22. package/template/blocks/collection-grid/block.json +3 -3
  23. package/template/blocks/collection-grid/preview.png +0 -0
  24. package/template/blocks/collection-header/Block.vue +82 -58
  25. package/template/blocks/collection-header/__tests__/Block.spec.ts +77 -1
  26. package/template/blocks/collection-header/preview.json +4 -4
  27. package/template/blocks/collection-header/preview.png +0 -0
  28. package/template/blocks/contact/preview.png +0 -0
  29. package/template/blocks/cta/preview.json +4 -4
  30. package/template/blocks/cta/preview.png +0 -0
  31. package/template/blocks/faq/preview.png +0 -0
  32. package/template/blocks/feature-grid/Block.vue +73 -4
  33. package/template/blocks/feature-grid/__tests__/Block.spec.ts +43 -1
  34. package/template/blocks/feature-grid/block.json +2 -2
  35. package/template/blocks/feature-grid/preview.json +49 -24
  36. package/template/blocks/feature-grid/preview.png +0 -0
  37. package/template/blocks/footer/Block.vue +186 -71
  38. package/template/blocks/footer/__tests__/Block.spec.ts +127 -32
  39. package/template/blocks/footer/block.json +42 -4
  40. package/template/blocks/footer/mock.json +31 -34
  41. package/template/blocks/footer/preview.png +0 -0
  42. package/template/blocks/form/preview.png +0 -0
  43. package/template/blocks/gallery/preview.json +24 -24
  44. package/template/blocks/gallery/preview.png +0 -0
  45. package/template/blocks/hero/Block.vue +117 -19
  46. package/template/blocks/hero/__tests__/Block.spec.ts +46 -0
  47. package/template/blocks/hero/block.json +36 -1
  48. package/template/blocks/hero/preview.json +33 -25
  49. package/template/blocks/hero/preview.png +0 -0
  50. package/template/blocks/image/preview.json +4 -4
  51. package/template/blocks/image/preview.png +0 -0
  52. package/template/blocks/logo-cloud/preview.png +0 -0
  53. package/template/blocks/navigation/Block.vue +623 -184
  54. package/template/blocks/navigation/__tests__/Block.spec.ts +416 -68
  55. package/template/blocks/navigation/__tests__/fixtures/menu.json +182 -0
  56. package/template/blocks/navigation/block.json +102 -6
  57. package/template/blocks/navigation/mock.json +279 -52
  58. package/template/blocks/navigation/preview.json +311 -0
  59. package/template/blocks/navigation/preview.png +0 -0
  60. package/template/blocks/newsletter/Block.vue +248 -144
  61. package/template/blocks/newsletter/__tests__/Block.spec.ts +42 -0
  62. package/template/blocks/newsletter/block.json +61 -2
  63. package/template/blocks/newsletter/preview.json +35 -0
  64. package/template/blocks/newsletter/preview.png +0 -0
  65. package/template/blocks/order-status/preview.png +0 -0
  66. package/template/blocks/pricing-table/preview.png +0 -0
  67. package/template/blocks/product-carousel/Block.vue +272 -26
  68. package/template/blocks/product-carousel/__tests__/Block.spec.ts +90 -0
  69. package/template/blocks/product-carousel/block.json +61 -0
  70. package/template/blocks/product-carousel/preview.json +12 -0
  71. package/template/blocks/product-carousel/preview.png +0 -0
  72. package/template/blocks/product-detail/Block.vue +148 -96
  73. package/template/blocks/product-detail/__tests__/Block.spec.ts +98 -74
  74. package/template/blocks/product-detail/block.json +11 -4
  75. package/template/blocks/product-detail/mock.json +53 -22
  76. package/template/blocks/product-detail/parts/Gallery.vue +52 -103
  77. package/template/blocks/product-detail/preview.png +0 -0
  78. package/template/blocks/quote/preview.png +0 -0
  79. package/template/blocks/rich-text/preview.png +0 -0
  80. package/template/blocks/search/Block.vue +1 -0
  81. package/template/blocks/search/TypeSection.vue +1 -0
  82. package/template/blocks/search/__tests__/Block.spec.ts +23 -0
  83. package/template/blocks/search/preview.png +0 -0
  84. package/template/blocks/split-content/Block.vue +98 -20
  85. package/template/blocks/split-content/__tests__/Block.spec.ts +57 -18
  86. package/template/blocks/split-content/block.json +72 -6
  87. package/template/blocks/split-content/preview.json +34 -13
  88. package/template/blocks/split-content/preview.png +0 -0
  89. package/template/blocks/stats/preview.png +0 -0
  90. package/template/blocks/tabs/preview.json +16 -16
  91. package/template/blocks/tabs/preview.png +0 -0
  92. package/template/blocks/team/preview.png +0 -0
  93. package/template/blocks/testimonials/preview.png +0 -0
  94. package/template/blocks/timeline/preview.png +0 -0
  95. package/template/blocks/trust-strip/Block.vue +67 -1
  96. package/template/blocks/trust-strip/__tests__/Block.spec.ts +30 -1
  97. package/template/blocks/trust-strip/block.json +4 -4
  98. package/template/blocks/trust-strip/preview.json +21 -0
  99. package/template/blocks/trust-strip/preview.png +0 -0
  100. package/template/blocks/video-embed/preview.png +0 -0
  101. package/template/blocks/wishlist/preview.png +0 -0
  102. package/template/i18n/en-US.json +16 -9
  103. package/template/i18n/is-IS.json +16 -9
  104. package/template/pages/article.page.json +19 -18
  105. package/template/pages/cart.page.json +3 -13
  106. package/template/pages/category.page.json +15 -7
  107. package/template/pages/collection.page.json +15 -14
  108. package/template/pages/home.page.json +217 -182
  109. package/template/pages/product.page.json +46 -36
  110. package/template/pages/products.page.json +3 -13
  111. package/template/pages/search.page.json +3 -13
  112. package/template/pages/wishlist.page.json +3 -13
  113. package/template/public/images/CREDITS.md +28 -0
  114. package/template/public/images/clay-hands.webp +0 -0
  115. package/template/public/images/coffee-table.webp +0 -0
  116. package/template/public/images/cup.webp +0 -0
  117. package/template/public/images/enamel-cups.webp +0 -0
  118. package/template/public/images/hero.webp +0 -0
  119. package/template/public/images/kitchen.webp +0 -0
  120. package/template/public/images/mug.webp +0 -0
  121. package/template/public/images/northwind-mark.svg +1 -0
  122. package/template/public/images/planters.webp +0 -0
  123. package/template/public/images/plates.webp +0 -0
  124. package/template/public/images/reading.webp +0 -0
  125. package/template/public/images/sweater.webp +0 -0
  126. package/template/public/images/terracotta.webp +0 -0
  127. package/template/public/images/throws.webp +0 -0
  128. package/template/public/images/vase.webp +0 -0
  129. package/template/public/images/wheel.webp +0 -0
  130. package/template/public/images/yarn-tools.webp +0 -0
  131. package/template/public/images/yarn.webp +0 -0
  132. package/template/stories/generated/collection-grid.stories.ts +6 -0
  133. package/template/stories/generated/feature-grid.stories.ts +6 -0
  134. package/template/stories/generated/footer.stories.ts +4 -4
  135. package/template/stories/generated/hero.stories.ts +6 -0
  136. package/template/stories/generated/navigation.stories.ts +14 -1
  137. package/template/stories/generated/newsletter.stories.ts +2 -1
  138. package/template/stories/generated/product-carousel.stories.ts +12 -0
  139. package/template/stories/generated/split-content.stories.ts +12 -0
  140. package/template/stories/generated/trust-strip.stories.ts +8 -1
  141. package/template/stories/pages/article.stories.ts +2 -1
  142. package/template/stories/pages/cart.stories.ts +2 -1
  143. package/template/stories/pages/category.stories.ts +2 -1
  144. package/template/stories/pages/collection.stories.ts +2 -1
  145. package/template/stories/pages/home.stories.ts +2 -1
  146. package/template/stories/pages/product.stories.ts +2 -1
  147. package/template/stories/pages/products.stories.ts +2 -1
  148. package/template/stories/pages/search.stories.ts +2 -1
  149. package/template/stories/pages/wishlist.stories.ts +2 -1
  150. package/template/stories/support/demoChrome.ts +32 -0
  151. package/template/stories/support/pageBlocks.ts +2 -4
  152. package/template/test/countPill.browser.spec.ts +21 -13
  153. package/template/test/localePrefix.spec.ts +11 -6
  154. package/template/test/pages/article.spec.ts +1 -1
  155. package/template/test/pages/category.spec.ts +34 -11
  156. package/template/test/pages/collection.spec.ts +182 -148
  157. package/template/test/pages/home.spec.ts +35 -40
  158. package/template/test/pages/hydration.spec.ts +4 -4
  159. package/template/test/pages/product.spec.ts +17 -14
  160. package/template/test/pages/seededPages.spec.ts +11 -6
  161. package/template/test/prerenderRefresh.browser.spec.ts +36 -15
  162. package/template/test/previewParity.browser.spec.ts +36 -2
  163. package/template/test/starter.spec.ts +31 -15
  164. package/template/test/storefront/gatewayPrerender.spec.ts +26 -0
  165. package/template/tokens.json +13 -13
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "apiId": "product-detail",
3
3
  "name": "Product detail",
4
- "description": "The product page's buy box: gallery, title, price, rating, variant pickers, quantity, add to cart, honest stock status, delivery notes and description tabs, plus a quick-add bar on narrow widths.",
4
+ "description": "The product page's buy box: gallery, title, price, rating, variant pickers, quantity, add to cart, honest stock status, delivery promises and a details accordion beside an image mosaic, plus a quick-add bar on narrow widths.",
5
5
  "icon": "shirt",
6
6
  "category": "commerce",
7
7
  "version": 1,
@@ -52,7 +52,7 @@
52
52
  "fieldId": "perks",
53
53
  "name": "Perks",
54
54
  "type": "list",
55
- "helpText": "Delivery and returns notes under the buy button. 2 work best.",
55
+ "helpText": "Delivery, collection and returns promises under the buy button, one ruled row each. 2 or 3 work best.",
56
56
  "metadata": {
57
57
  "item": {
58
58
  "fieldId": "perk",
@@ -65,7 +65,14 @@
65
65
  "name": "Icon",
66
66
  "type": "select",
67
67
  "metadata": {
68
- "options": ["truck", "arrow-back-up", "leaf", "shield-check", "gift"]
68
+ "options": [
69
+ "truck",
70
+ "arrow-back-up",
71
+ "leaf",
72
+ "shield-check",
73
+ "gift",
74
+ "building-store"
75
+ ]
69
76
  },
70
77
  "validators": { "required": true }
71
78
  },
@@ -93,7 +100,7 @@
93
100
  "fieldId": "tabs",
94
101
  "name": "Tabs",
95
102
  "type": "list",
96
- "helpText": "Details, Shipping and Returns by default.",
103
+ "helpText": "Shown as an accordion under the buy panel, the first one open. Details, Shipping and Returns by default.",
97
104
  "metadata": {
98
105
  "item": {
99
106
  "fieldId": "tab",
@@ -8,13 +8,18 @@
8
8
  "perks": [
9
9
  {
10
10
  "icon": "truck",
11
- "title": "Free delivery over $80.",
12
- "text": "Order today, arrives Tue 29 Sep to Thu 1 Oct."
11
+ "title": "Free delivery",
12
+ "text": "on orders over $80"
13
+ },
14
+ {
15
+ "icon": "building-store",
16
+ "title": "Collect for free",
17
+ "text": "from our Portland studio, usually the next day"
13
18
  },
14
19
  {
15
20
  "icon": "arrow-back-up",
16
- "title": "Free 30-day returns.",
17
- "text": "Unworn, with tags, no questions asked."
21
+ "title": "30-day returns",
22
+ "text": "on unworn items, with tags"
18
23
  }
19
24
  ],
20
25
  "tabs": [
@@ -23,15 +28,6 @@
23
28
  "body": {
24
29
  "type": "doc",
25
30
  "content": [
26
- {
27
- "type": "paragraph",
28
- "content": [
29
- {
30
- "type": "text",
31
- "text": "A relaxed crew knitted from extra-fine Merino in a family mill in Biella. Soft enough to wear next to skin, warm without the bulk."
32
- }
33
- ]
34
- },
35
31
  {
36
32
  "type": "bulletList",
37
33
  "content": [
@@ -41,7 +37,10 @@
41
37
  {
42
38
  "type": "paragraph",
43
39
  "content": [
44
- { "type": "text", "text": "100% extra-fine Merino wool, 17.5 micron" }
40
+ {
41
+ "type": "text",
42
+ "text": "100% extra-fine Merino wool, 17.5 micron"
43
+ }
45
44
  ]
46
45
  }
47
46
  ]
@@ -52,7 +51,10 @@
52
51
  {
53
52
  "type": "paragraph",
54
53
  "content": [
55
- { "type": "text", "text": "Hand wash cold or wool cycle, dry flat" }
54
+ {
55
+ "type": "text",
56
+ "text": "Knitted in a family mill in Biella, Italy"
57
+ }
56
58
  ]
57
59
  }
58
60
  ]
@@ -62,7 +64,12 @@
62
64
  "content": [
63
65
  {
64
66
  "type": "paragraph",
65
- "content": [{ "type": "text", "text": "Model is 180 cm and wears size M" }]
67
+ "content": [
68
+ {
69
+ "type": "text",
70
+ "text": "Relaxed fit; the model is 180 cm and wears size M"
71
+ }
72
+ ]
66
73
  }
67
74
  ]
68
75
  }
@@ -72,16 +79,40 @@
72
79
  }
73
80
  },
74
81
  {
75
- "label": "Shipping",
82
+ "label": "Care",
76
83
  "body": {
77
84
  "type": "doc",
78
85
  "content": [
79
86
  {
80
- "type": "paragraph",
87
+ "type": "bulletList",
81
88
  "content": [
82
89
  {
83
- "type": "text",
84
- "text": "US orders leave our Portland studio within 2 business days and arrive 2 to 4 days later. Free over $80."
90
+ "type": "listItem",
91
+ "content": [
92
+ {
93
+ "type": "paragraph",
94
+ "content": [
95
+ {
96
+ "type": "text",
97
+ "text": "Hand wash cold or use a wool cycle"
98
+ }
99
+ ]
100
+ }
101
+ ]
102
+ },
103
+ {
104
+ "type": "listItem",
105
+ "content": [
106
+ {
107
+ "type": "paragraph",
108
+ "content": [
109
+ {
110
+ "type": "text",
111
+ "text": "Dry flat, away from direct heat"
112
+ }
113
+ ]
114
+ }
115
+ ]
85
116
  }
86
117
  ]
87
118
  }
@@ -89,7 +120,7 @@
89
120
  }
90
121
  },
91
122
  {
92
- "label": "Returns",
123
+ "label": "Delivery and returns",
93
124
  "body": {
94
125
  "type": "doc",
95
126
  "content": [
@@ -98,7 +129,7 @@
98
129
  "content": [
99
130
  {
100
131
  "type": "text",
101
- "text": "30 days to send anything back unworn, with the prepaid label in your parcel. US returns are free."
132
+ "text": "US orders leave our Portland studio within 2 business days and arrive 2 to 4 days later; delivery costs are shown before you pay. Send anything unworn back within 30 days with the prepaid label in your parcel."
102
133
  }
103
134
  ]
104
135
  }
@@ -1,29 +1,30 @@
1
1
  <script setup lang="ts">
2
2
  /**
3
- * The product gallery: one 4:5 stage with the sale flag, an `aria-hidden` index pill, a zoom
4
- * button that opens `@eldrajs/ui`'s `Lightbox`, and a thumbnail strip below (spec `02-blocks.md`
5
- * "Product detail" → Layout, Gallery). Split out of `Block.vue` so that file keeps to state and
6
- * the information column; this part owns nothing but which image is current.
3
+ * The product gallery as a mosaic: every image on the page at once, the first one wide (5:4) across
4
+ * both columns and the rest in pairs below it (4:5), each one a button that opens `@eldrajs/ui`'s
5
+ * `Lightbox` at that image. Split out of `Block.vue` so that file keeps to state and the
6
+ * information column; this part owns nothing but which image the viewer opens on.
7
7
  *
8
8
  * `role="group"` named "Product images" (spec Keyboard & accessibility) — a group, not a region,
9
9
  * because the block's own `<section>` is already the named landmark.
10
10
  *
11
- * The stage image is decorative (`alt=""`): every thumbnail already carries the same description in
12
- * its own name ("Show image 2 of 5: …"), and the `Lightbox` renders the real `alt` on the full-size
13
- * photo, so announcing it a third time on the stage would only repeat it. With one image there is
14
- * nothing to pick between, so both the strip and the index pill are dropped (spec States,
15
- * "Minimal": "One image hides the thumbnails and the index").
11
+ * **Every tile is a `<button>`**, named by position and the image's own description ("Open image 2
12
+ * of 3: …"), so the photos stay reachable from the keyboard and a screen reader hears each
13
+ * description once; the `<img>` inside is decorative (`alt=""`) for the same reason the old stage
14
+ * image was, and the `Lightbox` renders the real `alt` on the full-size photo. The tiles are drawn
15
+ * by this theme — the one interactive element here that is not a package component — hence
16
+ * `focusRing` from `app/utils/classes.ts`, the same shape the `gallery` block's tiles use.
16
17
  *
17
- * Thumbnails are `<button>`s this theme draws itself — the one interactive element here that is not
18
- * a package component, hence `focusRing` from `app/utils/classes.ts`, the same shape the `gallery`
19
- * block's own tiles use. The current one is marked three ways so it never depends on colour alone
20
- * (spec Keyboard & accessibility): `aria-current="true"`, a 2px `text` inset ring, and a
21
- * `background` gap between the ring and the photo.
18
+ * **The shape follows the count**: one image fills the column; two sit side by side (a wide first
19
+ * image over a lone second one would leave half a row empty); three or more lead with the wide one,
20
+ * and an odd one out at the end spans the row as well, so the mosaic always closes square.
21
+ *
22
+ * The viewer is opened with `zoom` on: a shopper can enlarge the current photo to its real size and
23
+ * pan across it (mouse or arrow keys), and a phone keeps its own pinch-zoom.
22
24
  */
23
25
  import { computed, ref } from 'vue';
24
- import { Badge, Button, Lightbox } from '@eldrajs/ui';
26
+ import { Badge, Lightbox } from '@eldrajs/ui';
25
27
  import type { LightboxImage } from '@eldrajs/ui';
26
- import EldraIcon from '../../../app/components/EldraIcon.vue';
27
28
  import UiImage from '../../../app/components/ui/UiImage.vue';
28
29
  import { useI18n } from 'vue-i18n';
29
30
  import { focusRing } from '../../../app/utils/classes';
@@ -39,14 +40,14 @@ const props = defineProps<{
39
40
  images: GalleryImage[];
40
41
  /** The product title, for the viewer's accessible name. */
41
42
  title: string;
42
- /** Shows the sale flag over the stage. */
43
+ /** Shows the sale flag over the first image. */
43
44
  onSale: boolean;
44
45
  }>();
45
46
 
46
47
  const { t } = useI18n();
47
48
 
48
49
  /** `Lightbox` needs real intrinsic pixel sizes; a storefront image may not carry them, and these
49
- * are the same 4:5 fallbacks the stage reserves. */
50
+ * are the same 4:5 fallbacks the tiles reserve. */
50
51
  const FALLBACK_WIDTH = 1200;
51
52
  const FALLBACK_HEIGHT = 1500;
52
53
 
@@ -54,8 +55,6 @@ const current = ref(0);
54
55
  const lightboxOpen = ref(false);
55
56
 
56
57
  const count = computed(() => props.images.length);
57
- const hasStrip = computed(() => count.value > 1);
58
- const currentImage = computed(() => props.images[current.value] ?? props.images[0]);
59
58
 
60
59
  const lightboxImages = computed<LightboxImage[]>(() =>
61
60
  props.images.map((image) => ({
@@ -66,116 +65,66 @@ const lightboxImages = computed<LightboxImage[]>(() =>
66
65
  }))
67
66
  );
68
67
 
69
- function thumbnailLabel(image: GalleryImage, index: number): string {
70
- return t('product.showImage', { index: index + 1, count: count.value, alt: image.alt });
68
+ function tileLabel(image: GalleryImage, index: number): string {
69
+ return t('product.openImage', { index: index + 1, count: count.value, alt: image.alt });
71
70
  }
72
71
 
73
- function show(index: number): void {
72
+ function open(index: number): void {
74
73
  current.value = index;
74
+ lightboxOpen.value = true;
75
75
  }
76
76
 
77
- /**
78
- * Spec Layout: "a row of thumbnails sized so 5 fit exactly (0.5rem gaps), scrolling sideways (no
79
- * visible scrollbar) when there are more than 5" — five tracks and four 0.5rem gaps make each
80
- * basis `(100% - 2rem) / 5`. `eldra-scrollbar-hide` is `@eldrajs/ui`'s own utility, the same one
81
- * the `trust-strip` block's scrolling row uses, rather than a second hand-written recipe.
82
- */
83
- const THUMBNAIL_BASIS = 'shrink-0 basis-[calc((100%-2rem)/5)]';
77
+ /** Wide (both columns, 5:4) or a half (one column, 4:5) — see the module comment for the rule. */
78
+ function isWide(index: number): boolean {
79
+ if (count.value === 1) return true;
80
+ if (count.value === 2) return false;
81
+ if (index === 0) return true;
82
+ // After the wide first one the rest pair up; an odd one out at the very end spans the row.
83
+ return index === count.value - 1 && (count.value - 1) % 2 === 1;
84
+ }
84
85
 
85
- /** Spec Keyboard & accessibility: the current thumbnail has "a 2px `text` ring with a 2px
86
- * `background` gap"; the others "a 1px `border` inset line, `border-strong` on hover
87
- * (`duration-fast`)". Both are drawn as rings so the tile never changes size when it becomes
88
- * current. */
89
- const THUMBNAIL_CURRENT =
90
- 'ring-2 ring-text ring-offset-2 ring-offset-background motion-safe:transition-shadow';
91
- const THUMBNAIL_IDLE =
92
- 'ring-1 ring-border hover:ring-border-strong motion-safe:transition-shadow ' +
93
- 'motion-safe:duration-fast';
86
+ const TILE = 'group relative block w-full cursor-zoom-in overflow-hidden rounded-lg bg-surface';
94
87
  </script>
95
88
 
96
89
  <template>
97
- <div role="group" :aria-label="t('product.images')" class="flex flex-col gap-3">
98
- <div class="relative">
99
- <UiImage
100
- v-if="currentImage"
101
- :src="currentImage.src"
102
- alt=""
103
- aspect="4/5"
104
- rounded="lg"
105
- class="w-full"
106
- />
107
-
108
- <div v-if="onSale" class="absolute top-3 left-3 flex flex-wrap gap-1">
109
- <Badge variant="sale" :label="t('product.saleBadge')" />
110
- </div>
111
-
112
- <!-- Decorative: every thumbnail and the zoom button already name the position in words. -->
113
- <span
114
- v-if="hasStrip"
115
- aria-hidden="true"
116
- class="bg-background text-text @tablet:hidden absolute bottom-3 left-3 rounded-full px-2 py-0.5 text-[0.875rem] tabular-nums"
90
+ <div role="group" :aria-label="t('product.images')">
91
+ <ul role="list" class="grid grid-cols-2 gap-3">
92
+ <li
93
+ v-for="(image, index) in images"
94
+ :key="image.src + index"
95
+ :class="isWide(index) ? 'relative col-span-2' : 'relative col-span-1'"
117
96
  >
118
- {{ t('product.imageIndex', { index: current + 1, count }) }}
119
- </span>
120
-
121
- <!-- The positioning lives on a wrapper, not on the `Button` itself: the button's own
122
- `position: relative` (it draws its focus ring and spinner against itself) and an
123
- `absolute` utility passed in as a class are the same CSS property, so which one wins
124
- would depend on the order Tailwind happens to emit them in. -->
125
- <div v-if="currentImage" class="absolute right-3 bottom-3">
126
- <Button
127
- icon-only
128
- variant="outline"
129
- aria-haspopup="dialog"
130
- class="size-11 shadow-sm"
131
- :label="t('product.zoom', { index: current + 1, count })"
132
- @click="lightboxOpen = true"
133
- >
134
- <template #leadingIcon>
135
- <EldraIcon name="zoom-in" size="md" />
136
- </template>
137
- </Button>
138
- </div>
139
- </div>
140
-
141
- <!-- The current tile's ring + offset reach 4px outside its box; a scroll container clips what
142
- hangs outside it, so the strip carries that much padding (and pulls itself back out by the
143
- same amount sideways so the tiles still line up with the stage). -->
144
- <ul
145
- v-if="hasStrip"
146
- role="list"
147
- class="eldra-scrollbar-hide -mx-1 flex gap-2 overflow-x-auto px-1 py-1"
148
- >
149
- <li v-for="(image, index) in images" :key="image.src + index" :class="THUMBNAIL_BASIS">
150
97
  <button
151
98
  type="button"
152
- :aria-current="index === current ? 'true' : undefined"
153
- :aria-label="thumbnailLabel(image, index)"
154
- :class="[
155
- focusRing,
156
- 'block w-full cursor-pointer rounded-md',
157
- index === current ? THUMBNAIL_CURRENT : THUMBNAIL_IDLE,
158
- ]"
159
- @click="show(index)"
99
+ aria-haspopup="dialog"
100
+ :aria-label="tileLabel(image, index)"
101
+ :class="[focusRing, TILE]"
102
+ @click="open(index)"
160
103
  >
161
104
  <UiImage
162
105
  :src="image.src"
163
106
  alt=""
164
- aspect="4/5"
165
- class="w-full"
166
- :classes="{ frame: 'rounded-md' }"
107
+ :aspect="isWide(index) ? '5/4' : '4/5'"
108
+ :priority="index === 0"
109
+ class="motion-safe:duration-base w-full group-hover:scale-[1.02] motion-safe:transition-transform"
167
110
  />
168
111
  </button>
112
+ <!-- After the button, so it paints over the photo; it is text, not a control, so the
113
+ pointer passes through it to the tile. -->
114
+ <div v-if="index === 0 && onSale" class="pointer-events-none absolute top-3 left-3">
115
+ <Badge variant="sale" :label="t('product.saleBadge')" />
116
+ </div>
169
117
  </li>
170
118
  </ul>
171
119
 
172
120
  <Lightbox
173
- v-if="currentImage"
121
+ v-if="images.length > 0"
174
122
  v-model="lightboxOpen"
175
123
  v-model:index="current"
176
124
  :images="lightboxImages"
177
125
  :aria-label="t('product.viewer', { title })"
178
126
  thumbnails
127
+ zoom
179
128
  />
180
129
  </div>
181
130
  </template>
Binary file
@@ -504,6 +504,7 @@ const headingClass =
504
504
  :key="entry.item.handle"
505
505
  :product="entry.product"
506
506
  ratio="4x5"
507
+ class="min-w-0"
507
508
  :heading-level="2"
508
509
  :link-as="entry.internal ? EldraRouterLink : undefined"
509
510
  :currency="entry.currency ?? currency"
@@ -101,6 +101,7 @@ const JOURNAL_GRID_CLASS = 'grid grid-cols-1 gap-6 @tablet:grid-cols-3 @tablet:g
101
101
  :key="entry.item.handle"
102
102
  :product="entry.product"
103
103
  ratio="4x5"
104
+ class="min-w-0"
104
105
  :heading-level="3"
105
106
  :link-as="entry.internal ? EldraRouterLink : undefined"
106
107
  :currency="entry.currency ?? currency"
@@ -448,6 +448,29 @@ describe('search block', () => {
448
448
  expect(status.findAll('a[href^="/products/"]').length).toBeLessThanOrEqual(4);
449
449
  });
450
450
 
451
+ it('lets the grid track, not the card, decide a card width (two columns fit a phone)', async () => {
452
+ // `ProductCard` carries its own `min-w-56`: in a two-column grid on a phone that pushed the
453
+ // second column past the screen and widened the whole page. Both card grids, the results and
454
+ // the no-results suggestions, hand the width to the track, as `collection-grid` does.
455
+ const results = mountSearch(mock, {
456
+ storefront: withSearch({
457
+ query: 'linen',
458
+ total: 2,
459
+ products: [PRODUCTS[0]!, PRODUCTS[1]!],
460
+ articles: [],
461
+ pages: [],
462
+ suggestion: null,
463
+ }),
464
+ });
465
+ const none = mountSearch(mock, { storefront: withNoResults() });
466
+ await nextTick();
467
+ for (const wrapper of [results, none]) {
468
+ const cards = wrapper.findAll('article');
469
+ expect(cards.length).toBeGreaterThan(0);
470
+ for (const card of cards) expect(card.classes()).toContain('min-w-0');
471
+ }
472
+ });
473
+
451
474
  it('the popular-search chips are links to the results page', async () => {
452
475
  const wrapper = mountSearch(mock, { storefront: withNoResults() });
453
476
  await nextTick();
Binary file