@easy-web/core 1.3.3 → 1.5.0
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/LICENSE +21 -0
- package/package.json +9 -9
- package/src/components/Header.astro +205 -205
- package/src/components/HeaderCentered.astro +230 -230
- package/src/components/HeaderFlyout.astro +370 -370
- package/src/components/HeaderHideOnScroll.astro +234 -234
- package/src/components/LanguageSwitch.astro +82 -82
- package/src/components/NotFound.astro +115 -115
- package/src/components/PageShell.astro +82 -82
- package/src/components/SeoHead.astro +106 -106
- package/src/components/StructuredData.astro +1 -1
- package/src/components/ThemeToggle.astro +84 -84
- package/src/components/UniversalMedia.astro +106 -106
- package/src/components/__tests__/StructuredData.test.ts +1 -1
- package/src/components/__tests__/UniversalMedia.test.ts +65 -65
- package/src/contracts/__tests__/jsonld.test.ts +1 -1
- package/src/contracts/index.ts +1 -1
- package/src/contracts/jsonld.ts +1 -1
- package/src/i18n/__tests__/factory.test.ts +54 -54
- package/src/i18n/__tests__/localized-paths.test.ts +258 -258
- package/src/i18n/__tests__/routing-multi-locale.test.ts +89 -89
- package/src/i18n/__tests__/seo.test.ts +140 -140
- package/src/i18n/factory.ts +66 -66
- package/src/i18n/index.ts +5 -5
- package/src/i18n/localized-paths.ts +181 -181
- package/src/i18n/seo.ts +131 -131
- package/src/markdown/__tests__/__fixtures__/abs-src-assets.md +1 -1
- package/src/markdown/__tests__/__fixtures__/external-url.md +1 -1
- package/src/markdown/__tests__/__fixtures__/public-slash.md +1 -1
- package/src/markdown/__tests__/__fixtures__/rel-double-dot.md +1 -1
- package/src/markdown/__tests__/index.test.ts +60 -60
- package/src/markdown/index.ts +1 -1
- package/src/markdown/plugin.ts +42 -42
- package/src/schemas/__tests__/notFound.test.ts +32 -32
- package/src/schemas/notFound.ts +33 -33
- package/src/seo/__tests__/crawl-policy.test.ts +50 -50
- package/src/seo/__tests__/integration.test.ts +195 -195
- package/src/seo/__tests__/no-index-resolution.test.ts +53 -53
- package/src/seo/__tests__/robots-txt.test.ts +66 -66
- package/src/seo/__tests__/sitemap-options.test.ts +400 -400
- package/src/seo/crawl-policy.ts +36 -36
- package/src/seo/index.ts +254 -254
- package/src/seo/routes/robots-txt.ts +36 -36
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Achim Ismaili
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-web/core",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -42,12 +42,6 @@
|
|
|
42
42
|
"sideEffects": [
|
|
43
43
|
"*.css"
|
|
44
44
|
],
|
|
45
|
-
"scripts": {
|
|
46
|
-
"build": "tsc -p tsconfig.build.json",
|
|
47
|
-
"typecheck": "tsc --noEmit",
|
|
48
|
-
"test": "vitest run",
|
|
49
|
-
"lint": "eslint src"
|
|
50
|
-
},
|
|
51
45
|
"peerDependencies": {
|
|
52
46
|
"astro": ">=6.0.0 <8.0.0"
|
|
53
47
|
},
|
|
@@ -72,5 +66,11 @@
|
|
|
72
66
|
"url": "https://github.com/achimismaili/easy-web.git",
|
|
73
67
|
"directory": "packages/core"
|
|
74
68
|
},
|
|
75
|
-
"license": "MIT"
|
|
76
|
-
|
|
69
|
+
"license": "MIT",
|
|
70
|
+
"scripts": {
|
|
71
|
+
"build": "tsc -p tsconfig.build.json",
|
|
72
|
+
"typecheck": "tsc --noEmit",
|
|
73
|
+
"test": "vitest run",
|
|
74
|
+
"lint": "eslint src"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -1,205 +1,205 @@
|
|
|
1
|
-
---
|
|
2
|
-
/**
|
|
3
|
-
* Header – responsive site header with navigation, theme toggle, and language switch.
|
|
4
|
-
* Pure Astro component with minimal vanilla JS for mobile menu.
|
|
5
|
-
*/
|
|
6
|
-
import type { HeaderProps } from '../contracts/props.js';
|
|
7
|
-
import { resolveLabels } from './labels.js';
|
|
8
|
-
import Media from './Media.astro';
|
|
9
|
-
import ThemeToggle from './ThemeToggle.astro';
|
|
10
|
-
import LanguageSwitch from './LanguageSwitch.astro';
|
|
11
|
-
|
|
12
|
-
export type Props = HeaderProps;
|
|
13
|
-
|
|
14
|
-
const { lang = 'en', labels: labelOverrides } = Astro.props;
|
|
15
|
-
const labels = resolveLabels(lang, labelOverrides);
|
|
16
|
-
const { siteName, navItems, currentLang, pathname, brandHref, alternateHref, menuLabel = labels.toggleNavigationMenu, logo, navId = 'ew-header-nav', locales } = Astro.props;
|
|
17
|
-
const showLanguageSwitch = !locales || locales.length > 1;
|
|
18
|
-
// A bare logo URL keeps today's markup: the site name is its alt text.
|
|
19
|
-
const logoImage = !logo ? undefined : typeof logo === 'string' ? { src: logo, alt: siteName } : logo;
|
|
20
|
-
---
|
|
21
|
-
|
|
22
|
-
<header class="ew-header" data-testid="header-classic">
|
|
23
|
-
<div class="ew-header__inner">
|
|
24
|
-
<a href={brandHref ?? (currentLang === 'de' ? '/' : `/${currentLang}/`)} class="ew-header__brand">
|
|
25
|
-
{logoImage ? <Media image={logoImage} class="ew-header__logo" /> : siteName}
|
|
26
|
-
</a>
|
|
27
|
-
|
|
28
|
-
<button
|
|
29
|
-
type="button"
|
|
30
|
-
class="ew-header__menu-btn"
|
|
31
|
-
aria-label={menuLabel}
|
|
32
|
-
aria-expanded="false"
|
|
33
|
-
aria-controls={navId}
|
|
34
|
-
data-testid="mobile-menu-toggle"
|
|
35
|
-
>
|
|
36
|
-
<svg class="ew-header__menu-icon ew-header__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">
|
|
37
|
-
<line x1="3" y1="6" x2="21" y2="6"></line>
|
|
38
|
-
<line x1="3" y1="12" x2="21" y2="12"></line>
|
|
39
|
-
<line x1="3" y1="18" x2="21" y2="18"></line>
|
|
40
|
-
</svg>
|
|
41
|
-
<svg class="ew-header__menu-icon ew-header__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">
|
|
42
|
-
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
43
|
-
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
44
|
-
</svg>
|
|
45
|
-
</button>
|
|
46
|
-
|
|
47
|
-
<nav id={navId} class="ew-header__nav" aria-label={labels.mainNavigation}>
|
|
48
|
-
<ul class="ew-header__links">
|
|
49
|
-
{navItems.map((item) => (
|
|
50
|
-
<li>
|
|
51
|
-
<a href={item.href} class:list={['ew-header__link', { 'ew-header__link--active': pathname === item.href }]}>
|
|
52
|
-
{item.label}
|
|
53
|
-
</a>
|
|
54
|
-
</li>
|
|
55
|
-
))}
|
|
56
|
-
</ul>
|
|
57
|
-
<div class="ew-header__actions">
|
|
58
|
-
<slot name="actions">
|
|
59
|
-
<ThemeToggle lang={lang} labels={labelOverrides} />
|
|
60
|
-
{showLanguageSwitch && <LanguageSwitch currentLang={currentLang} pathname={pathname} alternateHref={alternateHref} lang={lang} labels={labelOverrides} />}
|
|
61
|
-
</slot>
|
|
62
|
-
</div>
|
|
63
|
-
</nav>
|
|
64
|
-
</div>
|
|
65
|
-
</header>
|
|
66
|
-
|
|
67
|
-
<style>
|
|
68
|
-
.ew-header {
|
|
69
|
-
position: sticky;
|
|
70
|
-
top: 0;
|
|
71
|
-
z-index: 100;
|
|
72
|
-
background: var(--ew-surface);
|
|
73
|
-
border-bottom: 1px solid var(--ew-border);
|
|
74
|
-
}
|
|
75
|
-
.ew-header__inner {
|
|
76
|
-
display: flex;
|
|
77
|
-
align-items: center;
|
|
78
|
-
justify-content: space-between;
|
|
79
|
-
max-width: 72rem;
|
|
80
|
-
margin: 0 auto;
|
|
81
|
-
padding: var(--ew-space-3) var(--ew-space-5);
|
|
82
|
-
}
|
|
83
|
-
.ew-header__brand {
|
|
84
|
-
font-family: var(--ew-font-sans);
|
|
85
|
-
font-size: var(--ew-text-lg);
|
|
86
|
-
font-weight: 700;
|
|
87
|
-
color: var(--ew-on-surface);
|
|
88
|
-
text-decoration: none;
|
|
89
|
-
letter-spacing: -0.01em;
|
|
90
|
-
}
|
|
91
|
-
.ew-header__brand:hover {
|
|
92
|
-
color: var(--ew-primary);
|
|
93
|
-
}
|
|
94
|
-
.ew-header__logo {
|
|
95
|
-
height: 1.5rem;
|
|
96
|
-
width: auto;
|
|
97
|
-
display: block;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
/* Mobile menu button */
|
|
101
|
-
.ew-header__menu-btn {
|
|
102
|
-
display: none;
|
|
103
|
-
background: transparent;
|
|
104
|
-
border: none;
|
|
105
|
-
color: var(--ew-on-surface);
|
|
106
|
-
cursor: pointer;
|
|
107
|
-
padding: var(--ew-space-1);
|
|
108
|
-
}
|
|
109
|
-
.ew-header__menu-btn:focus-visible {
|
|
110
|
-
outline: 2px solid var(--ew-primary);
|
|
111
|
-
outline-offset: 2px;
|
|
112
|
-
}
|
|
113
|
-
.ew-header__menu-icon--close { display: none; }
|
|
114
|
-
|
|
115
|
-
/* Nav */
|
|
116
|
-
.ew-header__nav {
|
|
117
|
-
display: flex;
|
|
118
|
-
align-items: center;
|
|
119
|
-
gap: var(--ew-space-5);
|
|
120
|
-
}
|
|
121
|
-
.ew-header__links {
|
|
122
|
-
display: flex;
|
|
123
|
-
list-style: none;
|
|
124
|
-
margin: 0;
|
|
125
|
-
padding: 0;
|
|
126
|
-
gap: var(--ew-space-1);
|
|
127
|
-
}
|
|
128
|
-
.ew-header__link {
|
|
129
|
-
display: block;
|
|
130
|
-
padding: var(--ew-space-2) var(--ew-space-3);
|
|
131
|
-
border-radius: var(--ew-radius-md);
|
|
132
|
-
color: var(--ew-muted);
|
|
133
|
-
font-family: var(--ew-font-sans);
|
|
134
|
-
font-size: var(--ew-text-sm);
|
|
135
|
-
font-weight: 500;
|
|
136
|
-
text-decoration: none;
|
|
137
|
-
}
|
|
138
|
-
.ew-header__link:hover {
|
|
139
|
-
color: var(--ew-on-surface);
|
|
140
|
-
background: var(--ew-surface-muted);
|
|
141
|
-
}
|
|
142
|
-
.ew-header__link--active {
|
|
143
|
-
color: var(--ew-on-surface);
|
|
144
|
-
background: var(--ew-surface-muted);
|
|
145
|
-
}
|
|
146
|
-
.ew-header__actions {
|
|
147
|
-
display: flex;
|
|
148
|
-
align-items: center;
|
|
149
|
-
gap: var(--ew-space-2);
|
|
150
|
-
border-left: 1px solid var(--ew-border);
|
|
151
|
-
padding-left: var(--ew-space-3);
|
|
152
|
-
margin-left: var(--ew-space-1);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/* Mobile: <=768px */
|
|
156
|
-
@media (max-width: 768px) {
|
|
157
|
-
.ew-header__menu-btn {
|
|
158
|
-
display: flex;
|
|
159
|
-
}
|
|
160
|
-
.ew-header__nav {
|
|
161
|
-
display: none;
|
|
162
|
-
position: absolute;
|
|
163
|
-
top: 100%;
|
|
164
|
-
left: 0;
|
|
165
|
-
right: 0;
|
|
166
|
-
flex-direction: column;
|
|
167
|
-
background: var(--ew-surface);
|
|
168
|
-
border-bottom: 1px solid var(--ew-border);
|
|
169
|
-
padding: var(--ew-space-4) var(--ew-space-5);
|
|
170
|
-
gap: var(--ew-space-4);
|
|
171
|
-
}
|
|
172
|
-
.ew-header__nav[data-open] {
|
|
173
|
-
display: flex;
|
|
174
|
-
}
|
|
175
|
-
.ew-header__links {
|
|
176
|
-
flex-direction: column;
|
|
177
|
-
gap: var(--ew-space-1);
|
|
178
|
-
}
|
|
179
|
-
.ew-header__actions {
|
|
180
|
-
border-left: none;
|
|
181
|
-
padding-left: 0;
|
|
182
|
-
margin-left: 0;
|
|
183
|
-
padding-top: var(--ew-space-3);
|
|
184
|
-
border-top: 1px solid var(--ew-border);
|
|
185
|
-
}
|
|
186
|
-
/* Toggle icon swap when open */
|
|
187
|
-
.ew-header__menu-btn[aria-expanded="true"] .ew-header__menu-icon--open { display: none; }
|
|
188
|
-
.ew-header__menu-btn[aria-expanded="true"] .ew-header__menu-icon--close { display: block; }
|
|
189
|
-
}
|
|
190
|
-
</style>
|
|
191
|
-
|
|
192
|
-
<script>
|
|
193
|
-
function initHeader(headerEl: Element) {
|
|
194
|
-
const btn = headerEl.querySelector('.ew-header__menu-btn') as HTMLButtonElement | null;
|
|
195
|
-
const nav = headerEl.querySelector('.ew-header__nav') as HTMLElement | null;
|
|
196
|
-
if (!btn || !nav) return;
|
|
197
|
-
btn.addEventListener('click', () => {
|
|
198
|
-
const isOpen = btn.getAttribute('aria-expanded') === 'true';
|
|
199
|
-
btn.setAttribute('aria-expanded', String(!isOpen));
|
|
200
|
-
if (isOpen) nav.removeAttribute('data-open');
|
|
201
|
-
else nav.setAttribute('data-open', '');
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
document.querySelectorAll('.ew-header').forEach(initHeader);
|
|
205
|
-
</script>
|
|
1
|
+
---
|
|
2
|
+
/**
|
|
3
|
+
* Header – responsive site header with navigation, theme toggle, and language switch.
|
|
4
|
+
* Pure Astro component with minimal vanilla JS for mobile menu.
|
|
5
|
+
*/
|
|
6
|
+
import type { HeaderProps } from '../contracts/props.js';
|
|
7
|
+
import { resolveLabels } from './labels.js';
|
|
8
|
+
import Media from './Media.astro';
|
|
9
|
+
import ThemeToggle from './ThemeToggle.astro';
|
|
10
|
+
import LanguageSwitch from './LanguageSwitch.astro';
|
|
11
|
+
|
|
12
|
+
export type Props = HeaderProps;
|
|
13
|
+
|
|
14
|
+
const { lang = 'en', labels: labelOverrides } = Astro.props;
|
|
15
|
+
const labels = resolveLabels(lang, labelOverrides);
|
|
16
|
+
const { siteName, navItems, currentLang, pathname, brandHref, alternateHref, menuLabel = labels.toggleNavigationMenu, logo, navId = 'ew-header-nav', locales } = Astro.props;
|
|
17
|
+
const showLanguageSwitch = !locales || locales.length > 1;
|
|
18
|
+
// A bare logo URL keeps today's markup: the site name is its alt text.
|
|
19
|
+
const logoImage = !logo ? undefined : typeof logo === 'string' ? { src: logo, alt: siteName } : logo;
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
<header class="ew-header" data-testid="header-classic">
|
|
23
|
+
<div class="ew-header__inner">
|
|
24
|
+
<a href={brandHref ?? (currentLang === 'de' ? '/' : `/${currentLang}/`)} class="ew-header__brand">
|
|
25
|
+
{logoImage ? <Media image={logoImage} class="ew-header__logo" /> : siteName}
|
|
26
|
+
</a>
|
|
27
|
+
|
|
28
|
+
<button
|
|
29
|
+
type="button"
|
|
30
|
+
class="ew-header__menu-btn"
|
|
31
|
+
aria-label={menuLabel}
|
|
32
|
+
aria-expanded="false"
|
|
33
|
+
aria-controls={navId}
|
|
34
|
+
data-testid="mobile-menu-toggle"
|
|
35
|
+
>
|
|
36
|
+
<svg class="ew-header__menu-icon ew-header__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">
|
|
37
|
+
<line x1="3" y1="6" x2="21" y2="6"></line>
|
|
38
|
+
<line x1="3" y1="12" x2="21" y2="12"></line>
|
|
39
|
+
<line x1="3" y1="18" x2="21" y2="18"></line>
|
|
40
|
+
</svg>
|
|
41
|
+
<svg class="ew-header__menu-icon ew-header__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">
|
|
42
|
+
<line x1="18" y1="6" x2="6" y2="18"></line>
|
|
43
|
+
<line x1="6" y1="6" x2="18" y2="18"></line>
|
|
44
|
+
</svg>
|
|
45
|
+
</button>
|
|
46
|
+
|
|
47
|
+
<nav id={navId} class="ew-header__nav" aria-label={labels.mainNavigation}>
|
|
48
|
+
<ul class="ew-header__links">
|
|
49
|
+
{navItems.map((item) => (
|
|
50
|
+
<li>
|
|
51
|
+
<a href={item.href} class:list={['ew-header__link', { 'ew-header__link--active': pathname === item.href }]}>
|
|
52
|
+
{item.label}
|
|
53
|
+
</a>
|
|
54
|
+
</li>
|
|
55
|
+
))}
|
|
56
|
+
</ul>
|
|
57
|
+
<div class="ew-header__actions">
|
|
58
|
+
<slot name="actions">
|
|
59
|
+
<ThemeToggle lang={lang} labels={labelOverrides} />
|
|
60
|
+
{showLanguageSwitch && <LanguageSwitch currentLang={currentLang} pathname={pathname} alternateHref={alternateHref} lang={lang} labels={labelOverrides} />}
|
|
61
|
+
</slot>
|
|
62
|
+
</div>
|
|
63
|
+
</nav>
|
|
64
|
+
</div>
|
|
65
|
+
</header>
|
|
66
|
+
|
|
67
|
+
<style>
|
|
68
|
+
.ew-header {
|
|
69
|
+
position: sticky;
|
|
70
|
+
top: 0;
|
|
71
|
+
z-index: 100;
|
|
72
|
+
background: var(--ew-surface);
|
|
73
|
+
border-bottom: 1px solid var(--ew-border);
|
|
74
|
+
}
|
|
75
|
+
.ew-header__inner {
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: center;
|
|
78
|
+
justify-content: space-between;
|
|
79
|
+
max-width: 72rem;
|
|
80
|
+
margin: 0 auto;
|
|
81
|
+
padding: var(--ew-space-3) var(--ew-space-5);
|
|
82
|
+
}
|
|
83
|
+
.ew-header__brand {
|
|
84
|
+
font-family: var(--ew-font-sans);
|
|
85
|
+
font-size: var(--ew-text-lg);
|
|
86
|
+
font-weight: 700;
|
|
87
|
+
color: var(--ew-on-surface);
|
|
88
|
+
text-decoration: none;
|
|
89
|
+
letter-spacing: -0.01em;
|
|
90
|
+
}
|
|
91
|
+
.ew-header__brand:hover {
|
|
92
|
+
color: var(--ew-primary);
|
|
93
|
+
}
|
|
94
|
+
.ew-header__logo {
|
|
95
|
+
height: 1.5rem;
|
|
96
|
+
width: auto;
|
|
97
|
+
display: block;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/* Mobile menu button */
|
|
101
|
+
.ew-header__menu-btn {
|
|
102
|
+
display: none;
|
|
103
|
+
background: transparent;
|
|
104
|
+
border: none;
|
|
105
|
+
color: var(--ew-on-surface);
|
|
106
|
+
cursor: pointer;
|
|
107
|
+
padding: var(--ew-space-1);
|
|
108
|
+
}
|
|
109
|
+
.ew-header__menu-btn:focus-visible {
|
|
110
|
+
outline: 2px solid var(--ew-primary);
|
|
111
|
+
outline-offset: 2px;
|
|
112
|
+
}
|
|
113
|
+
.ew-header__menu-icon--close { display: none; }
|
|
114
|
+
|
|
115
|
+
/* Nav */
|
|
116
|
+
.ew-header__nav {
|
|
117
|
+
display: flex;
|
|
118
|
+
align-items: center;
|
|
119
|
+
gap: var(--ew-space-5);
|
|
120
|
+
}
|
|
121
|
+
.ew-header__links {
|
|
122
|
+
display: flex;
|
|
123
|
+
list-style: none;
|
|
124
|
+
margin: 0;
|
|
125
|
+
padding: 0;
|
|
126
|
+
gap: var(--ew-space-1);
|
|
127
|
+
}
|
|
128
|
+
.ew-header__link {
|
|
129
|
+
display: block;
|
|
130
|
+
padding: var(--ew-space-2) var(--ew-space-3);
|
|
131
|
+
border-radius: var(--ew-radius-md);
|
|
132
|
+
color: var(--ew-muted);
|
|
133
|
+
font-family: var(--ew-font-sans);
|
|
134
|
+
font-size: var(--ew-text-sm);
|
|
135
|
+
font-weight: 500;
|
|
136
|
+
text-decoration: none;
|
|
137
|
+
}
|
|
138
|
+
.ew-header__link:hover {
|
|
139
|
+
color: var(--ew-on-surface);
|
|
140
|
+
background: var(--ew-surface-muted);
|
|
141
|
+
}
|
|
142
|
+
.ew-header__link--active {
|
|
143
|
+
color: var(--ew-on-surface);
|
|
144
|
+
background: var(--ew-surface-muted);
|
|
145
|
+
}
|
|
146
|
+
.ew-header__actions {
|
|
147
|
+
display: flex;
|
|
148
|
+
align-items: center;
|
|
149
|
+
gap: var(--ew-space-2);
|
|
150
|
+
border-left: 1px solid var(--ew-border);
|
|
151
|
+
padding-left: var(--ew-space-3);
|
|
152
|
+
margin-left: var(--ew-space-1);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* Mobile: <=768px */
|
|
156
|
+
@media (max-width: 768px) {
|
|
157
|
+
.ew-header__menu-btn {
|
|
158
|
+
display: flex;
|
|
159
|
+
}
|
|
160
|
+
.ew-header__nav {
|
|
161
|
+
display: none;
|
|
162
|
+
position: absolute;
|
|
163
|
+
top: 100%;
|
|
164
|
+
left: 0;
|
|
165
|
+
right: 0;
|
|
166
|
+
flex-direction: column;
|
|
167
|
+
background: var(--ew-surface);
|
|
168
|
+
border-bottom: 1px solid var(--ew-border);
|
|
169
|
+
padding: var(--ew-space-4) var(--ew-space-5);
|
|
170
|
+
gap: var(--ew-space-4);
|
|
171
|
+
}
|
|
172
|
+
.ew-header__nav[data-open] {
|
|
173
|
+
display: flex;
|
|
174
|
+
}
|
|
175
|
+
.ew-header__links {
|
|
176
|
+
flex-direction: column;
|
|
177
|
+
gap: var(--ew-space-1);
|
|
178
|
+
}
|
|
179
|
+
.ew-header__actions {
|
|
180
|
+
border-left: none;
|
|
181
|
+
padding-left: 0;
|
|
182
|
+
margin-left: 0;
|
|
183
|
+
padding-top: var(--ew-space-3);
|
|
184
|
+
border-top: 1px solid var(--ew-border);
|
|
185
|
+
}
|
|
186
|
+
/* Toggle icon swap when open */
|
|
187
|
+
.ew-header__menu-btn[aria-expanded="true"] .ew-header__menu-icon--open { display: none; }
|
|
188
|
+
.ew-header__menu-btn[aria-expanded="true"] .ew-header__menu-icon--close { display: block; }
|
|
189
|
+
}
|
|
190
|
+
</style>
|
|
191
|
+
|
|
192
|
+
<script>
|
|
193
|
+
function initHeader(headerEl: Element) {
|
|
194
|
+
const btn = headerEl.querySelector('.ew-header__menu-btn') as HTMLButtonElement | null;
|
|
195
|
+
const nav = headerEl.querySelector('.ew-header__nav') as HTMLElement | null;
|
|
196
|
+
if (!btn || !nav) return;
|
|
197
|
+
btn.addEventListener('click', () => {
|
|
198
|
+
const isOpen = btn.getAttribute('aria-expanded') === 'true';
|
|
199
|
+
btn.setAttribute('aria-expanded', String(!isOpen));
|
|
200
|
+
if (isOpen) nav.removeAttribute('data-open');
|
|
201
|
+
else nav.setAttribute('data-open', '');
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
document.querySelectorAll('.ew-header').forEach(initHeader);
|
|
205
|
+
</script>
|