@classic-homes/theme-svelte 1.8.1 → 1.8.2
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.
|
@@ -54,8 +54,7 @@ describe('PublicLayout accessibility', () => {
|
|
|
54
54
|
expect(links).toHaveLength(navigation.length);
|
|
55
55
|
for (const link of links) {
|
|
56
56
|
// 20px text line box + 2 x 12px padding = 44px border box; -m-3 cancels
|
|
57
|
-
// it in layout
|
|
58
|
-
// hit-testing missed the pseudo-element but honours padding.
|
|
57
|
+
// it in layout so the nav's gap-6 spacing is unchanged.
|
|
59
58
|
expect(link.className).toContain('p-3');
|
|
60
59
|
expect(link.className).toContain('-m-3');
|
|
61
60
|
expect(link.className).not.toContain('after:');
|
|
@@ -99,6 +98,18 @@ describe('PublicLayout accessibility', () => {
|
|
|
99
98
|
expect(cta.parentElement?.className).toContain('hidden');
|
|
100
99
|
expect(cta.parentElement?.className).toContain('md:contents');
|
|
101
100
|
});
|
|
101
|
+
it('should switch the header to the drawer at the given mobileBreakpoint', () => {
|
|
102
|
+
renderLayout({
|
|
103
|
+
mobileBreakpoint: 'lg',
|
|
104
|
+
headerEnd: textSnippet('Service Request'),
|
|
105
|
+
mobileNavEnd: ctaSnippet('Drawer CTA'),
|
|
106
|
+
});
|
|
107
|
+
const nav = screen.getByRole('navigation', { name: 'Main navigation' });
|
|
108
|
+
expect(nav.className).toContain('lg:flex');
|
|
109
|
+
expect(nav.className).not.toContain('md:flex');
|
|
110
|
+
expect(screen.getByRole('button', { name: 'Open menu' }).className).toContain('lg:hidden');
|
|
111
|
+
expect(screen.getByText('Service Request').parentElement?.className).toContain('lg:contents');
|
|
112
|
+
});
|
|
102
113
|
it('should render mobileNavEnd in the drawer and close it via the close argument', async () => {
|
|
103
114
|
renderLayout({
|
|
104
115
|
headerEnd: textSnippet('Service Request'),
|
|
@@ -17,9 +17,17 @@
|
|
|
17
17
|
import Header from './Header.svelte';
|
|
18
18
|
import LogoMain from '../LogoMain.svelte';
|
|
19
19
|
|
|
20
|
+
type Breakpoint = 'sm' | 'md' | 'lg';
|
|
21
|
+
|
|
20
22
|
interface Props {
|
|
21
23
|
/** Navigation items for header */
|
|
22
24
|
navigation?: NavItem[];
|
|
25
|
+
/**
|
|
26
|
+
* Breakpoint below which the header shows the hamburger drawer instead of the
|
|
27
|
+
* inline nav. Default `md` (768px). Pick `lg` when logo + nav + headerEnd need
|
|
28
|
+
* more than ~768px: at iPad portrait widths (820px) they otherwise overlap.
|
|
29
|
+
*/
|
|
30
|
+
mobileBreakpoint?: Breakpoint;
|
|
23
31
|
/** Whether to show footer */
|
|
24
32
|
showFooter?: boolean;
|
|
25
33
|
/** Footer link sections */
|
|
@@ -55,6 +63,7 @@
|
|
|
55
63
|
|
|
56
64
|
let {
|
|
57
65
|
navigation = [],
|
|
66
|
+
mobileBreakpoint = 'md',
|
|
58
67
|
showFooter = true,
|
|
59
68
|
footerLinks = [],
|
|
60
69
|
copyright,
|
|
@@ -71,6 +80,13 @@
|
|
|
71
80
|
}: Props = $props();
|
|
72
81
|
|
|
73
82
|
let mobileMenuOpen = $state(false);
|
|
83
|
+
|
|
84
|
+
// Full class strings so Tailwind's scanner sees them.
|
|
85
|
+
const desktopOnly: Record<Breakpoint, string> = {
|
|
86
|
+
sm: 'hidden sm:contents',
|
|
87
|
+
md: 'hidden md:contents',
|
|
88
|
+
lg: 'hidden lg:contents',
|
|
89
|
+
};
|
|
74
90
|
</script>
|
|
75
91
|
|
|
76
92
|
<AppShell>
|
|
@@ -78,7 +94,7 @@
|
|
|
78
94
|
showMenuButton={navigation.length > 0}
|
|
79
95
|
menuOpen={mobileMenuOpen}
|
|
80
96
|
onMenuClick={() => (mobileMenuOpen = !mobileMenuOpen)}
|
|
81
|
-
mobileBreakpoint
|
|
97
|
+
{mobileBreakpoint}
|
|
82
98
|
backdropBlur
|
|
83
99
|
elevated
|
|
84
100
|
maxWidth="7xl"
|
|
@@ -112,9 +128,7 @@
|
|
|
112
128
|
class={cn(
|
|
113
129
|
// Touch target: p-3 around the 20px line box makes the anchor's own
|
|
114
130
|
// border box 44px tall, and -m-3 cancels it in layout so the nav's
|
|
115
|
-
// gap-6 is unchanged (adjacent boxes meet without overlapping).
|
|
116
|
-
// box rather than an ::after overlay: iPadOS trackpad hit-testing
|
|
117
|
-
// landed below the text with the pseudo-element, but honours padding.
|
|
131
|
+
// gap-6 is unchanged (adjacent boxes meet without overlapping).
|
|
118
132
|
'-m-3 flex items-center p-3 text-sm font-bold uppercase hover:text-primary',
|
|
119
133
|
// iPadOS reports hover:none even with a trackpad attached, so the preset's
|
|
120
134
|
// hoverOnlyWhenSupported gating means hover: never fires there. any-pointer:fine
|
|
@@ -134,7 +148,7 @@
|
|
|
134
148
|
{#snippet end()}
|
|
135
149
|
{#if headerEnd && mobileNavEnd}
|
|
136
150
|
<!-- Desktop only: the mobile drawer carries mobileNavEnd instead -->
|
|
137
|
-
<div class=
|
|
151
|
+
<div class={desktopOnly[mobileBreakpoint]}>
|
|
138
152
|
{@render headerEnd()}
|
|
139
153
|
</div>
|
|
140
154
|
{:else if headerEnd}
|
|
@@ -10,9 +10,16 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import type { Snippet } from 'svelte';
|
|
12
12
|
import type { NavItem, NavSection, HeaderSearchConfig } from '../../types/layout.js';
|
|
13
|
+
type Breakpoint = 'sm' | 'md' | 'lg';
|
|
13
14
|
interface Props {
|
|
14
15
|
/** Navigation items for header */
|
|
15
16
|
navigation?: NavItem[];
|
|
17
|
+
/**
|
|
18
|
+
* Breakpoint below which the header shows the hamburger drawer instead of the
|
|
19
|
+
* inline nav. Default `md` (768px). Pick `lg` when logo + nav + headerEnd need
|
|
20
|
+
* more than ~768px: at iPad portrait widths (820px) they otherwise overlap.
|
|
21
|
+
*/
|
|
22
|
+
mobileBreakpoint?: Breakpoint;
|
|
16
23
|
/** Whether to show footer */
|
|
17
24
|
showFooter?: boolean;
|
|
18
25
|
/** Footer link sections */
|