@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
|
@@ -11,9 +11,14 @@
|
|
|
11
11
|
* section. With neither, the editor sees the "Choose a product" placeholder and the live site
|
|
12
12
|
* renders nothing (Global Constraints, "Editor vs live").
|
|
13
13
|
*
|
|
14
|
+
* **The layout** is an image mosaic beside a sticky buy panel from 60rem of the block's width,
|
|
15
|
+
* stacked below it: the panel carries the option pills, a pill-shaped quantity stepper with Add to
|
|
16
|
+
* cart and the heart, the delivery promises (`perks`) as a ruled list, and the `tabs` entries as an
|
|
17
|
+
* accordion with the first row open.
|
|
18
|
+
*
|
|
14
19
|
* **`gallery-right` mirrors visually only.** The gallery is first in the DOM in both variants and
|
|
15
|
-
* only the `@
|
|
16
|
-
* (spec Variants, `gallery-right` row).
|
|
20
|
+
* only the `@min-[60rem]:order-*` utilities swap the columns, so reading and focus order never
|
|
21
|
+
* change (spec Variants, `gallery-right` row).
|
|
17
22
|
*
|
|
18
23
|
* **The buy area is a real `<form>`**, the way a storefront's add-to-cart form always is: the
|
|
19
24
|
* pickers are its radio groups, the stepper its quantity field and Add to cart its submit button,
|
|
@@ -36,6 +41,8 @@
|
|
|
36
41
|
*/
|
|
37
42
|
import { computed, nextTick, onMounted, ref, watch } from 'vue';
|
|
38
43
|
import {
|
|
44
|
+
Accordion,
|
|
45
|
+
AccordionItem,
|
|
39
46
|
Badge,
|
|
40
47
|
Button,
|
|
41
48
|
Container,
|
|
@@ -50,9 +57,6 @@ import {
|
|
|
50
57
|
Rating,
|
|
51
58
|
Section,
|
|
52
59
|
StockBadge,
|
|
53
|
-
Tab,
|
|
54
|
-
TabPanel,
|
|
55
|
-
Tabs,
|
|
56
60
|
VariantPicker,
|
|
57
61
|
useToast,
|
|
58
62
|
type FormLayoutSubmitPayload,
|
|
@@ -626,25 +630,54 @@ async function submitNotify(payload: FormLayoutSubmitPayload): Promise<void> {
|
|
|
626
630
|
/* Presentation */
|
|
627
631
|
/* ------------------------------------------------------------------------- */
|
|
628
632
|
|
|
629
|
-
/**
|
|
630
|
-
*
|
|
631
|
-
|
|
632
|
-
const SECTION_SPACING = 'pt-4 @tablet:pt-8 pb-[var(--eldra-section-md)]';
|
|
633
|
+
/** 1rem top below 48rem block width, 1.5rem from it, 4rem bottom — the design's own steps, which
|
|
634
|
+
* `Section`'s symmetrical `spacing` presets do not carry, so the block sets its own halves. */
|
|
635
|
+
const SECTION_SPACING = 'pt-4 @tablet:pt-6 pb-16';
|
|
633
636
|
|
|
634
|
-
/**
|
|
635
|
-
*
|
|
636
|
-
const
|
|
637
|
-
'
|
|
638
|
-
'@
|
|
637
|
+
/** Two columns from 60rem of the block's width (the design's 960px edge, so a tablet gets the
|
|
638
|
+
* stacked page): the mosaic a little wider than the buy panel. */
|
|
639
|
+
const LAYOUT_CLASS =
|
|
640
|
+
'grid grid-cols-1 gap-8 @min-[60rem]:grid-cols-[minmax(0,1.25fr)_minmax(0,1fr)] ' +
|
|
641
|
+
'@min-[60rem]:items-start @min-[60rem]:gap-14';
|
|
639
642
|
|
|
640
|
-
|
|
643
|
+
/** The title: the serif at 2.25rem, 2.5rem from 48rem. */
|
|
644
|
+
const TITLE_CLASS =
|
|
645
|
+
'font-heading text-[2.25rem] leading-[1.08] font-medium tracking-[-0.015em] text-balance ' +
|
|
646
|
+
'@tablet:text-[2.5rem]';
|
|
641
647
|
|
|
642
|
-
|
|
643
|
-
|
|
648
|
+
/** A pill-shaped stepper at the Add to cart button's own 3.25rem height. */
|
|
649
|
+
const quantityStepperClasses = {
|
|
650
|
+
decrease: 'h-13 w-11 aspect-auto',
|
|
651
|
+
increase: 'h-13 w-11 aspect-auto',
|
|
652
|
+
input: 'h-13 w-9',
|
|
653
|
+
};
|
|
654
|
+
const QUANTITY_STEPPER_CLASS = '[--eldra-stepper-radius:var(--eldra-radius-full)]';
|
|
644
655
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
656
|
+
/**
|
|
657
|
+
* Option pills. The package's colour swatch is a bare disc with its name kept for assistive
|
|
658
|
+
* technology only; here each colour reads as a pill — disc and name — the way the size pills read,
|
|
659
|
+
* so a shopper never has to guess a colour from a 2.75rem dot. All of it through `classes`: the
|
|
660
|
+
* swatch's own name is un-hidden (`not-sr-only`), the drawn radio grows to fit it, and the resting
|
|
661
|
+
* ring is a 1px `border-strong` line that becomes the package's own 2px `text` ring when checked
|
|
662
|
+
* (the padding steps by the same 1px, so the pill never changes size).
|
|
663
|
+
*/
|
|
664
|
+
const SWATCH_PILL_CLASSES = {
|
|
665
|
+
radio:
|
|
666
|
+
'size-auto h-11 justify-start gap-2 ps-1.5 pe-4 ' +
|
|
667
|
+
'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)]',
|
|
669
|
+
swatch: 'size-7 shrink-0',
|
|
670
|
+
// 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',
|
|
673
|
+
};
|
|
674
|
+
const PILL_CLASSES = { radio: 'rounded-full min-h-11 px-5' };
|
|
675
|
+
|
|
676
|
+
/** Which accordion rows are open: the first one, as the design opens Details. */
|
|
677
|
+
const openSections = ref<boolean[]>([true]);
|
|
678
|
+
|
|
679
|
+
const detailsRoot = ref<HTMLElement | null>(null);
|
|
680
|
+
useRichTextScrollRegions(detailsRoot, (caption) => caption ?? t('product.tabsLabel'));
|
|
648
681
|
</script>
|
|
649
682
|
|
|
650
683
|
<template>
|
|
@@ -655,42 +688,40 @@ function tabValue(index: number): string {
|
|
|
655
688
|
:aria-busy="refreshing ? 'true' : undefined"
|
|
656
689
|
:class="SECTION_SPACING"
|
|
657
690
|
>
|
|
658
|
-
<Container width="
|
|
659
|
-
<div
|
|
660
|
-
class="@tablet:grid-cols-[7fr_5fr] @tablet:items-start @tablet:gap-8 @content:gap-12 grid gap-6"
|
|
661
|
-
>
|
|
691
|
+
<Container width="wide">
|
|
692
|
+
<div :class="LAYOUT_CLASS">
|
|
662
693
|
<!-- Gallery first in the DOM in both variants; only the order utilities mirror. -->
|
|
663
694
|
<Gallery
|
|
664
|
-
class="@
|
|
665
|
-
:class="galleryRight ? '@tablet:order-2' : '@tablet:order-1'"
|
|
695
|
+
:class="galleryRight ? '@min-[60rem]:order-2' : '@min-[60rem]:order-1'"
|
|
666
696
|
:images="product.images"
|
|
667
697
|
:title="product.title"
|
|
668
698
|
:on-sale="onSale"
|
|
669
699
|
/>
|
|
670
700
|
|
|
701
|
+
<!-- The buy panel stays in view beside a tall mosaic from 60rem. -->
|
|
671
702
|
<div
|
|
672
703
|
role="group"
|
|
673
704
|
:aria-label="t('product.information')"
|
|
674
|
-
class="flex flex-col gap-
|
|
675
|
-
:class="galleryRight ? '@
|
|
705
|
+
class="flex flex-col gap-5 @min-[60rem]:sticky @min-[60rem]:top-[calc(1.5rem_+_var(--eldra-header-height,0px))]"
|
|
706
|
+
:class="galleryRight ? '@min-[60rem]:order-1' : '@min-[60rem]:order-2'"
|
|
676
707
|
>
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
<
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
708
|
+
<!--
|
|
709
|
+
One label, not a trail, and deliberately not a `<nav>`: a second landmark named
|
|
710
|
+
"Breadcrumb" beside the `breadcrumbs` block's own is the duplication this used to
|
|
711
|
+
ship (see `categoryLeaf`). It stays a link because the destination is useful — the
|
|
712
|
+
catalogue filtered by that category — and `p` rather than a bare `Link` so the line
|
|
713
|
+
keeps its own type size whatever the link's tone does.
|
|
714
|
+
-->
|
|
715
|
+
<p v-if="showCategory && categoryLeaf !== null" class="-mb-3 text-[0.875rem]">
|
|
716
|
+
<Link :href="categoryLeaf.href" :as="EldraRouterLink" tone="muted">
|
|
717
|
+
{{ categoryLeaf.label }}
|
|
718
|
+
</Link>
|
|
719
|
+
</p>
|
|
720
|
+
|
|
721
|
+
<h1 :id="titleId" :class="TITLE_CLASS">{{ product.title }}</h1>
|
|
690
722
|
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
<div class="mt-2 flex flex-wrap items-center gap-x-4 gap-y-2">
|
|
723
|
+
<div class="flex flex-col gap-2">
|
|
724
|
+
<div class="flex flex-wrap items-baseline gap-x-3 gap-y-2">
|
|
694
725
|
<p v-if="notSold" class="text-text" data-eldra-not-sold>
|
|
695
726
|
{{ t('currency.notSoldInLong', { currency: shopperCurrency }) }}
|
|
696
727
|
</p>
|
|
@@ -704,25 +735,25 @@ function tabValue(index: number): string {
|
|
|
704
735
|
"
|
|
705
736
|
:currency="product.price.currency"
|
|
706
737
|
:revalidating="priceRevalidating"
|
|
738
|
+
:classes="{ current: 'text-[1.5rem] font-semibold' }"
|
|
707
739
|
/>
|
|
708
740
|
<Badge
|
|
709
741
|
v-if="saving && !notSold"
|
|
710
742
|
variant="sale"
|
|
711
743
|
:label="t('product.saving', { amount: saving })"
|
|
712
744
|
/>
|
|
713
|
-
<
|
|
714
|
-
v-if="showRating && rating"
|
|
715
|
-
:value="rating.value"
|
|
716
|
-
:count="rating.count"
|
|
717
|
-
href="#reviews"
|
|
718
|
-
:as="EldraRouterLink"
|
|
719
|
-
/>
|
|
745
|
+
<span class="text-muted text-[0.875rem]">{{ t('product.taxNote') }}</span>
|
|
720
746
|
</div>
|
|
721
|
-
|
|
722
|
-
|
|
747
|
+
<Rating
|
|
748
|
+
v-if="showRating && rating"
|
|
749
|
+
:value="rating.value"
|
|
750
|
+
:count="rating.count"
|
|
751
|
+
href="#reviews"
|
|
752
|
+
:as="EldraRouterLink"
|
|
753
|
+
/>
|
|
723
754
|
</div>
|
|
724
755
|
|
|
725
|
-
<
|
|
756
|
+
<p v-if="product.description" class="text-muted">{{ product.description }}</p>
|
|
726
757
|
|
|
727
758
|
<form class="flex flex-col gap-5" @submit.prevent="primaryAction">
|
|
728
759
|
<!--
|
|
@@ -755,6 +786,7 @@ function tabValue(index: number): string {
|
|
|
755
786
|
:legend="option.label"
|
|
756
787
|
:type="option.type"
|
|
757
788
|
:options="option.values"
|
|
789
|
+
:classes="option.type === 'swatches' ? SWATCH_PILL_CLASSES : PILL_CLASSES"
|
|
758
790
|
/>
|
|
759
791
|
<Link
|
|
760
792
|
v-if="optionIndex === sizeGuideOptionIndex && sizeGuideHref"
|
|
@@ -780,26 +812,34 @@ function tabValue(index: number): string {
|
|
|
780
812
|
}}</span>
|
|
781
813
|
</p>
|
|
782
814
|
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
:
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
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">
|
|
819
|
+
<FieldWrapper
|
|
820
|
+
v-if="showQuantity && !soldOut && !notSold"
|
|
821
|
+
:label="t('product.quantity')"
|
|
822
|
+
class="shrink-0"
|
|
823
|
+
:classes="{ label: 'sr-only' }"
|
|
824
|
+
>
|
|
825
|
+
<QuantityStepper
|
|
826
|
+
v-model="quantity"
|
|
827
|
+
name="quantity"
|
|
828
|
+
:max="stockLine.max"
|
|
829
|
+
:class="QUANTITY_STEPPER_CLASS"
|
|
830
|
+
:classes="quantityStepperClasses"
|
|
831
|
+
/>
|
|
832
|
+
</FieldWrapper>
|
|
833
|
+
<div
|
|
834
|
+
ref="addToCartEl"
|
|
835
|
+
class="@tablet:order-none @tablet:basis-auto order-last min-w-0 flex-1 basis-full"
|
|
836
|
+
>
|
|
798
837
|
<Button
|
|
799
838
|
type="submit"
|
|
800
839
|
variant="primary"
|
|
801
840
|
size="lg"
|
|
802
841
|
block
|
|
842
|
+
class="rounded-full"
|
|
803
843
|
:loading="cartBusy"
|
|
804
844
|
:disabled="notSoldAnywhere"
|
|
805
845
|
:label="addToCartLabel"
|
|
@@ -816,6 +856,7 @@ function tabValue(index: number): string {
|
|
|
816
856
|
icon-only
|
|
817
857
|
variant="outline"
|
|
818
858
|
size="lg"
|
|
859
|
+
class="shrink-0 rounded-full"
|
|
819
860
|
:pressed="wishlisted"
|
|
820
861
|
:label="wishlistLabel"
|
|
821
862
|
@click="toggleWishlist"
|
|
@@ -833,41 +874,52 @@ function tabValue(index: number): string {
|
|
|
833
874
|
<ul
|
|
834
875
|
v-if="perks.length > 0"
|
|
835
876
|
role="list"
|
|
836
|
-
class="
|
|
877
|
+
class="border-border divide-border divide-y rounded-lg border"
|
|
837
878
|
>
|
|
838
|
-
<li
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
879
|
+
<li
|
|
880
|
+
v-for="(perk, index) in perks"
|
|
881
|
+
:key="index"
|
|
882
|
+
class="flex items-start gap-3 px-4 py-3.5 text-[0.9375rem]"
|
|
883
|
+
>
|
|
884
|
+
<EldraIcon
|
|
885
|
+
v-if="perk.icon"
|
|
886
|
+
:name="perk.icon"
|
|
887
|
+
size="md"
|
|
888
|
+
class="text-primary mt-0.5 shrink-0"
|
|
889
|
+
/>
|
|
890
|
+
<p class="min-w-0">
|
|
891
|
+
<b class="font-semibold">{{ perk.title }}</b
|
|
892
|
+
>{{ perk.text ? ` ${perk.text}` : '' }}
|
|
893
|
+
</p>
|
|
844
894
|
</li>
|
|
845
895
|
</ul>
|
|
846
896
|
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
897
|
+
<!-- The details as an accordion, Details open: each row a native disclosure, so the
|
|
898
|
+
keyboard and assistive technology get the browser's own behaviour. -->
|
|
899
|
+
<div v-if="tabs.length > 0" ref="detailsRoot" class="border-border border-t">
|
|
900
|
+
<Accordion>
|
|
901
|
+
<AccordionItem
|
|
902
|
+
v-for="(tab, index) in tabs"
|
|
903
|
+
:key="index"
|
|
904
|
+
v-model="openSections[index]"
|
|
905
|
+
:title="tab.label!"
|
|
906
|
+
:heading-level="2"
|
|
907
|
+
:classes="{
|
|
908
|
+
summary: 'min-h-13 px-0',
|
|
909
|
+
title: 'text-body font-semibold font-body',
|
|
910
|
+
panel: 'px-0 pb-5 text-muted',
|
|
911
|
+
}"
|
|
912
|
+
>
|
|
913
|
+
<!-- Under this row's own `h2`, so the body's headings start at `h3`. -->
|
|
862
914
|
<EldraRichText
|
|
863
915
|
class="prose-eldra [&>*+*]:mt-3"
|
|
864
916
|
:entry-id="entryId"
|
|
865
917
|
:field="`tabs.${index}.body`"
|
|
866
918
|
:doc="tab.body"
|
|
867
|
-
:min-heading-level="
|
|
919
|
+
:min-heading-level="3"
|
|
868
920
|
/>
|
|
869
|
-
</
|
|
870
|
-
</
|
|
921
|
+
</AccordionItem>
|
|
922
|
+
</Accordion>
|
|
871
923
|
</div>
|
|
872
924
|
</div>
|
|
873
925
|
</div>
|
|
@@ -920,7 +972,7 @@ function tabValue(index: number): string {
|
|
|
920
972
|
</Section>
|
|
921
973
|
|
|
922
974
|
<Section v-else-if="showStatus" spacing="none" :class="SECTION_SPACING">
|
|
923
|
-
<Container width="
|
|
975
|
+
<Container width="wide">
|
|
924
976
|
<p role="status" class="text-muted">
|
|
925
977
|
{{ productResult.error.value ? t('storefront.error') : t('storefront.loading') }}
|
|
926
978
|
</p>
|
|
@@ -931,7 +983,7 @@ function tabValue(index: number): string {
|
|
|
931
983
|
editor hint below, because on a live page this is what a visitor who followed an old link
|
|
932
984
|
sees and the hint is not for them. -->
|
|
933
985
|
<Section v-else-if="notFound" spacing="none" :class="SECTION_SPACING">
|
|
934
|
-
<Container width="
|
|
986
|
+
<Container width="wide">
|
|
935
987
|
<p role="status" class="text-muted">{{ t('storefront.notFound') }}</p>
|
|
936
988
|
</Container>
|
|
937
989
|
</Section>
|
|
@@ -3,7 +3,7 @@ import { flushPromises, mount } from '@vue/test-utils';
|
|
|
3
3
|
import { computed, defineComponent, h, nextTick, ref, watch } from 'vue';
|
|
4
4
|
import { ELDRA_KEY, type EldraLocaleState } from '@eldrajs/theme-vue';
|
|
5
5
|
import { EldraHttpError } from '@eldrajs/sdk';
|
|
6
|
-
import { useToast, type ToastAction } from '@eldrajs/ui';
|
|
6
|
+
import { Lightbox, useToast, type ToastAction } from '@eldrajs/ui';
|
|
7
7
|
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
8
8
|
import { axe } from '../../../test/support/axe';
|
|
9
9
|
import { mountOptions } from '../../../test/support/mountBlock';
|
|
@@ -106,13 +106,10 @@ async function mountReady(
|
|
|
106
106
|
|
|
107
107
|
type Wrapper = Awaited<ReturnType<typeof mountReady>>;
|
|
108
108
|
|
|
109
|
-
/** The
|
|
110
|
-
* are never counted once the viewer is open. */
|
|
111
|
-
function
|
|
112
|
-
return wrapper.findAll('button[aria-label^="
|
|
113
|
-
}
|
|
114
|
-
function zoomButton(wrapper: Wrapper) {
|
|
115
|
-
return wrapper.get('button[aria-haspopup="dialog"]');
|
|
109
|
+
/** The mosaic's own tiles. Scoped by their name so the `Lightbox`'s own thumbnails ("Go to image
|
|
110
|
+
* n") are never counted once the viewer is open. */
|
|
111
|
+
function tiles(wrapper: Wrapper) {
|
|
112
|
+
return wrapper.findAll('button[aria-label^="Open image"]');
|
|
116
113
|
}
|
|
117
114
|
function lightbox(wrapper: Wrapper) {
|
|
118
115
|
return wrapper.get('dialog[aria-label="Merino crew sweater, images"]');
|
|
@@ -397,14 +394,14 @@ describe('product-detail block', () => {
|
|
|
397
394
|
expect(wrapper.text()).toContain('Merino crew sweater');
|
|
398
395
|
expect(wrapper.text()).toContain('$96.00');
|
|
399
396
|
expect(wrapper.text()).toContain('Knitwear');
|
|
400
|
-
expect(wrapper.text()).toContain('Free delivery over $80
|
|
397
|
+
expect(wrapper.text()).toContain('Free delivery on orders over $80');
|
|
401
398
|
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
402
399
|
});
|
|
403
400
|
|
|
404
401
|
it('renders the bare fixture — no perks, no tabs, no size guide — axe-clean', async () => {
|
|
405
402
|
const wrapper = await mountReady(bare);
|
|
406
403
|
expect(wrapper.text()).toContain('Merino crew sweater');
|
|
407
|
-
expect(wrapper.find('
|
|
404
|
+
expect(wrapper.find('details').exists()).toBe(false);
|
|
408
405
|
expect(wrapper.text()).not.toContain('Size guide');
|
|
409
406
|
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
410
407
|
});
|
|
@@ -424,11 +421,12 @@ describe('product-detail block', () => {
|
|
|
424
421
|
gallery.element.compareDocumentPosition(info.element) & Node.DOCUMENT_POSITION_FOLLOWING
|
|
425
422
|
).toBeTruthy();
|
|
426
423
|
// … only which column each one is painted in.
|
|
424
|
+
// The two columns start at 60rem (the design's own edge), so that is where they mirror.
|
|
427
425
|
expect(gallery.classes()).toContain(
|
|
428
|
-
variant === 'gallery-right' ? '@
|
|
426
|
+
variant === 'gallery-right' ? '@min-[60rem]:order-2' : '@min-[60rem]:order-1'
|
|
429
427
|
);
|
|
430
428
|
expect(info.classes()).toContain(
|
|
431
|
-
variant === 'gallery-right' ? '@
|
|
429
|
+
variant === 'gallery-right' ? '@min-[60rem]:order-1' : '@min-[60rem]:order-2'
|
|
432
430
|
);
|
|
433
431
|
}
|
|
434
432
|
});
|
|
@@ -585,62 +583,78 @@ describe('product-detail block', () => {
|
|
|
585
583
|
expect(wrapper.find('nav[aria-label="Breadcrumb"]').exists()).toBe(false);
|
|
586
584
|
});
|
|
587
585
|
|
|
586
|
+
/**
|
|
587
|
+
* The gallery is a mosaic now: every image on the page at once, each one a button that opens the
|
|
588
|
+
* viewer at itself. The thumbnail strip, its "current" marker, the index pill and the single zoom
|
|
589
|
+
* button went with the single stage they served.
|
|
590
|
+
*/
|
|
588
591
|
describe('gallery', () => {
|
|
589
|
-
it('
|
|
592
|
+
it('draws every image as a tile named by position and alt text, the first one wide', async () => {
|
|
590
593
|
const wrapper = await mountReady(mock);
|
|
591
|
-
const buttons =
|
|
592
|
-
expect(buttons
|
|
594
|
+
const buttons = tiles(wrapper);
|
|
595
|
+
expect(buttons).toHaveLength(3);
|
|
596
|
+
const alts = [
|
|
597
|
+
'Merino crew sweater',
|
|
598
|
+
'Merino crew sweater, alternate view',
|
|
599
|
+
'Merino crew sweater, in use',
|
|
600
|
+
];
|
|
593
601
|
buttons.forEach((button, index) => {
|
|
594
602
|
expect(button.attributes('aria-label')).toBe(
|
|
595
|
-
`
|
|
596
|
-
index === 0 ? 'Merino crew sweater' : 'Merino crew sweater, alternate view'
|
|
597
|
-
}`
|
|
603
|
+
`Open image ${index + 1} of ${buttons.length}: ${alts[index]}`
|
|
598
604
|
);
|
|
605
|
+
expect(button.attributes('aria-haspopup')).toBe('dialog');
|
|
606
|
+
// The photo inside is decorative: the button already says what it shows.
|
|
607
|
+
expect(button.get('img').attributes('alt')).toBe('');
|
|
599
608
|
});
|
|
600
|
-
expect(buttons[0]!.attributes('aria-current')).toBe('true');
|
|
601
|
-
expect(buttons[1]!.attributes('aria-current')).toBeUndefined();
|
|
602
609
|
});
|
|
603
610
|
|
|
604
|
-
it('
|
|
605
|
-
const
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
);
|
|
618
|
-
expect(
|
|
611
|
+
it('lays two images side by side, and leads with a wide one from three', async () => {
|
|
612
|
+
const spans = async (count: number) => {
|
|
613
|
+
const images = Array.from({ length: count }, (_, index) => ({
|
|
614
|
+
src: `/images/tile-${index}.webp`,
|
|
615
|
+
alt: `Tile ${index + 1}`,
|
|
616
|
+
width: 1200,
|
|
617
|
+
height: 1500,
|
|
618
|
+
}));
|
|
619
|
+
const wrapper = mountBlock(mock, { storefront: storefrontWith({ images }) });
|
|
620
|
+
await flushPromises();
|
|
621
|
+
await nextTick();
|
|
622
|
+
return tiles(wrapper).map((tile) => tile.element.parentElement!.className);
|
|
623
|
+
};
|
|
624
|
+
expect(await spans(1)).toEqual([expect.stringContaining('col-span-2')]);
|
|
625
|
+
expect((await spans(2)).every((span) => span.includes('col-span-1'))).toBe(true);
|
|
626
|
+
const three = await spans(3);
|
|
627
|
+
expect(three.map((span) => span.includes('col-span-2'))).toEqual([true, false, false]);
|
|
628
|
+
// An odd one out at the end spans the row, so the mosaic closes square.
|
|
629
|
+
const four = await spans(4);
|
|
630
|
+
expect(four.map((span) => span.includes('col-span-2'))).toEqual([true, false, false, true]);
|
|
619
631
|
});
|
|
620
632
|
|
|
621
|
-
it('opens the viewer
|
|
633
|
+
it('opens the viewer at the tile pressed, with zoom, arrows between images, and Esc returns focus', async () => {
|
|
622
634
|
const wrapper = await mountReady(mock);
|
|
623
|
-
const
|
|
624
|
-
|
|
625
|
-
await
|
|
635
|
+
const second = tiles(wrapper)[1]!;
|
|
636
|
+
second.element.focus();
|
|
637
|
+
await second.trigger('click');
|
|
626
638
|
await nextTick();
|
|
627
639
|
|
|
628
640
|
const dialog = lightbox(wrapper);
|
|
629
641
|
expect(dialog.attributes('open')).toBe('');
|
|
630
642
|
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
631
643
|
|
|
632
|
-
const count =
|
|
633
|
-
expect(dialog.text()).toContain(`1 / ${count}`);
|
|
634
|
-
await dialog.trigger('keydown', { key: 'ArrowRight' });
|
|
644
|
+
const count = tiles(wrapper).length;
|
|
635
645
|
expect(dialog.text()).toContain(`2 / ${count}`);
|
|
646
|
+
// `zoom` is on, so a photo larger than it is shown can be enlarged and panned.
|
|
647
|
+
expect(wrapper.findComponent(Lightbox).props('zoom')).toBe(true);
|
|
636
648
|
await dialog.trigger('keydown', { key: 'ArrowLeft' });
|
|
637
649
|
expect(dialog.text()).toContain(`1 / ${count}`);
|
|
650
|
+
await dialog.trigger('keydown', { key: 'ArrowRight' });
|
|
651
|
+
expect(dialog.text()).toContain(`2 / ${count}`);
|
|
638
652
|
|
|
639
653
|
document.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape' }));
|
|
640
654
|
await new Promise((resolve) => setTimeout(resolve));
|
|
641
655
|
await nextTick();
|
|
642
656
|
expect(lightbox(wrapper).attributes('open')).toBeUndefined();
|
|
643
|
-
expect(document.activeElement).toBe(
|
|
657
|
+
expect(document.activeElement).toBe(second.element);
|
|
644
658
|
});
|
|
645
659
|
});
|
|
646
660
|
|
|
@@ -1286,48 +1300,58 @@ describe('product-detail block', () => {
|
|
|
1286
1300
|
});
|
|
1287
1301
|
});
|
|
1288
1302
|
|
|
1289
|
-
|
|
1290
|
-
|
|
1303
|
+
/** The `tabs` entries render as an accordion now (the design's Details / Care / Delivery and
|
|
1304
|
+
* returns rows), the first one open — each row a native disclosure. */
|
|
1305
|
+
describe('details accordion', () => {
|
|
1306
|
+
const rows = (wrapper: Wrapper) => wrapper.findAll('details');
|
|
1307
|
+
const summaries = (wrapper: Wrapper) => wrapper.findAll('details > summary');
|
|
1308
|
+
|
|
1309
|
+
it('renders one row per entry under an h2 each, only the first open', async () => {
|
|
1291
1310
|
const wrapper = await mountReady(mock);
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1311
|
+
expect(summaries(wrapper).map((summary) => summary.text())).toEqual([
|
|
1312
|
+
'Details',
|
|
1313
|
+
'Care',
|
|
1314
|
+
'Delivery and returns',
|
|
1315
|
+
]);
|
|
1316
|
+
expect(rows(wrapper).map((row) => row.attributes('open') !== undefined)).toEqual([
|
|
1317
|
+
true,
|
|
1318
|
+
false,
|
|
1319
|
+
false,
|
|
1320
|
+
]);
|
|
1321
|
+
expect(summaries(wrapper).map((summary) => summary.find('h2').text())).toEqual([
|
|
1322
|
+
'Details',
|
|
1323
|
+
'Care',
|
|
1324
|
+
'Delivery and returns',
|
|
1325
|
+
]);
|
|
1326
|
+
expect(wrapper.text()).toContain('100% extra-fine Merino wool');
|
|
1297
1327
|
});
|
|
1298
1328
|
|
|
1299
|
-
it('
|
|
1329
|
+
it('opens and closes a row from the keyboard, its summary being the one tab stop', async () => {
|
|
1300
1330
|
const wrapper = await mountReady(mock);
|
|
1301
|
-
const
|
|
1302
|
-
|
|
1303
|
-
expect(
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
await
|
|
1310
|
-
expect(
|
|
1311
|
-
await tabs()[0]!.trigger('keydown', { key: 'End' });
|
|
1312
|
-
expect(tabs()[2]!.attributes('aria-selected')).toBe('true');
|
|
1331
|
+
const care = summaries(wrapper)[1]!;
|
|
1332
|
+
(care.element as HTMLElement).focus();
|
|
1333
|
+
expect(document.activeElement).toBe(care.element);
|
|
1334
|
+
// A browser turns Enter/Space on a focused <summary> into a click that toggles its <details>.
|
|
1335
|
+
await care.trigger('click');
|
|
1336
|
+
await nextTick();
|
|
1337
|
+
expect(rows(wrapper)[1]!.attributes('open')).toBeDefined();
|
|
1338
|
+
await care.trigger('click');
|
|
1339
|
+
await nextTick();
|
|
1340
|
+
expect(rows(wrapper)[1]!.attributes('open')).toBeUndefined();
|
|
1313
1341
|
});
|
|
1314
1342
|
|
|
1315
|
-
it('
|
|
1343
|
+
it('stays axe-clean with every row open', async () => {
|
|
1316
1344
|
const wrapper = await mountReady(mock);
|
|
1317
|
-
const
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
// reachable (`TabPanel`'s own rule); these three are plain prose.
|
|
1321
|
-
for (const panel of panels) expect(panel.attributes('tabindex')).toBe('0');
|
|
1345
|
+
for (const summary of summaries(wrapper).slice(1)) await summary.trigger('click');
|
|
1346
|
+
await nextTick();
|
|
1347
|
+
expect(await axe(wrapper.element)).toHaveNoViolations();
|
|
1322
1348
|
});
|
|
1323
1349
|
|
|
1324
|
-
it('puts Add to cart before the
|
|
1350
|
+
it('puts Add to cart before the details in reading order', async () => {
|
|
1325
1351
|
const wrapper = await mountReady(mock);
|
|
1326
1352
|
const button = addToCart(wrapper).element;
|
|
1327
|
-
const
|
|
1328
|
-
expect(
|
|
1329
|
-
button.compareDocumentPosition(tablist) & Node.DOCUMENT_POSITION_FOLLOWING
|
|
1330
|
-
).toBeTruthy();
|
|
1353
|
+
const first = summaries(wrapper)[0]!.element;
|
|
1354
|
+
expect(button.compareDocumentPosition(first) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
|
|
1331
1355
|
});
|
|
1332
1356
|
});
|
|
1333
1357
|
|