@eldrajs/theme-cli 0.2.8 → 0.2.10
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 +3 -1
- package/package.json +1 -1
- package/template/.eldra/block-types.d.ts +28 -7
- package/template/.eldra/manifest.json +1034 -355
- package/template/.eldra/previews.json +35 -35
- package/template/README.md +32 -0
- package/template/app/assets/main.css +23 -0
- package/template/app/plugins/eldra-storefront.ts +3 -0
- package/template/app/storefront/demo.ts +75 -24
- package/template/app/storefront/gateway.ts +16 -2
- package/template/blocks/announcement-bar/preview.png +0 -0
- package/template/blocks/article/preview.json +4 -4
- package/template/blocks/article/preview.png +0 -0
- package/template/blocks/article-list/Block.vue +48 -19
- package/template/blocks/article-list/__tests__/Block.spec.ts +15 -0
- package/template/blocks/article-list/preview.json +43 -43
- package/template/blocks/article-list/preview.png +0 -0
- package/template/blocks/breadcrumbs/preview.png +0 -0
- package/template/blocks/cart/preview.png +0 -0
- package/template/blocks/collection-grid/Block.vue +260 -9
- package/template/blocks/collection-grid/__tests__/Block.spec.ts +202 -0
- package/template/blocks/collection-grid/block.json +3 -3
- package/template/blocks/collection-grid/preview.png +0 -0
- package/template/blocks/collection-header/Block.vue +82 -58
- package/template/blocks/collection-header/__tests__/Block.spec.ts +77 -1
- package/template/blocks/collection-header/preview.json +4 -4
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/preview.json +4 -4
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/Block.vue +73 -4
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +43 -1
- package/template/blocks/feature-grid/block.json +2 -2
- package/template/blocks/feature-grid/preview.json +49 -24
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +186 -71
- package/template/blocks/footer/__tests__/Block.spec.ts +127 -32
- package/template/blocks/footer/block.json +42 -4
- package/template/blocks/footer/mock.json +31 -34
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/preview.png +0 -0
- package/template/blocks/gallery/preview.json +24 -24
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +117 -19
- package/template/blocks/hero/__tests__/Block.spec.ts +46 -0
- package/template/blocks/hero/block.json +36 -1
- package/template/blocks/hero/preview.json +33 -25
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/preview.json +4 -4
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +623 -184
- package/template/blocks/navigation/__tests__/Block.spec.ts +416 -68
- package/template/blocks/navigation/__tests__/fixtures/menu.json +182 -0
- package/template/blocks/navigation/block.json +102 -6
- package/template/blocks/navigation/mock.json +279 -52
- package/template/blocks/navigation/preview.json +311 -0
- package/template/blocks/navigation/preview.png +0 -0
- package/template/blocks/newsletter/Block.vue +248 -144
- package/template/blocks/newsletter/__tests__/Block.spec.ts +42 -0
- package/template/blocks/newsletter/block.json +61 -2
- package/template/blocks/newsletter/preview.json +35 -0
- package/template/blocks/newsletter/preview.png +0 -0
- package/template/blocks/order-status/preview.png +0 -0
- package/template/blocks/pricing-table/preview.png +0 -0
- package/template/blocks/product-carousel/Block.vue +272 -26
- package/template/blocks/product-carousel/__tests__/Block.spec.ts +90 -0
- package/template/blocks/product-carousel/block.json +61 -0
- package/template/blocks/product-carousel/preview.json +12 -0
- package/template/blocks/product-carousel/preview.png +0 -0
- package/template/blocks/product-detail/Block.vue +148 -96
- package/template/blocks/product-detail/__tests__/Block.spec.ts +98 -74
- package/template/blocks/product-detail/block.json +11 -4
- package/template/blocks/product-detail/mock.json +53 -22
- package/template/blocks/product-detail/parts/Gallery.vue +52 -103
- package/template/blocks/product-detail/preview.png +0 -0
- package/template/blocks/quote/preview.png +0 -0
- package/template/blocks/rich-text/preview.png +0 -0
- package/template/blocks/search/Block.vue +1 -0
- package/template/blocks/search/TypeSection.vue +1 -0
- package/template/blocks/search/__tests__/Block.spec.ts +23 -0
- package/template/blocks/search/preview.png +0 -0
- package/template/blocks/split-content/Block.vue +98 -20
- package/template/blocks/split-content/__tests__/Block.spec.ts +57 -18
- package/template/blocks/split-content/block.json +72 -6
- package/template/blocks/split-content/preview.json +34 -13
- package/template/blocks/split-content/preview.png +0 -0
- package/template/blocks/stats/preview.png +0 -0
- package/template/blocks/tabs/preview.json +16 -16
- package/template/blocks/tabs/preview.png +0 -0
- package/template/blocks/team/preview.png +0 -0
- package/template/blocks/testimonials/preview.png +0 -0
- package/template/blocks/timeline/preview.png +0 -0
- package/template/blocks/trust-strip/Block.vue +67 -1
- package/template/blocks/trust-strip/__tests__/Block.spec.ts +30 -1
- package/template/blocks/trust-strip/block.json +4 -4
- package/template/blocks/trust-strip/preview.json +21 -0
- package/template/blocks/trust-strip/preview.png +0 -0
- package/template/blocks/video-embed/preview.png +0 -0
- package/template/blocks/wishlist/preview.png +0 -0
- package/template/i18n/en-US.json +16 -9
- package/template/i18n/is-IS.json +16 -9
- package/template/pages/article.page.json +19 -18
- package/template/pages/cart.page.json +3 -13
- package/template/pages/category.page.json +15 -7
- package/template/pages/collection.page.json +15 -14
- package/template/pages/home.page.json +217 -182
- package/template/pages/product.page.json +46 -36
- package/template/pages/products.page.json +3 -13
- package/template/pages/search.page.json +3 -13
- package/template/pages/wishlist.page.json +3 -13
- package/template/public/images/CREDITS.md +28 -0
- package/template/public/images/clay-hands.webp +0 -0
- package/template/public/images/coffee-table.webp +0 -0
- package/template/public/images/cup.webp +0 -0
- package/template/public/images/enamel-cups.webp +0 -0
- package/template/public/images/hero.webp +0 -0
- package/template/public/images/kitchen.webp +0 -0
- package/template/public/images/mug.webp +0 -0
- package/template/public/images/northwind-mark.svg +1 -0
- package/template/public/images/planters.webp +0 -0
- package/template/public/images/plates.webp +0 -0
- package/template/public/images/reading.webp +0 -0
- package/template/public/images/sweater.webp +0 -0
- package/template/public/images/terracotta.webp +0 -0
- package/template/public/images/throws.webp +0 -0
- package/template/public/images/vase.webp +0 -0
- package/template/public/images/wheel.webp +0 -0
- package/template/public/images/yarn-tools.webp +0 -0
- package/template/public/images/yarn.webp +0 -0
- package/template/stories/generated/collection-grid.stories.ts +6 -0
- package/template/stories/generated/feature-grid.stories.ts +6 -0
- package/template/stories/generated/footer.stories.ts +4 -4
- package/template/stories/generated/hero.stories.ts +6 -0
- package/template/stories/generated/navigation.stories.ts +14 -1
- package/template/stories/generated/newsletter.stories.ts +2 -1
- package/template/stories/generated/product-carousel.stories.ts +12 -0
- package/template/stories/generated/split-content.stories.ts +12 -0
- package/template/stories/generated/trust-strip.stories.ts +8 -1
- package/template/stories/pages/article.stories.ts +2 -1
- package/template/stories/pages/cart.stories.ts +2 -1
- package/template/stories/pages/category.stories.ts +2 -1
- package/template/stories/pages/collection.stories.ts +2 -1
- package/template/stories/pages/home.stories.ts +2 -1
- package/template/stories/pages/product.stories.ts +2 -1
- package/template/stories/pages/products.stories.ts +2 -1
- package/template/stories/pages/search.stories.ts +2 -1
- package/template/stories/pages/wishlist.stories.ts +2 -1
- package/template/stories/support/demoChrome.ts +32 -0
- package/template/stories/support/pageBlocks.ts +2 -4
- package/template/test/countPill.browser.spec.ts +21 -13
- package/template/test/localePrefix.spec.ts +11 -6
- package/template/test/pages/article.spec.ts +1 -1
- package/template/test/pages/category.spec.ts +34 -11
- package/template/test/pages/collection.spec.ts +182 -148
- package/template/test/pages/home.spec.ts +35 -40
- package/template/test/pages/hydration.spec.ts +4 -4
- package/template/test/pages/product.spec.ts +17 -14
- package/template/test/pages/seededPages.spec.ts +11 -6
- package/template/test/prerenderRefresh.browser.spec.ts +36 -15
- package/template/test/previewParity.browser.spec.ts +36 -2
- package/template/test/starter.spec.ts +31 -15
- package/template/test/storefront/gatewayPrerender.spec.ts +26 -0
- package/template/tokens.json +13 -13
|
@@ -18,7 +18,6 @@ import type {
|
|
|
18
18
|
NavMenuItem,
|
|
19
19
|
NavMenuLink,
|
|
20
20
|
NavMenuPart,
|
|
21
|
-
NavMenuSection,
|
|
22
21
|
SearchResultItem,
|
|
23
22
|
SearchResults,
|
|
24
23
|
UiMessages,
|
|
@@ -30,10 +29,14 @@ import { useWishlist } from '../../app/composables/useWishlist';
|
|
|
30
29
|
import { useI18n } from 'vue-i18n';
|
|
31
30
|
import EldraIcon from '../../app/components/EldraIcon.vue';
|
|
32
31
|
import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
|
|
33
|
-
import { isInternalHref, SEARCH_PATH } from '../../app/utils/links';
|
|
32
|
+
import { isInternalHref, safeHref, SEARCH_PATH } from '../../app/utils/links';
|
|
34
33
|
import { useMoney } from '../../app/storefront/money';
|
|
35
34
|
import type { StorefrontSearchResponse } from '../../app/storefront/types';
|
|
36
35
|
import MenuLink from './parts/MenuLink.vue';
|
|
36
|
+
|
|
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];
|
|
37
40
|
import blockJson from './block.json';
|
|
38
41
|
|
|
39
42
|
const props = defineProps<{ entry: EldraBlockEntry<'navigation'> }>();
|
|
@@ -45,10 +48,79 @@ const storefront = useStorefront();
|
|
|
45
48
|
|
|
46
49
|
const variant = computed<'default' | 'centered' | 'minimal'>(() => data.value.variant ?? 'default');
|
|
47
50
|
|
|
51
|
+
// --- container-query stages ----------------------------------------------------------------------
|
|
52
|
+
//
|
|
53
|
+
// The bar gives up width in stages, each measured against the header's own `@container` (so the
|
|
54
|
+
// stages follow the block's width, not the window's):
|
|
55
|
+
//
|
|
56
|
+
// - from 80rem (`@wide:`): brand, inline links, a "Search the shop" pill and the labelled tools;
|
|
57
|
+
// - 68.8125rem–80rem (1101–1279px): the pill becomes a labelled Search button;
|
|
58
|
+
// - below 68.8125rem (≤1100px): the links move into the Menu drawer; Menu and Search sit at the
|
|
59
|
+
// start, the brand in the middle of a symmetric grid, Saved and Cart at the end;
|
|
60
|
+
// - below 47.5625rem (≤760px): a shorter bar and narrower tools, and the info strip keeps only its
|
|
61
|
+
// first item;
|
|
62
|
+
// - below 25.0625rem (≤400px): a square mark stands in for the logo or the wordmark;
|
|
63
|
+
// - below 22.5rem (<360px): a text-only wordmark wraps onto two centred lines.
|
|
64
|
+
//
|
|
65
|
+
// Tailwind only generates a class it can read in the source, so every stage is spelled out in full
|
|
66
|
+
// at each use (`@min-[68.8125rem]:…`, `@max-[47.5625rem]:…`) rather than assembled from a prefix.
|
|
67
|
+
|
|
48
68
|
// --- brand -----------------------------------------------------------------------------------
|
|
49
69
|
|
|
50
|
-
const
|
|
70
|
+
const brandLogo = computed(() => data.value.brandLogo);
|
|
71
|
+
const brandLogoUrl = computed(() => brandLogo.value?.url);
|
|
72
|
+
const brandMarkUrl = computed(() => data.value.brandMark?.url);
|
|
51
73
|
const brandHref = '/';
|
|
74
|
+
/** Named once on the link, so whichever of the mark, the logo and the wordmark a width shows, the
|
|
75
|
+
* brand link reads the same; the pictures inside it are decorative (`alt=""`). It starts with the
|
|
76
|
+
* visible wordmark (WCAG 2.5.3). */
|
|
77
|
+
const brandName = computed(() => t('header.home', { brand: data.value.brandText ?? '' }));
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* A logo wider than about 4:1 is unreadably small at a phone's 2rem height, so with no square mark
|
|
81
|
+
* to fall back on, phones below 400px print the store name instead. The shape is the image's own
|
|
82
|
+
* stored width and height (Studio stores both); a logo without them is never judged too wide.
|
|
83
|
+
*/
|
|
84
|
+
const LOGO_TOO_WIDE = 4;
|
|
85
|
+
const logoTooWide = computed(() => {
|
|
86
|
+
const width = Number(brandLogo.value?.width);
|
|
87
|
+
const height = Number(brandLogo.value?.height);
|
|
88
|
+
return width > 0 && height > 0 && width / height > LOGO_TOO_WIDE;
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
/** The mark: always beside the wordmark when there is no logo; only on small phones with one. */
|
|
92
|
+
const brandMarkClass = computed(() =>
|
|
93
|
+
[
|
|
94
|
+
'block size-8 shrink-0 @max-[47.5625rem]:size-7 @max-[25.0625rem]:size-9',
|
|
95
|
+
brandLogoUrl.value ? 'hidden @max-[25.0625rem]:block' : '',
|
|
96
|
+
]
|
|
97
|
+
.filter(Boolean)
|
|
98
|
+
.join(' ')
|
|
99
|
+
);
|
|
100
|
+
/** Sized by height and capped in width, so a wider logo gets smaller rather than pushing the links
|
|
101
|
+
* and the tools around: 2.25rem tall at most 15rem wide, 12rem below 80rem, the brand column's
|
|
102
|
+
* own width once it sits centred, and 2rem tall on a phone. */
|
|
103
|
+
const brandLogoClass = computed(() =>
|
|
104
|
+
[
|
|
105
|
+
'block h-9 w-auto min-w-0 max-w-60 object-contain object-left',
|
|
106
|
+
'@max-[80rem]:max-w-48 @max-[68.8125rem]:max-w-full @max-[68.8125rem]:object-center',
|
|
107
|
+
'@max-[47.5625rem]:h-auto @max-[47.5625rem]:max-h-8',
|
|
108
|
+
brandMarkUrl.value || logoTooWide.value ? '@max-[25.0625rem]:hidden' : '',
|
|
109
|
+
]
|
|
110
|
+
.filter(Boolean)
|
|
111
|
+
.join(' ')
|
|
112
|
+
);
|
|
113
|
+
/** `null` when the wordmark is never drawn: a logo that is not too wide, with no mark. */
|
|
114
|
+
const brandTextClass = computed(() => {
|
|
115
|
+
const base =
|
|
116
|
+
'font-heading overflow-hidden text-ellipsis whitespace-nowrap text-[1.375rem] leading-tight font-medium tracking-[-0.01em] @max-[47.5625rem]:text-[1.0625rem]';
|
|
117
|
+
if (brandLogoUrl.value) {
|
|
118
|
+
if (!logoTooWide.value || brandMarkUrl.value) return null;
|
|
119
|
+
return `${base} hidden @max-[25.0625rem]:block @max-[25.0625rem]:max-w-[8.5rem] @max-[25.0625rem]:whitespace-normal @max-[25.0625rem]:text-center @max-[25.0625rem]:text-base @max-[25.0625rem]:leading-[1.1]`;
|
|
120
|
+
}
|
|
121
|
+
if (brandMarkUrl.value) return `${base} @max-[25.0625rem]:hidden`;
|
|
122
|
+
return `${base} @max-[22.5rem]:max-w-[5.75rem] @max-[22.5rem]:whitespace-normal @max-[22.5rem]:text-center @max-[22.5rem]:leading-[1.05]`;
|
|
123
|
+
});
|
|
52
124
|
|
|
53
125
|
// --- links + mega-menus ------------------------------------------------------------------------
|
|
54
126
|
|
|
@@ -61,13 +133,51 @@ function toLinkAs(href: string | undefined): typeof EldraRouterLink | undefined
|
|
|
61
133
|
return href !== undefined && isInternalHref(href) ? EldraRouterLink : undefined;
|
|
62
134
|
}
|
|
63
135
|
|
|
64
|
-
/** A row with no label has nothing to show; one whose target is gone keeps its label as text.
|
|
65
|
-
|
|
136
|
+
/** A row with no label has nothing to show; one whose target is gone keeps its label as text. The
|
|
137
|
+
* stored value rides along for `linkExtras` below. */
|
|
138
|
+
const linkEntries = computed(() =>
|
|
66
139
|
rawLinks.value.flatMap((item) => {
|
|
67
140
|
const resolved = resolveLink(item);
|
|
68
|
-
return resolved === null || resolved.label === null ? [] : [resolved];
|
|
141
|
+
return resolved === null || resolved.label === null ? [] : [{ resolved, raw: item as unknown }];
|
|
69
142
|
})
|
|
70
143
|
);
|
|
144
|
+
const links = computed(() => linkEntries.value.map((entry) => entry.resolved));
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* A section link's `badge` ("New") and `description` (a dropdown's second line), which `NavMenu`
|
|
148
|
+
* draws but the resolved link does not carry: `@eldrajs/theme-core`'s link value has no such keys,
|
|
149
|
+
* so Studio's link editor cannot set them yet and they only ever arrive as extra keys on the stored
|
|
150
|
+
* value (the demo content does this). They are read straight off that value, matched to the
|
|
151
|
+
* resolved links by position — and only when the resolver dropped nothing in that section, so a
|
|
152
|
+
* badge can never land on the wrong link.
|
|
153
|
+
*/
|
|
154
|
+
interface LinkExtras {
|
|
155
|
+
badge?: string;
|
|
156
|
+
description?: string;
|
|
157
|
+
}
|
|
158
|
+
function plainString(value: unknown, key: string): string | undefined {
|
|
159
|
+
if (value === null || typeof value !== 'object') return undefined;
|
|
160
|
+
const field = (value as Record<string, unknown>)[key];
|
|
161
|
+
return typeof field === 'string' && field.trim() !== '' ? field : undefined;
|
|
162
|
+
}
|
|
163
|
+
function rawList(value: unknown, key: string): unknown[] {
|
|
164
|
+
if (value === null || typeof value !== 'object') return [];
|
|
165
|
+
const list = (value as Record<string, unknown>)[key];
|
|
166
|
+
return Array.isArray(list) ? list : [];
|
|
167
|
+
}
|
|
168
|
+
function sectionExtras(raw: unknown, sections: ResolvedSection[]): LinkExtras[][] {
|
|
169
|
+
const rawSections = rawList(raw, 'sections');
|
|
170
|
+
return sections.map((section, index) => {
|
|
171
|
+
const rawLinks = rawList(rawSections[index], 'links');
|
|
172
|
+
if (rawSections.length !== sections.length || rawLinks.length !== section.links.length) {
|
|
173
|
+
return [];
|
|
174
|
+
}
|
|
175
|
+
return rawLinks.map((link) => ({
|
|
176
|
+
badge: plainString(link, 'badge'),
|
|
177
|
+
description: plainString(link, 'description'),
|
|
178
|
+
}));
|
|
179
|
+
});
|
|
180
|
+
}
|
|
71
181
|
|
|
72
182
|
/**
|
|
73
183
|
* The picture crop of a menu card: the `aspect` this block's own `links` field declares in
|
|
@@ -76,12 +186,16 @@ const links = computed(() =>
|
|
|
76
186
|
*/
|
|
77
187
|
const cardAspect = (
|
|
78
188
|
blockJson.fields.find((field) => field.fieldId === 'links') as
|
|
79
|
-
| {
|
|
189
|
+
| {
|
|
190
|
+
metadata?: {
|
|
191
|
+
item?: { metadata?: { tree?: { cards?: { aspect?: string } } } };
|
|
192
|
+
};
|
|
193
|
+
}
|
|
80
194
|
| undefined
|
|
81
195
|
)?.metadata?.item?.metadata?.tree?.cards?.aspect;
|
|
82
196
|
|
|
83
197
|
/** A resolved link as the menu draws it, `display` and `card` (child and section links only) kept. */
|
|
84
|
-
function toNavLink(link: ResolvedLink): NavMenuLink {
|
|
198
|
+
function toNavLink(link: ResolvedLink, extras: LinkExtras = {}): NavMenuLink {
|
|
85
199
|
return {
|
|
86
200
|
label: link.label,
|
|
87
201
|
href: link.href,
|
|
@@ -90,26 +204,43 @@ function toNavLink(link: ResolvedLink): NavMenuLink {
|
|
|
90
204
|
current: isCurrent(link.href),
|
|
91
205
|
display: link.display,
|
|
92
206
|
card: link.card,
|
|
207
|
+
badge: extras.badge,
|
|
208
|
+
description: extras.description,
|
|
93
209
|
};
|
|
94
210
|
}
|
|
95
211
|
|
|
96
|
-
function toNavSection(section: ResolvedSection): NavMenuSection {
|
|
212
|
+
function toNavSection(section: ResolvedSection, extras: LinkExtras[] = []): NavMenuSection {
|
|
97
213
|
return {
|
|
98
214
|
heading: section.heading,
|
|
99
215
|
headingLink: section.headingLink === null ? null : toNavLink(section.headingLink),
|
|
100
216
|
display: section.display,
|
|
101
|
-
links: section.links.map(toNavLink),
|
|
217
|
+
links: section.links.map((link, index) => toNavLink(link, extras[index])),
|
|
102
218
|
seeAll: section.seeAll === null ? null : toNavLink(section.seeAll),
|
|
103
219
|
};
|
|
104
220
|
}
|
|
105
221
|
|
|
222
|
+
/**
|
|
223
|
+
* A panel that is one column with no heading and no cards — a short list of links, each perhaps
|
|
224
|
+
* with a line of description, like the Journal's — hangs under its own trigger as a compact
|
|
225
|
+
* dropdown. Anything with columns, headings or cards is a full-width mega panel.
|
|
226
|
+
*/
|
|
227
|
+
function isDropdown(sections: ResolvedSection[]): boolean {
|
|
228
|
+
const [only] = sections;
|
|
229
|
+
return (
|
|
230
|
+
sections.length === 1 &&
|
|
231
|
+
only !== undefined &&
|
|
232
|
+
only.heading === null &&
|
|
233
|
+
!only.links.some((link) => link.card !== undefined)
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
|
|
106
237
|
/**
|
|
107
238
|
* A parent with a panel is a disclosure, so its own destination moves to the panel's "View all". The
|
|
108
239
|
* panel is its `sections` when the site served them (this block declares them), else its `children`
|
|
109
240
|
* grouped by their `group`, which is what a menu stored before sections existed still is.
|
|
110
241
|
*/
|
|
111
242
|
const navItems = computed<NavMenuItem[]>(() =>
|
|
112
|
-
|
|
243
|
+
linkEntries.value.map(({ resolved: link, raw }) => {
|
|
113
244
|
const sections = link.sections ?? [];
|
|
114
245
|
const children = link.children.filter((child) => child.label !== null);
|
|
115
246
|
if (sections.length === 0 && children.length === 0) {
|
|
@@ -120,18 +251,28 @@ const navItems = computed<NavMenuItem[]>(() =>
|
|
|
120
251
|
current: isCurrent(link.href),
|
|
121
252
|
};
|
|
122
253
|
}
|
|
254
|
+
if (sections.length === 0) {
|
|
255
|
+
return {
|
|
256
|
+
label: link.label,
|
|
257
|
+
layout: 'mega',
|
|
258
|
+
children: children.map((c) => toNavLink(c)),
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
const extras = sectionExtras(raw, sections);
|
|
123
262
|
return {
|
|
124
263
|
label: link.label,
|
|
125
|
-
layout: 'mega',
|
|
126
|
-
|
|
127
|
-
? { sections: sections.map(toNavSection) }
|
|
128
|
-
: { children: children.map(toNavLink) }),
|
|
264
|
+
layout: isDropdown(sections) ? 'dropdown' : 'mega',
|
|
265
|
+
sections: sections.map((section, index) => toNavSection(section, extras[index])),
|
|
129
266
|
};
|
|
130
267
|
})
|
|
131
268
|
);
|
|
132
269
|
|
|
270
|
+
/** The panel's own "View all" footer — left out when a column already ends in its own "see all"
|
|
271
|
+
* link, which is the design's way of offering the same thing. */
|
|
133
272
|
function viewAllHref(index: number): string | undefined {
|
|
134
|
-
|
|
273
|
+
const link = links.value[index];
|
|
274
|
+
if (link?.sections?.some((section) => section.seeAll !== null) === true) return undefined;
|
|
275
|
+
return link?.href ?? undefined;
|
|
135
276
|
}
|
|
136
277
|
|
|
137
278
|
const openMenuIndex = ref<number | null>(null);
|
|
@@ -147,6 +288,57 @@ const ctaLinkAs = computed(() => toLinkAs(ctaHref.value));
|
|
|
147
288
|
const ctaLabel = computed(() => data.value.ctaLabel ?? ctaLink.value?.label ?? '');
|
|
148
289
|
const hasCta = computed(() => Boolean(ctaLabel.value && ctaHref.value));
|
|
149
290
|
|
|
291
|
+
// --- account -----------------------------------------------------------------------------------
|
|
292
|
+
|
|
293
|
+
/** The Account button: only when the merchant links it somewhere. The theme has no account page of
|
|
294
|
+
* its own, so there is nothing to point it at by default. */
|
|
295
|
+
const accountLink = computed(() => resolveLink(data.value.account));
|
|
296
|
+
const accountHref = computed(() => accountLink.value?.href ?? undefined);
|
|
297
|
+
const accountLinkAs = computed(() => toLinkAs(accountHref.value));
|
|
298
|
+
|
|
299
|
+
// --- info strip --------------------------------------------------------------------------------
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* The thin strip above the bar: delivery, returns and hours at the start, help links and a phone
|
|
303
|
+
* number at the end. Absent or empty, there is no strip at all. Phones keep only the first item;
|
|
304
|
+
* the end of the strip moves into the drawer's footer with the links (it would not fit beside the
|
|
305
|
+
* start below 68.8125rem), unless the strip has nothing at its start.
|
|
306
|
+
*/
|
|
307
|
+
interface InfoEntry {
|
|
308
|
+
text: string;
|
|
309
|
+
icon?: string;
|
|
310
|
+
/** Through `safeHref`: a `javascript:` value is no link at all. */
|
|
311
|
+
href?: string;
|
|
312
|
+
linkAs?: typeof EldraRouterLink;
|
|
313
|
+
}
|
|
314
|
+
const infoItems = computed(() =>
|
|
315
|
+
(data.value.infoItems ?? []).flatMap((item) => {
|
|
316
|
+
if ((item.text ?? '').trim() === '') return [];
|
|
317
|
+
const href = safeHref(item.href) ?? undefined;
|
|
318
|
+
const entry: InfoEntry & { end: boolean } = {
|
|
319
|
+
text: item.text,
|
|
320
|
+
icon: item.icon || undefined,
|
|
321
|
+
href,
|
|
322
|
+
linkAs: toLinkAs(href),
|
|
323
|
+
end: item.placement === 'end',
|
|
324
|
+
};
|
|
325
|
+
return [entry];
|
|
326
|
+
})
|
|
327
|
+
);
|
|
328
|
+
const infoStart = computed(() => infoItems.value.filter((item) => !item.end));
|
|
329
|
+
const infoEnd = computed(() => infoItems.value.filter((item) => item.end));
|
|
330
|
+
const hasInfo = computed(() => infoItems.value.length > 0);
|
|
331
|
+
/** With nothing at the start, the end of the strip takes its place on every width. */
|
|
332
|
+
const infoEndClass = computed(() => (infoStart.value.length > 0 ? '@max-[68.8125rem]:hidden' : ''));
|
|
333
|
+
/** The end items the drawer repeats while the strip hides them: the ones with somewhere to go. */
|
|
334
|
+
const infoEndLinks = computed(() =>
|
|
335
|
+
infoStart.value.length > 0 ? infoEnd.value.filter((item) => item.href !== undefined) : []
|
|
336
|
+
);
|
|
337
|
+
/** Phones keep only the strip's very first item. */
|
|
338
|
+
function infoItemClass(index: number): string {
|
|
339
|
+
return index === 0 ? '' : '@max-[47.5625rem]:hidden';
|
|
340
|
+
}
|
|
341
|
+
|
|
150
342
|
// --- search ------------------------------------------------------------------------------------
|
|
151
343
|
|
|
152
344
|
const showSearch = computed(() => data.value.showSearch !== false);
|
|
@@ -154,7 +346,11 @@ const showSearch = computed(() => data.value.showSearch !== false);
|
|
|
154
346
|
* centered variant only"). */
|
|
155
347
|
const searchStyle = computed<'icon' | 'field' | 'inline'>(() => {
|
|
156
348
|
const style = data.value.searchStyle ?? 'icon';
|
|
157
|
-
|
|
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;
|
|
158
354
|
});
|
|
159
355
|
|
|
160
356
|
const searchOpen = ref(false);
|
|
@@ -252,34 +448,37 @@ function openSearch(): void {
|
|
|
252
448
|
// --- cart + wishlist count pills --------------------------------------------------------------
|
|
253
449
|
|
|
254
450
|
/**
|
|
255
|
-
* A count pill is a corner badge
|
|
256
|
-
*
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
*
|
|
260
|
-
*
|
|
261
|
-
*
|
|
262
|
-
*
|
|
263
|
-
*
|
|
264
|
-
* corner badge sits *on* the icon by design — a ring here would just push it back off the corner.
|
|
265
|
-
* `-top-0.5 -right-0.5` sits it at the button's own top-right corner, nudged slightly outside it
|
|
266
|
-
* (2px past the 2rem button's own edge on each side) rather than tucked inside — `top-0.5
|
|
267
|
-
* right-0.5` was tried first and measured worse: with real padding and a real glyph the pill is
|
|
268
|
-
* wider than its 0.875rem floor, so pulled inside the button it still buried roughly a third of
|
|
269
|
-
* the icon's area under it. Pushed just outside instead, it lands mostly over the button's own
|
|
270
|
-
* padding and clears the icon by a wide margin. `countPill.browser.spec.ts` measures the overlap
|
|
271
|
-
* against the icon's real `<svg>` box (not an assumed one) and keeps it well under a quarter of
|
|
272
|
-
* the icon's area. The same override styles both the cart and the wishlist pill (spec: "the cart
|
|
273
|
-
* button and its count badge" — the wishlist one is drawn identically), so it is one constant
|
|
274
|
-
* rather than two copies that could drift.
|
|
451
|
+
* A count pill is a corner badge on a labelled tool: 1.125rem tall (`min-w` so "99+" still widens
|
|
452
|
+
* it), `0.6875rem` bold tabular figures, `accent` fill and `accent-contrast` text (both from the
|
|
453
|
+
* `tone="accent"` prop, not this constant), sitting at the tool's top-right — `top-0.5 right-1.5`,
|
|
454
|
+
* `right-0.5` on a phone's narrower tool — so it rides the icon's corner and leaves the label under
|
|
455
|
+
* it clear. No ring: a ring's whole job is separating a pill from what sits *beside* it, and a
|
|
456
|
+
* corner badge sits *on* the icon by design. `countPill.browser.spec.ts` measures the pill's height
|
|
457
|
+
* and its overlap with the icon's real `<svg>` box in a real browser. The same override styles
|
|
458
|
+
* both the cart and the saved-items pill, so it is one constant rather than two copies that could
|
|
459
|
+
* drift.
|
|
275
460
|
*
|
|
276
461
|
* `Badge`'s own root carries `min-h-6` and `text-badge` (1.5rem min height, the package's own
|
|
277
462
|
* type-style utility); passed as the Badge's `class`, these app utilities outrank its `eldra:`
|
|
278
463
|
* classes by cascade layer, with no `!important` and no need for a `size` prop (`Badge` has none).
|
|
279
464
|
*/
|
|
280
465
|
const COUNT_PILL_CLASSES =
|
|
281
|
-
'pointer-events-none absolute
|
|
282
|
-
'px-1 text-[0.
|
|
466
|
+
'pointer-events-none absolute top-0.5 right-1.5 @max-[47.5625rem]:right-0.5 h-[1.125rem] ' +
|
|
467
|
+
'min-h-[1.125rem] min-w-[1.125rem] justify-center px-1 text-[0.6875rem] font-bold tabular-nums leading-none';
|
|
468
|
+
|
|
469
|
+
/**
|
|
470
|
+
* A tool: an icon with its name printed under it (the design's labelled header buttons), one fixed
|
|
471
|
+
* width per stage. The width is fixed, not a minimum, because below 68.8125rem the bar is a
|
|
472
|
+
* symmetric grid — Menu and Search on one side, Saved and Cart on the other — and the brand is only
|
|
473
|
+
* truly centred when the two sides are the same width. `@eldrajs/ui`'s `Button` draws it; these
|
|
474
|
+
* app classes outrank its own size classes by cascade layer.
|
|
475
|
+
*/
|
|
476
|
+
const TOOL_WIDTH_CLASSES = 'w-14 @max-[47.5625rem]:w-11 @max-[22.5rem]:w-10';
|
|
477
|
+
const TOOL_CLASSES =
|
|
478
|
+
`${TOOL_WIDTH_CLASSES} h-auto min-h-12 flex-col justify-center gap-0.5 px-1 py-1 ` +
|
|
479
|
+
'text-xs leading-[1.1] font-medium @max-[47.5625rem]:px-0 @max-[47.5625rem]:text-[0.6875rem]';
|
|
480
|
+
/** The tool's icon, 1.375rem. */
|
|
481
|
+
const TOOL_ICON_CLASSES = 'size-[1.375rem]';
|
|
283
482
|
|
|
284
483
|
// --- cart --------------------------------------------------------------------------------------
|
|
285
484
|
|
|
@@ -354,18 +553,18 @@ function onCartClick(): void {
|
|
|
354
553
|
* would be the theme deciding the variant means something else. The drawer gets no wishlist row
|
|
355
554
|
* either, so the variant stays consistent in both directions.
|
|
356
555
|
*
|
|
357
|
-
* **It does render at mobile widths**, unlike the call to action, which
|
|
556
|
+
* **It does render at mobile widths**, unlike the call to action, which only shows from 68.8125rem.
|
|
358
557
|
* Deliberate, and the bag's own rule: a shopper who saved something on a phone has no other way
|
|
359
558
|
* back to it, where the call to action has a drawer row.
|
|
360
559
|
*/
|
|
361
560
|
const wishlist = useWishlist();
|
|
362
561
|
const wishlistCount = wishlist.count;
|
|
363
562
|
const wishlistHref = '/wishlist';
|
|
364
|
-
/** The bag's three forms, with a plainer empty one: nothing saved reads as just "
|
|
365
|
-
*
|
|
563
|
+
/** The bag's three forms, with a plainer empty one: nothing saved reads as just "Saved" — the
|
|
564
|
+
* tool's own visible label, no count to read out — where the bag says "Cart, empty", which is worth
|
|
366
565
|
* saying about a bag a visitor may have just filled and says nothing about a list they have never
|
|
367
|
-
* used.
|
|
368
|
-
* every visitor. */
|
|
566
|
+
* used. Every form starts with the visible label (WCAG 2.5.3). A number appears only once there is
|
|
567
|
+
* one, so the name in a prerendered file is the same for every visitor. */
|
|
369
568
|
const wishlistAccessibleName = computed(() => {
|
|
370
569
|
const count = wishlistCount.value;
|
|
371
570
|
if (count === 0) return t('header.wishlistEmpty');
|
|
@@ -442,11 +641,11 @@ const focusWithinBar = ref(false);
|
|
|
442
641
|
/**
|
|
443
642
|
* The bar's height, named once: the bar sets it on its own grid and the spacer reserves the very
|
|
444
643
|
* same box. Two literals would drift the first time a breakpoint moved, and a spacer that drifts
|
|
445
|
-
* from the bar is a page that jumps.
|
|
644
|
+
* from the bar is a page that jumps. The stage is a container query, so it is only ever as true
|
|
446
645
|
* as the container it is measured in — which is why both boxes sit inside an `@container` of the
|
|
447
646
|
* block's own width.
|
|
448
647
|
*/
|
|
449
|
-
const BAR_HEIGHT_CLASS = 'h-
|
|
648
|
+
const BAR_HEIGHT_CLASS = 'min-h-[4.5rem] @max-[47.5625rem]:min-h-[3.75rem]';
|
|
450
649
|
let lastScrollY = 0;
|
|
451
650
|
const SCROLL_JITTER = 4;
|
|
452
651
|
function onScroll(): void {
|
|
@@ -495,12 +694,17 @@ function onBarFocusOut(event: FocusEvent): void {
|
|
|
495
694
|
const next = event.relatedTarget;
|
|
496
695
|
focusWithinBar.value = next instanceof Node && (barRoot.value?.contains(next) ?? false);
|
|
497
696
|
}
|
|
498
|
-
/** Spec "Header" → Accessibility, "Sticky header and focus": scroll padding
|
|
499
|
-
*
|
|
697
|
+
/** Spec "Header" → Accessibility, "Sticky header and focus": scroll padding at least the sticky
|
|
698
|
+
* header's height (2.4.11), so a focused/anchored target is never hidden under it. A constant, not
|
|
699
|
+
* the measured `--eldra-header-height`: where the browser scrolls a focused field must not depend
|
|
700
|
+
* on when the bar was last measured, or a draft preview session (which focuses under its veil, before
|
|
701
|
+
* the live page would have) lands a field at a different scroll position than the live page does
|
|
702
|
+
* (`test/previewParity.browser.spec.ts`, "/focus-mid"). 7rem covers the tallest header: the 4.5rem
|
|
703
|
+
* bar plus the info strip. */
|
|
500
704
|
watchEffect((onCleanup) => {
|
|
501
705
|
if (typeof document === 'undefined') return;
|
|
502
706
|
if (!sticky.value) return;
|
|
503
|
-
document.documentElement.style.setProperty('scroll-padding-top', '
|
|
707
|
+
document.documentElement.style.setProperty('scroll-padding-top', '7rem');
|
|
504
708
|
onCleanup(() => document.documentElement.style.removeProperty('scroll-padding-top'));
|
|
505
709
|
});
|
|
506
710
|
|
|
@@ -611,9 +815,15 @@ const barSurfaceStyle = { [HEADER_SURFACE_VAR]: 'var(--color-background)' };
|
|
|
611
815
|
const barRootClasses = computed(() =>
|
|
612
816
|
[
|
|
613
817
|
'@container',
|
|
818
|
+
// Fixed, the bar is as wide as the viewport, and `@eldrajs/ui` takes the page's scrollbar away
|
|
819
|
+
// while a Dialog, Drawer, Lightbox or SearchModal is open — so the viewport widens by the
|
|
820
|
+
// scrollbar and the bar with it, shifting every tool sideways under the overlay. The package
|
|
821
|
+
// publishes the width it took as `--eldra-scrollbar-width` on `<html>` for exactly this; padding
|
|
822
|
+
// the bar by it keeps its content box (and so every container-query stage) where it was.
|
|
823
|
+
// Not fixed, the header is still the positioning box a full-width mega panel spans.
|
|
614
824
|
sticky.value
|
|
615
|
-
? 'fixed inset-x-0 top-0 z-40 motion-safe:transition-transform motion-safe:duration-base'
|
|
616
|
-
: '',
|
|
825
|
+
? 'fixed inset-x-0 top-0 z-40 pr-(--eldra-scrollbar-width,0px) motion-safe:transition-transform motion-safe:duration-base'
|
|
826
|
+
: 'relative',
|
|
617
827
|
barHidden.value ? '-translate-y-full' : '',
|
|
618
828
|
isTransparent.value
|
|
619
829
|
? 'bg-transparent text-primary-contrast'
|
|
@@ -630,7 +840,7 @@ const barRootClasses = computed(() =>
|
|
|
630
840
|
*
|
|
631
841
|
* The height classes are what the first paint of a prerendered page has, before the bar has been
|
|
632
842
|
* measured at all — a spacer that started at zero would drop the page by the bar's height and lift
|
|
633
|
-
* it again on hydration. They carry the `@
|
|
843
|
+
* it again on hydration. They carry the phone stage (`@max-[47.5625rem]:`), so they need a container of the
|
|
634
844
|
* block's own width to be measured in: the bar has one (its own `@container` root), and the spacer
|
|
635
845
|
* is one, which is why the box that holds the height is a child rather than the spacer itself.
|
|
636
846
|
* `barHeight` takes over the moment the `ResizeObserver` above has a real number, and from then on
|
|
@@ -658,63 +868,158 @@ const hairlineClass = computed(() =>
|
|
|
658
868
|
|
|
659
869
|
/** The drawer holds the links and the call to action; with neither there is no Menu button either. */
|
|
660
870
|
const drawerHasContent = computed(() => links.value.length > 0 || hasCta.value);
|
|
871
|
+
/** How the drawer shows a panel: folded rows (default) or every panel open under its heading. */
|
|
872
|
+
const drawerLayout = computed<'accordion' | 'sections'>(() =>
|
|
873
|
+
data.value.drawerLayout === 'sections' ? 'sections' : 'accordion'
|
|
874
|
+
);
|
|
661
875
|
/** More than one currency to shop in. On a phone the picker sits in the menu when there is one. */
|
|
662
876
|
const currency = storefront.currency;
|
|
663
877
|
const hasCurrencies = computed(() => currency.offered.value.length > 1);
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
);
|
|
878
|
+
/** The bar's picker only where the links are inline; with a drawer it lives in the drawer's footer. */
|
|
879
|
+
const barPickerClass = computed(() => {
|
|
880
|
+
if (!drawerHasContent.value) return 'ml-1';
|
|
881
|
+
return variant.value === 'minimal' ? 'hidden' : '@min-[68.8125rem]:block ml-1 hidden';
|
|
882
|
+
});
|
|
667
883
|
const showLinksPlaceholder = computed(
|
|
668
884
|
() => isEditing.value && variant.value !== 'minimal' && links.value.length === 0
|
|
669
885
|
);
|
|
670
886
|
|
|
887
|
+
/** The Menu tool's accessible name is its visible label (WCAG 2.5.3). */
|
|
671
888
|
const navMenuMessages = computed<Partial<UiMessages>>(() => ({
|
|
672
|
-
navMenuOpen: t('header.
|
|
889
|
+
navMenuOpen: t('header.menu'),
|
|
673
890
|
navMenuDrawer: t('header.menu'),
|
|
674
891
|
}));
|
|
675
892
|
|
|
676
|
-
/**
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
893
|
+
/**
|
|
894
|
+
* The bar's grid. Below 68.8125rem (and at every width in `minimal`) it is six tracks —
|
|
895
|
+
* `Menu | Search | 1fr | brand | 1fr | Saved+Cart` — and because the tools are one fixed width and the
|
|
896
|
+
* actions row's gap equals the grid's, the two sides are the same width and the brand sits in the
|
|
897
|
+
* exact middle (spacers stand in for a missing Menu or Search tool, or `minimal`'s missing Saved).
|
|
898
|
+
* The brand's own track is `minmax(0,auto)` so a wide logo shrinks into it rather than pushing the
|
|
899
|
+
* tools off the bar. From 68.8125rem `default` is `brand | links | search | actions` and `centered`
|
|
900
|
+
* is `search | brand | actions` over a second row of links.
|
|
901
|
+
*/
|
|
902
|
+
const barGridClass = computed(() => {
|
|
903
|
+
const drawer =
|
|
904
|
+
'grid grid-cols-[auto_auto_minmax(0,1fr)_minmax(0,auto)_minmax(0,1fr)_auto] items-center gap-x-0.5';
|
|
905
|
+
if (variant.value === 'minimal') return drawer;
|
|
680
906
|
if (variant.value === 'centered') {
|
|
681
|
-
return `${
|
|
907
|
+
return `${drawer} @min-[68.8125rem]:grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] @min-[68.8125rem]:gap-x-4 @min-[68.8125rem]:pt-1`;
|
|
682
908
|
}
|
|
683
|
-
return
|
|
909
|
+
return `${drawer} @min-[68.8125rem]:grid-cols-[auto_minmax(0,1fr)_auto_auto] @min-[68.8125rem]:gap-x-1`;
|
|
910
|
+
});
|
|
911
|
+
|
|
912
|
+
const brandPositionClass = computed(() => {
|
|
913
|
+
const drawer = 'col-start-4 row-start-1 justify-self-center';
|
|
914
|
+
if (variant.value === 'minimal') return drawer;
|
|
915
|
+
if (variant.value === 'centered') return `${drawer} @min-[68.8125rem]:col-start-2`;
|
|
916
|
+
return `${drawer} @min-[68.8125rem]:col-start-1 @min-[68.8125rem]:justify-self-start`;
|
|
684
917
|
});
|
|
685
918
|
const linksPositionClass = computed(() =>
|
|
686
919
|
variant.value === 'centered'
|
|
687
|
-
? `@
|
|
688
|
-
: '@
|
|
689
|
-
);
|
|
690
|
-
const searchPositionClass = computed(() =>
|
|
691
|
-
variant.value === 'centered' ? '@content:col-start-1 @content:row-start-1' : ''
|
|
920
|
+
? `@min-[68.8125rem]:col-start-1 @min-[68.8125rem]:col-end-4 @min-[68.8125rem]:row-start-2 @min-[68.8125rem]:border-t ${hairlineClass.value} @min-[68.8125rem]:py-1`
|
|
921
|
+
: '@min-[68.8125rem]:col-start-2 @min-[68.8125rem]:row-start-1 @min-[68.8125rem]:mx-5 @wide:mx-8'
|
|
692
922
|
);
|
|
693
|
-
const
|
|
694
|
-
|
|
923
|
+
const searchPositionClass = computed(() => {
|
|
924
|
+
const drawer = 'col-start-2 row-start-1';
|
|
925
|
+
if (variant.value === 'minimal') return drawer;
|
|
926
|
+
if (variant.value === 'centered') {
|
|
927
|
+
return `${drawer} @min-[68.8125rem]:col-start-1 @min-[68.8125rem]:justify-self-start`;
|
|
928
|
+
}
|
|
929
|
+
return `${drawer} @min-[68.8125rem]:col-start-3`;
|
|
930
|
+
});
|
|
931
|
+
const actionsPositionClass = computed(() => {
|
|
932
|
+
const drawer = 'col-start-6 row-start-1 justify-self-end';
|
|
933
|
+
if (variant.value === 'minimal') return drawer;
|
|
934
|
+
if (variant.value === 'centered') return `${drawer} @min-[68.8125rem]:col-start-3`;
|
|
935
|
+
return `${drawer} @min-[68.8125rem]:col-start-4`;
|
|
936
|
+
});
|
|
937
|
+
/** A placeholder the width of one tool, so a missing Menu or Search keeps the brand centred. Only
|
|
938
|
+
* in the drawer layout; from 68.8125rem the default and centered bars do not need one. */
|
|
939
|
+
const toolSpacerClass = computed(() =>
|
|
940
|
+
variant.value === 'minimal'
|
|
941
|
+
? TOOL_WIDTH_CLASSES
|
|
942
|
+
: `${TOOL_WIDTH_CLASSES} @min-[68.8125rem]:hidden`
|
|
695
943
|
);
|
|
696
944
|
|
|
945
|
+
/** Dropdown panels and mega panels share `NavMenu`'s `content` part; a dropdown's carries the
|
|
946
|
+
* package's own `eldra-nav-menu-dropdown` class, which is how the rules below tell them apart. */
|
|
947
|
+
const DROPDOWN = '[&[class~="eldra:eldra-nav-menu-dropdown"]]';
|
|
948
|
+
|
|
697
949
|
/** What this header draws differently from `NavMenu`'s own look, part by part. */
|
|
698
950
|
const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
699
|
-
nav:
|
|
700
|
-
list:
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
951
|
+
nav: `@max-[68.8125rem]:hidden self-stretch ${linksPositionClass.value}`,
|
|
952
|
+
list:
|
|
953
|
+
variant.value === 'centered'
|
|
954
|
+
? 'h-full flex-nowrap justify-center gap-0.5'
|
|
955
|
+
: 'h-full flex-nowrap gap-0.5',
|
|
956
|
+
// The design's pill entries: 2.75rem tall, full radius, `surface` on hover and while open, the
|
|
957
|
+
// current page on `surface-strong`. The pill marks the current page, so the package's underline
|
|
958
|
+
// for it is turned off here, as on `trigger`.
|
|
959
|
+
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',
|
|
960
|
+
trigger:
|
|
961
|
+
'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',
|
|
962
|
+
// The Menu tool: shown below 68.8125rem (the package hides it from `@content`), a labelled tool
|
|
963
|
+
// like its neighbours.
|
|
964
|
+
toggle: `${TOOL_CLASSES} @max-[68.8125rem]:inline-flex col-start-1 row-start-1 max-md:size-auto rounded-md`,
|
|
965
|
+
// A mega panel hangs from the whole header (its positioning box), full-bleed, with the columns
|
|
966
|
+
// inside the same wide container the bar uses; a dropdown hangs under its trigger.
|
|
707
967
|
panel: 'pt-0',
|
|
708
|
-
content:
|
|
709
|
-
'rounded-none
|
|
710
|
-
|
|
711
|
-
|
|
968
|
+
content: [
|
|
969
|
+
'rounded-none border-0 border-b border-border bg-(--eldra-header-surface) shadow-(--eldra-shadow-float)',
|
|
970
|
+
'py-8 px-(--eldra-gutter-mobile) @tablet:px-(--eldra-gutter-tablet) @content:px-(--eldra-gutter-desktop)',
|
|
971
|
+
`${DROPDOWN}:mt-2 ${DROPDOWN}:w-[21rem] ${DROPDOWN}:rounded-lg ${DROPDOWN}:border ${DROPDOWN}:px-2 ${DROPDOWN}:pt-2 ${DROPDOWN}:pb-3`,
|
|
972
|
+
].join(' '),
|
|
973
|
+
// Link columns in equal tracks; a column of cards spans two of them. Inside the wide container.
|
|
712
974
|
columns:
|
|
713
|
-
'grid-cols-12 gap-
|
|
975
|
+
'mx-auto w-full max-w-[calc(var(--eldra-container-wide)-2*var(--eldra-gutter-desktop))] grid-cols-12 gap-8 data-cards:grid-flow-col data-cards:auto-cols-fr data-cards:grid-cols-none',
|
|
714
976
|
group: 'col-span-3 [[data-cards]>&]:col-span-1 [[data-cards]>&[data-cards]]:col-span-2',
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
977
|
+
// Serif column headings, linked or plain.
|
|
978
|
+
groupHeading:
|
|
979
|
+
'font-heading px-0 pb-3 text-xl leading-tight font-medium tracking-normal normal-case text-text',
|
|
980
|
+
groupLink: 'text-text no-underline hover:underline underline-offset-[0.2em]',
|
|
981
|
+
panelList: 'gap-0.5',
|
|
982
|
+
// Quiet links that underline on hover; a link with a description (the dropdown) is a padded row
|
|
983
|
+
// with its title in `text` and a `surface` hover.
|
|
984
|
+
panelLink: [
|
|
985
|
+
'px-0 py-1.5 text-muted hover:bg-transparent hover:text-text hover:underline underline-offset-[0.2em]',
|
|
986
|
+
'[&:has([data-part=description])]:rounded-md [&:has([data-part=description])]:px-3 [&:has([data-part=description])]:py-2.5 [&:has([data-part=description])]:text-text [&:has([data-part=description])]:no-underline [&:has([data-part=description])]:hover:bg-surface',
|
|
987
|
+
// The column's "see all": primary, semibold, with an arrow.
|
|
988
|
+
'data-see-all:mt-2 data-see-all:text-[0.9375rem] data-see-all:font-semibold data-see-all:text-primary',
|
|
989
|
+
// In a dropdown it lines up with the padded rows above it.
|
|
990
|
+
'in-[[class~="eldra:eldra-nav-menu-dropdown"]]:data-see-all:px-3',
|
|
991
|
+
].join(' '),
|
|
992
|
+
panelLabel: `gap-x-2 text-base font-normal in-data-see-all:font-semibold in-data-see-all:after:content-['→'] [[data-part=panelLink]:has([data-part=description])_&]:font-semibold`,
|
|
993
|
+
description: 'text-sm leading-snug',
|
|
994
|
+
badge:
|
|
995
|
+
'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',
|
|
996
|
+
// Cards: the picture, a semibold title and the price under it.
|
|
997
|
+
card: 'gap-2',
|
|
998
|
+
cardImage: 'rounded-lg',
|
|
999
|
+
cardTitle: 'text-base leading-snug font-semibold',
|
|
1000
|
+
cardPrice: 'text-[0.9375rem]',
|
|
1001
|
+
footer:
|
|
1002
|
+
'mx-auto w-full max-w-[calc(var(--eldra-container-wide)-2*var(--eldra-gutter-desktop))] justify-end border-0 pt-2',
|
|
1003
|
+
// The drawer: serif rows, section headings as small capitals, links at body size.
|
|
1004
|
+
drawerBody: 'px-0 pt-0',
|
|
1005
|
+
drawerLink: 'font-heading min-h-14 px-4 text-xl font-normal',
|
|
1006
|
+
drawerTrigger:
|
|
1007
|
+
'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',
|
|
1008
|
+
drawerSectionHeading: 'font-heading min-h-14 px-4 text-xl font-normal',
|
|
1009
|
+
drawerPanel: 'pb-0',
|
|
1010
|
+
drawerNest: 'ms-0 border-s-0 px-4 pb-5',
|
|
1011
|
+
drawerColumns: 'gap-5',
|
|
1012
|
+
drawerGroupHeading: 'px-0 pb-1 text-xs font-bold tracking-[0.12em] uppercase text-muted',
|
|
1013
|
+
drawerGroupLink: 'text-muted no-underline hover:underline',
|
|
1014
|
+
drawerPanelLink:
|
|
1015
|
+
'py-2 text-[1.0625rem] data-see-all:mt-1 data-see-all:text-[0.9375rem] data-see-all:font-semibold data-see-all:text-primary',
|
|
1016
|
+
drawerPanelLabel: `font-normal in-data-see-all:font-semibold in-data-see-all:after:content-['→']`,
|
|
1017
|
+
drawerBadge:
|
|
1018
|
+
'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',
|
|
1019
|
+
drawerCardImage: 'rounded-lg',
|
|
1020
|
+
drawerCardTitle: 'font-semibold',
|
|
1021
|
+
drawerFooter:
|
|
1022
|
+
'flex-col items-stretch gap-3 bg-surface px-4 pt-5 pb-5 [&>[data-eldra-header-drawer-links]]:-mx-0',
|
|
718
1023
|
}));
|
|
719
1024
|
</script>
|
|
720
1025
|
|
|
@@ -727,42 +1032,118 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
727
1032
|
@focusin="onBarFocusIn"
|
|
728
1033
|
@focusout="onBarFocusOut"
|
|
729
1034
|
>
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
]
|
|
1035
|
+
<!-- The info strip: absent with no items. Phones keep its first item; below 68.8125rem the
|
|
1036
|
+
end of it moves into the drawer's footer. -->
|
|
1037
|
+
<div
|
|
1038
|
+
v-if="hasInfo"
|
|
1039
|
+
data-eldra-header-info
|
|
1040
|
+
role="region"
|
|
1041
|
+
:aria-label="t('header.info')"
|
|
1042
|
+
:class="[
|
|
1043
|
+
'text-[0.8125rem]',
|
|
1044
|
+
isTransparent
|
|
1045
|
+
? 'border-primary-contrast/24 border-b bg-transparent'
|
|
1046
|
+
: 'bg-surface text-muted border-border border-b',
|
|
1047
|
+
]"
|
|
1048
|
+
>
|
|
1049
|
+
<Container
|
|
1050
|
+
width="wide"
|
|
1051
|
+
class="flex min-h-9 items-center justify-between gap-4 @max-[47.5625rem]:justify-center"
|
|
739
1052
|
>
|
|
1053
|
+
<ul v-if="infoStart.length > 0" class="m-0 flex list-none gap-6 p-0">
|
|
1054
|
+
<li
|
|
1055
|
+
v-for="(item, index) in infoStart"
|
|
1056
|
+
:key="`start-${index}`"
|
|
1057
|
+
:class="['inline-flex items-center gap-1.5', infoItemClass(index)]"
|
|
1058
|
+
>
|
|
1059
|
+
<EldraIcon
|
|
1060
|
+
v-if="item.icon"
|
|
1061
|
+
:name="item.icon"
|
|
1062
|
+
size="sm"
|
|
1063
|
+
:class="['size-4', isTransparent ? '' : 'text-primary']"
|
|
1064
|
+
/>
|
|
1065
|
+
<Link
|
|
1066
|
+
v-if="item.href"
|
|
1067
|
+
:href="item.href"
|
|
1068
|
+
:as="item.linkAs"
|
|
1069
|
+
variant="standalone"
|
|
1070
|
+
:underline="false"
|
|
1071
|
+
:class="['font-normal', isTransparent ? 'text-current' : 'text-text']"
|
|
1072
|
+
>{{ item.text }}</Link
|
|
1073
|
+
>
|
|
1074
|
+
<span v-else>{{ item.text }}</span>
|
|
1075
|
+
</li>
|
|
1076
|
+
</ul>
|
|
1077
|
+
<ul v-if="infoEnd.length > 0" :class="['m-0 flex list-none gap-6 p-0', infoEndClass]">
|
|
1078
|
+
<li
|
|
1079
|
+
v-for="(item, index) in infoEnd"
|
|
1080
|
+
:key="`end-${index}`"
|
|
1081
|
+
:class="[
|
|
1082
|
+
'inline-flex items-center gap-1.5',
|
|
1083
|
+
infoStart.length > 0 ? '' : infoItemClass(index),
|
|
1084
|
+
]"
|
|
1085
|
+
>
|
|
1086
|
+
<EldraIcon
|
|
1087
|
+
v-if="item.icon"
|
|
1088
|
+
:name="item.icon"
|
|
1089
|
+
size="sm"
|
|
1090
|
+
:class="['size-4', isTransparent ? '' : 'text-primary']"
|
|
1091
|
+
/>
|
|
1092
|
+
<Link
|
|
1093
|
+
v-if="item.href"
|
|
1094
|
+
:href="item.href"
|
|
1095
|
+
:as="item.linkAs"
|
|
1096
|
+
variant="standalone"
|
|
1097
|
+
:underline="false"
|
|
1098
|
+
:class="['font-normal', isTransparent ? 'text-current' : 'text-text']"
|
|
1099
|
+
>{{ item.text }}</Link
|
|
1100
|
+
>
|
|
1101
|
+
<span v-else>{{ item.text }}</span>
|
|
1102
|
+
</li>
|
|
1103
|
+
</ul>
|
|
1104
|
+
</Container>
|
|
1105
|
+
</div>
|
|
1106
|
+
|
|
1107
|
+
<Container width="wide">
|
|
1108
|
+
<div data-eldra-header-bar :class="[BAR_HEIGHT_CLASS, barGridClass]">
|
|
740
1109
|
<Link
|
|
741
1110
|
:href="brandHref"
|
|
742
1111
|
:as="EldraRouterLink"
|
|
743
1112
|
variant="standalone"
|
|
744
1113
|
:underline="false"
|
|
1114
|
+
:aria-label="brandName"
|
|
745
1115
|
data-eldra-header-focus
|
|
746
|
-
|
|
1116
|
+
data-eldra-header-brand
|
|
1117
|
+
:class="`flex max-w-full min-w-0 rounded-sm text-current hover:no-underline ${brandPositionClass}`"
|
|
1118
|
+
:classes="{
|
|
1119
|
+
label: 'flex min-w-0 max-w-full items-center gap-2.5 @max-[47.5625rem]:gap-2',
|
|
1120
|
+
}"
|
|
747
1121
|
>
|
|
1122
|
+
<img
|
|
1123
|
+
v-if="brandMarkUrl"
|
|
1124
|
+
:src="brandMarkUrl"
|
|
1125
|
+
alt=""
|
|
1126
|
+
:class="brandMarkClass"
|
|
1127
|
+
loading="eager"
|
|
1128
|
+
decoding="async"
|
|
1129
|
+
/>
|
|
748
1130
|
<img
|
|
749
1131
|
v-if="brandLogoUrl"
|
|
750
1132
|
:src="brandLogoUrl"
|
|
751
|
-
|
|
752
|
-
class="
|
|
1133
|
+
alt=""
|
|
1134
|
+
:class="brandLogoClass"
|
|
753
1135
|
loading="eager"
|
|
754
1136
|
decoding="async"
|
|
755
1137
|
/>
|
|
756
|
-
<!-- The
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
<span v-else class="overflow-hidden text-ellipsis whitespace-nowrap">{{
|
|
762
|
-
data.brandText
|
|
763
|
-
}}</span>
|
|
1138
|
+
<!-- The wordmark never wraps on a wider screen (block.json's own 20-character maxLength
|
|
1139
|
+
keeps it fitting); `min-w-0` on the link and this span's ellipsis are the fallback for
|
|
1140
|
+
the rare case that still doesn't leave enough room. Below 360px a text-only wordmark
|
|
1141
|
+
wraps onto two centred lines instead. -->
|
|
1142
|
+
<span v-if="brandTextClass !== null" :class="brandTextClass">{{ data.brandText }}</span>
|
|
764
1143
|
</Link>
|
|
765
1144
|
|
|
1145
|
+
<!-- `NavMenu` collapses at its nearest stage, `@content` (64rem); the `nav` and `toggle`
|
|
1146
|
+
classes below move that to the design's 68.8125rem (1100px) from this side. -->
|
|
766
1147
|
<NavMenu
|
|
767
1148
|
v-if="drawerHasContent"
|
|
768
1149
|
v-model="openMenuIndex"
|
|
@@ -770,6 +1151,7 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
770
1151
|
:items="navItems"
|
|
771
1152
|
:aria-label="t('header.primary')"
|
|
772
1153
|
:collapse-below="variant === 'minimal' ? 'always' : '@content'"
|
|
1154
|
+
:drawer-layout="drawerLayout"
|
|
773
1155
|
open-on-hover
|
|
774
1156
|
:link-as="MenuLink"
|
|
775
1157
|
:card-aspect="cardAspect"
|
|
@@ -778,8 +1160,8 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
778
1160
|
:classes="navMenuClasses"
|
|
779
1161
|
>
|
|
780
1162
|
<template #toggle>
|
|
781
|
-
<EldraIcon name="menu-2" size="md" />
|
|
782
|
-
<span
|
|
1163
|
+
<EldraIcon name="menu-2" size="md" :class="TOOL_ICON_CLASSES" />
|
|
1164
|
+
<span class="whitespace-nowrap">{{ t('header.menu') }}</span>
|
|
783
1165
|
</template>
|
|
784
1166
|
<template #panelFooter="{ item, index }">
|
|
785
1167
|
<Link
|
|
@@ -789,13 +1171,59 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
789
1171
|
variant="standalone"
|
|
790
1172
|
arrow
|
|
791
1173
|
data-eldra-mega-view-all
|
|
1174
|
+
:underline="false"
|
|
792
1175
|
:aria-label="t('header.viewAllOf', { label: item.label ?? '' })"
|
|
793
|
-
class="text-
|
|
1176
|
+
class="text-primary text-[0.9375rem] font-semibold"
|
|
794
1177
|
>
|
|
795
1178
|
{{ t('header.viewAll') }}
|
|
796
1179
|
</Link>
|
|
797
1180
|
</template>
|
|
798
|
-
<template
|
|
1181
|
+
<template #drawerFooter="{ close }">
|
|
1182
|
+
<ul
|
|
1183
|
+
v-if="accountHref || variant !== 'minimal' || infoEndLinks.length > 0"
|
|
1184
|
+
data-eldra-header-drawer-links
|
|
1185
|
+
class="m-0 grid list-none gap-3 p-0 text-[0.9375rem]"
|
|
1186
|
+
>
|
|
1187
|
+
<li v-if="accountHref">
|
|
1188
|
+
<Link
|
|
1189
|
+
:href="accountHref"
|
|
1190
|
+
:as="accountLinkAs"
|
|
1191
|
+
variant="standalone"
|
|
1192
|
+
:underline="false"
|
|
1193
|
+
class="text-text font-medium"
|
|
1194
|
+
:classes="{ label: 'inline-flex items-center gap-2' }"
|
|
1195
|
+
@click="close"
|
|
1196
|
+
>
|
|
1197
|
+
<EldraIcon name="user" size="md" />{{ t('header.account') }}
|
|
1198
|
+
</Link>
|
|
1199
|
+
</li>
|
|
1200
|
+
<li v-if="variant !== 'minimal'">
|
|
1201
|
+
<Link
|
|
1202
|
+
:href="wishlistHref"
|
|
1203
|
+
:as="EldraRouterLink"
|
|
1204
|
+
variant="standalone"
|
|
1205
|
+
:underline="false"
|
|
1206
|
+
class="text-text font-medium"
|
|
1207
|
+
:classes="{ label: 'inline-flex items-center gap-2' }"
|
|
1208
|
+
@click="close"
|
|
1209
|
+
>
|
|
1210
|
+
<EldraIcon name="heart" size="md" />{{ t('header.savedItems') }}
|
|
1211
|
+
</Link>
|
|
1212
|
+
</li>
|
|
1213
|
+
<li v-for="(item, index) in infoEndLinks" :key="`drawer-info-${index}`">
|
|
1214
|
+
<Link
|
|
1215
|
+
:href="item.href"
|
|
1216
|
+
:as="item.linkAs"
|
|
1217
|
+
variant="standalone"
|
|
1218
|
+
:underline="false"
|
|
1219
|
+
class="text-text font-medium"
|
|
1220
|
+
:classes="{ label: 'inline-flex items-center gap-2' }"
|
|
1221
|
+
@click="close"
|
|
1222
|
+
>
|
|
1223
|
+
<EldraIcon v-if="item.icon" :name="item.icon" size="md" />{{ item.text }}
|
|
1224
|
+
</Link>
|
|
1225
|
+
</li>
|
|
1226
|
+
</ul>
|
|
799
1227
|
<CurrencyPicker
|
|
800
1228
|
:currencies="currency.offered.value"
|
|
801
1229
|
:model-value="currency.active.value"
|
|
@@ -818,87 +1246,87 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
818
1246
|
</Button>
|
|
819
1247
|
</template>
|
|
820
1248
|
</NavMenu>
|
|
1249
|
+
<span
|
|
1250
|
+
v-else
|
|
1251
|
+
aria-hidden="true"
|
|
1252
|
+
data-eldra-header-spacer-tool
|
|
1253
|
+
:class="['col-start-1 row-start-1', toolSpacerClass]"
|
|
1254
|
+
/>
|
|
821
1255
|
<EditorPlaceholder
|
|
822
1256
|
v-if="showLinksPlaceholder"
|
|
823
1257
|
inline
|
|
824
1258
|
:label="t('editor.addLink')"
|
|
825
|
-
:class="
|
|
1259
|
+
:class="`hidden @min-[68.8125rem]:flex ${linksPositionClass}`"
|
|
826
1260
|
/>
|
|
827
1261
|
|
|
828
|
-
|
|
829
|
-
button in the grid (nothing to put in the drawer), the search control auto-places into
|
|
830
|
-
the `minmax(0,1fr)` column the brand usually takes, and left-aligned it would sit
|
|
831
|
-
against the wordmark with the cart stranded across the bar. Everywhere else this
|
|
832
|
-
wrapper lands in an `auto` column, which is content-sized, so the rule does nothing. -->
|
|
833
|
-
<div :class="['flex items-center justify-end', searchPositionClass]">
|
|
1262
|
+
<div :class="['flex items-center', searchPositionClass]">
|
|
834
1263
|
<template v-if="showSearch">
|
|
1264
|
+
<!-- `field`: the "Search the shop" pill from 80rem, the labelled Search tool below.
|
|
1265
|
+
`inline`: the live search bar, centered variant only, from 68.8125rem. `icon`: the
|
|
1266
|
+
labelled tool at every width. All but the live bar open the search overlay. -->
|
|
1267
|
+
<Button
|
|
1268
|
+
v-if="searchStyle === 'field'"
|
|
1269
|
+
variant="ghost"
|
|
1270
|
+
size="md"
|
|
1271
|
+
aria-haspopup="dialog"
|
|
1272
|
+
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"
|
|
1273
|
+
:classes="{ label: 'text-base' }"
|
|
1274
|
+
@click="openSearch"
|
|
1275
|
+
>
|
|
1276
|
+
<template #leadingIcon>
|
|
1277
|
+
<EldraIcon name="search" size="md" class="size-[1.125rem]" />
|
|
1278
|
+
</template>
|
|
1279
|
+
{{ t('header.searchField') }}
|
|
1280
|
+
</Button>
|
|
1281
|
+
<SearchBar
|
|
1282
|
+
v-else-if="searchStyle === 'inline'"
|
|
1283
|
+
v-model="searchQuery"
|
|
1284
|
+
size="md"
|
|
1285
|
+
pill
|
|
1286
|
+
:action="searchAction"
|
|
1287
|
+
:label="t('header.searchField')"
|
|
1288
|
+
:results="searchResults"
|
|
1289
|
+
:loading="searchLoading"
|
|
1290
|
+
class="hidden w-64 @min-[68.8125rem]:block"
|
|
1291
|
+
/>
|
|
835
1292
|
<Button
|
|
836
|
-
v-if="searchStyle === 'icon'"
|
|
837
1293
|
variant="ghost"
|
|
838
1294
|
size="sm"
|
|
839
|
-
icon-only
|
|
840
|
-
:label="t('header.search')"
|
|
841
1295
|
aria-haspopup="dialog"
|
|
1296
|
+
:class="[
|
|
1297
|
+
TOOL_CLASSES,
|
|
1298
|
+
searchStyle === 'field'
|
|
1299
|
+
? '@wide:hidden'
|
|
1300
|
+
: searchStyle === 'inline'
|
|
1301
|
+
? '@min-[68.8125rem]:hidden'
|
|
1302
|
+
: '',
|
|
1303
|
+
]"
|
|
842
1304
|
@click="openSearch"
|
|
843
1305
|
>
|
|
844
1306
|
<template #leadingIcon>
|
|
845
|
-
<EldraIcon name="search" size="md" />
|
|
1307
|
+
<EldraIcon name="search" size="md" :class="TOOL_ICON_CLASSES" />
|
|
846
1308
|
</template>
|
|
1309
|
+
{{ t('header.search') }}
|
|
847
1310
|
</Button>
|
|
848
|
-
<template v-else-if="searchStyle === 'field'">
|
|
849
|
-
<Button
|
|
850
|
-
variant="outline"
|
|
851
|
-
size="sm"
|
|
852
|
-
aria-haspopup="dialog"
|
|
853
|
-
class="@content:inline-flex hidden rounded-full"
|
|
854
|
-
@click="openSearch"
|
|
855
|
-
>
|
|
856
|
-
{{ t('header.searchField') }}
|
|
857
|
-
<span class="text-muted ml-2 text-xs">⌘K</span>
|
|
858
|
-
</Button>
|
|
859
|
-
<Button
|
|
860
|
-
variant="ghost"
|
|
861
|
-
size="sm"
|
|
862
|
-
icon-only
|
|
863
|
-
:label="t('header.search')"
|
|
864
|
-
aria-haspopup="dialog"
|
|
865
|
-
class="@content:hidden"
|
|
866
|
-
@click="openSearch"
|
|
867
|
-
>
|
|
868
|
-
<template #leadingIcon>
|
|
869
|
-
<EldraIcon name="search" size="md" />
|
|
870
|
-
</template>
|
|
871
|
-
</Button>
|
|
872
|
-
</template>
|
|
873
|
-
<template v-else>
|
|
874
|
-
<SearchBar
|
|
875
|
-
v-model="searchQuery"
|
|
876
|
-
size="md"
|
|
877
|
-
pill
|
|
878
|
-
:action="searchAction"
|
|
879
|
-
:label="t('header.searchField')"
|
|
880
|
-
:results="searchResults"
|
|
881
|
-
:loading="searchLoading"
|
|
882
|
-
class="@content:block hidden w-64"
|
|
883
|
-
/>
|
|
884
|
-
<Button
|
|
885
|
-
variant="ghost"
|
|
886
|
-
size="sm"
|
|
887
|
-
icon-only
|
|
888
|
-
:label="t('header.search')"
|
|
889
|
-
aria-haspopup="dialog"
|
|
890
|
-
class="@content:hidden"
|
|
891
|
-
@click="openSearch"
|
|
892
|
-
>
|
|
893
|
-
<template #leadingIcon>
|
|
894
|
-
<EldraIcon name="search" size="md" />
|
|
895
|
-
</template>
|
|
896
|
-
</Button>
|
|
897
|
-
</template>
|
|
898
1311
|
</template>
|
|
1312
|
+
<span v-else aria-hidden="true" data-eldra-header-spacer-tool :class="toolSpacerClass" />
|
|
899
1313
|
</div>
|
|
900
1314
|
|
|
901
|
-
<div data-eldra-header-actions :class="['flex items-center gap-
|
|
1315
|
+
<div data-eldra-header-actions :class="['flex items-center gap-0.5', actionsPositionClass]">
|
|
1316
|
+
<Button
|
|
1317
|
+
v-if="accountHref"
|
|
1318
|
+
variant="ghost"
|
|
1319
|
+
size="sm"
|
|
1320
|
+
:href="accountHref"
|
|
1321
|
+
:as="accountLinkAs"
|
|
1322
|
+
:class="[TOOL_CLASSES, '@max-[68.8125rem]:hidden']"
|
|
1323
|
+
>
|
|
1324
|
+
<template #leadingIcon>
|
|
1325
|
+
<EldraIcon name="user" size="md" :class="TOOL_ICON_CLASSES" />
|
|
1326
|
+
</template>
|
|
1327
|
+
{{ t('header.account') }}
|
|
1328
|
+
</Button>
|
|
1329
|
+
|
|
902
1330
|
<!-- In every header but `minimal`, prerendered ones included: see `wishlist` in the
|
|
903
1331
|
script above. `EldraRouterLink` because `/wishlist` is this theme's own route — it
|
|
904
1332
|
should route, not reload the document. -->
|
|
@@ -906,14 +1334,15 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
906
1334
|
<Button
|
|
907
1335
|
variant="ghost"
|
|
908
1336
|
size="sm"
|
|
909
|
-
|
|
910
|
-
:label="wishlistAccessibleName"
|
|
1337
|
+
:aria-label="wishlistAccessibleName"
|
|
911
1338
|
:href="wishlistHref"
|
|
912
1339
|
:as="EldraRouterLink"
|
|
1340
|
+
:class="TOOL_CLASSES"
|
|
913
1341
|
>
|
|
914
1342
|
<template #leadingIcon>
|
|
915
|
-
<EldraIcon name="heart" size="md" />
|
|
1343
|
+
<EldraIcon name="heart" size="md" :class="TOOL_ICON_CLASSES" />
|
|
916
1344
|
</template>
|
|
1345
|
+
{{ t('header.saved') }}
|
|
917
1346
|
</Button>
|
|
918
1347
|
<!-- The bag's own two rules: no badge at zero, and `pointer-events-none`, because the
|
|
919
1348
|
count is decorative (the button's accessible name carries it) and must not swallow
|
|
@@ -921,41 +1350,46 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
921
1350
|
<Badge
|
|
922
1351
|
v-if="wishlistCount > 0"
|
|
923
1352
|
aria-hidden="true"
|
|
924
|
-
tone="
|
|
1353
|
+
tone="accent"
|
|
925
1354
|
pill
|
|
926
1355
|
:label="wishlistBadgeLabel"
|
|
927
1356
|
:class="COUNT_PILL_CLASSES"
|
|
928
1357
|
/>
|
|
929
1358
|
</span>
|
|
1359
|
+
<!-- `minimal` has no Saved tool; this keeps its two sides the same width. -->
|
|
1360
|
+
<span
|
|
1361
|
+
v-else
|
|
1362
|
+
aria-hidden="true"
|
|
1363
|
+
data-eldra-header-spacer-tool
|
|
1364
|
+
:class="TOOL_WIDTH_CLASSES"
|
|
1365
|
+
/>
|
|
930
1366
|
|
|
931
1367
|
<span class="relative inline-flex">
|
|
932
1368
|
<Button
|
|
933
1369
|
variant="ghost"
|
|
934
1370
|
size="sm"
|
|
935
|
-
|
|
936
|
-
:label="cartAccessibleName"
|
|
1371
|
+
:aria-label="cartAccessibleName"
|
|
937
1372
|
:href="cartHref"
|
|
938
1373
|
:as="toLinkAs(cartHref)"
|
|
939
1374
|
:aria-haspopup="cartPopupType"
|
|
1375
|
+
:class="TOOL_CLASSES"
|
|
940
1376
|
@click="onCartClick"
|
|
941
1377
|
>
|
|
942
1378
|
<template #leadingIcon>
|
|
943
|
-
<EldraIcon name="shopping-bag" size="md" />
|
|
1379
|
+
<EldraIcon name="shopping-bag" size="md" :class="TOOL_ICON_CLASSES" />
|
|
944
1380
|
</template>
|
|
1381
|
+
{{ t('header.cart') }}
|
|
945
1382
|
</Button>
|
|
946
1383
|
<Badge
|
|
947
1384
|
v-if="cartCount > 0"
|
|
948
1385
|
aria-hidden="true"
|
|
949
|
-
tone="
|
|
1386
|
+
tone="accent"
|
|
950
1387
|
pill
|
|
951
1388
|
:label="cartBadgeLabel"
|
|
952
1389
|
:class="COUNT_PILL_CLASSES"
|
|
953
1390
|
/>
|
|
954
1391
|
</span>
|
|
955
1392
|
|
|
956
|
-
<!-- Spec Header -> Layout, From 64rem: the call to action sits 0.75rem after the cart.
|
|
957
|
-
0.25rem of that is already the actions row's own gap-1; @content:ml-2 (0.5rem) makes
|
|
958
|
-
up the rest, so it reads as its own button rather than a fourth icon in the row. -->
|
|
959
1393
|
<CurrencyPicker
|
|
960
1394
|
:currencies="currency.offered.value"
|
|
961
1395
|
:model-value="currency.active.value"
|
|
@@ -963,13 +1397,15 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
963
1397
|
:class="barPickerClass"
|
|
964
1398
|
@update:model-value="currency.choose"
|
|
965
1399
|
/>
|
|
1400
|
+
<!-- The call to action sits 0.75rem after the cart where the links are inline: 0.125rem of
|
|
1401
|
+
that is the actions row's own gap, `ml-2.5` the rest. In the drawer below. -->
|
|
966
1402
|
<Button
|
|
967
1403
|
v-if="hasCta && variant !== 'minimal'"
|
|
968
1404
|
variant="primary"
|
|
969
1405
|
size="sm"
|
|
970
1406
|
:href="ctaHref"
|
|
971
1407
|
:as="ctaLinkAs"
|
|
972
|
-
class="@
|
|
1408
|
+
class="ml-2.5 hidden @min-[68.8125rem]:inline-flex"
|
|
973
1409
|
>
|
|
974
1410
|
{{ ctaLabel }}
|
|
975
1411
|
</Button>
|
|
@@ -988,7 +1424,9 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
988
1424
|
<!-- The flow the fixed bar left behind — see `barSpacerClasses`. Empty and unlabelled: it is
|
|
989
1425
|
layout, with nothing in it for a screen reader or the tab order to reach. The outer box is the
|
|
990
1426
|
`<header>`'s counterpart (the `@container` the height is measured in, and the hairline) and the
|
|
991
|
-
inner
|
|
1427
|
+
inner ones the info strip's and the bar grid's (the height itself). The info strip's box
|
|
1428
|
+
keeps its hairline outside the height, as the strip's own `border-b` sits outside its
|
|
1429
|
+
`min-h-9` container: one box with both would be a pixel short of the bar until measured. -->
|
|
992
1430
|
<div
|
|
993
1431
|
v-if="sticky"
|
|
994
1432
|
data-eldra-header-spacer
|
|
@@ -996,6 +1434,7 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
996
1434
|
:class="barSpacerClasses"
|
|
997
1435
|
:style="barSpacerStyle"
|
|
998
1436
|
>
|
|
1437
|
+
<div v-if="hasInfo" class="border-b border-transparent"><div class="min-h-9" /></div>
|
|
999
1438
|
<div :class="BAR_HEIGHT_CLASS" />
|
|
1000
1439
|
</div>
|
|
1001
1440
|
</template>
|