@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.
- package/CHANGELOG.md +2 -0
- package/package.json +3 -3
- package/template/.eldra/block-types.d.ts +28 -7
- package/template/.eldra/manifest.json +1152 -445
- package/template/.eldra/previews.json +35 -35
- package/template/README.md +32 -0
- package/template/app/assets/main.css +23 -0
- package/template/app/plugins/eldra-storefront.ts +3 -0
- package/template/app/storefront/demo.ts +75 -24
- package/template/app/storefront/gateway.ts +16 -2
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/preview.json +4 -4
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/Block.vue +48 -19
- package/template/blocks/article-list/__tests__/Block.spec.ts +15 -0
- package/template/blocks/article-list/preview.json +43 -43
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/preview.png +0 -0
- package/template/blocks/collection-grid/Block.vue +260 -9
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +202 -0
- package/template/blocks/collection-grid/block.json +3 -3
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/Block.vue +65 -52
- package/template/blocks/collection-header/preview.json +4 -4
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/preview.json +4 -4
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/Block.vue +73 -4
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +43 -1
- package/template/blocks/feature-grid/block.json +2 -2
- package/template/blocks/feature-grid/preview.json +49 -24
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +186 -71
- package/template/blocks/footer/__tests__/Block.spec.ts +127 -32
- package/template/blocks/footer/block.json +42 -4
- package/template/blocks/footer/mock.json +31 -34
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/preview.png +0 -0
- package/template/blocks/gallery/preview.json +24 -24
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +117 -19
- package/template/blocks/hero/__tests__/Block.spec.ts +46 -0
- package/template/blocks/hero/block.json +36 -1
- package/template/blocks/hero/preview.json +33 -25
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/preview.json +4 -4
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +665 -184
- package/template/blocks/navigation/__tests__/Block.spec.ts +496 -75
- package/template/blocks/navigation/__tests__/fixtures/menu.json +182 -0
- package/template/blocks/navigation/block.json +110 -6
- package/template/blocks/navigation/mock.json +372 -140
- package/template/blocks/navigation/preview.json +311 -0
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/Block.vue +248 -144
- package/template/blocks/newsletter/__tests__/Block.spec.ts +42 -0
- package/template/blocks/newsletter/block.json +61 -2
- package/template/blocks/newsletter/preview.json +35 -0
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/Block.vue +272 -26
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +90 -0
- package/template/blocks/product-carousel/block.json +61 -0
- package/template/blocks/product-carousel/preview.json +12 -0
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +148 -96
- package/template/blocks/product-detail/__tests__/Block.spec.ts +98 -74
- package/template/blocks/product-detail/block.json +11 -4
- package/template/blocks/product-detail/mock.json +53 -22
- package/template/blocks/product-detail/parts/Gallery.vue +52 -103
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/quote/preview.png +0 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/Block.vue +1 -0
- package/template/blocks/search/TypeSection.vue +1 -0
- package/template/blocks/search/__tests__/Block.spec.ts +23 -0
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/split-content/Block.vue +98 -20
- package/template/blocks/split-content/__tests__/Block.spec.ts +57 -18
- package/template/blocks/split-content/block.json +72 -6
- package/template/blocks/split-content/preview.json +34 -13
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/preview.json +16 -16
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/Block.vue +67 -1
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +30 -1
- package/template/blocks/trust-strip/block.json +4 -4
- package/template/blocks/trust-strip/preview.json +21 -0
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/i18n/en-US.json +16 -9
- package/template/i18n/is-IS.json +16 -9
- package/template/package.json +1 -1
- package/template/pages/article.page.json +19 -18
- package/template/pages/cart.page.json +3 -13
- package/template/pages/category.page.json +15 -7
- package/template/pages/collection.page.json +15 -14
- package/template/pages/home.page.json +217 -182
- package/template/pages/product.page.json +46 -36
- package/template/pages/products.page.json +3 -13
- package/template/pages/search.page.json +3 -13
- package/template/pages/wishlist.page.json +3 -13
- package/template/public/images/CREDITS.md +28 -0
- package/template/public/images/bowl.webp +0 -0
- package/template/public/images/clay-hands.webp +0 -0
- package/template/public/images/coffee-table.webp +0 -0
- package/template/public/images/cup.webp +0 -0
- package/template/public/images/enamel-cups.webp +0 -0
- package/template/public/images/hero.webp +0 -0
- package/template/public/images/kitchen.webp +0 -0
- package/template/public/images/mug.webp +0 -0
- package/template/public/images/northwind-mark.svg +1 -0
- package/template/public/images/planters.webp +0 -0
- package/template/public/images/plates.webp +0 -0
- package/template/public/images/reading.webp +0 -0
- package/template/public/images/sweater.webp +0 -0
- package/template/public/images/terracotta.webp +0 -0
- package/template/public/images/throws.webp +0 -0
- package/template/public/images/vase.webp +0 -0
- package/template/public/images/wheel.webp +0 -0
- package/template/public/images/yarn-tools.webp +0 -0
- package/template/public/images/yarn.webp +0 -0
- package/template/stories/generated/collection-grid.stories.ts +6 -0
- package/template/stories/generated/feature-grid.stories.ts +6 -0
- package/template/stories/generated/footer.stories.ts +4 -4
- package/template/stories/generated/hero.stories.ts +6 -0
- package/template/stories/generated/navigation.stories.ts +14 -1
- package/template/stories/generated/newsletter.stories.ts +2 -1
- package/template/stories/generated/product-carousel.stories.ts +12 -0
- package/template/stories/generated/split-content.stories.ts +12 -0
- package/template/stories/generated/trust-strip.stories.ts +8 -1
- package/template/stories/pages/article.stories.ts +2 -1
- package/template/stories/pages/cart.stories.ts +2 -1
- package/template/stories/pages/category.stories.ts +2 -1
- package/template/stories/pages/collection.stories.ts +2 -1
- package/template/stories/pages/home.stories.ts +2 -1
- package/template/stories/pages/product.stories.ts +2 -1
- package/template/stories/pages/products.stories.ts +2 -1
- package/template/stories/pages/search.stories.ts +2 -1
- package/template/stories/pages/wishlist.stories.ts +2 -1
- package/template/stories/support/demoChrome.ts +32 -0
- package/template/stories/support/pageBlocks.ts +2 -4
- package/template/test/countPill.browser.spec.ts +21 -13
- package/template/test/localePrefix.spec.ts +11 -6
- package/template/test/pages/article.spec.ts +1 -1
- package/template/test/pages/category.spec.ts +34 -11
- package/template/test/pages/collection.spec.ts +182 -148
- package/template/test/pages/home.spec.ts +35 -40
- package/template/test/pages/hydration.spec.ts +4 -4
- package/template/test/pages/product.spec.ts +17 -14
- package/template/test/pages/seededPages.spec.ts +11 -6
- package/template/test/prerenderFailure.spec.ts +4 -3
- package/template/test/prerenderRefresh.browser.spec.ts +36 -15
- package/template/test/previewParity.browser.spec.ts +1152 -0
- package/template/test/starter.spec.ts +37 -16
- package/template/test/storefront/gatewayPrerender.spec.ts +26 -0
- package/template/test/support/previewParity.ts +302 -0
- package/template/test/support/previewParityContent.ts +726 -0
- 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
|
|
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
|
|
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": [
|
|
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
|
|
12
|
-
"text": "
|
|
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": "
|
|
17
|
-
"text": "
|
|
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
|
-
{
|
|
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
|
-
{
|
|
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": [
|
|
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": "
|
|
82
|
+
"label": "Care",
|
|
76
83
|
"body": {
|
|
77
84
|
"type": "doc",
|
|
78
85
|
"content": [
|
|
79
86
|
{
|
|
80
|
-
"type": "
|
|
87
|
+
"type": "bulletList",
|
|
81
88
|
"content": [
|
|
82
89
|
{
|
|
83
|
-
"type": "
|
|
84
|
-
"
|
|
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": "
|
|
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": "
|
|
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
|
|
4
|
-
* button that opens `@eldrajs/ui`'s
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
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
|
-
*
|
|
18
|
-
* a
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
* `
|
|
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,
|
|
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
|
|
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
|
|
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
|
|
70
|
-
return t('product.
|
|
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
|
|
72
|
+
function open(index: number): void {
|
|
74
73
|
current.value = index;
|
|
74
|
+
lightboxOpen.value = true;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
/**
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
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')"
|
|
98
|
-
<
|
|
99
|
-
<
|
|
100
|
-
v-
|
|
101
|
-
:
|
|
102
|
-
|
|
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
|
-
|
|
153
|
-
:aria-label="
|
|
154
|
-
:class="[
|
|
155
|
-
|
|
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
|
-
|
|
166
|
-
|
|
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="
|
|
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
|
|
Binary file
|
|
Binary file
|
|
@@ -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
|