@eldrajs/theme-cli 0.2.4 → 0.2.6
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 +4 -0
- package/README.md +6 -0
- package/dist/cli.js +8 -2
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1 -1
- package/dist/{validate-FjQ-5_ne.js → validate-CC6Mp5i_.js} +2 -1
- package/package.json +3 -3
- package/template/.eldra/block-types.d.ts +1 -1
- package/template/.eldra/manifest.json +30 -2
- package/template/.eldra/previews.json +35 -35
- package/template/README.md +3 -1
- package/template/app/app.vue +16 -3
- package/template/app/assets/main.css +13 -15
- package/template/app/components/ui/UiImage.vue +29 -17
- package/template/app/components/ui/__tests__/UiImage.spec.ts +24 -15
- package/template/app/composables/useStorefront.ts +7 -2
- package/template/app/pages/[...slug].vue +1 -1
- package/template/app/plugins/eldra-storefront.ts +9 -0
- package/template/app/storefront/analytics.ts +15 -7
- package/template/app/storefront/cart.ts +228 -51
- package/template/app/storefront/commerce.ts +8 -2
- package/template/app/storefront/currency.ts +205 -0
- package/template/app/storefront/demo.ts +10 -2
- package/template/app/storefront/feedback.ts +2 -0
- package/template/app/storefront/gateway.ts +153 -35
- package/template/app/storefront/money.ts +6 -18
- package/template/app/storefront/structuredData.ts +16 -5
- package/template/app/storefront/toProductCard.ts +14 -14
- package/template/app/storefront/types.ts +13 -0
- package/template/app/storefront/volatile.ts +4 -0
- package/template/app/utils/seoInput.ts +4 -3
- package/template/blocks/announcement-bar/Block.vue +3 -2
- package/template/blocks/announcement-bar/__tests__/Block.spec.ts +1 -1
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/Block.vue +3 -4
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/Block.vue +18 -9
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/Block.vue +1 -1
- package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +9 -9
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/Block.vue +42 -23
- package/template/blocks/cart/__tests__/Block.spec.ts +2 -3
- package/template/blocks/cart/__tests__/loadFailed.spec.ts +135 -0
- package/template/blocks/cart/__tests__/notSold.spec.ts +109 -0
- package/template/blocks/cart/parts/CartLines.vue +16 -3
- package/template/blocks/cart/parts/CheckoutButton.vue +45 -0
- package/template/blocks/cart/parts/LoadFailed.vue +37 -0
- package/template/blocks/cart/parts/NotSoldNotice.vue +69 -0
- package/template/blocks/cart/parts/ShippingBar.vue +1 -1
- package/template/blocks/cart/parts/Summary.vue +14 -30
- package/template/blocks/cart/parts/notSold.ts +19 -0
- package/template/blocks/cart/preview.png +0 -0
- package/template/blocks/collection-grid/Block.vue +26 -16
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +26 -14
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/Block.vue +5 -5
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/Block.vue +1 -1
- package/template/blocks/contact/__tests__/Block.spec.ts +2 -2
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/Block.vue +16 -18
- package/template/blocks/cta/__tests__/Block.spec.ts +8 -12
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/Block.vue +3 -13
- package/template/blocks/faq/__tests__/Block.spec.ts +2 -2
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/Block.vue +1 -1
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +1 -1
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +33 -55
- package/template/blocks/footer/__tests__/Block.spec.ts +5 -5
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/Block.vue +1 -1
- package/template/blocks/form/preview.png +0 -0
- package/template/blocks/gallery/__tests__/Block.spec.ts +1 -1
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +8 -11
- package/template/blocks/hero/__tests__/Block.spec.ts +9 -7
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/Block.vue +4 -4
- package/template/blocks/image/__tests__/Block.spec.ts +5 -6
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/__tests__/Block.spec.ts +1 -1
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +55 -29
- package/template/blocks/navigation/__tests__/Block.spec.ts +22 -20
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/__tests__/Block.spec.ts +1 -1
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/Block.vue +23 -15
- package/template/blocks/order-status/__tests__/Block.spec.ts +1 -2
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/__tests__/Block.spec.ts +1 -1
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/Block.vue +11 -8
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +26 -8
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +54 -18
- package/template/blocks/product-detail/__tests__/Block.spec.ts +79 -2
- package/template/blocks/product-detail/parts/Gallery.vue +1 -1
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/quote/Block.vue +1 -1
- package/template/blocks/quote/__tests__/Block.spec.ts +7 -4
- package/template/blocks/quote/preview.png +0 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/Block.vue +10 -4
- package/template/blocks/search/PopularChips.vue +1 -1
- package/template/blocks/search/TypeSection.vue +8 -2
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/search/results.ts +5 -2
- package/template/blocks/split-content/Block.vue +2 -3
- package/template/blocks/split-content/__tests__/Block.spec.ts +2 -2
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/__tests__/Block.spec.ts +1 -1
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/Block.vue +4 -5
- package/template/blocks/tabs/__tests__/Block.spec.ts +2 -2
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/Block.vue +10 -9
- package/template/blocks/testimonials/__tests__/Block.spec.ts +1 -1
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/__tests__/Block.spec.ts +2 -2
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/Block.vue +1 -1
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +1 -1
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/Block.vue +3 -3
- package/template/blocks/video-embed/__tests__/Block.spec.ts +1 -1
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/Block.vue +6 -2
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/i18n/en-US.json +19 -3
- package/template/i18n/is-IS.json +19 -3
- package/template/nuxt.config.ts +5 -4
- package/template/package.json +1 -0
- package/template/stories/pages/article.stories.ts +2 -3
- package/template/stories/pages/cart.stories.ts +2 -3
- package/template/stories/pages/category.stories.ts +2 -3
- package/template/stories/pages/collection.stories.ts +2 -3
- package/template/stories/pages/home.stories.ts +2 -3
- package/template/stories/pages/product.stories.ts +3 -4
- package/template/stories/pages/products.stories.ts +2 -3
- package/template/stories/pages/search.stories.ts +2 -3
- package/template/stories/pages/wishlist.stories.ts +2 -3
- package/template/test/carouselKeyboard.spec.ts +2 -2
- package/template/test/carouselRing.browser.spec.ts +2 -2
- package/template/test/carouselSlideWidth.browser.spec.ts +9 -9
- package/template/test/currencyPicker.spec.ts +66 -0
- package/template/test/eldraIcon.spec.ts +1 -1
- package/template/test/mainCss.spec.ts +7 -0
- package/template/test/pages/article.spec.ts +5 -5
- package/template/test/pages/collection.spec.ts +5 -5
- package/template/test/pages/hydration.spec.ts +10 -10
- package/template/test/prerenderRefresh.browser.spec.ts +1 -1
- package/template/test/seoInput.spec.ts +22 -0
- package/template/test/storefront/analytics.spec.ts +15 -0
- package/template/test/storefront/cart.spec.ts +4 -4
- package/template/test/storefront/currency.spec.ts +549 -0
- package/template/test/storefront/currencyStore.spec.ts +845 -0
- package/template/test/storefront/gateway.spec.ts +22 -0
- package/template/test/storefront/money.spec.ts +2 -8
- package/template/test/storefront/structuredData.spec.ts +45 -0
- package/template/test/storefront/toProductCard.spec.ts +1 -1
- package/template/test/storefront/volatile.spec.ts +11 -0
- package/template/test/support/mountPage.ts +2 -3
|
@@ -203,11 +203,19 @@ const STEPPER_CLASSES = {
|
|
|
203
203
|
</Link>
|
|
204
204
|
<p v-else class="text-text text-base font-semibold">{{ line.title }}</p>
|
|
205
205
|
<p v-if="line.variantLabel" class="text-muted text-body-sm">{{ line.variantLabel }}</p>
|
|
206
|
-
<
|
|
206
|
+
<p
|
|
207
|
+
v-if="line.soldInCurrency === false"
|
|
208
|
+
class="text-body-sm text-warning"
|
|
209
|
+
data-eldra-line-not-sold
|
|
210
|
+
>
|
|
211
|
+
{{ t('currency.notSoldIn', { currency: money.currency.value ?? '' }) }}
|
|
212
|
+
</p>
|
|
213
|
+
<div v-else-if="line.quantity > 1" class="text-body-sm flex flex-wrap gap-x-1">
|
|
207
214
|
<Price
|
|
208
215
|
:amount="money.minor(line.unitPrice)"
|
|
209
216
|
size="sm"
|
|
210
|
-
|
|
217
|
+
class="inline"
|
|
218
|
+
:classes="{ current: 'text-muted' }"
|
|
211
219
|
/>
|
|
212
220
|
<span class="text-muted">{{ t('cart.each') }}</span>
|
|
213
221
|
</div>
|
|
@@ -218,7 +226,11 @@ const STEPPER_CLASSES = {
|
|
|
218
226
|
:aria-busy="busy"
|
|
219
227
|
>
|
|
220
228
|
<VisuallyHidden>{{ t('cart.lineTotal') }}</VisuallyHidden>
|
|
221
|
-
<Price
|
|
229
|
+
<Price
|
|
230
|
+
v-if="line.soldInCurrency !== false"
|
|
231
|
+
:amount="money.minor(line.lineTotal)"
|
|
232
|
+
class="inline"
|
|
233
|
+
/>
|
|
222
234
|
</div>
|
|
223
235
|
|
|
224
236
|
<div
|
|
@@ -233,6 +245,7 @@ const STEPPER_CLASSES = {
|
|
|
233
245
|
size="sm"
|
|
234
246
|
:model-value="line.quantity"
|
|
235
247
|
:max="line.max ?? undefined"
|
|
248
|
+
:disabled="line.soldInCurrency === false"
|
|
236
249
|
:item-name="line.title"
|
|
237
250
|
:classes="STEPPER_CLASSES"
|
|
238
251
|
@change="(value: number) => void onQuantity(line, value)"
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import { Button } from '@eldrajs/ui';
|
|
4
|
+
import { useI18n } from 'vue-i18n';
|
|
5
|
+
import { useStorefront } from '../../../app/composables/useStorefront';
|
|
6
|
+
import EldraIcon from '../../../app/components/EldraIcon.vue';
|
|
7
|
+
import EldraRouterLink from '../../../app/components/EldraRouterLink.vue';
|
|
8
|
+
import { useUiId } from '../../../app/composables/useUiId';
|
|
9
|
+
import { isInternalHref, safeHref } from '../../../app/utils/links';
|
|
10
|
+
import { useNotSoldSentence } from './notSold';
|
|
11
|
+
|
|
12
|
+
const { t } = useI18n();
|
|
13
|
+
const cart = useStorefront().cart;
|
|
14
|
+
|
|
15
|
+
const checkoutHref = computed(() => safeHref(cart.checkoutUrl.value));
|
|
16
|
+
const checkoutAs = computed(() =>
|
|
17
|
+
checkoutHref.value !== null && isInternalHref(checkoutHref.value) ? EldraRouterLink : undefined
|
|
18
|
+
);
|
|
19
|
+
/** Held, not hidden, while a line has no price in the cart's currency, so the reason sits where the shopper looks. */
|
|
20
|
+
const held = computed(() => cart.notSold.value.length > 0);
|
|
21
|
+
const reason = useNotSoldSentence(cart);
|
|
22
|
+
const reasonId = `cart-checkout-held-${useUiId()}`;
|
|
23
|
+
</script>
|
|
24
|
+
|
|
25
|
+
<template>
|
|
26
|
+
<Button
|
|
27
|
+
v-if="checkoutHref || held"
|
|
28
|
+
variant="primary"
|
|
29
|
+
size="lg"
|
|
30
|
+
block
|
|
31
|
+
:href="held ? undefined : (checkoutHref ?? undefined)"
|
|
32
|
+
:as="held ? undefined : checkoutAs"
|
|
33
|
+
:disabled="held"
|
|
34
|
+
:aria-describedby="held ? reasonId : undefined"
|
|
35
|
+
@click="cart.beginCheckout()"
|
|
36
|
+
>
|
|
37
|
+
<template #leadingIcon>
|
|
38
|
+
<EldraIcon name="lock" size="sm" />
|
|
39
|
+
</template>
|
|
40
|
+
{{ t('cart.checkout') }}
|
|
41
|
+
</Button>
|
|
42
|
+
<p v-if="held" :id="reasonId" class="text-muted text-body-sm text-center">
|
|
43
|
+
{{ reason }}
|
|
44
|
+
</p>
|
|
45
|
+
</template>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Button, Notice } from '@eldrajs/ui';
|
|
3
|
+
import { useI18n } from 'vue-i18n';
|
|
4
|
+
import { useStorefront } from '../../../app/composables/useStorefront';
|
|
5
|
+
import { useStorefrontFeedback } from '../../../app/composables/useStorefrontFeedback';
|
|
6
|
+
|
|
7
|
+
const cart = useStorefront().cart;
|
|
8
|
+
const feedback = useStorefrontFeedback();
|
|
9
|
+
const { t } = useI18n();
|
|
10
|
+
|
|
11
|
+
async function tryAgain(): Promise<void> {
|
|
12
|
+
const failure = await cart.reload();
|
|
13
|
+
if (failure !== null) feedback.report(failure, { id: 'cart-load' });
|
|
14
|
+
}
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<Notice
|
|
19
|
+
v-if="cart.loadFailed.value"
|
|
20
|
+
tone="danger"
|
|
21
|
+
:text="t('cart.loadFailed')"
|
|
22
|
+
class="mb-4"
|
|
23
|
+
data-eldra-cart-load-failed
|
|
24
|
+
>
|
|
25
|
+
<template #actions>
|
|
26
|
+
<Button
|
|
27
|
+
variant="outline"
|
|
28
|
+
size="sm"
|
|
29
|
+
type="button"
|
|
30
|
+
:loading="cart.pending.value"
|
|
31
|
+
@click="tryAgain"
|
|
32
|
+
>
|
|
33
|
+
{{ t('cart.tryAgain') }}
|
|
34
|
+
</Button>
|
|
35
|
+
</template>
|
|
36
|
+
</Notice>
|
|
37
|
+
</template>
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Button, Notice } from '@eldrajs/ui';
|
|
3
|
+
import { useI18n } from 'vue-i18n';
|
|
4
|
+
import { useStorefront } from '../../../app/composables/useStorefront';
|
|
5
|
+
import { useStorefrontFeedback } from '../../../app/composables/useStorefrontFeedback';
|
|
6
|
+
import { safeHref } from '../../../app/utils/links';
|
|
7
|
+
import { useNotSoldSentence } from './notSold';
|
|
8
|
+
|
|
9
|
+
const storefront = useStorefront();
|
|
10
|
+
const cart = storefront.cart;
|
|
11
|
+
const feedback = useStorefrontFeedback();
|
|
12
|
+
const { t } = useI18n();
|
|
13
|
+
const sentence = useNotSoldSentence(cart);
|
|
14
|
+
|
|
15
|
+
let leaving = false;
|
|
16
|
+
|
|
17
|
+
async function checkoutWithout(): Promise<void> {
|
|
18
|
+
if (leaving) return;
|
|
19
|
+
leaving = true;
|
|
20
|
+
try {
|
|
21
|
+
await removeThenCheckout();
|
|
22
|
+
} finally {
|
|
23
|
+
leaving = false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async function removeThenCheckout(): Promise<void> {
|
|
28
|
+
const failure = await cart.removeNotSold();
|
|
29
|
+
if (failure !== null) {
|
|
30
|
+
feedback.report(failure);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const checkout = safeHref(cart.checkoutUrl.value);
|
|
34
|
+
if (checkout !== null && cart.lines.value.length > 0) {
|
|
35
|
+
cart.beginCheckout();
|
|
36
|
+
window.location.assign(checkout);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
</script>
|
|
40
|
+
|
|
41
|
+
<template>
|
|
42
|
+
<Notice
|
|
43
|
+
tone="warning"
|
|
44
|
+
:text="sentence"
|
|
45
|
+
:classes="{ content: 'text-start' }"
|
|
46
|
+
data-eldra-not-sold-notice
|
|
47
|
+
>
|
|
48
|
+
<template #actions>
|
|
49
|
+
<Button
|
|
50
|
+
variant="primary"
|
|
51
|
+
size="sm"
|
|
52
|
+
type="button"
|
|
53
|
+
:loading="cart.pending.value"
|
|
54
|
+
@click="checkoutWithout"
|
|
55
|
+
>
|
|
56
|
+
{{ t('currency.checkoutWithout') }}
|
|
57
|
+
</Button>
|
|
58
|
+
<Button
|
|
59
|
+
v-if="storefront.currency.base"
|
|
60
|
+
variant="outline"
|
|
61
|
+
size="sm"
|
|
62
|
+
type="button"
|
|
63
|
+
@click="storefront.currency.chooseBase()"
|
|
64
|
+
>
|
|
65
|
+
{{ t('currency.shopIn', { currency: storefront.currency.base }) }}
|
|
66
|
+
</Button>
|
|
67
|
+
</template>
|
|
68
|
+
</Notice>
|
|
69
|
+
</template>
|
|
@@ -90,7 +90,7 @@ const rootClass = computed(() =>
|
|
|
90
90
|
</template>
|
|
91
91
|
<template v-else>
|
|
92
92
|
<span>{{ awayParts.before }}</span>
|
|
93
|
-
<Price :amount="money.minor(remaining)"
|
|
93
|
+
<Price :amount="money.minor(remaining)" class="inline font-semibold" />
|
|
94
94
|
<span>{{ awayParts.after }}</span>
|
|
95
95
|
</template>
|
|
96
96
|
</div>
|
|
@@ -44,9 +44,8 @@ import { useStorefrontFeedback } from '../../../app/composables/useStorefrontFee
|
|
|
44
44
|
import { useI18n } from 'vue-i18n';
|
|
45
45
|
import { useUiId } from '../../../app/composables/useUiId';
|
|
46
46
|
import EldraIcon from '../../../app/components/EldraIcon.vue';
|
|
47
|
-
import EldraRouterLink from '../../../app/components/EldraRouterLink.vue';
|
|
48
|
-
import { isInternalHref, safeHref } from '../../../app/utils/links';
|
|
49
47
|
import { useMoney } from '../../../app/storefront/money';
|
|
48
|
+
import CheckoutButton from './CheckoutButton.vue';
|
|
50
49
|
import type { ThemeIconName } from '../../../app/icons';
|
|
51
50
|
|
|
52
51
|
const props = withDefaults(
|
|
@@ -150,11 +149,6 @@ async function onRemoveCode(): Promise<void> {
|
|
|
150
149
|
if (failure !== null) feedback.report(failure, { id: 'cart-discount' });
|
|
151
150
|
}
|
|
152
151
|
|
|
153
|
-
const checkoutHref = computed(() => safeHref(cart.checkoutUrl.value));
|
|
154
|
-
const checkoutAs = computed(() =>
|
|
155
|
-
checkoutHref.value !== null && isInternalHref(checkoutHref.value) ? EldraRouterLink : undefined
|
|
156
|
-
);
|
|
157
|
-
|
|
158
152
|
/** Spec Accessibility: "The payment icons are one image labelled 'We accept Visa, Mastercard,
|
|
159
153
|
* PayPal and Apple Pay'" — one `role="img"`, not four named marks. Tabler ships no
|
|
160
154
|
* `brand-apple-pay`, so Apple Pay is `brand-apple` (the same decision the `trust-strip` block
|
|
@@ -229,7 +223,7 @@ const VALUE_CLASS = 'text-text text-body-sm font-medium tabular-nums';
|
|
|
229
223
|
<div :class="ROW_CLASS">
|
|
230
224
|
<dt :class="LABEL_CLASS">{{ t('cart.subtotal') }}</dt>
|
|
231
225
|
<dd :class="VALUE_CLASS">
|
|
232
|
-
<Price :amount="money.minor(totals.subtotal)" size="sm"
|
|
226
|
+
<Price :amount="money.minor(totals.subtotal)" size="sm" class="inline" />
|
|
233
227
|
</dd>
|
|
234
228
|
</div>
|
|
235
229
|
<div v-if="discount" :class="ROW_CLASS">
|
|
@@ -238,7 +232,8 @@ const VALUE_CLASS = 'text-text text-body-sm font-medium tabular-nums';
|
|
|
238
232
|
<Price
|
|
239
233
|
:amount="money.minor(-discount.amount)"
|
|
240
234
|
size="sm"
|
|
241
|
-
|
|
235
|
+
class="inline"
|
|
236
|
+
:classes="{ current: 'text-success' }"
|
|
242
237
|
/>
|
|
243
238
|
</dd>
|
|
244
239
|
</div>
|
|
@@ -247,36 +242,25 @@ const VALUE_CLASS = 'text-text text-body-sm font-medium tabular-nums';
|
|
|
247
242
|
<dd :class="VALUE_CLASS">
|
|
248
243
|
<span v-if="totals.shipping === null">{{ t('cart.shippingPending') }}</span>
|
|
249
244
|
<span v-else-if="totals.shipping === 0">{{ t('cart.shippingFree') }}</span>
|
|
250
|
-
<Price
|
|
251
|
-
v-else
|
|
252
|
-
:amount="money.minor(totals.shipping)"
|
|
253
|
-
size="sm"
|
|
254
|
-
:classes="{ root: 'inline' }"
|
|
255
|
-
/>
|
|
245
|
+
<Price v-else :amount="money.minor(totals.shipping)" size="sm" class="inline" />
|
|
256
246
|
</dd>
|
|
257
247
|
</div>
|
|
258
248
|
<div class="border-border flex items-baseline justify-between gap-4 border-t pt-3">
|
|
259
249
|
<dt class="text-text text-base font-semibold">{{ t('cart.total') }}</dt>
|
|
260
250
|
<dd class="text-text text-base font-semibold tabular-nums">
|
|
261
|
-
<Price :amount="money.minor(totals.total)"
|
|
251
|
+
<Price :amount="money.minor(totals.total)" class="inline" />
|
|
262
252
|
</dd>
|
|
263
253
|
</div>
|
|
264
254
|
</dl>
|
|
255
|
+
<p v-if="cart.notSold.value.length > 0" class="text-muted text-body-sm" data-eldra-not-included>
|
|
256
|
+
{{
|
|
257
|
+
cart.notSold.value.length === 1
|
|
258
|
+
? t('currency.notIncludedOne')
|
|
259
|
+
: t('currency.notIncludedMany', { count: cart.notSold.value.length })
|
|
260
|
+
}}
|
|
261
|
+
</p>
|
|
265
262
|
|
|
266
|
-
<
|
|
267
|
-
v-if="checkoutHref"
|
|
268
|
-
variant="primary"
|
|
269
|
-
size="lg"
|
|
270
|
-
block
|
|
271
|
-
:href="checkoutHref"
|
|
272
|
-
:as="checkoutAs"
|
|
273
|
-
@click="cart.beginCheckout()"
|
|
274
|
-
>
|
|
275
|
-
<template #leadingIcon>
|
|
276
|
-
<EldraIcon name="lock" size="sm" />
|
|
277
|
-
</template>
|
|
278
|
-
{{ t('cart.checkout') }}
|
|
279
|
-
</Button>
|
|
263
|
+
<CheckoutButton />
|
|
280
264
|
|
|
281
265
|
<p v-if="props.note" class="text-muted text-body-sm text-center">{{ props.note }}</p>
|
|
282
266
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { computed, type ComputedRef } from 'vue';
|
|
2
|
+
import { useEldraUiLocale } from '@eldrajs/ui';
|
|
3
|
+
import { listFormat } from '@eldrajs/sdk/format/list';
|
|
4
|
+
import { useI18n } from 'vue-i18n';
|
|
5
|
+
import type { CartStore } from '../../../app/storefront/cart';
|
|
6
|
+
|
|
7
|
+
/** "Walnut spoon can't be bought in EUR.": the cart's lines with no price in its currency, named. */
|
|
8
|
+
export function useNotSoldSentence(cart: CartStore): ComputedRef<string> {
|
|
9
|
+
const { t } = useI18n();
|
|
10
|
+
const locale = useEldraUiLocale();
|
|
11
|
+
return computed(() =>
|
|
12
|
+
t('currency.cartNotSold', {
|
|
13
|
+
currency: cart.currency.value ?? '',
|
|
14
|
+
items: listFormat(locale.value, { type: 'conjunction' }).format(
|
|
15
|
+
cart.notSold.value.map((line) => line.title)
|
|
16
|
+
),
|
|
17
|
+
})
|
|
18
|
+
);
|
|
19
|
+
}
|
|
Binary file
|
|
@@ -135,7 +135,7 @@ const SortIcon = iconComponent('arrows-sort');
|
|
|
135
135
|
* the width it is: two tracks of 14rem plus a gap do not fit a phone, and the card's minimum
|
|
136
136
|
* would push the second column off the edge. The track decides the width here, as in the carousel.
|
|
137
137
|
*/
|
|
138
|
-
const
|
|
138
|
+
const CARD_CLASS = 'min-w-0';
|
|
139
139
|
/** The freshly-inserted editor hint's box icon (spec States, "Empty (freshly inserted)"). */
|
|
140
140
|
const BoxIcon = iconComponent('box');
|
|
141
141
|
|
|
@@ -325,6 +325,8 @@ const filterFields = computed(() =>
|
|
|
325
325
|
((data.value.filters ?? []) as FilterField[]).filter(
|
|
326
326
|
(row): row is FilterField & { source: FilterFieldSource } => {
|
|
327
327
|
if (!isFilterFieldSource(row.source)) return false;
|
|
328
|
+
// Price filters work in the store's own currency only; in another one there is no price row.
|
|
329
|
+
if (row.source === 'price' && storefront.currency.requested.value !== undefined) return false;
|
|
328
330
|
const key = optionKeyOf(row.source);
|
|
329
331
|
return key === null || usableOptionKey(key) !== null;
|
|
330
332
|
}
|
|
@@ -627,6 +629,7 @@ const products = storeWideScope.value
|
|
|
627
629
|
|
|
628
630
|
const items = computed(() => products.data.value?.items ?? []);
|
|
629
631
|
const money = useMoney();
|
|
632
|
+
const shopperCurrency = useStorefront().currency.active;
|
|
630
633
|
const total = computed(() => products.data.value?.total ?? 0);
|
|
631
634
|
/** The storefront's own description of the scope it answered from — values, labels, swatches and
|
|
632
635
|
* counts for every group (`CatalogFacets`). `undefined` from a source that cannot describe it. */
|
|
@@ -731,7 +734,8 @@ const showSkeletons = computed(() => pending.value && !hasData.value);
|
|
|
731
734
|
*/
|
|
732
735
|
const { any: cardsRevalidating, refreshing } = useRevalidating({
|
|
733
736
|
keys: () => products.revalidating.value,
|
|
734
|
-
refreshing: () =>
|
|
737
|
+
refreshing: () =>
|
|
738
|
+
(loading.value && hasData.value && !loadingMore.value) || storefront.currency.pending.value,
|
|
735
739
|
});
|
|
736
740
|
/**
|
|
737
741
|
* The grid's own "this is about to change" flag: armed the moment a sidebar change is typed or
|
|
@@ -798,6 +802,7 @@ const cards = computed(() =>
|
|
|
798
802
|
toProductCardEntries(items.value, {
|
|
799
803
|
ratio: '4x5',
|
|
800
804
|
minorUnits: money.minor,
|
|
805
|
+
shopperCurrency: shopperCurrency.value,
|
|
801
806
|
revalidating: showCardRefresh.value,
|
|
802
807
|
})
|
|
803
808
|
);
|
|
@@ -1173,7 +1178,14 @@ onMounted(() => {
|
|
|
1173
1178
|
// has a `fabric` option, which is the first read answering.
|
|
1174
1179
|
watch(() => [route.filters, route.sort, route.columns, facets.value], adoptRouteState, {
|
|
1175
1180
|
deep: true,
|
|
1176
|
-
});
|
|
1181
|
+
}); // Price filters are in the store's own currency; in another one the range would be a wrong number.
|
|
1182
|
+
watch(
|
|
1183
|
+
() => storefront.currency.requested.value !== undefined && route.filters.price !== undefined,
|
|
1184
|
+
(stale) => {
|
|
1185
|
+
if (stale) route.setQuery({ price: null });
|
|
1186
|
+
},
|
|
1187
|
+
{ immediate: true }
|
|
1188
|
+
);
|
|
1177
1189
|
});
|
|
1178
1190
|
|
|
1179
1191
|
function publishState(): void {
|
|
@@ -1605,7 +1617,7 @@ function hrefForPage(page: number): string {
|
|
|
1605
1617
|
v-if="hasCollection || showNoCollectionHint || showNoCategoryHint"
|
|
1606
1618
|
spacing="none"
|
|
1607
1619
|
:aria-label="sectionLabel"
|
|
1608
|
-
|
|
1620
|
+
class="pt-6 pb-[var(--eldra-section-md)]"
|
|
1609
1621
|
>
|
|
1610
1622
|
<Container width="wide">
|
|
1611
1623
|
<EditorPlaceholder
|
|
@@ -1662,7 +1674,7 @@ function hrefForPage(page: number): string {
|
|
|
1662
1674
|
v-if="hasFilters"
|
|
1663
1675
|
variant="outline"
|
|
1664
1676
|
:icon-left="AdjustmentsIcon"
|
|
1665
|
-
|
|
1677
|
+
class="min-h-11"
|
|
1666
1678
|
aria-haspopup="dialog"
|
|
1667
1679
|
:aria-expanded="drawerOpen ? 'true' : 'false'"
|
|
1668
1680
|
:aria-controls="drawerId"
|
|
@@ -1673,7 +1685,7 @@ function hrefForPage(page: number): string {
|
|
|
1673
1685
|
v-if="activeCount > 0"
|
|
1674
1686
|
tone="primary"
|
|
1675
1687
|
pill
|
|
1676
|
-
|
|
1688
|
+
class="ms-1"
|
|
1677
1689
|
:hidden-suffix="t('grid.nActive', { count: activeCount })"
|
|
1678
1690
|
>
|
|
1679
1691
|
<span aria-hidden="true">{{ activeCount }}</span>
|
|
@@ -1682,7 +1694,8 @@ function hrefForPage(page: number): string {
|
|
|
1682
1694
|
<FieldWrapper
|
|
1683
1695
|
v-if="hasSort"
|
|
1684
1696
|
:label="t('grid.sortBy')"
|
|
1685
|
-
:
|
|
1697
|
+
:class="TOP_BAR_SORT"
|
|
1698
|
+
:classes="{ label: 'sr-only' }"
|
|
1686
1699
|
>
|
|
1687
1700
|
<Select
|
|
1688
1701
|
:model-value="sort"
|
|
@@ -1710,10 +1723,8 @@ function hrefForPage(page: number): string {
|
|
|
1710
1723
|
<FieldWrapper
|
|
1711
1724
|
v-if="hasSort"
|
|
1712
1725
|
:label="t('grid.sortBy')"
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
label: 'text-body-sm text-muted mb-0 shrink-0 font-medium',
|
|
1716
|
-
}"
|
|
1726
|
+
class="flex items-center gap-2"
|
|
1727
|
+
:classes="{ label: 'text-body-sm text-muted mb-0 shrink-0 font-medium' }"
|
|
1717
1728
|
>
|
|
1718
1729
|
<Select
|
|
1719
1730
|
:model-value="sort"
|
|
@@ -1725,10 +1736,8 @@ function hrefForPage(page: number): string {
|
|
|
1725
1736
|
<FieldWrapper
|
|
1726
1737
|
v-if="showColumnSelect"
|
|
1727
1738
|
:label="t('grid.columns')"
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
label: 'text-body-sm text-muted mb-0 shrink-0 font-medium',
|
|
1731
|
-
}"
|
|
1739
|
+
class="flex items-center gap-2"
|
|
1740
|
+
:classes="{ label: 'text-body-sm text-muted mb-0 shrink-0 font-medium' }"
|
|
1732
1741
|
>
|
|
1733
1742
|
<Select
|
|
1734
1743
|
:model-value="columnsChoice"
|
|
@@ -1778,9 +1787,10 @@ function hrefForPage(page: number): string {
|
|
|
1778
1787
|
cards to Load more, and a cart action is `product-detail`'s own. -->
|
|
1779
1788
|
<ProductCard
|
|
1780
1789
|
:product="entry.product"
|
|
1790
|
+
:currency="entry.currency"
|
|
1781
1791
|
ratio="4x5"
|
|
1782
1792
|
:heading-level="3"
|
|
1783
|
-
:
|
|
1793
|
+
:class="CARD_CLASS"
|
|
1784
1794
|
:quick-add="false"
|
|
1785
1795
|
:revalidating="entry.revalidating"
|
|
1786
1796
|
:announce="false"
|
|
@@ -290,7 +290,7 @@ const SEEDED_GROUPS = 5;
|
|
|
290
290
|
/** The grid's single visually hidden live region for the volatile refresh. The count line above
|
|
291
291
|
* and `LoadMore`'s own "Showing N of M" are the block's other `role="status"` elements, and both
|
|
292
292
|
* are visible — this is the only hidden one. */
|
|
293
|
-
const liveRegion = (wrapper: VueWrapper) => wrapper.get('p.sr-only[role="status"]');
|
|
293
|
+
const liveRegion = (wrapper: VueWrapper) => wrapper.get('p.eldra\\:sr-only[role="status"]');
|
|
294
294
|
/** The grid itself: the list of product cards (never the skeleton list, which is aria-hidden). */
|
|
295
295
|
const cards = (wrapper: VueWrapper) =>
|
|
296
296
|
wrapper.findAll('ul[aria-labelledby]:not([aria-hidden]) > li');
|
|
@@ -388,7 +388,7 @@ describe('collection-grid block', () => {
|
|
|
388
388
|
const h2 = wrapper
|
|
389
389
|
.findAll('h2')
|
|
390
390
|
.find((candidate) => candidate.text() === enUS.grid.products)!;
|
|
391
|
-
expect(h2.classes()).toContain('sr-only');
|
|
391
|
+
expect(h2.classes()).toContain('eldra:sr-only');
|
|
392
392
|
|
|
393
393
|
const titles = wrapper.findAll('h3');
|
|
394
394
|
expect(titles.some((title) => title.text() === 'Merino crew sweater')).toBe(true);
|
|
@@ -421,7 +421,7 @@ describe('collection-grid block', () => {
|
|
|
421
421
|
const { trigger, panel } = panelFor(wrapper, legend);
|
|
422
422
|
expect(trigger.attributes('aria-expanded')).toBe('true');
|
|
423
423
|
expect(panel.element.tagName).toBe('FIELDSET');
|
|
424
|
-
expect(panel.get('legend').classes()).toContain('sr-only');
|
|
424
|
+
expect(panel.get('legend').classes()).toContain('eldra:sr-only');
|
|
425
425
|
}
|
|
426
426
|
});
|
|
427
427
|
|
|
@@ -488,12 +488,12 @@ describe('collection-grid block', () => {
|
|
|
488
488
|
const dot = row.get('span');
|
|
489
489
|
const name = row.get('[data-part="rowLabel"]');
|
|
490
490
|
|
|
491
|
-
expect(dot.classes()).toContain('border-transparent');
|
|
492
|
-
expect(name.classes()).not.toContain('font-semibold');
|
|
491
|
+
expect(dot.classes()).toContain('eldra:border-transparent');
|
|
492
|
+
expect(name.classes()).not.toContain('eldra:font-semibold');
|
|
493
493
|
await input.setValue(true);
|
|
494
494
|
|
|
495
|
-
expect(dot.classes()).toContain('border-text');
|
|
496
|
-
expect(name.classes()).toContain('font-semibold');
|
|
495
|
+
expect(dot.classes()).toContain('eldra:border-text');
|
|
496
|
+
expect(name.classes()).toContain('eldra:font-semibold');
|
|
497
497
|
});
|
|
498
498
|
|
|
499
499
|
/**
|
|
@@ -1154,6 +1154,20 @@ describe('collection-grid block', () => {
|
|
|
1154
1154
|
expect(thumbs[0]!.attributes('aria-label')).toBe(`Minimum ${PRICE_LEGEND}`);
|
|
1155
1155
|
});
|
|
1156
1156
|
|
|
1157
|
+
it('offers no price filter while the visitor shops in another currency', async () => {
|
|
1158
|
+
const { source } = createStub();
|
|
1159
|
+
source.currency.offered.value = ['USD', 'EUR'];
|
|
1160
|
+
source.currency.started.value = true;
|
|
1161
|
+
source.currency.choose('EUR');
|
|
1162
|
+
await vi.waitFor(() => expect(source.currency.active.value).toBe('EUR'));
|
|
1163
|
+
const wrapper = mountGrid(mock, { source });
|
|
1164
|
+
await flushPromises();
|
|
1165
|
+
expect(wrapper.findAll('[role="slider"]')).toHaveLength(0);
|
|
1166
|
+
source.currency.choose('USD');
|
|
1167
|
+
await flushPromises();
|
|
1168
|
+
expect(wrapper.findAll('[role="slider"]').length).toBeGreaterThan(0);
|
|
1169
|
+
});
|
|
1170
|
+
|
|
1157
1171
|
/** `priceSlider` off: the two typed fields alone, which is what a store whose prices sit in a
|
|
1158
1172
|
* few tight clusters sets (spec Fields). */
|
|
1159
1173
|
it('falls back to the two fields when the author turns the slider off', async () => {
|
|
@@ -1249,7 +1263,7 @@ describe('collection-grid block', () => {
|
|
|
1249
1263
|
await wrapper.vm.$nextTick();
|
|
1250
1264
|
const soldOut = cards(wrapper).find((card) => card.text().includes('Linen tea towels'))!;
|
|
1251
1265
|
expect(soldOut.text()).toContain('Sold out');
|
|
1252
|
-
expect(soldOut.get('img').classes()).toContain('opacity-60');
|
|
1266
|
+
expect(soldOut.get('img').classes()).toContain('eldra:opacity-60');
|
|
1253
1267
|
});
|
|
1254
1268
|
|
|
1255
1269
|
/**
|
|
@@ -1293,7 +1307,7 @@ describe('collection-grid block', () => {
|
|
|
1293
1307
|
const loadMore = wrapper.get('[data-part="button"]');
|
|
1294
1308
|
const bar = wrapper
|
|
1295
1309
|
.findAll('div[aria-hidden="true"]')
|
|
1296
|
-
.find((div) => div.classes().includes('rounded-full'))!;
|
|
1310
|
+
.find((div) => div.classes().includes('eldra:rounded-full'))!;
|
|
1297
1311
|
expect(bar.attributes('aria-hidden')).toBe('true');
|
|
1298
1312
|
|
|
1299
1313
|
loadMore.element.focus();
|
|
@@ -1432,9 +1446,8 @@ describe('collection-grid block', () => {
|
|
|
1432
1446
|
// background fill, supplied by the Drawer's own chrome.
|
|
1433
1447
|
expect(footer.classes()).toContain('grid');
|
|
1434
1448
|
expect(footer.classes()).toContain('grid-cols-[auto_1fr]');
|
|
1435
|
-
expect(footer.classes()).
|
|
1436
|
-
expect(footer.classes()).toContain('
|
|
1437
|
-
expect(footer.classes()).toContain('bg-background');
|
|
1449
|
+
expect(footer.classes()).toContain('eldra:border-t');
|
|
1450
|
+
expect(footer.classes()).toContain('eldra:bg-background');
|
|
1438
1451
|
|
|
1439
1452
|
const footerButtons = footer.findAll('button');
|
|
1440
1453
|
expect(footerButtons.map((button) => button.text())).toEqual([
|
|
@@ -2600,7 +2613,7 @@ describe('collection-grid block', () => {
|
|
|
2600
2613
|
await wrapper.vm.$nextTick();
|
|
2601
2614
|
|
|
2602
2615
|
expect(liveRegion(wrapper).text()).toBe(enUS.storefront.updatingValues);
|
|
2603
|
-
expect(wrapper.findAll('p.sr-only[role="status"]')).toHaveLength(1);
|
|
2616
|
+
expect(wrapper.findAll('p.eldra\\:sr-only[role="status"]')).toHaveLength(1);
|
|
2604
2617
|
// `announce: false` on every card — the per-value regions are gone, not merely empty.
|
|
2605
2618
|
expect(wrapper.findAll('[data-part="srStatus"]')).toHaveLength(0);
|
|
2606
2619
|
expect(
|
|
@@ -3145,7 +3158,6 @@ describe('collection-grid — card width on a phone', () => {
|
|
|
3145
3158
|
// The card's own root is the list item's first element; `cards()` answers the items.
|
|
3146
3159
|
const root = cards(wrapper)[0]!.element.firstElementChild as HTMLElement;
|
|
3147
3160
|
expect(root.className).toContain('min-w-0');
|
|
3148
|
-
expect(root.className).not.toMatch(/\bmin-w-56\b/);
|
|
3149
3161
|
wrapper.unmount();
|
|
3150
3162
|
});
|
|
3151
3163
|
});
|
|
Binary file
|
|
@@ -402,9 +402,9 @@ function pillClass(pill: ResolvedPill): string {
|
|
|
402
402
|
* carry these exact asymmetric steps, so `spacing="none"` on `Section` and the padding is written
|
|
403
403
|
* here — the same pattern `footer`'s own `paddingClass` uses. */
|
|
404
404
|
const PADDING_CLASS = 'pt-6 pb-8 @tablet:pt-8 @tablet:pb-12';
|
|
405
|
-
const
|
|
406
|
-
|
|
407
|
-
|
|
405
|
+
const sectionClass = computed(() =>
|
|
406
|
+
isImageVariant.value ? PADDING_CLASS : `${PADDING_CLASS} border-border border-b`
|
|
407
|
+
);
|
|
408
408
|
|
|
409
409
|
const rootClass = computed(() =>
|
|
410
410
|
isImageVariant.value
|
|
@@ -424,7 +424,7 @@ const textColumnClass = computed(() =>
|
|
|
424
424
|
as="header"
|
|
425
425
|
spacing="none"
|
|
426
426
|
:labelled-by="headingId"
|
|
427
|
-
:
|
|
427
|
+
:class="sectionClass"
|
|
428
428
|
>
|
|
429
429
|
<Container width="wide">
|
|
430
430
|
<div :class="rootClass">
|
|
@@ -519,7 +519,7 @@ const textColumnClass = computed(() =>
|
|
|
519
519
|
:as="pill.as"
|
|
520
520
|
:underline="false"
|
|
521
521
|
:aria-current="pill.current ? 'page' : undefined"
|
|
522
|
-
:
|
|
522
|
+
:class="pillClass(pill)"
|
|
523
523
|
>
|
|
524
524
|
{{ pill.label }}
|
|
525
525
|
</Link>
|
|
Binary file
|
|
@@ -632,7 +632,7 @@ const successText = computed(() => data.value.successText || t('contact.successT
|
|
|
632
632
|
variant="standalone"
|
|
633
633
|
arrow
|
|
634
634
|
external
|
|
635
|
-
|
|
635
|
+
class="text-body-sm font-semibold"
|
|
636
636
|
>{{ mapLinkLabel }}</Link
|
|
637
637
|
>
|
|
638
638
|
</div>
|
|
@@ -116,7 +116,7 @@ describe('contact block', () => {
|
|
|
116
116
|
const wrapper = mountContact(merged);
|
|
117
117
|
const section = wrapper.find('section');
|
|
118
118
|
expect(section.exists()).toBe(true);
|
|
119
|
-
expect(section.classes()).toContain('
|
|
119
|
+
expect(section.classes()).toContain('eldra:@container');
|
|
120
120
|
});
|
|
121
121
|
|
|
122
122
|
it('form-only with hideHeading keeps the h2 in the outline but hides it visually', () => {
|
|
@@ -124,7 +124,7 @@ describe('contact block', () => {
|
|
|
124
124
|
const heading = wrapper.find('h2');
|
|
125
125
|
expect(heading.exists()).toBe(true);
|
|
126
126
|
expect(heading.text()).toBe(mock.heading);
|
|
127
|
-
expect(heading.classes()).toContain('sr-only');
|
|
127
|
+
expect(heading.classes()).toContain('eldra:sr-only');
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
it('every field has a visible, programmatically tied label, and the optional one says "(optional)"', () => {
|
|
Binary file
|