@eldrajs/theme-cli 0.2.5 → 0.2.7
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 +1 -0
- package/package.json +3 -3
- package/template/.eldra/block-types.d.ts +1 -1
- package/template/.eldra/manifest.json +32 -2
- package/template/.eldra/previews.json +35 -35
- package/template/app/app.vue +15 -0
- package/template/app/composables/useStorefront.ts +7 -2
- 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 +12 -2
- package/template/app/storefront/currency.ts +272 -0
- package/template/app/storefront/demo.ts +10 -2
- package/template/app/storefront/feedback.ts +3 -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/preview.png +0 -0
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/Block.vue +41 -22
- 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 +150 -0
- package/template/blocks/cart/parts/CartLines.vue +14 -2
- 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 +74 -0
- package/template/blocks/cart/parts/Summary.vue +9 -21
- package/template/blocks/cart/parts/notSold.ts +19 -0
- package/template/blocks/cart/preview.png +0 -0
- package/template/blocks/collection-grid/Block.vue +15 -2
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +14 -0
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +20 -45
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/preview.png +0 -0
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +39 -3
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/Block.vue +15 -6
- 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 +5 -2
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +68 -10
- package/template/blocks/product-detail/__tests__/Block.spec.ts +190 -2
- 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 +8 -2
- 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/preview.png +0 -0
- package/template/blocks/stats/preview.png +0 -0
- 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/preview.png +0 -0
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/Block.vue +5 -1
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/i18n/en-US.json +20 -3
- package/template/i18n/is-IS.json +20 -3
- package/template/test/currencyPicker.spec.ts +66 -0
- 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/currencyDefault.spec.ts +475 -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
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue';
|
|
3
|
+
import { Button, Notice } from '@eldrajs/ui';
|
|
4
|
+
import { useI18n } from 'vue-i18n';
|
|
5
|
+
import { useStorefront } from '../../../app/composables/useStorefront';
|
|
6
|
+
import { useStorefrontFeedback } from '../../../app/composables/useStorefrontFeedback';
|
|
7
|
+
import { safeHref } from '../../../app/utils/links';
|
|
8
|
+
import { useNotSoldSentence } from './notSold';
|
|
9
|
+
|
|
10
|
+
const storefront = useStorefront();
|
|
11
|
+
const cart = storefront.cart;
|
|
12
|
+
const feedback = useStorefrontFeedback();
|
|
13
|
+
const { t } = useI18n();
|
|
14
|
+
const sentence = useNotSoldSentence(cart);
|
|
15
|
+
const shopInDefault = computed(() => {
|
|
16
|
+
const fallback = storefront.currency.defaultCurrency;
|
|
17
|
+
return fallback !== undefined && cart.currency.value !== fallback;
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
let leaving = false;
|
|
21
|
+
|
|
22
|
+
async function checkoutWithout(): Promise<void> {
|
|
23
|
+
if (leaving) return;
|
|
24
|
+
leaving = true;
|
|
25
|
+
try {
|
|
26
|
+
await removeThenCheckout();
|
|
27
|
+
} finally {
|
|
28
|
+
leaving = false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function removeThenCheckout(): Promise<void> {
|
|
33
|
+
const failure = await cart.removeNotSold();
|
|
34
|
+
if (failure !== null) {
|
|
35
|
+
feedback.report(failure);
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const checkout = safeHref(cart.checkoutUrl.value);
|
|
39
|
+
if (checkout !== null && cart.lines.value.length > 0) {
|
|
40
|
+
cart.beginCheckout();
|
|
41
|
+
window.location.assign(checkout);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<template>
|
|
47
|
+
<Notice
|
|
48
|
+
tone="warning"
|
|
49
|
+
:text="sentence"
|
|
50
|
+
:classes="{ content: 'text-start' }"
|
|
51
|
+
data-eldra-not-sold-notice
|
|
52
|
+
>
|
|
53
|
+
<template #actions>
|
|
54
|
+
<Button
|
|
55
|
+
variant="primary"
|
|
56
|
+
size="sm"
|
|
57
|
+
type="button"
|
|
58
|
+
:loading="cart.pending.value"
|
|
59
|
+
@click="checkoutWithout"
|
|
60
|
+
>
|
|
61
|
+
{{ t('currency.checkoutWithout') }}
|
|
62
|
+
</Button>
|
|
63
|
+
<Button
|
|
64
|
+
v-if="shopInDefault"
|
|
65
|
+
variant="outline"
|
|
66
|
+
size="sm"
|
|
67
|
+
type="button"
|
|
68
|
+
@click="storefront.currency.chooseBase()"
|
|
69
|
+
>
|
|
70
|
+
{{ t('currency.shopIn', { currency: storefront.currency.defaultCurrency }) }}
|
|
71
|
+
</Button>
|
|
72
|
+
</template>
|
|
73
|
+
</Notice>
|
|
74
|
+
</template>
|
|
@@ -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
|
|
@@ -258,21 +252,15 @@ const VALUE_CLASS = 'text-text text-body-sm font-medium tabular-nums';
|
|
|
258
252
|
</dd>
|
|
259
253
|
</div>
|
|
260
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>
|
|
261
262
|
|
|
262
|
-
<
|
|
263
|
-
v-if="checkoutHref"
|
|
264
|
-
variant="primary"
|
|
265
|
-
size="lg"
|
|
266
|
-
block
|
|
267
|
-
:href="checkoutHref"
|
|
268
|
-
:as="checkoutAs"
|
|
269
|
-
@click="cart.beginCheckout()"
|
|
270
|
-
>
|
|
271
|
-
<template #leadingIcon>
|
|
272
|
-
<EldraIcon name="lock" size="sm" />
|
|
273
|
-
</template>
|
|
274
|
-
{{ t('cart.checkout') }}
|
|
275
|
-
</Button>
|
|
263
|
+
<CheckoutButton />
|
|
276
264
|
|
|
277
265
|
<p v-if="props.note" class="text-muted text-body-sm text-center">{{ props.note }}</p>
|
|
278
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
|
|
@@ -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 {
|
|
@@ -1775,6 +1787,7 @@ function hrefForPage(page: number): string {
|
|
|
1775
1787
|
cards to Load more, and a cart action is `product-detail`'s own. -->
|
|
1776
1788
|
<ProductCard
|
|
1777
1789
|
:product="entry.product"
|
|
1790
|
+
:currency="entry.currency"
|
|
1778
1791
|
ratio="4x5"
|
|
1779
1792
|
:heading-level="3"
|
|
1780
1793
|
:class="CARD_CLASS"
|
|
@@ -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 () => {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -45,17 +45,7 @@
|
|
|
45
45
|
* or a click (its own contract; arrow keys alone only move the active option), so nothing extra is
|
|
46
46
|
* needed here to satisfy "prices reload only after Enter or a click" (3.2.2).
|
|
47
47
|
*
|
|
48
|
-
* The currency selector
|
|
49
|
-
* platform supports exactly one currency per store today. So its options are derived from the
|
|
50
|
-
* store (`useMoney().currency`, `app/storefront/money.ts`), not from a constant list, and there is
|
|
51
|
-
* at most one of them — `currencyLabel()` names it "ISK kr." style (code + the sign
|
|
52
|
-
* `@eldrajs/ui` writes the store's prices with in the content locale, falling back to the code
|
|
53
|
-
* alone when the locale has no sign distinct from it). With exactly one option
|
|
54
|
-
* there is nothing to select, so it renders as plain text with the same leading icon and a visually
|
|
55
|
-
* hidden "Currency" label, not a `Select` — a native-looking control a visitor could try to open
|
|
56
|
-
* with nothing inside it would be worse than no control at all. With no currency published, the
|
|
57
|
-
* slot renders nothing. The `Select` branch stays for the day the derived list carries two or more
|
|
58
|
-
* entries; which branch renders is driven by that list's length, not by a separate flag.
|
|
48
|
+
* The currency selector drives the same choice as the header's picker; one currency is plain text.
|
|
59
49
|
*
|
|
60
50
|
* The newsletter zone posts through `useStorefront().forms.submit('newsletter', …)` — the platform's
|
|
61
51
|
* seeded `newsletter` form, the same one the newsletter block defaults to. Email format is validated
|
|
@@ -81,6 +71,7 @@ import type { ResolvedLink } from '@eldrajs/theme-vue';
|
|
|
81
71
|
import {
|
|
82
72
|
Button,
|
|
83
73
|
Container,
|
|
74
|
+
CurrencyPicker,
|
|
84
75
|
EditorPlaceholder,
|
|
85
76
|
FieldWrapper,
|
|
86
77
|
FormLayout,
|
|
@@ -256,21 +247,14 @@ const showLocale = computed(
|
|
|
256
247
|
);
|
|
257
248
|
const showCurrency = computed(() => data.value.showCurrency ?? true);
|
|
258
249
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
* currency, this grows to match and the template's `Select` branch (below) is already there.
|
|
266
|
-
*/
|
|
267
|
-
const currencyOptions = computed<SelectOption[]>(() => {
|
|
268
|
-
const code = money.currency.value;
|
|
269
|
-
return code === undefined ? [] : [{ value: code, label: currencyLabel(code, uiLocale.value) }];
|
|
250
|
+
const currencyStore = storefront.currency;
|
|
251
|
+
/** The currencies the store offers, or the one `Price` formats in. */
|
|
252
|
+
const currencyCodes = computed<readonly string[]>(() => {
|
|
253
|
+
const offered = currencyStore.offered.value;
|
|
254
|
+
const store = money.currency.value;
|
|
255
|
+
return offered.length > 0 ? offered : store === undefined ? [] : [store];
|
|
270
256
|
});
|
|
271
|
-
|
|
272
|
-
/** Whether the currency slot renders anything: `showCurrency` on *and* a currency to show it. */
|
|
273
|
-
const showCurrencySelector = computed(() => showCurrency.value && currencyOptions.value.length > 0);
|
|
257
|
+
const showCurrencySelector = computed(() => showCurrency.value && currencyCodes.value.length > 0);
|
|
274
258
|
|
|
275
259
|
const hasSelectors = computed(() => showLocale.value || showCurrencySelector.value);
|
|
276
260
|
|
|
@@ -297,8 +281,6 @@ const locale = computed<string>({
|
|
|
297
281
|
if (value !== '' && value !== activeLocale.active) activeLocale.select(value);
|
|
298
282
|
},
|
|
299
283
|
});
|
|
300
|
-
/** Only reached once `currencyOptions` carries two or more entries — see the template. */
|
|
301
|
-
const currency = ref<string>(currencyOptions.value[0]?.value ?? '');
|
|
302
284
|
|
|
303
285
|
/* ---------------------------------------------------------------------- */
|
|
304
286
|
/* Newsletter */
|
|
@@ -678,33 +660,26 @@ async function onNewsletterSubmit(payload: FormLayoutSubmitPayload): Promise<voi
|
|
|
678
660
|
over three options is one more thing between a visitor and their language. -->
|
|
679
661
|
<Select v-model="locale" :options="localeOptions" placement="above" />
|
|
680
662
|
</FieldWrapper>
|
|
681
|
-
<!--
|
|
682
|
-
With exactly one currency there is nothing to select — see the file doc comment — so
|
|
683
|
-
this renders the currency as plain text (same leading icon, a visually hidden
|
|
684
|
-
"Currency" label) rather than a `Select` a visitor could open onto an empty list. The
|
|
685
|
-
`Select` branch stays for the day `currencyOptions` carries two or more entries.
|
|
686
|
-
-->
|
|
663
|
+
<!-- One currency is plain text: there is nothing to pick. -->
|
|
687
664
|
<p
|
|
688
|
-
v-if="showCurrencySelector &&
|
|
665
|
+
v-if="showCurrencySelector && currencyCodes.length === 1"
|
|
689
666
|
class="text-text @tablet:w-auto flex w-full items-center gap-1.5 text-[0.8125rem] font-medium"
|
|
690
667
|
>
|
|
691
668
|
<EldraIcon name="credit-card" size="sm" class="text-muted shrink-0" />
|
|
692
669
|
<VisuallyHidden>{{ t('footer.currencyLabel') }}</VisuallyHidden>
|
|
693
|
-
{{
|
|
670
|
+
{{ currencyLabel(currencyCodes[0]!, uiLocale) }}
|
|
694
671
|
</p>
|
|
695
|
-
<
|
|
672
|
+
<CurrencyPicker
|
|
696
673
|
v-else-if="showCurrencySelector"
|
|
674
|
+
:currencies="currencyCodes"
|
|
675
|
+
:model-value="currencyStore.active.value"
|
|
676
|
+
:busy="currencyStore.busy.value"
|
|
697
677
|
:label="t('footer.currencyLabel')"
|
|
678
|
+
size="md"
|
|
679
|
+
placement="above"
|
|
698
680
|
class="@tablet:w-auto w-full"
|
|
699
|
-
:
|
|
700
|
-
|
|
701
|
-
<Select
|
|
702
|
-
v-model="currency"
|
|
703
|
-
:options="currencyOptions"
|
|
704
|
-
placement="above"
|
|
705
|
-
:searchable="false"
|
|
706
|
-
/>
|
|
707
|
-
</FieldWrapper>
|
|
681
|
+
@update:model-value="currencyStore.choose"
|
|
682
|
+
/>
|
|
708
683
|
</div>
|
|
709
684
|
</div>
|
|
710
685
|
</Container>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
Badge,
|
|
7
7
|
Button,
|
|
8
8
|
Container,
|
|
9
|
+
CurrencyPicker,
|
|
9
10
|
EditorPlaceholder,
|
|
10
11
|
Link,
|
|
11
12
|
NavMenu,
|
|
@@ -155,7 +156,10 @@ function toSearchResults(response: StorefrontSearchResponse | null): SearchResul
|
|
|
155
156
|
// Optional on `SearchResultItem`, and `null` on a product the storefront could not price: the
|
|
156
157
|
// row keeps the product and drops the price rather than printing the store's own "$0.00"
|
|
157
158
|
// (`StorefrontSearchProduct`).
|
|
158
|
-
price:
|
|
159
|
+
price:
|
|
160
|
+
product.price === null || product.price.soldInCurrency === false
|
|
161
|
+
? undefined
|
|
162
|
+
: money.format(product.price.amount, product.price.currency),
|
|
159
163
|
image: product.featuredImage?.src,
|
|
160
164
|
imageAlt: product.featuredImage?.alt,
|
|
161
165
|
}));
|
|
@@ -266,6 +270,8 @@ const cartHref = computed(() => (cartDrawerAvailable.value ? undefined : '/cart'
|
|
|
266
270
|
const cartPopupType = computed(() => (cartDrawerAvailable.value ? 'dialog' : undefined));
|
|
267
271
|
const cartAccessibleName = computed(() => {
|
|
268
272
|
const count = cartCount.value;
|
|
273
|
+
// A cart that could not be read has no count to say.
|
|
274
|
+
if (mounted.value && storefront.cart.loadFailed.value) return t('header.cart');
|
|
269
275
|
if (count === 0) return t('header.cartEmpty');
|
|
270
276
|
if (count === 1) return t('header.cartOne');
|
|
271
277
|
return t('header.cartMany', { count });
|
|
@@ -613,6 +619,12 @@ const hairlineClass = computed(() =>
|
|
|
613
619
|
|
|
614
620
|
/** The drawer holds the links and the call to action; with neither there is no Menu button either. */
|
|
615
621
|
const drawerHasContent = computed(() => links.value.length > 0 || hasCta.value);
|
|
622
|
+
/** More than one currency to shop in. On a phone the picker sits in the menu when there is one. */
|
|
623
|
+
const currency = storefront.currency;
|
|
624
|
+
const hasCurrencies = computed(() => currency.offered.value.length > 1);
|
|
625
|
+
const barPickerClass = computed(() =>
|
|
626
|
+
drawerHasContent.value ? '@content:block ml-1 hidden' : 'ml-1'
|
|
627
|
+
);
|
|
616
628
|
const showLinksPlaceholder = computed(
|
|
617
629
|
() => isEditing.value && variant.value !== 'minimal' && links.value.length === 0
|
|
618
630
|
);
|
|
@@ -740,8 +752,25 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
740
752
|
{{ t('header.viewAll') }}
|
|
741
753
|
</Link>
|
|
742
754
|
</template>
|
|
743
|
-
<template v-if="hasCta" #drawerFooter="{ close }">
|
|
744
|
-
<
|
|
755
|
+
<template v-if="hasCta || hasCurrencies" #drawerFooter="{ close }">
|
|
756
|
+
<CurrencyPicker
|
|
757
|
+
:currencies="currency.offered.value"
|
|
758
|
+
:model-value="currency.active.value"
|
|
759
|
+
:busy="currency.busy.value"
|
|
760
|
+
show-label
|
|
761
|
+
size="md"
|
|
762
|
+
placement="above"
|
|
763
|
+
class="w-full"
|
|
764
|
+
@update:model-value="currency.choose"
|
|
765
|
+
/>
|
|
766
|
+
<Button
|
|
767
|
+
v-if="hasCta"
|
|
768
|
+
variant="primary"
|
|
769
|
+
block
|
|
770
|
+
:href="ctaHref"
|
|
771
|
+
:as="ctaLinkAs"
|
|
772
|
+
@click="close"
|
|
773
|
+
>
|
|
745
774
|
{{ ctaLabel }}
|
|
746
775
|
</Button>
|
|
747
776
|
</template>
|
|
@@ -884,6 +913,13 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
884
913
|
<!-- Spec Header -> Layout, From 64rem: the call to action sits 0.75rem after the cart.
|
|
885
914
|
0.25rem of that is already the actions row's own gap-1; @content:ml-2 (0.5rem) makes
|
|
886
915
|
up the rest, so it reads as its own button rather than a fourth icon in the row. -->
|
|
916
|
+
<CurrencyPicker
|
|
917
|
+
:currencies="currency.offered.value"
|
|
918
|
+
:model-value="currency.active.value"
|
|
919
|
+
:busy="currency.busy.value"
|
|
920
|
+
:class="barPickerClass"
|
|
921
|
+
@update:model-value="currency.choose"
|
|
922
|
+
/>
|
|
887
923
|
<Button
|
|
888
924
|
v-if="hasCta && variant !== 'minimal'"
|
|
889
925
|
variant="primary"
|
|
Binary file
|
|
Binary file
|
|
@@ -82,9 +82,10 @@
|
|
|
82
82
|
* truth this block renders, so a delivered order's last step shows the done check, not the
|
|
83
83
|
* ring.
|
|
84
84
|
*/
|
|
85
|
-
import { computed, defineComponent, h, ref, type Component } from 'vue';
|
|
85
|
+
import { computed, defineComponent, h, provide, ref, type Component } from 'vue';
|
|
86
86
|
import {
|
|
87
87
|
Badge,
|
|
88
|
+
CURRENCY_KEY,
|
|
88
89
|
Button,
|
|
89
90
|
Container,
|
|
90
91
|
EmptyState,
|
|
@@ -156,6 +157,10 @@ const order = computed<StorefrontOrder | null>(() => {
|
|
|
156
157
|
return editing.value ? buildOrder('shipped') : null;
|
|
157
158
|
});
|
|
158
159
|
|
|
160
|
+
const orderCurrency = computed(() => order.value?.currency ?? money.currency.value);
|
|
161
|
+
// The order's amounts are in its own currency, which can differ from the store's.
|
|
162
|
+
provide(CURRENCY_KEY, () => orderCurrency.value);
|
|
163
|
+
|
|
159
164
|
/** See the module doc comment's "Loading / error" section — a real token in the URL, but the
|
|
160
165
|
* fetch it drives is still in flight or failed (never true while `order` already has a value,
|
|
161
166
|
* which includes the editor's own demo-order fallback above). */
|
|
@@ -647,7 +652,11 @@ const helpLinks = computed<HelpLinkView[]>(() =>
|
|
|
647
652
|
</Link>
|
|
648
653
|
<p class="text-muted text-body-sm">{{ lineMeta(line) }}</p>
|
|
649
654
|
</div>
|
|
650
|
-
<Price
|
|
655
|
+
<Price
|
|
656
|
+
:amount="money.minor(line.lineTotal, orderCurrency)"
|
|
657
|
+
size="sm"
|
|
658
|
+
class="justify-self-end"
|
|
659
|
+
/>
|
|
651
660
|
</li>
|
|
652
661
|
</ul>
|
|
653
662
|
<Button
|
|
@@ -667,7 +676,7 @@ const helpLinks = computed<HelpLinkView[]>(() =>
|
|
|
667
676
|
<div class="flex items-baseline justify-between gap-4">
|
|
668
677
|
<dt class="text-muted text-body-sm">{{ t('order.subtotal') }}</dt>
|
|
669
678
|
<dd class="text-text text-base tabular-nums">
|
|
670
|
-
<Price :amount="money.minor(totals.subtotal)" size="sm" />
|
|
679
|
+
<Price :amount="money.minor(totals.subtotal, orderCurrency)" size="sm" />
|
|
671
680
|
</dd>
|
|
672
681
|
</div>
|
|
673
682
|
<div class="flex items-baseline justify-between gap-4">
|
|
@@ -676,7 +685,7 @@ const helpLinks = computed<HelpLinkView[]>(() =>
|
|
|
676
685
|
<span v-if="isShippingFree">{{ t('order.shippingFree') }}</span>
|
|
677
686
|
<Price
|
|
678
687
|
v-else-if="totals.shipping != null"
|
|
679
|
-
:amount="money.minor(totals.shipping)"
|
|
688
|
+
:amount="money.minor(totals.shipping, orderCurrency)"
|
|
680
689
|
size="sm"
|
|
681
690
|
/>
|
|
682
691
|
</dd>
|
|
@@ -684,13 +693,13 @@ const helpLinks = computed<HelpLinkView[]>(() =>
|
|
|
684
693
|
<div v-if="hasTax" class="flex items-baseline justify-between gap-4">
|
|
685
694
|
<dt class="text-muted text-body-sm">{{ t('order.tax') }}</dt>
|
|
686
695
|
<dd class="text-text text-base tabular-nums">
|
|
687
|
-
<Price :amount="money.minor(totals.tax
|
|
696
|
+
<Price :amount="money.minor(totals.tax!, orderCurrency)" size="sm" />
|
|
688
697
|
</dd>
|
|
689
698
|
</div>
|
|
690
699
|
<div class="border-border flex items-baseline justify-between gap-4 border-t pt-3">
|
|
691
700
|
<dt class="text-h4 font-bold">{{ t('order.total') }}</dt>
|
|
692
701
|
<dd class="text-h4 font-bold tabular-nums">
|
|
693
|
-
<Price :amount="money.minor(totals.total)" size="md" />
|
|
702
|
+
<Price :amount="money.minor(totals.total, orderCurrency)" size="md" />
|
|
694
703
|
</dd>
|
|
695
704
|
</div>
|
|
696
705
|
</dl>
|
|
Binary file
|
|
Binary file
|
|
@@ -186,7 +186,8 @@ const hasData = computed(() => activeResult.value.data.value !== null);
|
|
|
186
186
|
const showSkeletons = computed(() => pending.value && !hasData.value);
|
|
187
187
|
const { any: cardsRevalidating, refreshing } = useRevalidating({
|
|
188
188
|
keys: () => activeResult.value.revalidating.value,
|
|
189
|
-
refreshing: () =>
|
|
189
|
+
refreshing: () =>
|
|
190
|
+
(activeResult.value.loading.value && hasData.value) || storefront.currency.pending.value,
|
|
190
191
|
});
|
|
191
192
|
|
|
192
193
|
/**
|
|
@@ -216,10 +217,12 @@ const cappedProducts = computed(() => products.value.slice(0, limit.value));
|
|
|
216
217
|
* "fewer than 2 products" floor or leave the carousel controls claiming a slide that isn't there.
|
|
217
218
|
*/
|
|
218
219
|
const money = useMoney();
|
|
220
|
+
const shopperCurrency = useStorefront().currency.active;
|
|
219
221
|
const cards = computed(() =>
|
|
220
222
|
toProductCardEntries(cappedProducts.value, {
|
|
221
223
|
ratio: cardRatio.value,
|
|
222
224
|
minorUnits: money.minor,
|
|
225
|
+
shopperCurrency: shopperCurrency.value,
|
|
223
226
|
revalidating: cardsRevalidating.value,
|
|
224
227
|
})
|
|
225
228
|
);
|
|
@@ -448,7 +451,7 @@ const showBlock = computed(() =>
|
|
|
448
451
|
:revalidating="entry.revalidating"
|
|
449
452
|
:announce="false"
|
|
450
453
|
:link-as="entry.internal ? EldraRouterLink : undefined"
|
|
451
|
-
:currency="currency"
|
|
454
|
+
:currency="entry.currency ?? currency"
|
|
452
455
|
:locale="locale"
|
|
453
456
|
/>
|
|
454
457
|
</div>
|
|
Binary file
|