@eldrajs/theme-cli 0.2.7 → 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 -0
- package/package.json +3 -3
- package/template/.eldra/block-types.d.ts +28 -7
- package/template/.eldra/manifest.json +1152 -445
- 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 +665 -184
- package/template/blocks/navigation/__tests__/Block.spec.ts +496 -75
- package/template/blocks/navigation/__tests__/fixtures/menu.json +182 -0
- package/template/blocks/navigation/block.json +110 -6
- package/template/blocks/navigation/mock.json +372 -140
- 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/package.json +1 -1
- 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/bowl.webp +0 -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/prerenderFailure.spec.ts +4 -3
- package/template/test/prerenderRefresh.browser.spec.ts +36 -15
- package/template/test/previewParity.browser.spec.ts +1152 -0
- package/template/test/starter.spec.ts +37 -16
- package/template/test/storefront/gatewayPrerender.spec.ts +26 -0
- package/template/test/support/previewParity.ts +302 -0
- package/template/test/support/previewParityContent.ts +726 -0
- package/template/tokens.json +13 -13
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/** Header (design spec 2); apiId stays `navigation`. Layout: docs/starter-kit.md, "The header". */
|
|
3
3
|
import { computed, onMounted, ref, watchEffect } from 'vue';
|
|
4
4
|
import { useEldraLink, useEldraLocale } from '@eldrajs/theme-vue';
|
|
5
|
+
import type { ResolvedLink, ResolvedSection } from '@eldrajs/theme-vue';
|
|
5
6
|
import {
|
|
6
7
|
Badge,
|
|
7
8
|
Button,
|
|
@@ -15,6 +16,7 @@ import {
|
|
|
15
16
|
} from '@eldrajs/ui';
|
|
16
17
|
import type {
|
|
17
18
|
NavMenuItem,
|
|
19
|
+
NavMenuLink,
|
|
18
20
|
NavMenuPart,
|
|
19
21
|
SearchResultItem,
|
|
20
22
|
SearchResults,
|
|
@@ -27,11 +29,16 @@ import { useWishlist } from '../../app/composables/useWishlist';
|
|
|
27
29
|
import { useI18n } from 'vue-i18n';
|
|
28
30
|
import EldraIcon from '../../app/components/EldraIcon.vue';
|
|
29
31
|
import EldraRouterLink from '../../app/components/EldraRouterLink.vue';
|
|
30
|
-
import { isInternalHref, SEARCH_PATH } from '../../app/utils/links';
|
|
32
|
+
import { isInternalHref, safeHref, SEARCH_PATH } from '../../app/utils/links';
|
|
31
33
|
import { useMoney } from '../../app/storefront/money';
|
|
32
34
|
import type { StorefrontSearchResponse } from '../../app/storefront/types';
|
|
33
35
|
import MenuLink from './parts/MenuLink.vue';
|
|
34
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];
|
|
40
|
+
import blockJson from './block.json';
|
|
41
|
+
|
|
35
42
|
const props = defineProps<{ entry: EldraBlockEntry<'navigation'> }>();
|
|
36
43
|
const { data } = useBlockData(props, 'navigation');
|
|
37
44
|
|
|
@@ -41,10 +48,79 @@ const storefront = useStorefront();
|
|
|
41
48
|
|
|
42
49
|
const variant = computed<'default' | 'centered' | 'minimal'>(() => data.value.variant ?? 'default');
|
|
43
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
|
+
|
|
44
68
|
// --- brand -----------------------------------------------------------------------------------
|
|
45
69
|
|
|
46
|
-
const
|
|
70
|
+
const brandLogo = computed(() => data.value.brandLogo);
|
|
71
|
+
const brandLogoUrl = computed(() => brandLogo.value?.url);
|
|
72
|
+
const brandMarkUrl = computed(() => data.value.brandMark?.url);
|
|
47
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
|
+
});
|
|
48
124
|
|
|
49
125
|
// --- links + mega-menus ------------------------------------------------------------------------
|
|
50
126
|
|
|
@@ -57,19 +133,117 @@ function toLinkAs(href: string | undefined): typeof EldraRouterLink | undefined
|
|
|
57
133
|
return href !== undefined && isInternalHref(href) ? EldraRouterLink : undefined;
|
|
58
134
|
}
|
|
59
135
|
|
|
60
|
-
/** A row with no label has nothing to show; one whose target is gone keeps its label as text.
|
|
61
|
-
|
|
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(() =>
|
|
62
139
|
rawLinks.value.flatMap((item) => {
|
|
63
140
|
const resolved = resolveLink(item);
|
|
64
|
-
return resolved === null || resolved.label === null ? [] : [resolved];
|
|
141
|
+
return resolved === null || resolved.label === null ? [] : [{ resolved, raw: item as unknown }];
|
|
65
142
|
})
|
|
66
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
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* The picture crop of a menu card: the `aspect` this block's own `links` field declares in
|
|
184
|
+
* `cards`, so the declaration and the drawing cannot drift. `NavMenu` falls back to 4:3 on a
|
|
185
|
+
* value that is not `width:height`.
|
|
186
|
+
*/
|
|
187
|
+
const cardAspect = (
|
|
188
|
+
blockJson.fields.find((field) => field.fieldId === 'links') as
|
|
189
|
+
| {
|
|
190
|
+
metadata?: {
|
|
191
|
+
item?: { metadata?: { tree?: { cards?: { aspect?: string } } } };
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
| undefined
|
|
195
|
+
)?.metadata?.item?.metadata?.tree?.cards?.aspect;
|
|
196
|
+
|
|
197
|
+
/** A resolved link as the menu draws it, `display` and `card` (child and section links only) kept. */
|
|
198
|
+
function toNavLink(link: ResolvedLink, extras: LinkExtras = {}): NavMenuLink {
|
|
199
|
+
return {
|
|
200
|
+
label: link.label,
|
|
201
|
+
href: link.href,
|
|
202
|
+
newTab: link.newTab,
|
|
203
|
+
group: link.group,
|
|
204
|
+
current: isCurrent(link.href),
|
|
205
|
+
display: link.display,
|
|
206
|
+
card: link.card,
|
|
207
|
+
badge: extras.badge,
|
|
208
|
+
description: extras.description,
|
|
209
|
+
};
|
|
210
|
+
}
|
|
67
211
|
|
|
68
|
-
|
|
212
|
+
function toNavSection(section: ResolvedSection, extras: LinkExtras[] = []): NavMenuSection {
|
|
213
|
+
return {
|
|
214
|
+
heading: section.heading,
|
|
215
|
+
headingLink: section.headingLink === null ? null : toNavLink(section.headingLink),
|
|
216
|
+
display: section.display,
|
|
217
|
+
links: section.links.map((link, index) => toNavLink(link, extras[index])),
|
|
218
|
+
seeAll: section.seeAll === null ? null : toNavLink(section.seeAll),
|
|
219
|
+
};
|
|
220
|
+
}
|
|
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
|
+
|
|
237
|
+
/**
|
|
238
|
+
* A parent with a panel is a disclosure, so its own destination moves to the panel's "View all". The
|
|
239
|
+
* panel is its `sections` when the site served them (this block declares them), else its `children`
|
|
240
|
+
* grouped by their `group`, which is what a menu stored before sections existed still is.
|
|
241
|
+
*/
|
|
69
242
|
const navItems = computed<NavMenuItem[]>(() =>
|
|
70
|
-
|
|
243
|
+
linkEntries.value.map(({ resolved: link, raw }) => {
|
|
244
|
+
const sections = link.sections ?? [];
|
|
71
245
|
const children = link.children.filter((child) => child.label !== null);
|
|
72
|
-
if (children.length === 0) {
|
|
246
|
+
if (sections.length === 0 && children.length === 0) {
|
|
73
247
|
return {
|
|
74
248
|
label: link.label,
|
|
75
249
|
href: link.href,
|
|
@@ -77,22 +251,28 @@ const navItems = computed<NavMenuItem[]>(() =>
|
|
|
77
251
|
current: isCurrent(link.href),
|
|
78
252
|
};
|
|
79
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);
|
|
80
262
|
return {
|
|
81
263
|
label: link.label,
|
|
82
|
-
layout: 'mega',
|
|
83
|
-
|
|
84
|
-
label: child.label,
|
|
85
|
-
href: child.href,
|
|
86
|
-
newTab: child.newTab,
|
|
87
|
-
group: child.group,
|
|
88
|
-
current: isCurrent(child.href),
|
|
89
|
-
})),
|
|
264
|
+
layout: isDropdown(sections) ? 'dropdown' : 'mega',
|
|
265
|
+
sections: sections.map((section, index) => toNavSection(section, extras[index])),
|
|
90
266
|
};
|
|
91
267
|
})
|
|
92
268
|
);
|
|
93
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. */
|
|
94
272
|
function viewAllHref(index: number): string | undefined {
|
|
95
|
-
|
|
273
|
+
const link = links.value[index];
|
|
274
|
+
if (link?.sections?.some((section) => section.seeAll !== null) === true) return undefined;
|
|
275
|
+
return link?.href ?? undefined;
|
|
96
276
|
}
|
|
97
277
|
|
|
98
278
|
const openMenuIndex = ref<number | null>(null);
|
|
@@ -108,6 +288,57 @@ const ctaLinkAs = computed(() => toLinkAs(ctaHref.value));
|
|
|
108
288
|
const ctaLabel = computed(() => data.value.ctaLabel ?? ctaLink.value?.label ?? '');
|
|
109
289
|
const hasCta = computed(() => Boolean(ctaLabel.value && ctaHref.value));
|
|
110
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
|
+
|
|
111
342
|
// --- search ------------------------------------------------------------------------------------
|
|
112
343
|
|
|
113
344
|
const showSearch = computed(() => data.value.showSearch !== false);
|
|
@@ -115,7 +346,11 @@ const showSearch = computed(() => data.value.showSearch !== false);
|
|
|
115
346
|
* centered variant only"). */
|
|
116
347
|
const searchStyle = computed<'icon' | 'field' | 'inline'>(() => {
|
|
117
348
|
const style = data.value.searchStyle ?? 'icon';
|
|
118
|
-
|
|
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;
|
|
119
354
|
});
|
|
120
355
|
|
|
121
356
|
const searchOpen = ref(false);
|
|
@@ -213,34 +448,37 @@ function openSearch(): void {
|
|
|
213
448
|
// --- cart + wishlist count pills --------------------------------------------------------------
|
|
214
449
|
|
|
215
450
|
/**
|
|
216
|
-
* A count pill is a corner badge
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
225
|
-
* corner badge sits *on* the icon by design — a ring here would just push it back off the corner.
|
|
226
|
-
* `-top-0.5 -right-0.5` sits it at the button's own top-right corner, nudged slightly outside it
|
|
227
|
-
* (2px past the 2rem button's own edge on each side) rather than tucked inside — `top-0.5
|
|
228
|
-
* right-0.5` was tried first and measured worse: with real padding and a real glyph the pill is
|
|
229
|
-
* wider than its 0.875rem floor, so pulled inside the button it still buried roughly a third of
|
|
230
|
-
* the icon's area under it. Pushed just outside instead, it lands mostly over the button's own
|
|
231
|
-
* padding and clears the icon by a wide margin. `countPill.browser.spec.ts` measures the overlap
|
|
232
|
-
* against the icon's real `<svg>` box (not an assumed one) and keeps it well under a quarter of
|
|
233
|
-
* the icon's area. The same override styles both the cart and the wishlist pill (spec: "the cart
|
|
234
|
-
* button and its count badge" — the wishlist one is drawn identically), so it is one constant
|
|
235
|
-
* 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.
|
|
236
460
|
*
|
|
237
461
|
* `Badge`'s own root carries `min-h-6` and `text-badge` (1.5rem min height, the package's own
|
|
238
462
|
* type-style utility); passed as the Badge's `class`, these app utilities outrank its `eldra:`
|
|
239
463
|
* classes by cascade layer, with no `!important` and no need for a `size` prop (`Badge` has none).
|
|
240
464
|
*/
|
|
241
465
|
const COUNT_PILL_CLASSES =
|
|
242
|
-
'pointer-events-none absolute
|
|
243
|
-
'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]';
|
|
244
482
|
|
|
245
483
|
// --- cart --------------------------------------------------------------------------------------
|
|
246
484
|
|
|
@@ -315,18 +553,18 @@ function onCartClick(): void {
|
|
|
315
553
|
* would be the theme deciding the variant means something else. The drawer gets no wishlist row
|
|
316
554
|
* either, so the variant stays consistent in both directions.
|
|
317
555
|
*
|
|
318
|
-
* **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.
|
|
319
557
|
* Deliberate, and the bag's own rule: a shopper who saved something on a phone has no other way
|
|
320
558
|
* back to it, where the call to action has a drawer row.
|
|
321
559
|
*/
|
|
322
560
|
const wishlist = useWishlist();
|
|
323
561
|
const wishlistCount = wishlist.count;
|
|
324
562
|
const wishlistHref = '/wishlist';
|
|
325
|
-
/** The bag's three forms, with a plainer empty one: nothing saved reads as just "
|
|
326
|
-
*
|
|
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
|
|
327
565
|
* saying about a bag a visitor may have just filled and says nothing about a list they have never
|
|
328
|
-
* used.
|
|
329
|
-
* 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. */
|
|
330
568
|
const wishlistAccessibleName = computed(() => {
|
|
331
569
|
const count = wishlistCount.value;
|
|
332
570
|
if (count === 0) return t('header.wishlistEmpty');
|
|
@@ -403,11 +641,11 @@ const focusWithinBar = ref(false);
|
|
|
403
641
|
/**
|
|
404
642
|
* The bar's height, named once: the bar sets it on its own grid and the spacer reserves the very
|
|
405
643
|
* same box. Two literals would drift the first time a breakpoint moved, and a spacer that drifts
|
|
406
|
-
* 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
|
|
407
645
|
* as the container it is measured in — which is why both boxes sit inside an `@container` of the
|
|
408
646
|
* block's own width.
|
|
409
647
|
*/
|
|
410
|
-
const BAR_HEIGHT_CLASS = 'h-
|
|
648
|
+
const BAR_HEIGHT_CLASS = 'min-h-[4.5rem] @max-[47.5625rem]:min-h-[3.75rem]';
|
|
411
649
|
let lastScrollY = 0;
|
|
412
650
|
const SCROLL_JITTER = 4;
|
|
413
651
|
function onScroll(): void {
|
|
@@ -456,12 +694,17 @@ function onBarFocusOut(event: FocusEvent): void {
|
|
|
456
694
|
const next = event.relatedTarget;
|
|
457
695
|
focusWithinBar.value = next instanceof Node && (barRoot.value?.contains(next) ?? false);
|
|
458
696
|
}
|
|
459
|
-
/** Spec "Header" → Accessibility, "Sticky header and focus": scroll padding
|
|
460
|
-
*
|
|
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. */
|
|
461
704
|
watchEffect((onCleanup) => {
|
|
462
705
|
if (typeof document === 'undefined') return;
|
|
463
706
|
if (!sticky.value) return;
|
|
464
|
-
document.documentElement.style.setProperty('scroll-padding-top', '
|
|
707
|
+
document.documentElement.style.setProperty('scroll-padding-top', '7rem');
|
|
465
708
|
onCleanup(() => document.documentElement.style.removeProperty('scroll-padding-top'));
|
|
466
709
|
});
|
|
467
710
|
|
|
@@ -572,9 +815,15 @@ const barSurfaceStyle = { [HEADER_SURFACE_VAR]: 'var(--color-background)' };
|
|
|
572
815
|
const barRootClasses = computed(() =>
|
|
573
816
|
[
|
|
574
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.
|
|
575
824
|
sticky.value
|
|
576
|
-
? 'fixed inset-x-0 top-0 z-40 motion-safe:transition-transform motion-safe:duration-base'
|
|
577
|
-
: '',
|
|
825
|
+
? 'fixed inset-x-0 top-0 z-40 pr-(--eldra-scrollbar-width,0px) motion-safe:transition-transform motion-safe:duration-base'
|
|
826
|
+
: 'relative',
|
|
578
827
|
barHidden.value ? '-translate-y-full' : '',
|
|
579
828
|
isTransparent.value
|
|
580
829
|
? 'bg-transparent text-primary-contrast'
|
|
@@ -591,7 +840,7 @@ const barRootClasses = computed(() =>
|
|
|
591
840
|
*
|
|
592
841
|
* The height classes are what the first paint of a prerendered page has, before the bar has been
|
|
593
842
|
* measured at all — a spacer that started at zero would drop the page by the bar's height and lift
|
|
594
|
-
* 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
|
|
595
844
|
* block's own width to be measured in: the bar has one (its own `@container` root), and the spacer
|
|
596
845
|
* is one, which is why the box that holds the height is a child rather than the spacer itself.
|
|
597
846
|
* `barHeight` takes over the moment the `ResizeObserver` above has a real number, and from then on
|
|
@@ -619,60 +868,157 @@ const hairlineClass = computed(() =>
|
|
|
619
868
|
|
|
620
869
|
/** The drawer holds the links and the call to action; with neither there is no Menu button either. */
|
|
621
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
|
+
);
|
|
622
875
|
/** More than one currency to shop in. On a phone the picker sits in the menu when there is one. */
|
|
623
876
|
const currency = storefront.currency;
|
|
624
877
|
const hasCurrencies = computed(() => currency.offered.value.length > 1);
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
);
|
|
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
|
+
});
|
|
628
883
|
const showLinksPlaceholder = computed(
|
|
629
884
|
() => isEditing.value && variant.value !== 'minimal' && links.value.length === 0
|
|
630
885
|
);
|
|
631
886
|
|
|
887
|
+
/** The Menu tool's accessible name is its visible label (WCAG 2.5.3). */
|
|
632
888
|
const navMenuMessages = computed<Partial<UiMessages>>(() => ({
|
|
633
|
-
navMenuOpen: t('header.
|
|
889
|
+
navMenuOpen: t('header.menu'),
|
|
634
890
|
navMenuDrawer: t('header.menu'),
|
|
635
891
|
}));
|
|
636
892
|
|
|
637
|
-
/**
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
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;
|
|
641
906
|
if (variant.value === 'centered') {
|
|
642
|
-
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`;
|
|
643
908
|
}
|
|
644
|
-
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`;
|
|
645
917
|
});
|
|
646
918
|
const linksPositionClass = computed(() =>
|
|
647
919
|
variant.value === 'centered'
|
|
648
|
-
? `@
|
|
649
|
-
: '@
|
|
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'
|
|
650
922
|
);
|
|
651
|
-
const searchPositionClass = computed(() =>
|
|
652
|
-
|
|
653
|
-
);
|
|
654
|
-
|
|
655
|
-
|
|
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`
|
|
656
943
|
);
|
|
657
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
|
+
|
|
658
949
|
/** What this header draws differently from `NavMenu`'s own look, part by part. */
|
|
659
950
|
const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
660
|
-
nav:
|
|
661
|
-
list:
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
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.
|
|
668
966
|
panel: 'pt-0',
|
|
669
|
-
content:
|
|
670
|
-
'rounded-none
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
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.
|
|
973
|
+
columns:
|
|
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',
|
|
975
|
+
group: 'col-span-3 [[data-cards]>&]:col-span-1 [[data-cards]>&[data-cards]]:col-span-2',
|
|
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',
|
|
676
1022
|
}));
|
|
677
1023
|
</script>
|
|
678
1024
|
|
|
@@ -685,42 +1031,118 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
685
1031
|
@focusin="onBarFocusIn"
|
|
686
1032
|
@focusout="onBarFocusOut"
|
|
687
1033
|
>
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
]
|
|
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"
|
|
697
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]">
|
|
698
1108
|
<Link
|
|
699
1109
|
:href="brandHref"
|
|
700
1110
|
:as="EldraRouterLink"
|
|
701
1111
|
variant="standalone"
|
|
702
1112
|
:underline="false"
|
|
1113
|
+
:aria-label="brandName"
|
|
703
1114
|
data-eldra-header-focus
|
|
704
|
-
|
|
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
|
+
}"
|
|
705
1120
|
>
|
|
1121
|
+
<img
|
|
1122
|
+
v-if="brandMarkUrl"
|
|
1123
|
+
:src="brandMarkUrl"
|
|
1124
|
+
alt=""
|
|
1125
|
+
:class="brandMarkClass"
|
|
1126
|
+
loading="eager"
|
|
1127
|
+
decoding="async"
|
|
1128
|
+
/>
|
|
706
1129
|
<img
|
|
707
1130
|
v-if="brandLogoUrl"
|
|
708
1131
|
:src="brandLogoUrl"
|
|
709
|
-
|
|
710
|
-
class="
|
|
1132
|
+
alt=""
|
|
1133
|
+
:class="brandLogoClass"
|
|
711
1134
|
loading="eager"
|
|
712
1135
|
decoding="async"
|
|
713
1136
|
/>
|
|
714
|
-
<!-- The
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
<span v-else class="overflow-hidden text-ellipsis whitespace-nowrap">{{
|
|
720
|
-
data.brandText
|
|
721
|
-
}}</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>
|
|
722
1142
|
</Link>
|
|
723
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. -->
|
|
724
1146
|
<NavMenu
|
|
725
1147
|
v-if="drawerHasContent"
|
|
726
1148
|
v-model="openMenuIndex"
|
|
@@ -728,15 +1150,17 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
728
1150
|
:items="navItems"
|
|
729
1151
|
:aria-label="t('header.primary')"
|
|
730
1152
|
:collapse-below="variant === 'minimal' ? 'always' : '@content'"
|
|
1153
|
+
:drawer-layout="drawerLayout"
|
|
731
1154
|
open-on-hover
|
|
732
1155
|
:link-as="MenuLink"
|
|
1156
|
+
:card-aspect="cardAspect"
|
|
733
1157
|
:messages="navMenuMessages"
|
|
734
1158
|
class="static contents"
|
|
735
1159
|
:classes="navMenuClasses"
|
|
736
1160
|
>
|
|
737
1161
|
<template #toggle>
|
|
738
|
-
<EldraIcon name="menu-2" size="md" />
|
|
739
|
-
<span
|
|
1162
|
+
<EldraIcon name="menu-2" size="md" :class="TOOL_ICON_CLASSES" />
|
|
1163
|
+
<span class="whitespace-nowrap">{{ t('header.menu') }}</span>
|
|
740
1164
|
</template>
|
|
741
1165
|
<template #panelFooter="{ item, index }">
|
|
742
1166
|
<Link
|
|
@@ -746,13 +1170,59 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
746
1170
|
variant="standalone"
|
|
747
1171
|
arrow
|
|
748
1172
|
data-eldra-mega-view-all
|
|
1173
|
+
:underline="false"
|
|
749
1174
|
:aria-label="t('header.viewAllOf', { label: item.label ?? '' })"
|
|
750
|
-
class="text-
|
|
1175
|
+
class="text-primary text-[0.9375rem] font-semibold"
|
|
751
1176
|
>
|
|
752
1177
|
{{ t('header.viewAll') }}
|
|
753
1178
|
</Link>
|
|
754
1179
|
</template>
|
|
755
|
-
<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>
|
|
756
1226
|
<CurrencyPicker
|
|
757
1227
|
:currencies="currency.offered.value"
|
|
758
1228
|
:model-value="currency.active.value"
|
|
@@ -775,87 +1245,87 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
775
1245
|
</Button>
|
|
776
1246
|
</template>
|
|
777
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
|
+
/>
|
|
778
1254
|
<EditorPlaceholder
|
|
779
1255
|
v-if="showLinksPlaceholder"
|
|
780
1256
|
inline
|
|
781
1257
|
:label="t('editor.addLink')"
|
|
782
|
-
:class="
|
|
1258
|
+
:class="`hidden @min-[68.8125rem]:flex ${linksPositionClass}`"
|
|
783
1259
|
/>
|
|
784
1260
|
|
|
785
|
-
|
|
786
|
-
button in the grid (nothing to put in the drawer), the search control auto-places into
|
|
787
|
-
the `minmax(0,1fr)` column the brand usually takes, and left-aligned it would sit
|
|
788
|
-
against the wordmark with the cart stranded across the bar. Everywhere else this
|
|
789
|
-
wrapper lands in an `auto` column, which is content-sized, so the rule does nothing. -->
|
|
790
|
-
<div :class="['flex items-center justify-end', searchPositionClass]">
|
|
1261
|
+
<div :class="['flex items-center', searchPositionClass]">
|
|
791
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
|
+
/>
|
|
792
1291
|
<Button
|
|
793
|
-
v-if="searchStyle === 'icon'"
|
|
794
1292
|
variant="ghost"
|
|
795
1293
|
size="sm"
|
|
796
|
-
icon-only
|
|
797
|
-
:label="t('header.search')"
|
|
798
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
|
+
]"
|
|
799
1303
|
@click="openSearch"
|
|
800
1304
|
>
|
|
801
1305
|
<template #leadingIcon>
|
|
802
|
-
<EldraIcon name="search" size="md" />
|
|
1306
|
+
<EldraIcon name="search" size="md" :class="TOOL_ICON_CLASSES" />
|
|
803
1307
|
</template>
|
|
1308
|
+
{{ t('header.search') }}
|
|
804
1309
|
</Button>
|
|
805
|
-
<template v-else-if="searchStyle === 'field'">
|
|
806
|
-
<Button
|
|
807
|
-
variant="outline"
|
|
808
|
-
size="sm"
|
|
809
|
-
aria-haspopup="dialog"
|
|
810
|
-
class="@content:inline-flex hidden rounded-full"
|
|
811
|
-
@click="openSearch"
|
|
812
|
-
>
|
|
813
|
-
{{ t('header.searchField') }}
|
|
814
|
-
<span class="text-muted ml-2 text-xs">⌘K</span>
|
|
815
|
-
</Button>
|
|
816
|
-
<Button
|
|
817
|
-
variant="ghost"
|
|
818
|
-
size="sm"
|
|
819
|
-
icon-only
|
|
820
|
-
:label="t('header.search')"
|
|
821
|
-
aria-haspopup="dialog"
|
|
822
|
-
class="@content:hidden"
|
|
823
|
-
@click="openSearch"
|
|
824
|
-
>
|
|
825
|
-
<template #leadingIcon>
|
|
826
|
-
<EldraIcon name="search" size="md" />
|
|
827
|
-
</template>
|
|
828
|
-
</Button>
|
|
829
|
-
</template>
|
|
830
|
-
<template v-else>
|
|
831
|
-
<SearchBar
|
|
832
|
-
v-model="searchQuery"
|
|
833
|
-
size="md"
|
|
834
|
-
pill
|
|
835
|
-
:action="searchAction"
|
|
836
|
-
:label="t('header.searchField')"
|
|
837
|
-
:results="searchResults"
|
|
838
|
-
:loading="searchLoading"
|
|
839
|
-
class="@content:block hidden w-64"
|
|
840
|
-
/>
|
|
841
|
-
<Button
|
|
842
|
-
variant="ghost"
|
|
843
|
-
size="sm"
|
|
844
|
-
icon-only
|
|
845
|
-
:label="t('header.search')"
|
|
846
|
-
aria-haspopup="dialog"
|
|
847
|
-
class="@content:hidden"
|
|
848
|
-
@click="openSearch"
|
|
849
|
-
>
|
|
850
|
-
<template #leadingIcon>
|
|
851
|
-
<EldraIcon name="search" size="md" />
|
|
852
|
-
</template>
|
|
853
|
-
</Button>
|
|
854
|
-
</template>
|
|
855
1310
|
</template>
|
|
1311
|
+
<span v-else aria-hidden="true" data-eldra-header-spacer-tool :class="toolSpacerClass" />
|
|
856
1312
|
</div>
|
|
857
1313
|
|
|
858
|
-
<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
|
+
|
|
859
1329
|
<!-- In every header but `minimal`, prerendered ones included: see `wishlist` in the
|
|
860
1330
|
script above. `EldraRouterLink` because `/wishlist` is this theme's own route — it
|
|
861
1331
|
should route, not reload the document. -->
|
|
@@ -863,14 +1333,15 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
863
1333
|
<Button
|
|
864
1334
|
variant="ghost"
|
|
865
1335
|
size="sm"
|
|
866
|
-
|
|
867
|
-
:label="wishlistAccessibleName"
|
|
1336
|
+
:aria-label="wishlistAccessibleName"
|
|
868
1337
|
:href="wishlistHref"
|
|
869
1338
|
:as="EldraRouterLink"
|
|
1339
|
+
:class="TOOL_CLASSES"
|
|
870
1340
|
>
|
|
871
1341
|
<template #leadingIcon>
|
|
872
|
-
<EldraIcon name="heart" size="md" />
|
|
1342
|
+
<EldraIcon name="heart" size="md" :class="TOOL_ICON_CLASSES" />
|
|
873
1343
|
</template>
|
|
1344
|
+
{{ t('header.saved') }}
|
|
874
1345
|
</Button>
|
|
875
1346
|
<!-- The bag's own two rules: no badge at zero, and `pointer-events-none`, because the
|
|
876
1347
|
count is decorative (the button's accessible name carries it) and must not swallow
|
|
@@ -878,41 +1349,46 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
878
1349
|
<Badge
|
|
879
1350
|
v-if="wishlistCount > 0"
|
|
880
1351
|
aria-hidden="true"
|
|
881
|
-
tone="
|
|
1352
|
+
tone="accent"
|
|
882
1353
|
pill
|
|
883
1354
|
:label="wishlistBadgeLabel"
|
|
884
1355
|
:class="COUNT_PILL_CLASSES"
|
|
885
1356
|
/>
|
|
886
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
|
+
/>
|
|
887
1365
|
|
|
888
1366
|
<span class="relative inline-flex">
|
|
889
1367
|
<Button
|
|
890
1368
|
variant="ghost"
|
|
891
1369
|
size="sm"
|
|
892
|
-
|
|
893
|
-
:label="cartAccessibleName"
|
|
1370
|
+
:aria-label="cartAccessibleName"
|
|
894
1371
|
:href="cartHref"
|
|
895
1372
|
:as="toLinkAs(cartHref)"
|
|
896
1373
|
:aria-haspopup="cartPopupType"
|
|
1374
|
+
:class="TOOL_CLASSES"
|
|
897
1375
|
@click="onCartClick"
|
|
898
1376
|
>
|
|
899
1377
|
<template #leadingIcon>
|
|
900
|
-
<EldraIcon name="shopping-bag" size="md" />
|
|
1378
|
+
<EldraIcon name="shopping-bag" size="md" :class="TOOL_ICON_CLASSES" />
|
|
901
1379
|
</template>
|
|
1380
|
+
{{ t('header.cart') }}
|
|
902
1381
|
</Button>
|
|
903
1382
|
<Badge
|
|
904
1383
|
v-if="cartCount > 0"
|
|
905
1384
|
aria-hidden="true"
|
|
906
|
-
tone="
|
|
1385
|
+
tone="accent"
|
|
907
1386
|
pill
|
|
908
1387
|
:label="cartBadgeLabel"
|
|
909
1388
|
:class="COUNT_PILL_CLASSES"
|
|
910
1389
|
/>
|
|
911
1390
|
</span>
|
|
912
1391
|
|
|
913
|
-
<!-- Spec Header -> Layout, From 64rem: the call to action sits 0.75rem after the cart.
|
|
914
|
-
0.25rem of that is already the actions row's own gap-1; @content:ml-2 (0.5rem) makes
|
|
915
|
-
up the rest, so it reads as its own button rather than a fourth icon in the row. -->
|
|
916
1392
|
<CurrencyPicker
|
|
917
1393
|
:currencies="currency.offered.value"
|
|
918
1394
|
:model-value="currency.active.value"
|
|
@@ -920,13 +1396,15 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
920
1396
|
:class="barPickerClass"
|
|
921
1397
|
@update:model-value="currency.choose"
|
|
922
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. -->
|
|
923
1401
|
<Button
|
|
924
1402
|
v-if="hasCta && variant !== 'minimal'"
|
|
925
1403
|
variant="primary"
|
|
926
1404
|
size="sm"
|
|
927
1405
|
:href="ctaHref"
|
|
928
1406
|
:as="ctaLinkAs"
|
|
929
|
-
class="@
|
|
1407
|
+
class="ml-2.5 hidden @min-[68.8125rem]:inline-flex"
|
|
930
1408
|
>
|
|
931
1409
|
{{ ctaLabel }}
|
|
932
1410
|
</Button>
|
|
@@ -945,7 +1423,9 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
945
1423
|
<!-- The flow the fixed bar left behind — see `barSpacerClasses`. Empty and unlabelled: it is
|
|
946
1424
|
layout, with nothing in it for a screen reader or the tab order to reach. The outer box is the
|
|
947
1425
|
`<header>`'s counterpart (the `@container` the height is measured in, and the hairline) and the
|
|
948
|
-
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. -->
|
|
949
1429
|
<div
|
|
950
1430
|
v-if="sticky"
|
|
951
1431
|
data-eldra-header-spacer
|
|
@@ -953,6 +1433,7 @@ const navMenuClasses = computed<Partial<Record<NavMenuPart, string>>>(() => ({
|
|
|
953
1433
|
:class="barSpacerClasses"
|
|
954
1434
|
:style="barSpacerStyle"
|
|
955
1435
|
>
|
|
1436
|
+
<div v-if="hasInfo" class="border-b border-transparent"><div class="min-h-9" /></div>
|
|
956
1437
|
<div :class="BAR_HEIGHT_CLASS" />
|
|
957
1438
|
</div>
|
|
958
1439
|
</template>
|