@eldrajs/theme-cli 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -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 +65 -52
- package/template/blocks/collection-header/preview.json +4 -4
- package/template/blocks/collection-header/preview.png +0 -0
- package/template/blocks/contact/preview.png +0 -0
- package/template/blocks/cta/preview.json +4 -4
- package/template/blocks/cta/preview.png +0 -0
- package/template/blocks/faq/preview.png +0 -0
- package/template/blocks/feature-grid/Block.vue +73 -4
- package/template/blocks/feature-grid/__tests__/Block.spec.ts +43 -1
- package/template/blocks/feature-grid/block.json +2 -2
- package/template/blocks/feature-grid/preview.json +49 -24
- package/template/blocks/feature-grid/preview.png +0 -0
- package/template/blocks/footer/Block.vue +186 -71
- package/template/blocks/footer/__tests__/Block.spec.ts +127 -32
- package/template/blocks/footer/block.json +42 -4
- package/template/blocks/footer/mock.json +31 -34
- package/template/blocks/footer/preview.png +0 -0
- package/template/blocks/form/preview.png +0 -0
- package/template/blocks/gallery/preview.json +24 -24
- package/template/blocks/gallery/preview.png +0 -0
- package/template/blocks/hero/Block.vue +117 -19
- package/template/blocks/hero/__tests__/Block.spec.ts +46 -0
- package/template/blocks/hero/block.json +36 -1
- package/template/blocks/hero/preview.json +33 -25
- package/template/blocks/hero/preview.png +0 -0
- package/template/blocks/image/preview.json +4 -4
- package/template/blocks/image/preview.png +0 -0
- package/template/blocks/logo-cloud/preview.png +0 -0
- package/template/blocks/navigation/Block.vue +622 -184
- package/template/blocks/navigation/__tests__/Block.spec.ts +406 -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/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,157 @@ 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`.
|
|
958
|
+
link: 'min-h-11 rounded-full px-3 text-base font-medium hover:bg-surface aria-[current=page]:bg-surface-strong',
|
|
959
|
+
trigger:
|
|
960
|
+
'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
|
+
// The Menu tool: shown below 68.8125rem (the package hides it from `@content`), a labelled tool
|
|
962
|
+
// like its neighbours.
|
|
963
|
+
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, with the columns
|
|
965
|
+
// inside the same wide container the bar uses; a dropdown hangs under its trigger.
|
|
707
966
|
panel: 'pt-0',
|
|
708
|
-
content:
|
|
709
|
-
'rounded-none
|
|
710
|
-
|
|
711
|
-
|
|
967
|
+
content: [
|
|
968
|
+
'rounded-none border-0 border-b border-border bg-(--eldra-header-surface) shadow-(--eldra-shadow-float)',
|
|
969
|
+
'py-8 px-(--eldra-gutter-mobile) @tablet:px-(--eldra-gutter-tablet) @content:px-(--eldra-gutter-desktop)',
|
|
970
|
+
`${DROPDOWN}:mt-2 ${DROPDOWN}:w-[21rem] ${DROPDOWN}:rounded-lg ${DROPDOWN}:border ${DROPDOWN}:px-2 ${DROPDOWN}:pt-2 ${DROPDOWN}:pb-3`,
|
|
971
|
+
].join(' '),
|
|
972
|
+
// Link columns in equal tracks; a column of cards spans two of them. Inside the wide container.
|
|
712
973
|
columns:
|
|
713
|
-
'grid-cols-12 gap-
|
|
974
|
+
'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
975
|
group: 'col-span-3 [[data-cards]>&]:col-span-1 [[data-cards]>&[data-cards]]:col-span-2',
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
976
|
+
// Serif column headings, linked or plain.
|
|
977
|
+
groupHeading:
|
|
978
|
+
'font-heading px-0 pb-3 text-xl leading-tight font-medium tracking-normal normal-case text-text',
|
|
979
|
+
groupLink: 'text-text no-underline hover:underline underline-offset-[0.2em]',
|
|
980
|
+
panelList: 'gap-0.5',
|
|
981
|
+
// Quiet links that underline on hover; a link with a description (the dropdown) is a padded row
|
|
982
|
+
// with its title in `text` and a `surface` hover.
|
|
983
|
+
panelLink: [
|
|
984
|
+
'px-0 py-1.5 text-muted hover:bg-transparent hover:text-text hover:underline underline-offset-[0.2em]',
|
|
985
|
+
'[&: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',
|
|
986
|
+
// The column's "see all": primary, semibold, with an arrow.
|
|
987
|
+
'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 padded rows above it.
|
|
989
|
+
'in-[[class~="eldra:eldra-nav-menu-dropdown"]]:data-see-all:px-3',
|
|
990
|
+
].join(' '),
|
|
991
|
+
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`,
|
|
992
|
+
description: 'text-sm leading-snug',
|
|
993
|
+
badge:
|
|
994
|
+
'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 under it.
|
|
996
|
+
card: 'gap-2',
|
|
997
|
+
cardImage: 'rounded-lg',
|
|
998
|
+
cardTitle: 'text-base leading-snug font-semibold',
|
|
999
|
+
cardPrice: 'text-[0.9375rem]',
|
|
1000
|
+
footer:
|
|
1001
|
+
'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 size.
|
|
1003
|
+
drawerBody: 'px-0 pt-0',
|
|
1004
|
+
drawerLink: 'font-heading min-h-14 px-4 text-xl font-normal',
|
|
1005
|
+
drawerTrigger:
|
|
1006
|
+
'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
|
+
drawerSectionHeading: 'font-heading min-h-14 px-4 text-xl font-normal',
|
|
1008
|
+
drawerPanel: 'pb-0',
|
|
1009
|
+
drawerNest: 'ms-0 border-s-0 px-4 pb-5',
|
|
1010
|
+
drawerColumns: 'gap-5',
|
|
1011
|
+
drawerGroupHeading: 'px-0 pb-1 text-xs font-bold tracking-[0.12em] uppercase text-muted',
|
|
1012
|
+
drawerGroupLink: 'text-muted no-underline hover:underline',
|
|
1013
|
+
drawerPanelLink:
|
|
1014
|
+
'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',
|
|
1015
|
+
drawerPanelLabel: `font-normal in-data-see-all:font-semibold in-data-see-all:after:content-['→']`,
|
|
1016
|
+
drawerBadge:
|
|
1017
|
+
'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
|
+
drawerCardImage: 'rounded-lg',
|
|
1019
|
+
drawerCardTitle: 'font-semibold',
|
|
1020
|
+
drawerFooter:
|
|
1021
|
+
'flex-col items-stretch gap-3 bg-surface px-4 pt-5 pb-5 [&>[data-eldra-header-drawer-links]]:-mx-0',
|
|
718
1022
|
}));
|
|
719
1023
|
</script>
|
|
720
1024
|
|
|
@@ -727,42 +1031,118 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
727
1031
|
@focusin="onBarFocusIn"
|
|
728
1032
|
@focusout="onBarFocusOut"
|
|
729
1033
|
>
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
]
|
|
1034
|
+
<!-- The info strip: absent with no items. Phones keep its first item; below 68.8125rem the
|
|
1035
|
+
end of it moves into the drawer's footer. -->
|
|
1036
|
+
<div
|
|
1037
|
+
v-if="hasInfo"
|
|
1038
|
+
data-eldra-header-info
|
|
1039
|
+
role="region"
|
|
1040
|
+
:aria-label="t('header.info')"
|
|
1041
|
+
:class="[
|
|
1042
|
+
'text-[0.8125rem]',
|
|
1043
|
+
isTransparent
|
|
1044
|
+
? 'border-primary-contrast/24 border-b bg-transparent'
|
|
1045
|
+
: 'bg-surface text-muted border-border border-b',
|
|
1046
|
+
]"
|
|
1047
|
+
>
|
|
1048
|
+
<Container
|
|
1049
|
+
width="wide"
|
|
1050
|
+
class="flex min-h-9 items-center justify-between gap-4 @max-[47.5625rem]:justify-center"
|
|
739
1051
|
>
|
|
1052
|
+
<ul v-if="infoStart.length > 0" class="m-0 flex list-none gap-6 p-0">
|
|
1053
|
+
<li
|
|
1054
|
+
v-for="(item, index) in infoStart"
|
|
1055
|
+
:key="`start-${index}`"
|
|
1056
|
+
:class="['inline-flex items-center gap-1.5', infoItemClass(index)]"
|
|
1057
|
+
>
|
|
1058
|
+
<EldraIcon
|
|
1059
|
+
v-if="item.icon"
|
|
1060
|
+
:name="item.icon"
|
|
1061
|
+
size="sm"
|
|
1062
|
+
:class="['size-4', isTransparent ? '' : 'text-primary']"
|
|
1063
|
+
/>
|
|
1064
|
+
<Link
|
|
1065
|
+
v-if="item.href"
|
|
1066
|
+
:href="item.href"
|
|
1067
|
+
:as="item.linkAs"
|
|
1068
|
+
variant="standalone"
|
|
1069
|
+
:underline="false"
|
|
1070
|
+
:class="['font-normal', isTransparent ? 'text-current' : 'text-text']"
|
|
1071
|
+
>{{ item.text }}</Link
|
|
1072
|
+
>
|
|
1073
|
+
<span v-else>{{ item.text }}</span>
|
|
1074
|
+
</li>
|
|
1075
|
+
</ul>
|
|
1076
|
+
<ul v-if="infoEnd.length > 0" :class="['m-0 flex list-none gap-6 p-0', infoEndClass]">
|
|
1077
|
+
<li
|
|
1078
|
+
v-for="(item, index) in infoEnd"
|
|
1079
|
+
:key="`end-${index}`"
|
|
1080
|
+
:class="[
|
|
1081
|
+
'inline-flex items-center gap-1.5',
|
|
1082
|
+
infoStart.length > 0 ? '' : infoItemClass(index),
|
|
1083
|
+
]"
|
|
1084
|
+
>
|
|
1085
|
+
<EldraIcon
|
|
1086
|
+
v-if="item.icon"
|
|
1087
|
+
:name="item.icon"
|
|
1088
|
+
size="sm"
|
|
1089
|
+
:class="['size-4', isTransparent ? '' : 'text-primary']"
|
|
1090
|
+
/>
|
|
1091
|
+
<Link
|
|
1092
|
+
v-if="item.href"
|
|
1093
|
+
:href="item.href"
|
|
1094
|
+
:as="item.linkAs"
|
|
1095
|
+
variant="standalone"
|
|
1096
|
+
:underline="false"
|
|
1097
|
+
:class="['font-normal', isTransparent ? 'text-current' : 'text-text']"
|
|
1098
|
+
>{{ item.text }}</Link
|
|
1099
|
+
>
|
|
1100
|
+
<span v-else>{{ item.text }}</span>
|
|
1101
|
+
</li>
|
|
1102
|
+
</ul>
|
|
1103
|
+
</Container>
|
|
1104
|
+
</div>
|
|
1105
|
+
|
|
1106
|
+
<Container width="wide">
|
|
1107
|
+
<div data-eldra-header-bar :class="[BAR_HEIGHT_CLASS, barGridClass]">
|
|
740
1108
|
<Link
|
|
741
1109
|
:href="brandHref"
|
|
742
1110
|
:as="EldraRouterLink"
|
|
743
1111
|
variant="standalone"
|
|
744
1112
|
:underline="false"
|
|
1113
|
+
:aria-label="brandName"
|
|
745
1114
|
data-eldra-header-focus
|
|
746
|
-
|
|
1115
|
+
data-eldra-header-brand
|
|
1116
|
+
:class="`flex max-w-full min-w-0 rounded-sm text-current hover:no-underline ${brandPositionClass}`"
|
|
1117
|
+
:classes="{
|
|
1118
|
+
label: 'flex min-w-0 max-w-full items-center gap-2.5 @max-[47.5625rem]:gap-2',
|
|
1119
|
+
}"
|
|
747
1120
|
>
|
|
1121
|
+
<img
|
|
1122
|
+
v-if="brandMarkUrl"
|
|
1123
|
+
:src="brandMarkUrl"
|
|
1124
|
+
alt=""
|
|
1125
|
+
:class="brandMarkClass"
|
|
1126
|
+
loading="eager"
|
|
1127
|
+
decoding="async"
|
|
1128
|
+
/>
|
|
748
1129
|
<img
|
|
749
1130
|
v-if="brandLogoUrl"
|
|
750
1131
|
:src="brandLogoUrl"
|
|
751
|
-
|
|
752
|
-
class="
|
|
1132
|
+
alt=""
|
|
1133
|
+
:class="brandLogoClass"
|
|
753
1134
|
loading="eager"
|
|
754
1135
|
decoding="async"
|
|
755
1136
|
/>
|
|
756
|
-
<!-- The
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
<span v-else class="overflow-hidden text-ellipsis whitespace-nowrap">{{
|
|
762
|
-
data.brandText
|
|
763
|
-
}}</span>
|
|
1137
|
+
<!-- The wordmark never wraps on a wider screen (block.json's own 20-character maxLength
|
|
1138
|
+
keeps it fitting); `min-w-0` on the link and this span's ellipsis are the fallback for
|
|
1139
|
+
the rare case that still doesn't leave enough room. Below 360px a text-only wordmark
|
|
1140
|
+
wraps onto two centred lines instead. -->
|
|
1141
|
+
<span v-if="brandTextClass !== null" :class="brandTextClass">{{ data.brandText }}</span>
|
|
764
1142
|
</Link>
|
|
765
1143
|
|
|
1144
|
+
<!-- `NavMenu` collapses at its nearest stage, `@content` (64rem); the `nav` and `toggle`
|
|
1145
|
+
classes below move that to the design's 68.8125rem (1100px) from this side. -->
|
|
766
1146
|
<NavMenu
|
|
767
1147
|
v-if="drawerHasContent"
|
|
768
1148
|
v-model="openMenuIndex"
|
|
@@ -770,6 +1150,7 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
770
1150
|
:items="navItems"
|
|
771
1151
|
:aria-label="t('header.primary')"
|
|
772
1152
|
:collapse-below="variant === 'minimal' ? 'always' : '@content'"
|
|
1153
|
+
:drawer-layout="drawerLayout"
|
|
773
1154
|
open-on-hover
|
|
774
1155
|
:link-as="MenuLink"
|
|
775
1156
|
:card-aspect="cardAspect"
|
|
@@ -778,8 +1159,8 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
778
1159
|
:classes="navMenuClasses"
|
|
779
1160
|
>
|
|
780
1161
|
<template #toggle>
|
|
781
|
-
<EldraIcon name="menu-2" size="md" />
|
|
782
|
-
<span
|
|
1162
|
+
<EldraIcon name="menu-2" size="md" :class="TOOL_ICON_CLASSES" />
|
|
1163
|
+
<span class="whitespace-nowrap">{{ t('header.menu') }}</span>
|
|
783
1164
|
</template>
|
|
784
1165
|
<template #panelFooter="{ item, index }">
|
|
785
1166
|
<Link
|
|
@@ -789,13 +1170,59 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
789
1170
|
variant="standalone"
|
|
790
1171
|
arrow
|
|
791
1172
|
data-eldra-mega-view-all
|
|
1173
|
+
:underline="false"
|
|
792
1174
|
:aria-label="t('header.viewAllOf', { label: item.label ?? '' })"
|
|
793
|
-
class="text-
|
|
1175
|
+
class="text-primary text-[0.9375rem] font-semibold"
|
|
794
1176
|
>
|
|
795
1177
|
{{ t('header.viewAll') }}
|
|
796
1178
|
</Link>
|
|
797
1179
|
</template>
|
|
798
|
-
<template
|
|
1180
|
+
<template #drawerFooter="{ close }">
|
|
1181
|
+
<ul
|
|
1182
|
+
v-if="accountHref || variant !== 'minimal' || infoEndLinks.length > 0"
|
|
1183
|
+
data-eldra-header-drawer-links
|
|
1184
|
+
class="m-0 grid list-none gap-3 p-0 text-[0.9375rem]"
|
|
1185
|
+
>
|
|
1186
|
+
<li v-if="accountHref">
|
|
1187
|
+
<Link
|
|
1188
|
+
:href="accountHref"
|
|
1189
|
+
:as="accountLinkAs"
|
|
1190
|
+
variant="standalone"
|
|
1191
|
+
:underline="false"
|
|
1192
|
+
class="text-text font-medium"
|
|
1193
|
+
:classes="{ label: 'inline-flex items-center gap-2' }"
|
|
1194
|
+
@click="close"
|
|
1195
|
+
>
|
|
1196
|
+
<EldraIcon name="user" size="md" />{{ t('header.account') }}
|
|
1197
|
+
</Link>
|
|
1198
|
+
</li>
|
|
1199
|
+
<li v-if="variant !== 'minimal'">
|
|
1200
|
+
<Link
|
|
1201
|
+
:href="wishlistHref"
|
|
1202
|
+
:as="EldraRouterLink"
|
|
1203
|
+
variant="standalone"
|
|
1204
|
+
:underline="false"
|
|
1205
|
+
class="text-text font-medium"
|
|
1206
|
+
:classes="{ label: 'inline-flex items-center gap-2' }"
|
|
1207
|
+
@click="close"
|
|
1208
|
+
>
|
|
1209
|
+
<EldraIcon name="heart" size="md" />{{ t('header.savedItems') }}
|
|
1210
|
+
</Link>
|
|
1211
|
+
</li>
|
|
1212
|
+
<li v-for="(item, index) in infoEndLinks" :key="`drawer-info-${index}`">
|
|
1213
|
+
<Link
|
|
1214
|
+
:href="item.href"
|
|
1215
|
+
:as="item.linkAs"
|
|
1216
|
+
variant="standalone"
|
|
1217
|
+
:underline="false"
|
|
1218
|
+
class="text-text font-medium"
|
|
1219
|
+
:classes="{ label: 'inline-flex items-center gap-2' }"
|
|
1220
|
+
@click="close"
|
|
1221
|
+
>
|
|
1222
|
+
<EldraIcon v-if="item.icon" :name="item.icon" size="md" />{{ item.text }}
|
|
1223
|
+
</Link>
|
|
1224
|
+
</li>
|
|
1225
|
+
</ul>
|
|
799
1226
|
<CurrencyPicker
|
|
800
1227
|
:currencies="currency.offered.value"
|
|
801
1228
|
:model-value="currency.active.value"
|
|
@@ -818,87 +1245,87 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
818
1245
|
</Button>
|
|
819
1246
|
</template>
|
|
820
1247
|
</NavMenu>
|
|
1248
|
+
<span
|
|
1249
|
+
v-else
|
|
1250
|
+
aria-hidden="true"
|
|
1251
|
+
data-eldra-header-spacer-tool
|
|
1252
|
+
:class="['col-start-1 row-start-1', toolSpacerClass]"
|
|
1253
|
+
/>
|
|
821
1254
|
<EditorPlaceholder
|
|
822
1255
|
v-if="showLinksPlaceholder"
|
|
823
1256
|
inline
|
|
824
1257
|
:label="t('editor.addLink')"
|
|
825
|
-
:class="
|
|
1258
|
+
:class="`hidden @min-[68.8125rem]:flex ${linksPositionClass}`"
|
|
826
1259
|
/>
|
|
827
1260
|
|
|
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]">
|
|
1261
|
+
<div :class="['flex items-center', searchPositionClass]">
|
|
834
1262
|
<template v-if="showSearch">
|
|
1263
|
+
<!-- `field`: the "Search the shop" pill from 80rem, the labelled Search tool below.
|
|
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
|
+
/>
|
|
835
1291
|
<Button
|
|
836
|
-
v-if="searchStyle === 'icon'"
|
|
837
1292
|
variant="ghost"
|
|
838
1293
|
size="sm"
|
|
839
|
-
icon-only
|
|
840
|
-
:label="t('header.search')"
|
|
841
1294
|
aria-haspopup="dialog"
|
|
1295
|
+
:class="[
|
|
1296
|
+
TOOL_CLASSES,
|
|
1297
|
+
searchStyle === 'field'
|
|
1298
|
+
? '@wide:hidden'
|
|
1299
|
+
: searchStyle === 'inline'
|
|
1300
|
+
? '@min-[68.8125rem]:hidden'
|
|
1301
|
+
: '',
|
|
1302
|
+
]"
|
|
842
1303
|
@click="openSearch"
|
|
843
1304
|
>
|
|
844
1305
|
<template #leadingIcon>
|
|
845
|
-
<EldraIcon name="search" size="md" />
|
|
1306
|
+
<EldraIcon name="search" size="md" :class="TOOL_ICON_CLASSES" />
|
|
846
1307
|
</template>
|
|
1308
|
+
{{ t('header.search') }}
|
|
847
1309
|
</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
1310
|
</template>
|
|
1311
|
+
<span v-else aria-hidden="true" data-eldra-header-spacer-tool :class="toolSpacerClass" />
|
|
899
1312
|
</div>
|
|
900
1313
|
|
|
901
|
-
<div data-eldra-header-actions :class="['flex items-center gap-
|
|
1314
|
+
<div data-eldra-header-actions :class="['flex items-center gap-0.5', actionsPositionClass]">
|
|
1315
|
+
<Button
|
|
1316
|
+
v-if="accountHref"
|
|
1317
|
+
variant="ghost"
|
|
1318
|
+
size="sm"
|
|
1319
|
+
:href="accountHref"
|
|
1320
|
+
:as="accountLinkAs"
|
|
1321
|
+
:class="[TOOL_CLASSES, '@max-[68.8125rem]:hidden']"
|
|
1322
|
+
>
|
|
1323
|
+
<template #leadingIcon>
|
|
1324
|
+
<EldraIcon name="user" size="md" :class="TOOL_ICON_CLASSES" />
|
|
1325
|
+
</template>
|
|
1326
|
+
{{ t('header.account') }}
|
|
1327
|
+
</Button>
|
|
1328
|
+
|
|
902
1329
|
<!-- In every header but `minimal`, prerendered ones included: see `wishlist` in the
|
|
903
1330
|
script above. `EldraRouterLink` because `/wishlist` is this theme's own route — it
|
|
904
1331
|
should route, not reload the document. -->
|
|
@@ -906,14 +1333,15 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
906
1333
|
<Button
|
|
907
1334
|
variant="ghost"
|
|
908
1335
|
size="sm"
|
|
909
|
-
|
|
910
|
-
:label="wishlistAccessibleName"
|
|
1336
|
+
:aria-label="wishlistAccessibleName"
|
|
911
1337
|
:href="wishlistHref"
|
|
912
1338
|
:as="EldraRouterLink"
|
|
1339
|
+
:class="TOOL_CLASSES"
|
|
913
1340
|
>
|
|
914
1341
|
<template #leadingIcon>
|
|
915
|
-
<EldraIcon name="heart" size="md" />
|
|
1342
|
+
<EldraIcon name="heart" size="md" :class="TOOL_ICON_CLASSES" />
|
|
916
1343
|
</template>
|
|
1344
|
+
{{ t('header.saved') }}
|
|
917
1345
|
</Button>
|
|
918
1346
|
<!-- The bag's own two rules: no badge at zero, and `pointer-events-none`, because the
|
|
919
1347
|
count is decorative (the button's accessible name carries it) and must not swallow
|
|
@@ -921,41 +1349,46 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
921
1349
|
<Badge
|
|
922
1350
|
v-if="wishlistCount > 0"
|
|
923
1351
|
aria-hidden="true"
|
|
924
|
-
tone="
|
|
1352
|
+
tone="accent"
|
|
925
1353
|
pill
|
|
926
1354
|
:label="wishlistBadgeLabel"
|
|
927
1355
|
:class="COUNT_PILL_CLASSES"
|
|
928
1356
|
/>
|
|
929
1357
|
</span>
|
|
1358
|
+
<!-- `minimal` has no Saved tool; this keeps its two sides the same width. -->
|
|
1359
|
+
<span
|
|
1360
|
+
v-else
|
|
1361
|
+
aria-hidden="true"
|
|
1362
|
+
data-eldra-header-spacer-tool
|
|
1363
|
+
:class="TOOL_WIDTH_CLASSES"
|
|
1364
|
+
/>
|
|
930
1365
|
|
|
931
1366
|
<span class="relative inline-flex">
|
|
932
1367
|
<Button
|
|
933
1368
|
variant="ghost"
|
|
934
1369
|
size="sm"
|
|
935
|
-
|
|
936
|
-
:label="cartAccessibleName"
|
|
1370
|
+
:aria-label="cartAccessibleName"
|
|
937
1371
|
:href="cartHref"
|
|
938
1372
|
:as="toLinkAs(cartHref)"
|
|
939
1373
|
:aria-haspopup="cartPopupType"
|
|
1374
|
+
:class="TOOL_CLASSES"
|
|
940
1375
|
@click="onCartClick"
|
|
941
1376
|
>
|
|
942
1377
|
<template #leadingIcon>
|
|
943
|
-
<EldraIcon name="shopping-bag" size="md" />
|
|
1378
|
+
<EldraIcon name="shopping-bag" size="md" :class="TOOL_ICON_CLASSES" />
|
|
944
1379
|
</template>
|
|
1380
|
+
{{ t('header.cart') }}
|
|
945
1381
|
</Button>
|
|
946
1382
|
<Badge
|
|
947
1383
|
v-if="cartCount > 0"
|
|
948
1384
|
aria-hidden="true"
|
|
949
|
-
tone="
|
|
1385
|
+
tone="accent"
|
|
950
1386
|
pill
|
|
951
1387
|
:label="cartBadgeLabel"
|
|
952
1388
|
:class="COUNT_PILL_CLASSES"
|
|
953
1389
|
/>
|
|
954
1390
|
</span>
|
|
955
1391
|
|
|
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
1392
|
<CurrencyPicker
|
|
960
1393
|
:currencies="currency.offered.value"
|
|
961
1394
|
:model-value="currency.active.value"
|
|
@@ -963,13 +1396,15 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
963
1396
|
:class="barPickerClass"
|
|
964
1397
|
@update:model-value="currency.choose"
|
|
965
1398
|
/>
|
|
1399
|
+
<!-- The call to action sits 0.75rem after the cart where the links are inline: 0.125rem of
|
|
1400
|
+
that is the actions row's own gap, `ml-2.5` the rest. In the drawer below. -->
|
|
966
1401
|
<Button
|
|
967
1402
|
v-if="hasCta && variant !== 'minimal'"
|
|
968
1403
|
variant="primary"
|
|
969
1404
|
size="sm"
|
|
970
1405
|
:href="ctaHref"
|
|
971
1406
|
:as="ctaLinkAs"
|
|
972
|
-
class="@
|
|
1407
|
+
class="ml-2.5 hidden @min-[68.8125rem]:inline-flex"
|
|
973
1408
|
>
|
|
974
1409
|
{{ ctaLabel }}
|
|
975
1410
|
</Button>
|
|
@@ -988,7 +1423,9 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
988
1423
|
<!-- The flow the fixed bar left behind — see `barSpacerClasses`. Empty and unlabelled: it is
|
|
989
1424
|
layout, with nothing in it for a screen reader or the tab order to reach. The outer box is the
|
|
990
1425
|
`<header>`'s counterpart (the `@container` the height is measured in, and the hairline) and the
|
|
991
|
-
inner
|
|
1426
|
+
inner ones the info strip's and the bar grid's (the height itself). The info strip's box
|
|
1427
|
+
keeps its hairline outside the height, as the strip's own `border-b` sits outside its
|
|
1428
|
+
`min-h-9` container: one box with both would be a pixel short of the bar until measured. -->
|
|
992
1429
|
<div
|
|
993
1430
|
v-if="sticky"
|
|
994
1431
|
data-eldra-header-spacer
|
|
@@ -996,6 +1433,7 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
996
1433
|
:class="barSpacerClasses"
|
|
997
1434
|
:style="barSpacerStyle"
|
|
998
1435
|
>
|
|
1436
|
+
<div v-if="hasInfo" class="border-b border-transparent"><div class="min-h-9" /></div>
|
|
999
1437
|
<div :class="BAR_HEIGHT_CLASS" />
|
|
1000
1438
|
</div>
|
|
1001
1439
|
</template>
|