@easy-web/content-blocks 1.3.3 → 1.4.1

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.
Files changed (54) hide show
  1. package/README.md +10 -395
  2. package/dist/schemas/galleries.d.ts +3 -316
  3. package/dist/schemas/galleries.d.ts.map +1 -1
  4. package/dist/schemas/galleries.js +3 -133
  5. package/dist/schemas/galleries.js.map +1 -1
  6. package/dist/schemas/notFound.d.ts +3 -32
  7. package/dist/schemas/notFound.d.ts.map +1 -1
  8. package/dist/schemas/notFound.js +3 -27
  9. package/dist/schemas/notFound.js.map +1 -1
  10. package/package.json +3 -4
  11. package/src/components/BlogPostCard.astro +8 -74
  12. package/src/components/Card.astro +8 -65
  13. package/src/components/CardGrid.astro +8 -24
  14. package/src/components/ContactSection.astro +8 -68
  15. package/src/components/CtaSection.astro +8 -77
  16. package/src/components/DraftBanner.astro +8 -28
  17. package/src/components/Footer.astro +8 -76
  18. package/src/components/GalleryCarousel.astro +9 -292
  19. package/src/components/GalleryFeatureHighlight.astro +9 -149
  20. package/src/components/GalleryHeroSlider.astro +9 -358
  21. package/src/components/GalleryImageGrid.astro +9 -139
  22. package/src/components/GalleryLightboxGrid.astro +9 -349
  23. package/src/components/GalleryMasonryGrid.astro +9 -123
  24. package/src/components/GallerySection.astro +9 -65
  25. package/src/components/Header.astro +13 -217
  26. package/src/components/HeaderCentered.astro +17 -242
  27. package/src/components/HeaderFlyout.astro +13 -380
  28. package/src/components/HeaderHideOnScroll.astro +17 -248
  29. package/src/components/Hero.astro +8 -73
  30. package/src/components/LanguageNotice.astro +8 -27
  31. package/src/components/LanguageSwitch.astro +7 -65
  32. package/src/components/LegalLayout.astro +8 -57
  33. package/src/components/NotFound.astro +7 -118
  34. package/src/components/PageShell.astro +7 -79
  35. package/src/components/Prose.astro +10 -153
  36. package/src/components/Section.astro +8 -32
  37. package/src/components/ThemeToggle.astro +8 -77
  38. package/src/components/UniversalMedia.astro +7 -96
  39. package/src/schemas/galleries.ts +3 -150
  40. package/src/schemas/notFound.ts +3 -31
  41. package/dist/__tests__/exports-resolution.test.d.ts +0 -2
  42. package/dist/__tests__/exports-resolution.test.d.ts.map +0 -1
  43. package/dist/__tests__/exports-resolution.test.js +0 -83
  44. package/dist/__tests__/exports-resolution.test.js.map +0 -1
  45. package/dist/components/__tests__/UniversalMedia.test.d.ts +0 -2
  46. package/dist/components/__tests__/UniversalMedia.test.d.ts.map +0 -1
  47. package/dist/components/__tests__/UniversalMedia.test.js +0 -46
  48. package/dist/components/__tests__/UniversalMedia.test.js.map +0 -1
  49. package/dist/schemas/__tests__/notFound.test.d.ts +0 -2
  50. package/dist/schemas/__tests__/notFound.test.d.ts.map +0 -1
  51. package/dist/schemas/__tests__/notFound.test.js +0 -29
  52. package/dist/schemas/__tests__/notFound.test.js.map +0 -1
  53. package/src/components/__tests__/UniversalMedia.test.ts +0 -65
  54. package/src/schemas/__tests__/notFound.test.ts +0 -32
@@ -1,386 +1,19 @@
1
1
  ---
2
2
  /**
3
- * HeaderFlyout – responsive site header with dropdown flyout navigation.
4
- * Pure Astro component with scoped vanilla JS for mobile and flyout behavior.
3
+ * @deprecated Import `@easy-web/core/components/HeaderFlyout.astro` instead.
4
+ * Compatibility wrapper: renders the core component with the same props and slots.
5
+ *
6
+ * The `actions` slot is forwarded only when the caller fills it. Astro registers
7
+ * a slot even when its `{cond && <Fragment slot>}` expression is false, which
8
+ * would replace the core fallback (theme toggle and language switch) with nothing.
5
9
  */
6
- import type { NavItem } from '@easy-web/cms-adapters';
7
- import ThemeToggle from './ThemeToggle.astro';
8
- import LanguageSwitch from './LanguageSwitch.astro';
10
+ import type { ComponentProps } from 'astro/types';
11
+ import HeaderFlyout from '@easy-web/core/components/HeaderFlyout.astro';
9
12
 
10
- interface Props {
11
- siteName: string;
12
- navItems: NavItem[];
13
- currentLang: string;
14
- pathname: string;
15
- /** Explicit alternate locale URL to pass to LanguageSwitch. */
16
- alternateHref?: string;
17
- /** Accessible label for the mobile menu toggle button. */
18
- menuLabel?: string;
19
- /** Optional logo URL. When provided, renders an <img> in the brand area instead of site name text. */
20
- logo?: string;
21
- /**
22
- * DOM id linking the menu button's `aria-controls` to the `<nav>`, and the
23
- * prefix for each dropdown's id. Stable by default so builds are reproducible.
24
- * Override only when rendering more than one of this header variant on a single page.
25
- */
26
- navId?: string;
27
- /**
28
- * Locales this site actually serves. When it holds a single entry the
29
- * language switch is omitted, because on a one-locale site it is a control
30
- * that navigates to a route the site does not build. Omit the prop to keep
31
- * the switch rendering unconditionally.
32
- */
33
- locales?: readonly string[];
34
- }
13
+ type Props = ComponentProps<typeof HeaderFlyout>;
35
14
 
36
- const { siteName, navItems, currentLang, pathname, alternateHref, menuLabel = 'Toggle navigation menu', logo, navId = 'ew-header-flyout-nav', locales } = Astro.props;
37
- const showLanguageSwitch = !locales || locales.length > 1;
38
- const dropdownIdPrefix = `${navId}-dropdown`;
15
+ const props = Astro.props;
39
16
  ---
40
-
41
- <header class="ew-header-flyout" data-testid="header-flyout">
42
- <div class="ew-header-flyout__inner">
43
- <a href={currentLang === 'de' ? '/' : `/${currentLang}/`} class="ew-header-flyout__brand">
44
- {logo ? <img src={logo} alt={siteName} class="ew-header-flyout__logo" /> : siteName}
45
- </a>
46
-
47
- <button
48
- type="button"
49
- class="ew-header-flyout__menu-btn"
50
- aria-label={menuLabel}
51
- aria-expanded="false"
52
- aria-controls={navId}
53
- data-testid="mobile-menu-toggle"
54
- >
55
- <svg class="ew-header-flyout__menu-icon ew-header-flyout__menu-icon--open" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
56
- <line x1="3" y1="6" x2="21" y2="6"></line>
57
- <line x1="3" y1="12" x2="21" y2="12"></line>
58
- <line x1="3" y1="18" x2="21" y2="18"></line>
59
- </svg>
60
- <svg class="ew-header-flyout__menu-icon ew-header-flyout__menu-icon--close" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
61
- <line x1="18" y1="6" x2="6" y2="18"></line>
62
- <line x1="6" y1="6" x2="18" y2="18"></line>
63
- </svg>
64
- </button>
65
-
66
- <nav id={navId} class="ew-header-flyout__nav" aria-label="Main navigation">
67
- <ul class="ew-header-flyout__links">
68
- {navItems.map((item, index) => {
69
- const hasChildren = Boolean(item.children && item.children.length > 0);
70
- const dropdownId = `${dropdownIdPrefix}-${index}`;
71
- return (
72
- <li class="ew-header-flyout__item">
73
- {hasChildren ? (
74
- <div class="ew-header-flyout__dropdown-wrapper">
75
- <button
76
- type="button"
77
- class:list={[
78
- 'ew-header-flyout__link',
79
- 'ew-header-flyout__trigger',
80
- { 'ew-header-flyout__link--active': pathname === item.href }
81
- ]}
82
- aria-expanded="false"
83
- aria-haspopup="true"
84
- aria-controls={dropdownId}
85
- >
86
- <span>{item.label}</span>
87
- <svg class="ew-header-flyout__chevron" width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">
88
- <path d="M4 6l4 4 4-4"></path>
89
- </svg>
90
- </button>
91
- <ul id={dropdownId} class="ew-header-flyout__dropdown" role="menu">
92
- {item.children?.map((child) => (
93
- <li class="ew-header-flyout__dropdown-item" role="none">
94
- <a
95
- href={child.href}
96
- class:list={[
97
- 'ew-header-flyout__dropdown-link',
98
- { 'ew-header-flyout__dropdown-link--active': pathname === child.href }
99
- ]}
100
- role="menuitem"
101
- >
102
- {child.label}
103
- </a>
104
- </li>
105
- ))}
106
- </ul>
107
- </div>
108
- ) : (
109
- <a href={item.href} class:list={['ew-header-flyout__link', { 'ew-header-flyout__link--active': pathname === item.href }]}>
110
- {item.label}
111
- </a>
112
- )}
113
- </li>
114
- );
115
- })}
116
- </ul>
117
- <div class="ew-header-flyout__actions">
118
- <slot name="actions">
119
- <ThemeToggle />
120
- {showLanguageSwitch && <LanguageSwitch currentLang={currentLang} pathname={pathname} alternateHref={alternateHref} />}
121
- </slot>
122
- </div>
123
- </nav>
124
- </div>
125
- </header>
126
-
127
- <style>
128
- .ew-header-flyout {
129
- position: sticky;
130
- top: 0;
131
- z-index: 100;
132
- background: var(--ew-surface);
133
- border-bottom: 1px solid var(--ew-border);
134
- }
135
- .ew-header-flyout__inner {
136
- display: flex;
137
- align-items: center;
138
- justify-content: space-between;
139
- max-width: 72rem;
140
- margin: 0 auto;
141
- padding: var(--ew-space-3) var(--ew-space-5);
142
- }
143
- .ew-header-flyout__brand {
144
- font-family: var(--ew-font-sans);
145
- font-size: var(--ew-text-lg);
146
- font-weight: 700;
147
- color: var(--ew-on-surface);
148
- text-decoration: none;
149
- letter-spacing: -0.01em;
150
- }
151
- .ew-header-flyout__brand:hover {
152
- color: var(--ew-primary);
153
- }
154
- .ew-header-flyout__logo {
155
- height: 1.5rem;
156
- width: auto;
157
- display: block;
158
- }
159
-
160
- .ew-header-flyout__menu-btn {
161
- display: none;
162
- background: transparent;
163
- border: none;
164
- color: var(--ew-on-surface);
165
- cursor: pointer;
166
- padding: var(--ew-space-1);
167
- }
168
- .ew-header-flyout__menu-btn:focus-visible,
169
- .ew-header-flyout__link:focus-visible,
170
- .ew-header-flyout__dropdown-link:focus-visible {
171
- outline: 2px solid var(--ew-primary);
172
- outline-offset: 2px;
173
- }
174
- .ew-header-flyout__menu-icon--close { display: none; }
175
-
176
- .ew-header-flyout__nav {
177
- display: flex;
178
- align-items: center;
179
- gap: var(--ew-space-5);
180
- }
181
- .ew-header-flyout__links {
182
- display: flex;
183
- align-items: center;
184
- list-style: none;
185
- margin: 0;
186
- padding: 0;
187
- gap: var(--ew-space-1);
188
- }
189
- .ew-header-flyout__item {
190
- margin: 0;
191
- }
192
- .ew-header-flyout__link {
193
- display: flex;
194
- align-items: center;
195
- gap: var(--ew-space-1);
196
- padding: var(--ew-space-2) var(--ew-space-3);
197
- border: none;
198
- border-radius: var(--ew-radius-md);
199
- background: transparent;
200
- color: var(--ew-muted);
201
- cursor: pointer;
202
- font-family: var(--ew-font-sans);
203
- font-size: var(--ew-text-sm);
204
- font-weight: 500;
205
- line-height: var(--ew-leading-normal);
206
- text-decoration: none;
207
- }
208
- .ew-header-flyout__link:hover,
209
- .ew-header-flyout__link[aria-expanded="true"] {
210
- color: var(--ew-on-surface);
211
- background: var(--ew-surface-muted);
212
- }
213
- .ew-header-flyout__link--active {
214
- color: var(--ew-on-surface);
215
- background: var(--ew-surface-muted);
216
- }
217
- .ew-header-flyout__trigger[aria-expanded="true"] .ew-header-flyout__chevron {
218
- transform: rotate(180deg);
219
- }
220
- .ew-header-flyout__chevron {
221
- flex: none;
222
- }
223
- .ew-header-flyout__dropdown-wrapper {
224
- position: relative;
225
- }
226
- .ew-header-flyout__dropdown {
227
- display: none;
228
- position: absolute;
229
- top: 100%;
230
- left: 0;
231
- min-width: 12rem;
232
- background: var(--ew-surface);
233
- border: 1px solid var(--ew-border);
234
- border-radius: var(--ew-radius-md);
235
- padding: var(--ew-space-2);
236
- list-style: none;
237
- margin: 0;
238
- z-index: 200;
239
- }
240
- .ew-header-flyout__dropdown[data-open] {
241
- display: block;
242
- }
243
- .ew-header-flyout__dropdown-link {
244
- display: block;
245
- padding: var(--ew-space-2) var(--ew-space-3);
246
- border-radius: var(--ew-radius-sm);
247
- color: var(--ew-muted);
248
- font-family: var(--ew-font-sans);
249
- font-size: var(--ew-text-sm);
250
- font-weight: 500;
251
- text-decoration: none;
252
- }
253
- .ew-header-flyout__dropdown-link:hover,
254
- .ew-header-flyout__dropdown-link--active {
255
- color: var(--ew-on-surface);
256
- background: var(--ew-surface-muted);
257
- }
258
- .ew-header-flyout__actions {
259
- display: flex;
260
- align-items: center;
261
- gap: var(--ew-space-2);
262
- border-left: 1px solid var(--ew-border);
263
- padding-left: var(--ew-space-3);
264
- margin-left: var(--ew-space-1);
265
- }
266
-
267
- @media (max-width: 768px) {
268
- .ew-header-flyout__menu-btn {
269
- display: flex;
270
- }
271
- .ew-header-flyout__nav {
272
- display: none;
273
- position: absolute;
274
- top: 100%;
275
- left: 0;
276
- right: 0;
277
- flex-direction: column;
278
- align-items: stretch;
279
- background: var(--ew-surface);
280
- border-bottom: 1px solid var(--ew-border);
281
- padding: var(--ew-space-4) var(--ew-space-5);
282
- gap: var(--ew-space-4);
283
- }
284
- .ew-header-flyout__nav[data-open] {
285
- display: flex;
286
- }
287
- .ew-header-flyout__links {
288
- flex-direction: column;
289
- align-items: stretch;
290
- gap: var(--ew-space-1);
291
- }
292
- .ew-header-flyout__link {
293
- width: 100%;
294
- justify-content: space-between;
295
- }
296
- .ew-header-flyout__dropdown {
297
- position: static;
298
- min-width: 0;
299
- margin-top: var(--ew-space-1);
300
- border-radius: var(--ew-radius-md);
301
- }
302
- .ew-header-flyout__actions {
303
- border-left: none;
304
- padding-left: 0;
305
- margin-left: 0;
306
- padding-top: var(--ew-space-3);
307
- border-top: 1px solid var(--ew-border);
308
- }
309
- .ew-header-flyout__menu-btn[aria-expanded="true"] .ew-header-flyout__menu-icon--open { display: none; }
310
- .ew-header-flyout__menu-btn[aria-expanded="true"] .ew-header-flyout__menu-icon--close { display: block; }
311
- }
312
- </style>
313
-
314
- <script>
315
- function initHeader(headerEl: Element) {
316
- const menuBtn = headerEl.querySelector('.ew-header-flyout__menu-btn') as HTMLButtonElement | null;
317
- const nav = headerEl.querySelector('.ew-header-flyout__nav') as HTMLElement | null;
318
-
319
- if (menuBtn && nav) {
320
- menuBtn.addEventListener('click', () => {
321
- const isOpen = menuBtn.getAttribute('aria-expanded') === 'true';
322
- menuBtn.setAttribute('aria-expanded', String(!isOpen));
323
- isOpen ? nav.removeAttribute('data-open') : nav.setAttribute('data-open', '');
324
- });
325
- }
326
-
327
- const closeAllDropdowns = () => {
328
- headerEl.querySelectorAll('.ew-header-flyout__trigger').forEach((trigger) => {
329
- const wrapper = trigger.closest('.ew-header-flyout__dropdown-wrapper');
330
- const dropdown = wrapper?.querySelector('.ew-header-flyout__dropdown');
331
- trigger.setAttribute('aria-expanded', 'false');
332
- dropdown?.removeAttribute('data-open');
333
- });
334
- };
335
-
336
- headerEl.querySelectorAll('.ew-header-flyout__trigger').forEach((trigger) => {
337
- const button = trigger as HTMLButtonElement;
338
- const wrapper = button.closest('.ew-header-flyout__dropdown-wrapper');
339
- const dropdown = wrapper?.querySelector('.ew-header-flyout__dropdown') as HTMLElement | null;
340
- if (!wrapper || !dropdown) return;
341
-
342
- const open = () => {
343
- closeAllDropdowns();
344
- button.setAttribute('aria-expanded', 'true');
345
- dropdown.setAttribute('data-open', '');
346
- };
347
- const close = () => {
348
- button.setAttribute('aria-expanded', 'false');
349
- dropdown.removeAttribute('data-open');
350
- };
351
-
352
- wrapper.addEventListener('mouseenter', open);
353
- wrapper.addEventListener('mouseleave', close);
354
- wrapper.addEventListener('focusin', open);
355
- wrapper.addEventListener('focusout', (event) => {
356
- const nextTarget = event.relatedTarget as Node | null;
357
- if (!nextTarget || !wrapper.contains(nextTarget)) close();
358
- });
359
-
360
- button.addEventListener('click', () => {
361
- button.getAttribute('aria-expanded') === 'true' ? close() : open();
362
- });
363
- button.addEventListener('keydown', (event) => {
364
- if (event.key === 'Enter') {
365
- event.preventDefault();
366
- open();
367
- }
368
- if (event.key === 'Escape') {
369
- close();
370
- }
371
- });
372
- dropdown.addEventListener('keydown', (event) => {
373
- if (event.key === 'Escape') {
374
- close();
375
- button.focus();
376
- }
377
- });
378
- });
379
-
380
- document.addEventListener('click', (event) => {
381
- if (!headerEl.contains(event.target as Node)) closeAllDropdowns();
382
- });
383
- }
384
-
385
- document.querySelectorAll('.ew-header-flyout').forEach(initHeader);
386
- </script>
17
+ {Astro.slots.has('actions')
18
+ ? <HeaderFlyout {...props}><Fragment slot="actions"><slot name="actions" /></Fragment></HeaderFlyout>
19
+ : <HeaderFlyout {...props} />}
@@ -1,250 +1,19 @@
1
1
  ---
2
- import ThemeToggle from './ThemeToggle.astro';
3
- import LanguageSwitch from './LanguageSwitch.astro';
4
-
5
- interface Props {
6
- siteName: string;
7
- navItems: Array<{ label: string; href: string }>;
8
- currentLang: string;
9
- pathname: string;
10
- /** Explicit alternate locale URL to pass to LanguageSwitch. */
11
- alternateHref?: string;
12
- /** Accessible label for the mobile menu toggle button. */
13
- menuLabel?: string;
14
- /** Optional logo URL. When provided, renders an <img> in the brand area instead of site name text. */
15
- logo?: string;
16
- /**
17
- * DOM id linking the menu button's `aria-controls` to the `<nav>`.
18
- * Stable by default so builds are reproducible. Override only when rendering
19
- * more than one of this header variant on a single page.
20
- */
21
- navId?: string;
22
- /**
23
- * Locales this site actually serves. When it holds a single entry the
24
- * language switch is omitted, because on a one-locale site it is a control
25
- * that navigates to a route the site does not build. Omit the prop to keep
26
- * the switch rendering unconditionally.
27
- */
28
- locales?: readonly string[];
29
- }
30
-
31
- const { siteName, navItems, currentLang, pathname, alternateHref, menuLabel = 'Toggle navigation menu', logo, navId = 'ew-header-hos-nav', locales } = Astro.props;
32
- const showLanguageSwitch = !locales || locales.length > 1;
2
+ /**
3
+ * @deprecated Import `@easy-web/core/components/HeaderHideOnScroll.astro` instead.
4
+ * Compatibility wrapper: renders the core component with the same props and slots.
5
+ *
6
+ * The `actions` slot is forwarded only when the caller fills it. Astro registers
7
+ * a slot even when its `{cond && <Fragment slot>}` expression is false, which
8
+ * would replace the core fallback (theme toggle and language switch) with nothing.
9
+ */
10
+ import type { ComponentProps } from 'astro/types';
11
+ import HeaderHideOnScroll from '@easy-web/core/components/HeaderHideOnScroll.astro';
12
+
13
+ type Props = ComponentProps<typeof HeaderHideOnScroll>;
14
+
15
+ const props = Astro.props;
33
16
  ---
34
-
35
- <header class="ew-header-hide-on-scroll" data-testid="header-hide-on-scroll">
36
- <div class="ew-header-hide-on-scroll__inner">
37
- <a href={currentLang === 'de' ? '/' : `/${currentLang}/`} class="ew-header-hide-on-scroll__brand">
38
- {logo ? <img src={logo} alt={siteName} class="ew-header-hide-on-scroll__logo" /> : siteName}
39
- </a>
40
-
41
- <button
42
- type="button"
43
- class="ew-header-hide-on-scroll__menu-btn"
44
- aria-label={menuLabel}
45
- aria-expanded="false"
46
- aria-controls={navId}
47
- data-testid="mobile-menu-toggle"
48
- >
49
- <svg class="ew-header-hide-on-scroll__menu-icon ew-header-hide-on-scroll__menu-icon--open" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
50
- <line x1="3" y1="6" x2="21" y2="6"></line>
51
- <line x1="3" y1="12" x2="21" y2="12"></line>
52
- <line x1="3" y1="18" x2="21" y2="18"></line>
53
- </svg>
54
- <svg class="ew-header-hide-on-scroll__menu-icon ew-header-hide-on-scroll__menu-icon--close" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true">
55
- <line x1="18" y1="6" x2="6" y2="18"></line>
56
- <line x1="6" y1="6" x2="18" y2="18"></line>
57
- </svg>
58
- </button>
59
-
60
- <nav id={navId} class="ew-header-hide-on-scroll__nav" aria-label="Main navigation">
61
- <ul class="ew-header-hide-on-scroll__links">
62
- {navItems.map((item) => (
63
- <li>
64
- <a href={item.href} class:list={['ew-header-hide-on-scroll__link', { 'ew-header-hide-on-scroll__link--active': pathname === item.href }]}>
65
- {item.label}
66
- </a>
67
- </li>
68
- ))}
69
- </ul>
70
- <div class="ew-header-hide-on-scroll__actions">
71
- <slot name="actions">
72
- <ThemeToggle />
73
- {showLanguageSwitch && <LanguageSwitch currentLang={currentLang} pathname={pathname} alternateHref={alternateHref} />}
74
- </slot>
75
- </div>
76
- </nav>
77
- </div>
78
- </header>
79
-
80
- <style>
81
- .ew-header-hide-on-scroll {
82
- position: fixed;
83
- top: 0;
84
- left: 0;
85
- right: 0;
86
- z-index: 100;
87
- transition: transform 0.3s ease;
88
- background: var(--ew-surface);
89
- border-bottom: 1px solid var(--ew-border);
90
- }
91
- .ew-header-hide-on-scroll--hidden {
92
- transform: translateY(-100%);
93
- }
94
- .ew-header-hide-on-scroll__inner {
95
- display: flex;
96
- align-items: center;
97
- justify-content: space-between;
98
- max-width: 72rem;
99
- margin: 0 auto;
100
- padding: var(--ew-space-3) var(--ew-space-5);
101
- }
102
- .ew-header-hide-on-scroll__brand {
103
- font-family: var(--ew-font-sans);
104
- font-size: var(--ew-text-lg);
105
- font-weight: 700;
106
- color: var(--ew-on-surface);
107
- text-decoration: none;
108
- letter-spacing: -0.01em;
109
- }
110
- .ew-header-hide-on-scroll__brand:hover {
111
- color: var(--ew-primary);
112
- }
113
- .ew-header-hide-on-scroll__logo {
114
- height: 1.5rem;
115
- width: auto;
116
- display: block;
117
- }
118
-
119
- .ew-header-hide-on-scroll__menu-btn {
120
- display: none;
121
- background: transparent;
122
- border: none;
123
- color: var(--ew-on-surface);
124
- cursor: pointer;
125
- padding: var(--ew-space-1);
126
- }
127
- .ew-header-hide-on-scroll__menu-btn:focus-visible {
128
- outline: 2px solid var(--ew-primary);
129
- outline-offset: 2px;
130
- }
131
- .ew-header-hide-on-scroll__menu-icon--close { display: none; }
132
-
133
- .ew-header-hide-on-scroll__nav {
134
- display: flex;
135
- align-items: center;
136
- gap: var(--ew-space-5);
137
- }
138
- .ew-header-hide-on-scroll__links {
139
- display: flex;
140
- list-style: none;
141
- margin: 0;
142
- padding: 0;
143
- gap: var(--ew-space-1);
144
- }
145
- .ew-header-hide-on-scroll__link {
146
- display: block;
147
- padding: var(--ew-space-2) var(--ew-space-3);
148
- border-radius: var(--ew-radius-md);
149
- color: var(--ew-muted);
150
- font-family: var(--ew-font-sans);
151
- font-size: var(--ew-text-sm);
152
- font-weight: 500;
153
- text-decoration: none;
154
- }
155
- .ew-header-hide-on-scroll__link:hover {
156
- color: var(--ew-on-surface);
157
- background: var(--ew-surface-muted);
158
- }
159
- .ew-header-hide-on-scroll__link--active {
160
- color: var(--ew-on-surface);
161
- background: var(--ew-surface-muted);
162
- }
163
- .ew-header-hide-on-scroll__actions {
164
- display: flex;
165
- align-items: center;
166
- gap: var(--ew-space-2);
167
- border-left: 1px solid var(--ew-border);
168
- padding-left: var(--ew-space-3);
169
- margin-left: var(--ew-space-1);
170
- }
171
-
172
- @media (max-width: 768px) {
173
- .ew-header-hide-on-scroll__menu-btn {
174
- display: flex;
175
- }
176
- .ew-header-hide-on-scroll__nav {
177
- display: none;
178
- position: absolute;
179
- top: 100%;
180
- left: 0;
181
- right: 0;
182
- flex-direction: column;
183
- background: var(--ew-surface);
184
- border-bottom: 1px solid var(--ew-border);
185
- padding: var(--ew-space-4) var(--ew-space-5);
186
- gap: var(--ew-space-4);
187
- }
188
- .ew-header-hide-on-scroll__nav[data-open] {
189
- display: flex;
190
- }
191
- .ew-header-hide-on-scroll__links {
192
- flex-direction: column;
193
- gap: var(--ew-space-1);
194
- }
195
- .ew-header-hide-on-scroll__actions {
196
- border-left: none;
197
- padding-left: 0;
198
- margin-left: 0;
199
- padding-top: var(--ew-space-3);
200
- border-top: 1px solid var(--ew-border);
201
- }
202
- .ew-header-hide-on-scroll__menu-btn[aria-expanded="true"] .ew-header-hide-on-scroll__menu-icon--open { display: none; }
203
- .ew-header-hide-on-scroll__menu-btn[aria-expanded="true"] .ew-header-hide-on-scroll__menu-icon--close { display: block; }
204
- }
205
- </style>
206
-
207
- <script>
208
- function initHeader(headerEl: Element) {
209
- const applyPadding = () => {
210
- document.body.style.paddingTop = `${headerEl.getBoundingClientRect().height}px`;
211
- };
212
- applyPadding();
213
-
214
- let lastScrollY = window.scrollY;
215
- let ticking = false;
216
-
217
- const handleScroll = () => {
218
- if (!ticking) {
219
- window.requestAnimationFrame(() => {
220
- const currentScrollY = window.scrollY;
221
- if (currentScrollY > lastScrollY && currentScrollY > 80) {
222
- headerEl.classList.add('ew-header-hide-on-scroll--hidden');
223
- } else {
224
- headerEl.classList.remove('ew-header-hide-on-scroll--hidden');
225
- }
226
- lastScrollY = currentScrollY;
227
- ticking = false;
228
- });
229
- ticking = true;
230
- }
231
- };
232
-
233
- window.addEventListener('scroll', handleScroll, { passive: true });
234
- window.addEventListener('resize', applyPadding);
235
-
236
- const resizeObserver = 'ResizeObserver' in window ? new ResizeObserver(applyPadding) : null;
237
- resizeObserver?.observe(headerEl);
238
-
239
- const btn = headerEl.querySelector('.ew-header-hide-on-scroll__menu-btn') as HTMLButtonElement | null;
240
- const nav = headerEl.querySelector('.ew-header-hide-on-scroll__nav') as HTMLElement | null;
241
- if (btn && nav) {
242
- btn.addEventListener('click', () => {
243
- const isOpen = btn.getAttribute('aria-expanded') === 'true';
244
- btn.setAttribute('aria-expanded', String(!isOpen));
245
- isOpen ? nav.removeAttribute('data-open') : nav.setAttribute('data-open', '');
246
- });
247
- }
248
- }
249
- document.querySelectorAll('.ew-header-hide-on-scroll').forEach(initHeader);
250
- </script>
17
+ {Astro.slots.has('actions')
18
+ ? <HeaderHideOnScroll {...props}><Fragment slot="actions"><slot name="actions" /></Fragment></HeaderHideOnScroll>
19
+ : <HeaderHideOnScroll {...props} />}