@eldrajs/theme-cli 0.2.9 → 0.2.11
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 +12 -1
- package/package.json +3 -3
- package/template/.eldra/block-types.d.ts +4 -6
- package/template/.eldra/manifest.json +228 -246
- package/template/.eldra/previews.json +35 -35
- package/template/.storybook/eldra.ts +7 -2
- package/template/app/assets/main.css +5 -0
- package/template/app/composables/useBlockData.ts +9 -2
- package/template/app/composables/usePriceTokens.ts +150 -0
- package/template/app/composables/useQuickAdd.ts +95 -0
- package/template/app/composables/useRegionalFormat.ts +94 -0
- package/template/app/icons.ts +4 -0
- package/template/app/plugins/eldra-storefront.ts +2 -0
- package/template/app/plugins/eldra-ui-messages.ts +22 -8
- package/template/app/storefront/demo.ts +188 -16
- package/template/app/storefront/gateway.ts +19 -0
- package/template/app/storefront/productCardLook.ts +76 -0
- package/template/app/storefront/productReference.ts +17 -0
- package/template/app/storefront/toProductCard.ts +12 -8
- package/template/app/storefront/types.ts +17 -0
- package/template/blocks/announcement-bar/__tests__/Block.spec.ts +19 -7
- package/template/blocks/announcement-bar/block.json +2 -1
- package/template/blocks/announcement-bar/mock.json +1 -1
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/Block.vue +8 -18
- package/template/blocks/article/block.json +3 -1
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/block.json +10 -1
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/Block.vue +15 -3
- package/template/blocks/breadcrumbs/__tests__/Block.spec.ts +13 -0
- package/template/blocks/breadcrumbs/block.json +1 -0
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/Block.vue +15 -5
- package/template/blocks/cart/__tests__/Block.spec.ts +53 -10
- package/template/blocks/cart/__tests__/ShippingBar.spec.ts +10 -8
- package/template/blocks/cart/block.json +8 -5
- package/template/blocks/cart/mock.json +2 -2
- package/template/blocks/cart/parts/ShippingBar.vue +24 -30
- package/template/blocks/cart/parts/notSold.ts +4 -3
- package/template/blocks/collection-grid/Block.vue +168 -85
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +101 -23
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/Block.vue +51 -17
- package/template/blocks/collection-header/__tests__/Block.spec.ts +80 -4
- package/template/blocks/collection-header/block.json +2 -0
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/block.json +4 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/block.json +2 -0
- package/template/blocks/faq/Block.vue +5 -10
- package/template/blocks/faq/block.json +2 -1
- package/template/blocks/faq/mock.json +12 -1
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +30 -7
- package/template/blocks/feature-grid/block.json +3 -2
- package/template/blocks/feature-grid/mock.json +1 -1
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +64 -21
- package/template/blocks/footer/__tests__/Block.spec.ts +97 -1
- package/template/blocks/footer/block.json +5 -2
- package/template/blocks/footer/mock.json +1 -1
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/block.json +1 -0
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +38 -9
- package/template/blocks/hero/__tests__/Block.spec.ts +71 -19
- package/template/blocks/hero/block.json +16 -22
- package/template/blocks/hero/preview.json +1 -3
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/block.json +2 -1
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/block.json +1 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +405 -159
- package/template/blocks/navigation/__tests__/Block.spec.ts +816 -172
- package/template/blocks/navigation/__tests__/currentItem.spec.ts +90 -0
- package/template/blocks/navigation/block.json +2 -11
- package/template/blocks/navigation/mock.json +3 -3
- package/template/blocks/navigation/parts/LocalePicker.vue +103 -0
- package/template/blocks/navigation/parts/currentItem.ts +82 -0
- package/template/blocks/navigation/preview.json +7 -1
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/Block.vue +6 -2
- package/template/blocks/newsletter/block.json +2 -0
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/Block.vue +8 -17
- package/template/blocks/order-status/block.json +3 -0
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/__tests__/Block.spec.ts +12 -4
- package/template/blocks/pricing-table/block.json +2 -0
- package/template/blocks/pricing-table/mock.json +6 -6
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/Block.vue +36 -126
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +88 -0
- package/template/blocks/product-carousel/block.json +1 -0
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +84 -31
- package/template/blocks/product-detail/__tests__/Block.spec.ts +86 -0
- package/template/blocks/product-detail/__tests__/specs.spec.ts +79 -0
- package/template/blocks/product-detail/block.json +3 -1
- package/template/blocks/product-detail/mock.json +54 -4
- package/template/blocks/product-detail/parts/Gallery.vue +8 -2
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/product-detail/specs.ts +75 -0
- package/template/blocks/quote/block.json +1 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/Block.vue +6 -1
- package/template/blocks/search/TypeSection.vue +8 -1
- package/template/blocks/search/__tests__/Block.spec.ts +24 -1
- package/template/blocks/search/block.json +1 -0
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/split-content/Block.vue +12 -5
- package/template/blocks/split-content/__tests__/Block.spec.ts +13 -0
- package/template/blocks/split-content/block.json +4 -2
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/Block.vue +3 -4
- package/template/blocks/tabs/block.json +1 -1
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/block.json +3 -1
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/block.json +2 -0
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/block.json +2 -1
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/Block.vue +2 -2
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +38 -9
- package/template/blocks/trust-strip/block.json +1 -1
- package/template/blocks/trust-strip/mock.json +1 -1
- package/template/blocks/trust-strip/preview.json +1 -1
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/block.json +2 -0
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/Block.vue +2 -2
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/i18n/en-US.json +13 -5
- package/template/i18n/is-IS.json +12 -4
- package/template/pages/article.page.json +1 -3
- package/template/pages/cart.page.json +1 -3
- package/template/pages/category.page.json +2 -4
- package/template/pages/collection.page.json +1 -3
- package/template/pages/home.page.json +7 -18
- package/template/pages/product.page.json +62 -131
- package/template/pages/products.page.json +1 -3
- package/template/pages/search.page.json +1 -3
- package/template/pages/wishlist.page.json +1 -3
- package/template/stories/generated/footer.stories.ts +6 -0
- package/template/stories/generated/navigation.stories.ts +0 -18
- package/template/test/inlineEditable.spec.ts +10 -2
- package/template/test/localePrefix.spec.ts +2 -19
- package/template/test/pages/article.spec.ts +0 -2
- package/template/test/pages/category.spec.ts +35 -13
- package/template/test/pages/home.spec.ts +33 -17
- package/template/test/pages/product.spec.ts +64 -44
- package/template/test/pages/ssr.spec.ts +3 -1
- package/template/test/prerenderRefresh.browser.spec.ts +30 -25
- package/template/test/previewParity.browser.spec.ts +36 -2
- package/template/test/priceTokens.spec.ts +309 -0
- package/template/test/regionalFormat.spec.ts +80 -0
- package/template/test/starter.spec.ts +23 -7
- package/template/test/storefront/demo.spec.ts +19 -18
- package/template/test/storefront/toProductCard.spec.ts +17 -2
- package/template/test/structuredData.generate.spec.ts +4 -2
- package/template/test/support/mockGateway.ts +21 -1
- package/template/test/support/mountBlock.ts +25 -4
- package/template/test/support/priceTokens.ts +20 -0
- package/template/test/uiMessagesPlugin.spec.ts +34 -1
- package/template/tokens.json +8 -8
|
@@ -11,13 +11,14 @@ import {
|
|
|
11
11
|
EditorPlaceholder,
|
|
12
12
|
Link,
|
|
13
13
|
NavMenu,
|
|
14
|
-
SearchBar,
|
|
15
14
|
SearchModal,
|
|
16
15
|
} from '@eldrajs/ui';
|
|
17
16
|
import type {
|
|
18
17
|
NavMenuItem,
|
|
19
18
|
NavMenuLink,
|
|
20
19
|
NavMenuPart,
|
|
20
|
+
NavMenuSection,
|
|
21
|
+
NavMenuTone,
|
|
21
22
|
SearchResultItem,
|
|
22
23
|
SearchResults,
|
|
23
24
|
UiMessages,
|
|
@@ -28,21 +29,21 @@ import { useStorefront } from '../../app/composables/useStorefront';
|
|
|
28
29
|
import { useWishlist } from '../../app/composables/useWishlist';
|
|
29
30
|
import { useI18n } from 'vue-i18n';
|
|
30
31
|
import EldraIcon from '../../app/components/EldraIcon.vue';
|
|
32
|
+
import LocalePicker from './parts/LocalePicker.vue';
|
|
31
33
|
import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
|
|
32
|
-
import { isInternalHref, safeHref, SEARCH_PATH } from '../../app/utils/links';
|
|
34
|
+
import { categoryHref, isInternalHref, safeHref, SEARCH_PATH } from '../../app/utils/links';
|
|
33
35
|
import { useMoney } from '../../app/storefront/money';
|
|
34
36
|
import type { StorefrontSearchResponse } from '../../app/storefront/types';
|
|
35
37
|
import MenuLink from './parts/MenuLink.vue';
|
|
38
|
+
import { markCurrent } from './parts/currentItem';
|
|
36
39
|
|
|
37
|
-
/** One panel column. `@eldrajs/ui` does not export this type by name (only `NavMenuItem`, whose
|
|
38
|
-
* `sections` it is), so it is read off the item. */
|
|
39
|
-
type NavMenuSection = NonNullable<NavMenuItem['sections']>[number];
|
|
40
40
|
import blockJson from './block.json';
|
|
41
41
|
|
|
42
42
|
const props = defineProps<{ entry: EldraBlockEntry<'navigation'> }>();
|
|
43
43
|
const { data } = useBlockData(props, 'navigation');
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
/** Currency names are words in the page's language; prices follow the regional format instead. */
|
|
46
|
+
const { t, locale: contentLocale } = useI18n();
|
|
46
47
|
const isEditing = useEditing();
|
|
47
48
|
const storefront = useStorefront();
|
|
48
49
|
|
|
@@ -53,8 +54,8 @@ const variant = computed<'default' | 'centered' | 'minimal'>(() => data.value.va
|
|
|
53
54
|
// The bar gives up width in stages, each measured against the header's own `@container` (so the
|
|
54
55
|
// stages follow the block's width, not the window's):
|
|
55
56
|
//
|
|
56
|
-
// - from
|
|
57
|
-
//
|
|
57
|
+
// - from 68.8125rem (1101px): brand, inline links, a labelled Search button and the labelled
|
|
58
|
+
// tools (from 80rem, `@wide:`, the links only spread further apart);
|
|
58
59
|
// - below 68.8125rem (≤1100px): the links move into the Menu drawer; Menu and Search sit at the
|
|
59
60
|
// start, the brand in the middle of a symmetric grid, Saved and Cart at the end;
|
|
60
61
|
// - below 47.5625rem (≤760px): a shorter bar and narrower tools, and the info strip keeps only its
|
|
@@ -179,6 +180,17 @@ function sectionExtras(raw: unknown, sections: ResolvedSection[]): LinkExtras[][
|
|
|
179
180
|
});
|
|
180
181
|
}
|
|
181
182
|
|
|
183
|
+
/**
|
|
184
|
+
* A top-level link the merchant marked `tone: "accent"` — the design's "Sale" — is drawn in the
|
|
185
|
+
* accent colour, in the bar and as a drawer row (`NavMenuLink.tone`). It is the link's own
|
|
186
|
+
* setting rather than a rule about a label or a position, so it survives a translation, a rename
|
|
187
|
+
* and a reorder. Like `badge` and `description` it rides on the stored link value as an extra key
|
|
188
|
+
* (Studio's link editor has no field for it yet), and is read straight off the item it is on.
|
|
189
|
+
*/
|
|
190
|
+
function linkTone(raw: unknown): NavMenuTone | undefined {
|
|
191
|
+
return plainString(raw, 'tone') === 'accent' ? 'accent' : undefined;
|
|
192
|
+
}
|
|
193
|
+
|
|
182
194
|
/**
|
|
183
195
|
* The picture crop of a menu card: the `aspect` this block's own `links` field declares in
|
|
184
196
|
* `cards`, so the declaration and the drawing cannot drift. `NavMenu` falls back to 4:3 on a
|
|
@@ -195,13 +207,13 @@ const cardAspect = (
|
|
|
195
207
|
)?.metadata?.item?.metadata?.tree?.cards?.aspect;
|
|
196
208
|
|
|
197
209
|
/** A resolved link as the menu draws it, `display` and `card` (child and section links only) kept. */
|
|
198
|
-
function toNavLink(link: ResolvedLink, extras: LinkExtras = {}): NavMenuLink {
|
|
210
|
+
function toNavLink(link: ResolvedLink, extras: LinkExtras = {}, held = true): NavMenuLink {
|
|
199
211
|
return {
|
|
200
212
|
label: link.label,
|
|
201
213
|
href: link.href,
|
|
202
214
|
newTab: link.newTab,
|
|
203
215
|
group: link.group,
|
|
204
|
-
current: isCurrent(link.href),
|
|
216
|
+
current: held && isCurrent(link.href),
|
|
205
217
|
display: link.display,
|
|
206
218
|
card: link.card,
|
|
207
219
|
badge: extras.badge,
|
|
@@ -209,13 +221,17 @@ function toNavLink(link: ResolvedLink, extras: LinkExtras = {}): NavMenuLink {
|
|
|
209
221
|
};
|
|
210
222
|
}
|
|
211
223
|
|
|
212
|
-
function toNavSection(
|
|
224
|
+
function toNavSection(
|
|
225
|
+
section: ResolvedSection,
|
|
226
|
+
extras: LinkExtras[] = [],
|
|
227
|
+
held = true
|
|
228
|
+
): NavMenuSection {
|
|
213
229
|
return {
|
|
214
230
|
heading: section.heading,
|
|
215
|
-
headingLink: section.headingLink === null ? null : toNavLink(section.headingLink),
|
|
231
|
+
headingLink: section.headingLink === null ? null : toNavLink(section.headingLink, {}, held),
|
|
216
232
|
display: section.display,
|
|
217
|
-
links: section.links.map((link, index) => toNavLink(link, extras[index])),
|
|
218
|
-
seeAll: section.seeAll === null ? null : toNavLink(section.seeAll),
|
|
233
|
+
links: section.links.map((link, index) => toNavLink(link, extras[index], held)),
|
|
234
|
+
seeAll: section.seeAll === null ? null : toNavLink(section.seeAll, {}, held),
|
|
219
235
|
};
|
|
220
236
|
}
|
|
221
237
|
|
|
@@ -240,38 +256,52 @@ function isDropdown(sections: ResolvedSection[]): boolean {
|
|
|
240
256
|
* grouped by their `group`, which is what a menu stored before sections existed still is.
|
|
241
257
|
*/
|
|
242
258
|
const navItems = computed<NavMenuItem[]>(() =>
|
|
243
|
-
linkEntries.value.map(({ resolved: link, raw }) => {
|
|
259
|
+
linkEntries.value.map(({ resolved: link, raw }, at) => {
|
|
260
|
+
// Only the one marked entry holds the current page; a link inside another entry's panel is not
|
|
261
|
+
// marked even when its path is the page's, so at most one entry is ever current.
|
|
262
|
+
const mark = currentMarks.value[at];
|
|
263
|
+
const held = mark !== undefined;
|
|
244
264
|
const sections = link.sections ?? [];
|
|
245
265
|
const children = link.children.filter((child) => child.label !== null);
|
|
266
|
+
const tone = linkTone(raw);
|
|
246
267
|
if (sections.length === 0 && children.length === 0) {
|
|
247
268
|
return {
|
|
248
269
|
label: link.label,
|
|
249
270
|
href: link.href,
|
|
250
271
|
newTab: link.newTab,
|
|
251
|
-
current:
|
|
272
|
+
current: mark,
|
|
273
|
+
tone,
|
|
252
274
|
};
|
|
253
275
|
}
|
|
254
276
|
if (sections.length === 0) {
|
|
255
277
|
return {
|
|
256
278
|
label: link.label,
|
|
257
279
|
layout: 'mega',
|
|
258
|
-
|
|
280
|
+
tone,
|
|
281
|
+
current: mark,
|
|
282
|
+
children: children.map((c) => toNavLink(c, {}, held)),
|
|
259
283
|
};
|
|
260
284
|
}
|
|
261
285
|
const extras = sectionExtras(raw, sections);
|
|
262
286
|
return {
|
|
263
287
|
label: link.label,
|
|
288
|
+
tone,
|
|
264
289
|
layout: isDropdown(sections) ? 'dropdown' : 'mega',
|
|
265
|
-
|
|
290
|
+
current: mark,
|
|
291
|
+
sections: sections.map((section, index) => toNavSection(section, extras[index], held)),
|
|
266
292
|
};
|
|
267
293
|
})
|
|
268
294
|
);
|
|
269
295
|
|
|
270
|
-
/**
|
|
271
|
-
*
|
|
296
|
+
/**
|
|
297
|
+
* The panel's own "View all" footer, for a menu stored before sections existed: a panel of
|
|
298
|
+
* `children` has no headings to link from, so the parent's own page is offered under it. A panel of
|
|
299
|
+
* sections has none (the design's Shop and Ceramics panels end on their columns): its headings and
|
|
300
|
+
* "see all" links are how an author points at a department's page.
|
|
301
|
+
*/
|
|
272
302
|
function viewAllHref(index: number): string | undefined {
|
|
273
303
|
const link = links.value[index];
|
|
274
|
-
if (link?.sections?.
|
|
304
|
+
if ((link?.sections?.length ?? 0) > 0) return undefined;
|
|
275
305
|
return link?.href ?? undefined;
|
|
276
306
|
}
|
|
277
307
|
|
|
@@ -342,16 +372,6 @@ function infoItemClass(index: number): string {
|
|
|
342
372
|
// --- search ------------------------------------------------------------------------------------
|
|
343
373
|
|
|
344
374
|
const showSearch = computed(() => data.value.showSearch !== false);
|
|
345
|
-
/** `inline` only ever applies to `centered`; otherwise it falls back to `icon` (spec: "inline:
|
|
346
|
-
* centered variant only"). */
|
|
347
|
-
const searchStyle = computed<'icon' | 'field' | 'inline'>(() => {
|
|
348
|
-
const style = data.value.searchStyle ?? 'icon';
|
|
349
|
-
if (style === 'inline' && variant.value !== 'centered') return 'icon';
|
|
350
|
-
// `minimal` is a tool row at every width, and its brand is centred by the two sides matching:
|
|
351
|
-
// a pill field on one side would push it off the middle.
|
|
352
|
-
if (style === 'field' && variant.value === 'minimal') return 'icon';
|
|
353
|
-
return style;
|
|
354
|
-
});
|
|
355
375
|
|
|
356
376
|
const searchOpen = ref(false);
|
|
357
377
|
const searchQuery = ref('');
|
|
@@ -364,7 +384,7 @@ const money = useMoney();
|
|
|
364
384
|
*
|
|
365
385
|
* Three destinations, none of which `EldraRouterLink` can reach:
|
|
366
386
|
*
|
|
367
|
-
* 1. `
|
|
387
|
+
* 1. `SearchModal` renders a real `<form role="search" method="get" :action>`, so
|
|
368
388
|
* pressing Enter with no active option is a native document submit. Left to its default the
|
|
369
389
|
* action is `/search`, and a shopper searching from `/is-IS/products/x` lands on the **English**
|
|
370
390
|
* results page.
|
|
@@ -429,8 +449,8 @@ const searchAnswer = computed(() => {
|
|
|
429
449
|
const answer = searchResult.data.value;
|
|
430
450
|
return answer !== null && answer.query === searchQuery.value ? answer : null;
|
|
431
451
|
});
|
|
432
|
-
/** `undefined` while there is no answer for this query — which is how
|
|
433
|
-
*
|
|
452
|
+
/** `undefined` while there is no answer for this query — which is how `SearchModal` is told
|
|
453
|
+
* "nothing yet", as opposed to "nothing found". */
|
|
434
454
|
const searchResults = computed(() => toSearchResults(searchAnswer.value));
|
|
435
455
|
/**
|
|
436
456
|
* `loading`, not `pending`: `pending` is the skeleton flag and means "a read in flight with nothing
|
|
@@ -579,12 +599,10 @@ const wishlistBadgeLabel = computed(() =>
|
|
|
579
599
|
// --- current page ------------------------------------------------------------------------------
|
|
580
600
|
|
|
581
601
|
/**
|
|
582
|
-
*
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
* `
|
|
586
|
-
* fire it, so the highlighted link can go stale until the next popstate/reload — a known
|
|
587
|
-
* limitation of staying router-free, not something this block can close without one.
|
|
602
|
+
* The path comes from `storefront.route.path`, which the storefront plugin keeps equal to the
|
|
603
|
+
* router's committed route, so the mark moves on every client-side navigation (a block may not call
|
|
604
|
+
* `useRoute()` itself). Only where there is no router — Storybook, a block spec — is that path empty,
|
|
605
|
+
* and `window.location` with a `popstate` listener stands in.
|
|
588
606
|
*
|
|
589
607
|
* Every `watchEffect` below opens with `if (typeof window === 'undefined') return;`. That is not
|
|
590
608
|
* defensive padding: a `flush: 'pre'` effect with no callback runs its body *immediately*, during
|
|
@@ -603,10 +621,57 @@ watchEffect((onCleanup) => {
|
|
|
603
621
|
window.addEventListener('popstate', onPopState);
|
|
604
622
|
onCleanup(() => window.removeEventListener('popstate', onPopState));
|
|
605
623
|
});
|
|
624
|
+
/**
|
|
625
|
+
* The page's path: the storefront's route (the router's committed route, reactive on every
|
|
626
|
+
* client-side navigation), and `window.location` only where there is no router (Storybook, a spec).
|
|
627
|
+
*/
|
|
628
|
+
const pagePath = computed(() => storefront.route.path || currentPath.value);
|
|
606
629
|
function isCurrent(href: string | null | undefined): boolean {
|
|
607
|
-
return typeof href === 'string' && href ===
|
|
630
|
+
return typeof href === 'string' && href === pagePath.value;
|
|
608
631
|
}
|
|
609
632
|
|
|
633
|
+
/**
|
|
634
|
+
* The page's main category, for the header's one "current" entry. A product page names it through
|
|
635
|
+
* the product's `categoryTrail`, which the storefront walks from the product's primary category
|
|
636
|
+
* (`primaryCategoryId`), so the first-category fallback is not needed; a category page names it by
|
|
637
|
+
* its route, which follows the router; the product is the one this page resolved at setup.
|
|
638
|
+
*/
|
|
639
|
+
// The product handle is captured at setup, as `breadcrumbs` does: this block's page is created
|
|
640
|
+
// fresh against the committed route, and a live handle would make the departing page's header read
|
|
641
|
+
// the product a clicked card points at (a second read the destination already has).
|
|
642
|
+
const routeProductHandle = storefront.route.productHandle;
|
|
643
|
+
const navProduct = storefront.catalog.product(computed(() => routeProductHandle));
|
|
644
|
+
const mainCategoryTrail = computed<string[]>(() => {
|
|
645
|
+
const categoryPath = storefront.route.categoryPath;
|
|
646
|
+
if (categoryPath !== null) {
|
|
647
|
+
const segments = categoryPath.split('/').filter((segment) => segment !== '');
|
|
648
|
+
return segments.map((_, depth) => categoryHref(segments.slice(0, depth + 1).join('/')));
|
|
649
|
+
}
|
|
650
|
+
// Only while the route is still that product's page: once it moves on, its category no longer counts.
|
|
651
|
+
if (routeProductHandle === null || storefront.route.productHandle !== routeProductHandle)
|
|
652
|
+
return [];
|
|
653
|
+
return (navProduct.data.value?.categoryTrail ?? []).map((level) => level.href);
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
function menuHrefs(link: ResolvedLink): (string | null)[] {
|
|
657
|
+
return [
|
|
658
|
+
...link.children.map((child) => child.href),
|
|
659
|
+
...(link.sections ?? []).flatMap((section) => [
|
|
660
|
+
section.headingLink?.href ?? null,
|
|
661
|
+
section.seeAll?.href ?? null,
|
|
662
|
+
...section.links.map((child) => child.href),
|
|
663
|
+
]),
|
|
664
|
+
];
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
/** One mark per top-level entry; at most one is not `undefined`. */
|
|
668
|
+
const currentMarks = computed(() =>
|
|
669
|
+
markCurrent(
|
|
670
|
+
linkEntries.value.map(({ resolved }) => ({ href: resolved.href, menu: menuHrefs(resolved) })),
|
|
671
|
+
{ path: pagePath.value, trail: mainCategoryTrail.value }
|
|
672
|
+
)
|
|
673
|
+
);
|
|
674
|
+
|
|
610
675
|
// --- sticky, scroll padding and scrolled shadow -----------------------------------------------
|
|
611
676
|
|
|
612
677
|
const sticky = computed(() => data.value.sticky !== false);
|
|
@@ -718,7 +783,8 @@ watchEffect((onCleanup) => {
|
|
|
718
783
|
* one place that variable is ever written: a `ResizeObserver` (guarded for an environment with
|
|
719
784
|
* none, e.g. jsdom under Vitest — the same guard `trust-strip`'s own list-overflow measurement
|
|
720
785
|
* uses) keeps the published value equal to the bar's real rendered height, which changes with
|
|
721
|
-
* `sticky`/`variant
|
|
786
|
+
* `sticky`/`variant` and the mobile/tablet/desktop breakpoint — or 0 while the bar
|
|
787
|
+
* is slid out of view (the effect after this one). The property is
|
|
722
788
|
* removed — not just left stale — the moment `sticky` turns off, so a non-sticky header never
|
|
723
789
|
* claims space it doesn't occupy in the page's fixed flow, and on unmount (`onCleanup`), so it
|
|
724
790
|
* never survives past this instance of the block.
|
|
@@ -736,10 +802,9 @@ watchEffect((onCleanup) => {
|
|
|
736
802
|
}
|
|
737
803
|
const el = barRoot.value;
|
|
738
804
|
const publish = (): void => {
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
barHeight.value = height;
|
|
805
|
+
// The same measurement the spacer reserves, so the two can never disagree; the effect below
|
|
806
|
+
// publishes it.
|
|
807
|
+
barHeight.value = el.getBoundingClientRect().height;
|
|
743
808
|
};
|
|
744
809
|
const observer = new ResizeObserver(publish);
|
|
745
810
|
observer.observe(el);
|
|
@@ -750,6 +815,23 @@ watchEffect((onCleanup) => {
|
|
|
750
815
|
barHeight.value = null;
|
|
751
816
|
});
|
|
752
817
|
});
|
|
818
|
+
/**
|
|
819
|
+
* What is published is the bar's **visible** height: its measured height while it shows, `0px`
|
|
820
|
+
* while it is slid out of view (`barHidden`). A reader offsets a sticky box by it to sit under the
|
|
821
|
+
* bar, and a bar that has slid away covers nothing — publishing its full height then left every
|
|
822
|
+
* such box (the collection grid's filter rail and filter bar, `faq`'s head column) hanging a
|
|
823
|
+
* header's height below the viewport's top over an empty strip (WS-1277). The spacer keeps
|
|
824
|
+
* reserving the full `barHeight`, since the page's flow never changes as the bar slides. `sync`,
|
|
825
|
+
* so a resize is published in the observer's own callback, as it was when that callback wrote it.
|
|
826
|
+
*/
|
|
827
|
+
watchEffect(
|
|
828
|
+
() => {
|
|
829
|
+
if (typeof document === 'undefined' || barHeight.value === null) return;
|
|
830
|
+
const visible = barHidden.value ? 0 : barHeight.value;
|
|
831
|
+
document.documentElement.style.setProperty('--eldra-header-height', `${visible}px`);
|
|
832
|
+
},
|
|
833
|
+
{ flush: 'sync' }
|
|
834
|
+
);
|
|
753
835
|
|
|
754
836
|
// --- transparent-over-hero -----------------------------------------------------------------------
|
|
755
837
|
|
|
@@ -875,8 +957,66 @@ const drawerLayout = computed<'accordion' | 'sections'>(() =>
|
|
|
875
957
|
/** More than one currency to shop in. On a phone the picker sits in the menu when there is one. */
|
|
876
958
|
const currency = storefront.currency;
|
|
877
959
|
const hasCurrencies = computed(() => currency.offered.value.length > 1);
|
|
878
|
-
/**
|
|
960
|
+
/**
|
|
961
|
+
* More than one language to read the site in. The language picker sits beside the currency picker,
|
|
962
|
+
* wherever that one would: strip, drawer footer or bar. A site with one locale (or none configured,
|
|
963
|
+
* and every story and unit mount) has no language picker at all; `LocalePicker` checks the same.
|
|
964
|
+
*/
|
|
965
|
+
const hasLocales = computed(() => activeLocale.supported.length > 1);
|
|
966
|
+
/** Something for the visitor to set: a language, a currency, or both. */
|
|
967
|
+
const hasSettings = computed(() => hasCurrencies.value || hasLocales.value);
|
|
968
|
+
/**
|
|
969
|
+
* With an info strip the pickers sit at its end, "EN · Prices in ISK", from 47.625rem up: settings
|
|
970
|
+
* next to Help and Order status rather than boxed controls among the tools. Phones have no room in
|
|
971
|
+
* the strip, so there they are in the drawer's footer (or in the bar, with no drawer).
|
|
972
|
+
*/
|
|
973
|
+
const stripPicker = computed(() => hasInfo.value && hasSettings.value);
|
|
974
|
+
/**
|
|
975
|
+
* The divider before it, wherever the strip's end items show beside it: a hairline 1.25rem before
|
|
976
|
+
* the button, pulled 0.25rem back towards the links so the gap either side of the rule reads even.
|
|
977
|
+
*/
|
|
978
|
+
const stripPickerClass = computed(() => {
|
|
979
|
+
if (infoEnd.value.length === 0) return '';
|
|
980
|
+
const divider = isTransparent.value ? 'border-primary-contrast/24' : 'border-border';
|
|
981
|
+
return infoStart.value.length > 0
|
|
982
|
+
? `@min-[68.8125rem]:-ms-1 @min-[68.8125rem]:border-l @min-[68.8125rem]:ps-5 ${divider}`
|
|
983
|
+
: `-ms-1 border-l ps-5 ${divider}`;
|
|
984
|
+
});
|
|
985
|
+
/**
|
|
986
|
+
* A picker's list is teleported out of the header, so it lifts itself over the fixed bar's own
|
|
987
|
+
* `z-40` (a popover's `z-popover`, 30, sits under it).
|
|
988
|
+
*/
|
|
989
|
+
const PICKER_PANEL_LIFT = 'z-41';
|
|
990
|
+
/**
|
|
991
|
+
* The strip's picker reads as a setting in the strip, not as a field: no box, the strip's own size,
|
|
992
|
+
* the words in `text` with the code bold, an underline under the words on hover. Its list is a
|
|
993
|
+
* 17rem card under the button's end: each row the currency's name, its code muted beside it and
|
|
994
|
+
* the check, the chosen row on `surface-strong`. Its padding is the header's dropdown menus' own
|
|
995
|
+
* (0.5rem at the top and sides, 0.75rem below), counting the `0.25rem` the list adds inside it.
|
|
996
|
+
*/
|
|
997
|
+
const stripPickerClasses = computed(() => ({
|
|
998
|
+
trigger: [
|
|
999
|
+
'h-9 min-h-9 w-auto gap-1.5 rounded-sm border-0 bg-transparent px-1 text-[0.8125rem] shadow-none hover:bg-transparent',
|
|
1000
|
+
isTransparent.value ? 'text-current' : 'text-text',
|
|
1001
|
+
'[&:hover_[data-eldra-header-setting-words]]:underline underline-offset-[0.2em]',
|
|
1002
|
+
// Open from a pointer it is a setting, not a field: no ring. A keyboard keeps its ring.
|
|
1003
|
+
'aria-expanded:not-focus-visible:[--eldra-focus-alpha:0]',
|
|
1004
|
+
].join(' '),
|
|
1005
|
+
leadingIcon: 'size-4',
|
|
1006
|
+
value: 'overflow-visible',
|
|
1007
|
+
chevron:
|
|
1008
|
+
'size-3.5 text-current motion-safe:transition-[rotate] motion-safe:duration-fast [[aria-expanded=true]_&]:rotate-180',
|
|
1009
|
+
panel: `${PICKER_PANEL_LIFT} w-68 rounded-lg border-border bg-background px-1 pt-1 pb-2 text-[0.9375rem] shadow-md`,
|
|
1010
|
+
option:
|
|
1011
|
+
'min-h-11 gap-3 rounded-md px-3 text-[0.9375rem] hover:bg-surface aria-selected:bg-surface-strong aria-selected:font-semibold',
|
|
1012
|
+
optionCheck: 'size-5 text-primary',
|
|
1013
|
+
}));
|
|
1014
|
+
/**
|
|
1015
|
+
* The bar's picker: without a strip, only where the links are inline (with a drawer it lives in the
|
|
1016
|
+
* drawer's footer); with a strip, only on a phone with no drawer to hold it.
|
|
1017
|
+
*/
|
|
879
1018
|
const barPickerClass = computed(() => {
|
|
1019
|
+
if (stripPicker.value) return drawerHasContent.value ? 'hidden' : 'ml-1 @min-[47.625rem]:hidden';
|
|
880
1020
|
if (!drawerHasContent.value) return 'ml-1';
|
|
881
1021
|
return variant.value === 'minimal' ? 'hidden' : '@min-[68.8125rem]:block ml-1 hidden';
|
|
882
1022
|
});
|
|
@@ -884,12 +1024,20 @@ const showLinksPlaceholder = computed(
|
|
|
884
1024
|
() => isEditing.value && variant.value !== 'minimal' && links.value.length === 0
|
|
885
1025
|
);
|
|
886
1026
|
|
|
887
|
-
/** The Menu tool's accessible name is its visible label (WCAG 2.5.3)
|
|
1027
|
+
/** The Menu tool's accessible name is its visible label (WCAG 2.5.3): Menu, and Close while the
|
|
1028
|
+
* menu is open under the bar. */
|
|
888
1029
|
const navMenuMessages = computed<Partial<UiMessages>>(() => ({
|
|
889
1030
|
navMenuOpen: t('header.menu'),
|
|
890
1031
|
navMenuDrawer: t('header.menu'),
|
|
1032
|
+
close: t('header.close'),
|
|
891
1033
|
}));
|
|
892
1034
|
|
|
1035
|
+
/** A drawer footer row's icon: its own, else a phone for a `tel:` number. */
|
|
1036
|
+
function footerIcon(item: InfoEntry): string | undefined {
|
|
1037
|
+
if (item.icon) return item.icon;
|
|
1038
|
+
return item.href?.startsWith('tel:') === true ? 'phone' : undefined;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
893
1041
|
/**
|
|
894
1042
|
* The bar's grid. Below 68.8125rem (and at every width in `minimal`) it is six tracks —
|
|
895
1043
|
* `Menu | Search | 1fr | brand | 1fr | Saved+Cart` — and because the tools are one fixed width and the
|
|
@@ -942,10 +1090,12 @@ const toolSpacerClass = computed(() =>
|
|
|
942
1090
|
: `${TOOL_WIDTH_CLASSES} @min-[68.8125rem]:hidden`
|
|
943
1091
|
);
|
|
944
1092
|
|
|
945
|
-
/**
|
|
946
|
-
*
|
|
947
|
-
|
|
948
|
-
|
|
1093
|
+
/**
|
|
1094
|
+
* Dropdown panels and mega panels share `NavMenu`'s `panel` and `content` parts, each marked with
|
|
1095
|
+
* its `data-layout`; a link inside one is styled through `in-data-[layout=…]:`. Every rule below
|
|
1096
|
+
* that differs between the two is written once per layout, so no element carries two values for
|
|
1097
|
+
* one property — and written out in full, since Tailwind only generates a class it can read.
|
|
1098
|
+
*/
|
|
949
1099
|
/** What this header draws differently from `NavMenu`'s own look, part by part. */
|
|
950
1100
|
const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
951
1101
|
nav: `@max-[68.8125rem]:hidden self-stretch ${linksPositionClass.value}`,
|
|
@@ -954,20 +1104,27 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
954
1104
|
? 'h-full flex-nowrap justify-center gap-0.5'
|
|
955
1105
|
: 'h-full flex-nowrap gap-0.5',
|
|
956
1106
|
// The design's pill entries: 2.75rem tall, full radius, `surface` on hover and while open, the
|
|
957
|
-
// current page on `surface-strong`.
|
|
958
|
-
|
|
1107
|
+
// current page on `surface-strong`. The pill marks the current page, so the package's underline
|
|
1108
|
+
// for it is turned off here, as on `trigger`. An entry that only holds the page (`aria-current=true`)
|
|
1109
|
+
// gets the same pill. An accent entry (`tone`) keeps its colour.
|
|
1110
|
+
link: 'min-h-11 rounded-full px-3 text-base font-medium hover:bg-surface aria-[current=page]:no-underline aria-[current=page]:bg-surface-strong aria-[current=true]:no-underline aria-[current=true]:bg-surface-strong',
|
|
959
1111
|
trigger:
|
|
960
1112
|
'min-h-11 rounded-full px-3 text-base font-medium hover:bg-surface aria-expanded:bg-surface data-current:no-underline data-current:bg-surface-strong',
|
|
961
1113
|
// The Menu tool: shown below 68.8125rem (the package hides it from `@content`), a labelled tool
|
|
962
1114
|
// like its neighbours.
|
|
963
1115
|
toggle: `${TOOL_CLASSES} @max-[68.8125rem]:inline-flex col-start-1 row-start-1 max-md:size-auto rounded-md`,
|
|
964
|
-
// A mega panel hangs from the whole header (its positioning box), full-bleed,
|
|
965
|
-
//
|
|
966
|
-
|
|
1116
|
+
// A mega panel hangs from the whole header (its positioning box), full-bleed, flush under the
|
|
1117
|
+
// bar; a dropdown hangs 0.5rem under its trigger — padding, not a margin, so the pointer crossing
|
|
1118
|
+
// the gap is still over the menu.
|
|
1119
|
+
panel: `data-[layout=mega]:pt-0 data-[layout=dropdown]:pt-2`,
|
|
967
1120
|
content: [
|
|
968
|
-
'
|
|
969
|
-
'
|
|
970
|
-
|
|
1121
|
+
// The design's panel shadow is a deep, soft one under the sheet: the theme's `md` shadow.
|
|
1122
|
+
'border-border bg-(--eldra-header-surface) shadow-md',
|
|
1123
|
+
// Mega: a square sheet with a bottom rule, 2rem above and below, the page's gutters at the sides.
|
|
1124
|
+
`data-[layout=mega]:rounded-none data-[layout=mega]:border-0 data-[layout=mega]:border-b data-[layout=mega]:py-8`,
|
|
1125
|
+
`data-[layout=mega]:px-(--eldra-gutter-mobile) data-[layout=mega]:@tablet:px-(--eldra-gutter-tablet) data-[layout=mega]:@content:px-(--eldra-gutter-desktop)`,
|
|
1126
|
+
// Dropdown: a 21rem rounded card, 0.5rem inside (0.75rem at the foot).
|
|
1127
|
+
`data-[layout=dropdown]:w-[21rem] data-[layout=dropdown]:rounded-lg data-[layout=dropdown]:border data-[layout=dropdown]:px-2 data-[layout=dropdown]:pt-2 data-[layout=dropdown]:pb-3`,
|
|
971
1128
|
].join(' '),
|
|
972
1129
|
// Link columns in equal tracks; a column of cards spans two of them. Inside the wide container.
|
|
973
1130
|
columns:
|
|
@@ -977,48 +1134,59 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
977
1134
|
groupHeading:
|
|
978
1135
|
'font-heading px-0 pb-3 text-xl leading-tight font-medium tracking-normal normal-case text-text',
|
|
979
1136
|
groupLink: 'text-text no-underline hover:underline underline-offset-[0.2em]',
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
// with its title in `text` and a `surface` hover.
|
|
1137
|
+
// Two cards side by side, 1rem apart; a column of links nearly touching; a dropdown's rows flush.
|
|
1138
|
+
panelList: `gap-0.5 [[data-cards]>&]:gap-4 in-data-[layout=dropdown]:gap-0`,
|
|
983
1139
|
panelLink: [
|
|
984
|
-
|
|
985
|
-
|
|
1140
|
+
// Mega: quiet links that underline on hover; a card's link underlines only its title.
|
|
1141
|
+
`in-data-[layout=mega]:px-0 in-data-[layout=mega]:py-1.5 in-data-[layout=mega]:text-muted in-data-[layout=mega]:hover:bg-transparent in-data-[layout=mega]:hover:text-text`,
|
|
1142
|
+
`in-data-[layout=mega]:hover:underline underline-offset-[0.2em] has-data-[part=card]:py-0 has-data-[part=card]:hover:no-underline`,
|
|
1143
|
+
// Dropdown: padded rows, the title in `text`, `surface` on hover.
|
|
1144
|
+
`in-data-[layout=dropdown]:px-3 in-data-[layout=dropdown]:py-2.5 in-data-[layout=dropdown]:text-text in-data-[layout=dropdown]:hover:bg-surface`,
|
|
986
1145
|
// The column's "see all": primary, semibold, with an arrow.
|
|
987
1146
|
'data-see-all:mt-2 data-see-all:text-[0.9375rem] data-see-all:font-semibold data-see-all:text-primary',
|
|
988
|
-
// In a dropdown it lines up with the
|
|
989
|
-
|
|
1147
|
+
// In a dropdown it lines up with the rows' text, a 2.25rem line under them that underlines.
|
|
1148
|
+
`in-data-[layout=dropdown]:data-see-all:mt-1 in-data-[layout=dropdown]:data-see-all:min-h-9 in-data-[layout=dropdown]:data-see-all:justify-center in-data-[layout=dropdown]:data-see-all:py-0`,
|
|
1149
|
+
`in-data-[layout=dropdown]:data-see-all:hover:bg-transparent in-data-[layout=dropdown]:data-see-all:hover:underline`,
|
|
990
1150
|
].join(' '),
|
|
991
|
-
panelLabel: `gap-x-2 text-base font-normal in-data-see-all:font-semibold in-data-see-all:after:
|
|
992
|
-
description: 'text-sm leading-
|
|
1151
|
+
panelLabel: `gap-x-2 text-base font-normal in-data-[layout=dropdown]:font-semibold in-data-see-all:text-[0.9375rem] in-data-see-all:font-semibold in-data-see-all:relative in-data-see-all:w-fit in-data-see-all:after:absolute in-data-see-all:after:start-full in-data-see-all:after:ms-2 in-data-see-all:after:content-['→']`,
|
|
1152
|
+
description: 'text-sm leading-[1.4]',
|
|
993
1153
|
badge:
|
|
994
1154
|
'min-h-0 rounded-sm bg-accent px-1.5 py-0 text-[0.6875rem] leading-[1.4] font-bold tracking-[0.04em] text-accent-contrast',
|
|
995
|
-
// Cards: the picture, a semibold title and the price
|
|
1155
|
+
// Cards: the picture (rounded, on `surface` while it loads), a semibold title and the price
|
|
1156
|
+
// under it in `muted`.
|
|
996
1157
|
card: 'gap-2',
|
|
997
1158
|
cardImage: 'rounded-lg',
|
|
998
|
-
cardTitle: 'text-base leading-
|
|
999
|
-
cardPrice: 'text-[0.9375rem]',
|
|
1159
|
+
cardTitle: 'text-base leading-[1.3] font-semibold [a:hover_&]:underline underline-offset-[0.2em]',
|
|
1160
|
+
cardPrice: 'mt-0.5 text-[0.9375rem]',
|
|
1000
1161
|
footer:
|
|
1001
1162
|
'mx-auto w-full max-w-[calc(var(--eldra-container-wide)-2*var(--eldra-gutter-desktop))] justify-end border-0 pt-2',
|
|
1002
|
-
// The drawer: serif rows, section headings as small capitals, links at body
|
|
1163
|
+
// The inline drawer: serif rows with chevrons, section headings as small capitals, links at body
|
|
1164
|
+
// size; from 37.5rem its columns sit two abreast and a column of cards spans both, four across.
|
|
1003
1165
|
drawerBody: 'px-0 pt-0',
|
|
1004
1166
|
drawerLink: 'font-heading min-h-14 px-4 text-xl font-normal',
|
|
1005
1167
|
drawerTrigger:
|
|
1006
1168
|
'min-h-14 px-4 py-3 hover:no-underline [&_[data-part=title]]:font-heading [&_[data-part=title]]:text-xl [&_[data-part=title]]:font-normal [&_[data-part=title]]:no-underline',
|
|
1007
|
-
|
|
1169
|
+
// A section's heading row links to its page, with an arrow at the end in place of a chevron.
|
|
1170
|
+
drawerSectionHeading:
|
|
1171
|
+
"font-heading min-h-14 px-4 py-0 text-xl font-normal after:ms-auto after:font-body after:text-muted after:content-['→']",
|
|
1172
|
+
drawerItem: 'pb-0',
|
|
1008
1173
|
drawerPanel: 'pb-0',
|
|
1009
|
-
drawerNest: 'ms-0 border-s-0 px-4 pb-5',
|
|
1010
|
-
drawerColumns: 'gap-5',
|
|
1174
|
+
drawerNest: 'ms-0 border-s-0 px-4 pt-1 pb-5',
|
|
1175
|
+
drawerColumns: 'gap-5 @min-[37.5rem]:grid @min-[37.5rem]:grid-cols-2 @min-[37.5rem]:gap-x-8',
|
|
1176
|
+
drawerGroup: '@min-[37.5rem]:data-cards:col-span-full',
|
|
1011
1177
|
drawerGroupHeading: 'px-0 pb-1 text-xs font-bold tracking-[0.12em] uppercase text-muted',
|
|
1012
1178
|
drawerGroupLink: 'text-muted no-underline hover:underline',
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1179
|
+
drawerPanelList: '[[data-cards]>&]:gap-3 @min-[37.5rem]:[[data-cards]>&]:grid-cols-4',
|
|
1180
|
+
// Links at 1.0625rem with 0.5rem above and below; the "see all" smaller, tucked under them.
|
|
1181
|
+
drawerPanelLink: 'py-2 data-see-all:mt-0 data-see-all:py-1 data-see-all:text-primary',
|
|
1182
|
+
drawerPanelLabel: `text-[1.0625rem] font-normal in-data-see-all:text-[0.9375rem] in-data-see-all:font-semibold in-data-see-all:relative in-data-see-all:w-fit in-data-see-all:after:absolute in-data-see-all:after:start-full in-data-see-all:after:ms-2 in-data-see-all:after:content-['→']`,
|
|
1016
1183
|
drawerBadge:
|
|
1017
1184
|
'min-h-0 rounded-sm bg-accent px-1.5 py-0 text-[0.6875rem] leading-[1.4] font-bold tracking-[0.04em] text-accent-contrast',
|
|
1018
|
-
|
|
1185
|
+
// Square pictures in the drawer, whatever the bar's crop.
|
|
1186
|
+
drawerCardImage: 'rounded-lg aspect-square',
|
|
1019
1187
|
drawerCardTitle: 'font-semibold',
|
|
1020
|
-
|
|
1021
|
-
|
|
1188
|
+
// The foot, on `surface`: account, saved items, the strip's own links and the currency.
|
|
1189
|
+
drawerFooter: 'gap-3 px-4 pt-5 text-[0.9375rem]',
|
|
1022
1190
|
}));
|
|
1023
1191
|
</script>
|
|
1024
1192
|
|
|
@@ -1073,33 +1241,91 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
1073
1241
|
<span v-else>{{ item.text }}</span>
|
|
1074
1242
|
</li>
|
|
1075
1243
|
</ul>
|
|
1076
|
-
<
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1244
|
+
<div
|
|
1245
|
+
v-if="infoEnd.length > 0 || stripPicker"
|
|
1246
|
+
data-eldra-header-info-end
|
|
1247
|
+
class="flex items-center gap-4"
|
|
1248
|
+
>
|
|
1249
|
+
<ul v-if="infoEnd.length > 0" :class="['m-0 flex list-none gap-6 p-0', infoEndClass]">
|
|
1250
|
+
<li
|
|
1251
|
+
v-for="(item, index) in infoEnd"
|
|
1252
|
+
:key="`end-${index}`"
|
|
1253
|
+
:class="[
|
|
1254
|
+
'inline-flex items-center gap-1.5',
|
|
1255
|
+
infoStart.length > 0 ? '' : infoItemClass(index),
|
|
1256
|
+
]"
|
|
1257
|
+
>
|
|
1258
|
+
<EldraIcon
|
|
1259
|
+
v-if="item.icon"
|
|
1260
|
+
:name="item.icon"
|
|
1261
|
+
size="sm"
|
|
1262
|
+
:class="['size-4', isTransparent ? '' : 'text-primary']"
|
|
1263
|
+
/>
|
|
1264
|
+
<Link
|
|
1265
|
+
v-if="item.href"
|
|
1266
|
+
:href="item.href"
|
|
1267
|
+
:as="item.linkAs"
|
|
1268
|
+
variant="standalone"
|
|
1269
|
+
:underline="false"
|
|
1270
|
+
:class="['font-normal', isTransparent ? 'text-current' : 'text-text']"
|
|
1271
|
+
>{{ item.text }}</Link
|
|
1272
|
+
>
|
|
1273
|
+
<span v-else>{{ item.text }}</span>
|
|
1274
|
+
</li>
|
|
1275
|
+
</ul>
|
|
1276
|
+
<div
|
|
1277
|
+
v-if="stripPicker"
|
|
1278
|
+
data-eldra-header-currency
|
|
1279
|
+
:class="['flex items-center gap-3 @max-[47.5625rem]:hidden', stripPickerClass]"
|
|
1084
1280
|
>
|
|
1085
|
-
<
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1281
|
+
<LocalePicker :label="t('header.language')" :classes="stripPickerClasses">
|
|
1282
|
+
<template #leading
|
|
1283
|
+
><EldraIcon
|
|
1284
|
+
name="language"
|
|
1285
|
+
size="sm"
|
|
1286
|
+
:class="['size-4', isTransparent ? '' : 'text-primary']"
|
|
1287
|
+
/></template>
|
|
1288
|
+
<template #value="{ code }"
|
|
1289
|
+
><span data-eldra-header-setting-words
|
|
1290
|
+
><b class="font-semibold">{{ code }}</b></span
|
|
1291
|
+
></template
|
|
1292
|
+
>
|
|
1293
|
+
<template #optionContent="{ code, label }">
|
|
1294
|
+
<span class="min-w-0 flex-1">{{ label }}</span>
|
|
1295
|
+
<small class="text-muted text-[0.8125rem] font-medium tracking-[0.04em]">{{
|
|
1296
|
+
code
|
|
1297
|
+
}}</small>
|
|
1298
|
+
</template>
|
|
1299
|
+
</LocalePicker>
|
|
1300
|
+
<CurrencyPicker
|
|
1301
|
+
:locale="contentLocale"
|
|
1302
|
+
:currencies="currency.offered.value"
|
|
1303
|
+
:model-value="currency.active.value"
|
|
1304
|
+
:busy="currency.busy.value"
|
|
1305
|
+
:label="t('header.pricesIn')"
|
|
1306
|
+
:classes="stripPickerClasses"
|
|
1307
|
+
@update:model-value="currency.choose"
|
|
1099
1308
|
>
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1309
|
+
<template #leading
|
|
1310
|
+
><EldraIcon
|
|
1311
|
+
name="world"
|
|
1312
|
+
size="sm"
|
|
1313
|
+
:class="['size-4', isTransparent ? '' : 'text-primary']"
|
|
1314
|
+
/></template>
|
|
1315
|
+
<template #value="{ code }"
|
|
1316
|
+
><span data-eldra-header-setting-words
|
|
1317
|
+
>{{ t('header.pricesIn') }} <b class="font-semibold">{{ code }}</b></span
|
|
1318
|
+
></template
|
|
1319
|
+
>
|
|
1320
|
+
<template #optionContent="{ code, currencyName }">
|
|
1321
|
+
<span class="min-w-0 flex-1">{{ currencyName }}</span>
|
|
1322
|
+
<small class="text-muted text-[0.8125rem] font-medium tracking-[0.04em]">{{
|
|
1323
|
+
code
|
|
1324
|
+
}}</small>
|
|
1325
|
+
</template>
|
|
1326
|
+
</CurrencyPicker>
|
|
1327
|
+
</div>
|
|
1328
|
+
</div>
|
|
1103
1329
|
</Container>
|
|
1104
1330
|
</div>
|
|
1105
1331
|
|
|
@@ -1151,16 +1377,17 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
1151
1377
|
:aria-label="t('header.primary')"
|
|
1152
1378
|
:collapse-below="variant === 'minimal' ? 'always' : '@content'"
|
|
1153
1379
|
:drawer-layout="drawerLayout"
|
|
1154
|
-
|
|
1380
|
+
drawer-mode="inline"
|
|
1155
1381
|
:link-as="MenuLink"
|
|
1156
1382
|
:card-aspect="cardAspect"
|
|
1157
1383
|
:messages="navMenuMessages"
|
|
1158
1384
|
class="static contents"
|
|
1159
1385
|
:classes="navMenuClasses"
|
|
1160
1386
|
>
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
<
|
|
1387
|
+
<!-- Menu, and Close with an × while the menu is open under the bar. -->
|
|
1388
|
+
<template #toggle="{ open }">
|
|
1389
|
+
<EldraIcon :name="open ? 'x' : 'menu-2'" size="md" :class="TOOL_ICON_CLASSES" />
|
|
1390
|
+
<span class="whitespace-nowrap">{{ open ? t('header.close') : t('header.menu') }}</span>
|
|
1164
1391
|
</template>
|
|
1165
1392
|
<template #panelFooter="{ item, index }">
|
|
1166
1393
|
<Link
|
|
@@ -1177,11 +1404,13 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
1177
1404
|
{{ t('header.viewAll') }}
|
|
1178
1405
|
</Link>
|
|
1179
1406
|
</template>
|
|
1407
|
+
<!-- The foot, on `surface`: Account, Saved items, the strip's own links (its phone line
|
|
1408
|
+
among them) and, under a rule, the currency as a labelled select. -->
|
|
1180
1409
|
<template #drawerFooter="{ close }">
|
|
1181
1410
|
<ul
|
|
1182
1411
|
v-if="accountHref || variant !== 'minimal' || infoEndLinks.length > 0"
|
|
1183
1412
|
data-eldra-header-drawer-links
|
|
1184
|
-
class="m-0 grid list-none gap-3 p-0
|
|
1413
|
+
class="m-0 grid list-none gap-3 p-0"
|
|
1185
1414
|
>
|
|
1186
1415
|
<li v-if="accountHref">
|
|
1187
1416
|
<Link
|
|
@@ -1219,20 +1448,64 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
1219
1448
|
:classes="{ label: 'inline-flex items-center gap-2' }"
|
|
1220
1449
|
@click="close"
|
|
1221
1450
|
>
|
|
1222
|
-
<EldraIcon v-if="item
|
|
1451
|
+
<EldraIcon v-if="footerIcon(item)" :name="footerIcon(item)!" size="md" />{{
|
|
1452
|
+
item.text
|
|
1453
|
+
}}
|
|
1223
1454
|
</Link>
|
|
1224
1455
|
</li>
|
|
1225
1456
|
</ul>
|
|
1226
|
-
<
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
:
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1457
|
+
<div
|
|
1458
|
+
v-if="hasSettings"
|
|
1459
|
+
data-eldra-header-drawer-currency
|
|
1460
|
+
:class="[
|
|
1461
|
+
'grid gap-4',
|
|
1462
|
+
accountHref || variant !== 'minimal' || infoEndLinks.length > 0
|
|
1463
|
+
? 'border-border border-t pt-3'
|
|
1464
|
+
: '',
|
|
1465
|
+
]"
|
|
1466
|
+
>
|
|
1467
|
+
<LocalePicker
|
|
1468
|
+
:label="t('header.language')"
|
|
1469
|
+
show-label
|
|
1470
|
+
size="md"
|
|
1471
|
+
placement="above"
|
|
1472
|
+
class="w-full"
|
|
1473
|
+
:classes="{
|
|
1474
|
+
label: 'text-text mb-0 inline-flex items-center gap-2 font-medium',
|
|
1475
|
+
panel: PICKER_PANEL_LIFT,
|
|
1476
|
+
}"
|
|
1477
|
+
>
|
|
1478
|
+
<template #label
|
|
1479
|
+
><EldraIcon name="language" size="md" class="text-primary" />{{
|
|
1480
|
+
t('header.language')
|
|
1481
|
+
}}</template
|
|
1482
|
+
>
|
|
1483
|
+
<template #value="{ label }">{{ label }}</template>
|
|
1484
|
+
</LocalePicker>
|
|
1485
|
+
<CurrencyPicker
|
|
1486
|
+
:locale="contentLocale"
|
|
1487
|
+
:currencies="currency.offered.value"
|
|
1488
|
+
:model-value="currency.active.value"
|
|
1489
|
+
:busy="currency.busy.value"
|
|
1490
|
+
:label="t('header.pricesIn')"
|
|
1491
|
+
show-label
|
|
1492
|
+
size="md"
|
|
1493
|
+
placement="above"
|
|
1494
|
+
class="w-full"
|
|
1495
|
+
:classes="{
|
|
1496
|
+
label: 'text-text mb-0 inline-flex items-center gap-2 font-medium',
|
|
1497
|
+
panel: PICKER_PANEL_LIFT,
|
|
1498
|
+
}"
|
|
1499
|
+
@update:model-value="currency.choose"
|
|
1500
|
+
>
|
|
1501
|
+
<template #label
|
|
1502
|
+
><EldraIcon name="world" size="md" class="text-primary" />{{
|
|
1503
|
+
t('header.pricesIn')
|
|
1504
|
+
}}</template
|
|
1505
|
+
>
|
|
1506
|
+
<template #value="{ label }">{{ label }}</template>
|
|
1507
|
+
</CurrencyPicker>
|
|
1508
|
+
</div>
|
|
1236
1509
|
<Button
|
|
1237
1510
|
v-if="hasCta"
|
|
1238
1511
|
variant="primary"
|
|
@@ -1260,46 +1533,12 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
1260
1533
|
|
|
1261
1534
|
<div :class="['flex items-center', searchPositionClass]">
|
|
1262
1535
|
<template v-if="showSearch">
|
|
1263
|
-
<!--
|
|
1264
|
-
`inline`: the live search bar, centered variant only, from 68.8125rem. `icon`: the
|
|
1265
|
-
labelled tool at every width. All but the live bar open the search overlay. -->
|
|
1266
|
-
<Button
|
|
1267
|
-
v-if="searchStyle === 'field'"
|
|
1268
|
-
variant="ghost"
|
|
1269
|
-
size="md"
|
|
1270
|
-
aria-haspopup="dialog"
|
|
1271
|
-
class="bg-surface text-muted hover:border-border-strong hover:bg-surface @wide:inline-flex hidden w-60 justify-start gap-2.5 rounded-full border border-transparent px-3.5 font-normal"
|
|
1272
|
-
:classes="{ label: 'text-base' }"
|
|
1273
|
-
@click="openSearch"
|
|
1274
|
-
>
|
|
1275
|
-
<template #leadingIcon>
|
|
1276
|
-
<EldraIcon name="search" size="md" class="size-[1.125rem]" />
|
|
1277
|
-
</template>
|
|
1278
|
-
{{ t('header.searchField') }}
|
|
1279
|
-
</Button>
|
|
1280
|
-
<SearchBar
|
|
1281
|
-
v-else-if="searchStyle === 'inline'"
|
|
1282
|
-
v-model="searchQuery"
|
|
1283
|
-
size="md"
|
|
1284
|
-
pill
|
|
1285
|
-
:action="searchAction"
|
|
1286
|
-
:label="t('header.searchField')"
|
|
1287
|
-
:results="searchResults"
|
|
1288
|
-
:loading="searchLoading"
|
|
1289
|
-
class="hidden w-64 @min-[68.8125rem]:block"
|
|
1290
|
-
/>
|
|
1536
|
+
<!-- A labelled Search button at every width; it opens the search overlay. -->
|
|
1291
1537
|
<Button
|
|
1292
1538
|
variant="ghost"
|
|
1293
1539
|
size="sm"
|
|
1294
1540
|
aria-haspopup="dialog"
|
|
1295
|
-
:class="
|
|
1296
|
-
TOOL_CLASSES,
|
|
1297
|
-
searchStyle === 'field'
|
|
1298
|
-
? '@wide:hidden'
|
|
1299
|
-
: searchStyle === 'inline'
|
|
1300
|
-
? '@min-[68.8125rem]:hidden'
|
|
1301
|
-
: '',
|
|
1302
|
-
]"
|
|
1541
|
+
:class="TOOL_CLASSES"
|
|
1303
1542
|
@click="openSearch"
|
|
1304
1543
|
>
|
|
1305
1544
|
<template #leadingIcon>
|
|
@@ -1389,10 +1628,17 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
1389
1628
|
/>
|
|
1390
1629
|
</span>
|
|
1391
1630
|
|
|
1631
|
+
<LocalePicker
|
|
1632
|
+
:label="t('header.language')"
|
|
1633
|
+
:classes="{ panel: PICKER_PANEL_LIFT }"
|
|
1634
|
+
:class="barPickerClass"
|
|
1635
|
+
/>
|
|
1392
1636
|
<CurrencyPicker
|
|
1637
|
+
:locale="contentLocale"
|
|
1393
1638
|
:currencies="currency.offered.value"
|
|
1394
1639
|
:model-value="currency.active.value"
|
|
1395
1640
|
:busy="currency.busy.value"
|
|
1641
|
+
:classes="{ panel: PICKER_PANEL_LIFT }"
|
|
1396
1642
|
:class="barPickerClass"
|
|
1397
1643
|
@update:model-value="currency.choose"
|
|
1398
1644
|
/>
|