@progressive-development/pd-page 0.9.1 → 1.0.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 -2
- package/README.md +34 -57
- package/dist/generated/locales/be.d.ts +19 -1
- package/dist/generated/locales/be.d.ts.map +1 -1
- package/dist/generated/locales/de.d.ts +19 -1
- package/dist/generated/locales/de.d.ts.map +1 -1
- package/dist/generated/locales/en.d.ts +19 -1
- package/dist/generated/locales/en.d.ts.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/locales/be.js +19 -1
- package/dist/locales/de.js +19 -1
- package/dist/locales/en.js +19 -1
- package/dist/pd-contact-us/PdContactUs.d.ts +15 -5
- package/dist/pd-contact-us/PdContactUs.d.ts.map +1 -1
- package/dist/pd-contact-us/PdContactUs.js +94 -134
- package/dist/pd-contact-us/pd-contact-us.stories.d.ts +36 -5
- package/dist/pd-contact-us/pd-contact-us.stories.d.ts.map +1 -1
- package/dist/pd-content/dist/pd-notice-box/PdNoticeBox.js +224 -0
- package/dist/pd-content/dist/pd-notice-box/pd-notice-box.js +8 -0
- package/dist/pd-footer/PdFooter.d.ts +27 -15
- package/dist/pd-footer/PdFooter.d.ts.map +1 -1
- package/dist/pd-footer/PdFooter.js +122 -74
- package/dist/pd-footer/pd-footer.stories.d.ts +47 -7
- package/dist/pd-footer/pd-footer.stories.d.ts.map +1 -1
- package/dist/pd-login/PdLogin.d.ts +59 -0
- package/dist/pd-login/PdLogin.d.ts.map +1 -0
- package/dist/pd-login/PdLogin.js +292 -0
- package/dist/pd-login/pd-login.d.ts +3 -0
- package/dist/pd-login/pd-login.d.ts.map +1 -0
- package/dist/pd-login/pd-login.stories.d.ts +55 -0
- package/dist/pd-login/pd-login.stories.d.ts.map +1 -0
- package/dist/pd-login.d.ts +2 -0
- package/dist/pd-login.js +8 -0
- package/dist/pd-menu/PdMenu.d.ts +72 -40
- package/dist/pd-menu/PdMenu.d.ts.map +1 -1
- package/dist/pd-menu/PdMenu.js +384 -276
- package/dist/pd-menu/pd-menu.stories.d.ts +59 -17
- package/dist/pd-menu/pd-menu.stories.d.ts.map +1 -1
- package/dist/pd-socialmedia/PdSocialmedia.d.ts +56 -0
- package/dist/pd-socialmedia/PdSocialmedia.d.ts.map +1 -0
- package/dist/pd-socialmedia/PdSocialmedia.js +426 -0
- package/dist/pd-socialmedia/pd-socialmedia-model.d.ts +16 -0
- package/dist/pd-socialmedia/pd-socialmedia-model.d.ts.map +1 -0
- package/dist/pd-socialmedia/pd-socialmedia-model.js +240 -0
- package/dist/pd-socialmedia/pd-socialmedia.d.ts +3 -0
- package/dist/pd-socialmedia/pd-socialmedia.d.ts.map +1 -0
- package/dist/pd-socialmedia/pd-socialmedia.stories.d.ts +53 -0
- package/dist/pd-socialmedia/pd-socialmedia.stories.d.ts.map +1 -0
- package/dist/pd-socialmedia.d.ts +2 -0
- package/dist/pd-socialmedia.js +7 -0
- package/dist/pd-toast/PdToast.d.ts +23 -0
- package/dist/pd-toast/PdToast.d.ts.map +1 -0
- package/dist/pd-toast/PdToast.js +222 -0
- package/dist/pd-toast/pd-toast.d.ts +3 -0
- package/dist/pd-toast/pd-toast.d.ts.map +1 -0
- package/dist/pd-toast/pd-toast.stories.d.ts +47 -0
- package/dist/pd-toast/pd-toast.stories.d.ts.map +1 -0
- package/dist/pd-toast.d.ts +2 -0
- package/dist/pd-toast.js +8 -0
- package/dist/stories/01_index.stories.d.ts +36 -4
- package/dist/stories/01_index.stories.d.ts.map +1 -1
- package/dist/toast-bus/toast-bus.d.ts +61 -0
- package/dist/toast-bus/toast-bus.d.ts.map +1 -0
- package/dist/toast-bus/toast-bus.js +42 -0
- package/dist/types.d.ts +18 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +14 -8
package/dist/pd-menu/PdMenu.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { css, LitElement, html } from 'lit';
|
|
2
2
|
import { property, state } from 'lit/decorators.js';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { PdColorStyles, PdFontStyles } from '@progressive-development/pd-shared-styles';
|
|
3
|
+
import { classMap } from 'lit/directives/class-map.js';
|
|
4
|
+
import { localized, msg } from '@lit/localize';
|
|
6
5
|
import { pdIcons } from '@progressive-development/pd-icon';
|
|
7
6
|
import '@progressive-development/pd-icon/pd-icon';
|
|
7
|
+
import '@progressive-development/pd-forms/pd-button-select-group';
|
|
8
8
|
|
|
9
9
|
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
11
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
11
|
-
var result = void 0 ;
|
|
12
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
12
13
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
13
14
|
if (decorator = decorators[i])
|
|
14
|
-
result = (decorator(target, key, result) ) || result;
|
|
15
|
-
if (result) __defProp(target, key, result);
|
|
15
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
16
|
+
if (kind && result) __defProp(target, key, result);
|
|
16
17
|
return result;
|
|
17
18
|
};
|
|
18
|
-
|
|
19
|
+
let PdMenu = class extends LitElement {
|
|
19
20
|
constructor() {
|
|
20
21
|
super(...arguments);
|
|
21
22
|
this.activeRoute = "";
|
|
@@ -24,24 +25,308 @@ const _PdMenu = class _PdMenu extends LitElement {
|
|
|
24
25
|
this.menuItems = [];
|
|
25
26
|
this.topMenuItems = [];
|
|
26
27
|
this.noBurgerMenu = false;
|
|
27
|
-
this.headerSize = 0;
|
|
28
28
|
this._activeSecIndex = 0;
|
|
29
29
|
this._activeBurgerMenu = false;
|
|
30
|
-
this._activeLocaleMenu = false;
|
|
31
30
|
this._smallScreen = false;
|
|
31
|
+
/** @ignore */
|
|
32
|
+
this._boundScrollHandler = this._handleScroll.bind(this);
|
|
33
|
+
/** @ignore */
|
|
34
|
+
this._boundMediaQueryHandler = this._handleMediaQuery.bind(this);
|
|
35
|
+
this._ticking = false;
|
|
32
36
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
connectedCallback() {
|
|
38
|
+
super.connectedCallback();
|
|
39
|
+
document.addEventListener("scroll", this._boundScrollHandler);
|
|
40
|
+
this._mediaQueryList = window.matchMedia("(max-width: 767px)");
|
|
41
|
+
this._mediaQueryList.addEventListener(
|
|
42
|
+
"change",
|
|
43
|
+
this._boundMediaQueryHandler
|
|
44
|
+
);
|
|
45
|
+
this._smallScreen = this._mediaQueryList.matches && !this.noBurgerMenu;
|
|
46
|
+
}
|
|
47
|
+
disconnectedCallback() {
|
|
48
|
+
super.disconnectedCallback();
|
|
49
|
+
document.removeEventListener("scroll", this._boundScrollHandler);
|
|
50
|
+
if (this._mediaQueryList) {
|
|
51
|
+
this._mediaQueryList.removeEventListener(
|
|
52
|
+
"change",
|
|
53
|
+
this._boundMediaQueryHandler
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
_handleScroll() {
|
|
58
|
+
const scrollY = window.scrollY;
|
|
59
|
+
if (!this._ticking) {
|
|
60
|
+
window.requestAnimationFrame(() => {
|
|
61
|
+
this._updateActiveSection(scrollY);
|
|
62
|
+
this._ticking = false;
|
|
63
|
+
});
|
|
64
|
+
this._ticking = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
_handleMediaQuery(e) {
|
|
68
|
+
this._smallScreen = e.matches && !this.noBurgerMenu;
|
|
69
|
+
}
|
|
70
|
+
_updateActiveSection(_scrollPos) {
|
|
71
|
+
let activeIndex = -1;
|
|
72
|
+
let closestDistance = Infinity;
|
|
73
|
+
let lastVisibleIndex = -1;
|
|
74
|
+
this.menuItems.forEach((item, index) => {
|
|
75
|
+
if (item.ref) {
|
|
76
|
+
const rect = item.ref.getBoundingClientRect();
|
|
77
|
+
if (rect.top < window.innerHeight && rect.bottom > 0) {
|
|
78
|
+
lastVisibleIndex = index;
|
|
79
|
+
}
|
|
80
|
+
if (rect.top <= 150 && rect.bottom > 0) {
|
|
81
|
+
const distance = Math.abs(rect.top);
|
|
82
|
+
if (distance < closestDistance) {
|
|
83
|
+
activeIndex = index;
|
|
84
|
+
closestDistance = distance;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
if (lastVisibleIndex >= 0) {
|
|
90
|
+
const atBottom = window.innerHeight + window.scrollY >= document.documentElement.scrollHeight - 50;
|
|
91
|
+
if (atBottom && lastVisibleIndex > activeIndex) {
|
|
92
|
+
activeIndex = lastVisibleIndex;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const newActiveIndex = activeIndex >= 0 ? activeIndex + 1 : 0;
|
|
96
|
+
if (newActiveIndex !== this._activeSecIndex && newActiveIndex > 0) {
|
|
97
|
+
const activeItem = this.menuItems[newActiveIndex - 1];
|
|
98
|
+
if (activeItem?.sec) {
|
|
99
|
+
this.dispatchEvent(
|
|
100
|
+
new CustomEvent("section-activated", {
|
|
101
|
+
detail: { sectionId: activeItem.sec },
|
|
102
|
+
bubbles: true,
|
|
103
|
+
composed: true
|
|
104
|
+
})
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
this._activeSecIndex = newActiveIndex;
|
|
109
|
+
}
|
|
110
|
+
render() {
|
|
111
|
+
return html`
|
|
112
|
+
<nav
|
|
113
|
+
class="menu-container"
|
|
114
|
+
aria-label="${msg("Hauptnavigation", { id: "pd.menu.nav.aria" })}"
|
|
115
|
+
>
|
|
116
|
+
<slot name="slotLogo" @click="${this._logoClicked}"></slot>
|
|
117
|
+
|
|
118
|
+
<ul
|
|
119
|
+
id="${this._smallScreen ? "burger-menu-list" : ""}"
|
|
120
|
+
class="${classMap({
|
|
121
|
+
"menu-ul": true,
|
|
122
|
+
"burger-ul": this._smallScreen,
|
|
123
|
+
"burger-open": this._activeBurgerMenu
|
|
124
|
+
})}"
|
|
125
|
+
role="menubar"
|
|
126
|
+
>
|
|
127
|
+
${this._renderItems(
|
|
128
|
+
this._smallScreen ? [...this.menuItems, ...this.topMenuItems] : this.menuItems,
|
|
129
|
+
true
|
|
130
|
+
)}
|
|
131
|
+
</ul>
|
|
132
|
+
|
|
133
|
+
${!this._smallScreen ? html`
|
|
134
|
+
<ul class="menu-ul topMenu" role="menubar">
|
|
135
|
+
${this._renderItems(this.topMenuItems, false)}
|
|
136
|
+
${this.locales.length > 1 ? html`
|
|
137
|
+
<pd-button-select-group
|
|
138
|
+
class="locale-selector"
|
|
139
|
+
.options="${this.locales}"
|
|
140
|
+
.initValue="${this._getSelectedLocaleIndex()}"
|
|
141
|
+
group-label="${msg("Sprache auswählen", {
|
|
142
|
+
id: "pd.menu.locale.aria"
|
|
143
|
+
})}"
|
|
144
|
+
@pd-button-selection-changed="${this._handleLocaleChange}"
|
|
145
|
+
></pd-button-select-group>
|
|
146
|
+
` : ""}
|
|
147
|
+
</ul>
|
|
148
|
+
` : html`
|
|
149
|
+
<div class="menu-wrapper">
|
|
150
|
+
${this.locales.length > 1 ? html`
|
|
151
|
+
<pd-button-select-group
|
|
152
|
+
class="locale-selector"
|
|
153
|
+
.options="${this._getCompactLocales()}"
|
|
154
|
+
.initValue="${this._getSelectedLocaleIndex()}"
|
|
155
|
+
group-label="${msg("Sprache auswählen", {
|
|
156
|
+
id: "pd.menu.locale.aria"
|
|
157
|
+
})}"
|
|
158
|
+
@pd-button-selection-changed="${this._handleLocaleChange}"
|
|
159
|
+
></pd-button-select-group>
|
|
160
|
+
` : ""}
|
|
161
|
+
<div
|
|
162
|
+
class="burger-menu"
|
|
163
|
+
role="button"
|
|
164
|
+
tabindex="0"
|
|
165
|
+
aria-expanded="${this._activeBurgerMenu}"
|
|
166
|
+
aria-controls="burger-menu-list"
|
|
167
|
+
aria-label="${msg("Menü öffnen", {
|
|
168
|
+
id: "pd.menu.burger.aria"
|
|
169
|
+
})}"
|
|
170
|
+
@click="${this._toggleBurgerMenu}"
|
|
171
|
+
@keydown="${this._handleBurgerKeydown}"
|
|
172
|
+
>
|
|
173
|
+
<pd-icon
|
|
174
|
+
class="burgerLogo"
|
|
175
|
+
icon="${pdIcons.ICON_BURGER_MENU}"
|
|
176
|
+
?activeIcon="${!this._activeBurgerMenu}"
|
|
177
|
+
></pd-icon>
|
|
178
|
+
</div>
|
|
179
|
+
</div>
|
|
180
|
+
`}
|
|
181
|
+
</nav>
|
|
182
|
+
`;
|
|
183
|
+
}
|
|
184
|
+
_renderItems(items, highlight) {
|
|
185
|
+
return html`
|
|
186
|
+
${items.map(
|
|
187
|
+
(item, index) => html`
|
|
188
|
+
<li
|
|
189
|
+
class="item menu-li ${this._smallScreen ? "burger-li burger-item" : ""}
|
|
190
|
+
${highlight && (this._activeSecIndex === index + 1 || item.route === this.activeRoute) ? "active" : ""}"
|
|
191
|
+
role="menuitem"
|
|
192
|
+
tabindex="0"
|
|
193
|
+
data-key="${item.key}"
|
|
194
|
+
@click="${this._menuItemClicked}"
|
|
195
|
+
@keydown="${this._handleMenuItemKeydown}"
|
|
196
|
+
>
|
|
197
|
+
${item.icon ? html`<pd-icon
|
|
198
|
+
class="topItemLogo"
|
|
199
|
+
icon="${item.icon}"
|
|
200
|
+
></pd-icon>` : ""}
|
|
201
|
+
${item.name}
|
|
202
|
+
</li>
|
|
203
|
+
`
|
|
204
|
+
)}
|
|
205
|
+
`;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Handles keyboard events on menu items.
|
|
209
|
+
*/
|
|
210
|
+
_handleMenuItemKeydown(e) {
|
|
211
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
212
|
+
e.preventDefault();
|
|
213
|
+
this._menuItemClicked(e);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Handles keyboard events on burger menu toggle.
|
|
218
|
+
*/
|
|
219
|
+
_handleBurgerKeydown(e) {
|
|
220
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
221
|
+
e.preventDefault();
|
|
222
|
+
this._toggleBurgerMenu();
|
|
223
|
+
} else if (e.key === "Escape" && this._activeBurgerMenu) {
|
|
224
|
+
e.preventDefault();
|
|
225
|
+
this._activeBurgerMenu = false;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
_toggleBurgerMenu() {
|
|
229
|
+
this._activeBurgerMenu = !this._activeBurgerMenu;
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Returns the index of the currently selected locale in the locales array.
|
|
233
|
+
*/
|
|
234
|
+
_getSelectedLocaleIndex() {
|
|
235
|
+
return this.locales.findIndex((l) => l.value === this.selectedLocale);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Returns compact locale options for mobile display.
|
|
239
|
+
* Uses shortText if available, otherwise falls back to text.
|
|
240
|
+
*/
|
|
241
|
+
_getCompactLocales() {
|
|
242
|
+
return this.locales.map((l) => ({
|
|
243
|
+
...l,
|
|
244
|
+
text: l.shortText ?? l.text
|
|
245
|
+
}));
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Handles locale selection change from PdButtonSelectGroup.
|
|
249
|
+
*/
|
|
250
|
+
_handleLocaleChange(e) {
|
|
251
|
+
const index = e.detail.selected;
|
|
252
|
+
const localeValue = this.locales[index]?.value;
|
|
253
|
+
if (localeValue && localeValue !== this.selectedLocale) {
|
|
254
|
+
this.dispatchEvent(
|
|
255
|
+
new CustomEvent("locale-change", {
|
|
256
|
+
detail: localeValue,
|
|
257
|
+
bubbles: true,
|
|
258
|
+
composed: true
|
|
259
|
+
})
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
_menuItemClicked(e) {
|
|
264
|
+
const key = e.target.dataset.key;
|
|
265
|
+
const item = [...this.menuItems, ...this.topMenuItems].find(
|
|
266
|
+
(i) => i.key === key
|
|
267
|
+
);
|
|
268
|
+
if (!item) return;
|
|
269
|
+
if (item.sec && item.ref) {
|
|
270
|
+
this.dispatchEvent(
|
|
271
|
+
new CustomEvent("route-event", {
|
|
272
|
+
detail: { el: item.ref },
|
|
273
|
+
bubbles: true,
|
|
274
|
+
composed: true
|
|
275
|
+
})
|
|
276
|
+
);
|
|
277
|
+
} else if (item.route && item.sec) {
|
|
278
|
+
this.dispatchEvent(
|
|
279
|
+
new CustomEvent("route-event", {
|
|
280
|
+
detail: {
|
|
281
|
+
route: item.route,
|
|
282
|
+
sectionId: item.sec
|
|
283
|
+
},
|
|
284
|
+
bubbles: true,
|
|
285
|
+
composed: true
|
|
286
|
+
})
|
|
287
|
+
);
|
|
288
|
+
} else if (item.route) {
|
|
289
|
+
this.dispatchEvent(
|
|
290
|
+
new CustomEvent("route-event", {
|
|
291
|
+
detail: { route: item.route },
|
|
292
|
+
bubbles: true,
|
|
293
|
+
composed: true
|
|
294
|
+
})
|
|
295
|
+
);
|
|
296
|
+
} else if (item.action) {
|
|
297
|
+
item.action();
|
|
298
|
+
}
|
|
299
|
+
if (this._activeBurgerMenu) {
|
|
300
|
+
this._activeBurgerMenu = false;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
_logoClicked() {
|
|
304
|
+
PdMenu._scrollToTop();
|
|
305
|
+
if (this.logoRoute) {
|
|
306
|
+
this.dispatchEvent(
|
|
307
|
+
new CustomEvent("route-event", {
|
|
308
|
+
detail: {
|
|
309
|
+
route: this.logoRoute
|
|
310
|
+
},
|
|
311
|
+
bubbles: true,
|
|
312
|
+
composed: true
|
|
313
|
+
})
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
static _scrollToTop() {
|
|
318
|
+
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
319
|
+
}
|
|
320
|
+
};
|
|
321
|
+
PdMenu.styles = [
|
|
322
|
+
css`
|
|
38
323
|
:host {
|
|
39
324
|
display: block;
|
|
40
325
|
position: relative;
|
|
41
326
|
height: var(--pd-menu-height, 100px);
|
|
42
327
|
background-color: var(--pd-menu-bg-col, var(--pd-default-col));
|
|
43
|
-
box-shadow: var(--pd-menu-shadow,
|
|
44
|
-
|
|
328
|
+
box-shadow: var(--pd-menu-shadow, var(--pd-shadow-lg));
|
|
329
|
+
border-radius: var(--pd-menu-border-radius, 0);
|
|
45
330
|
/*
|
|
46
331
|
Add into component, before styled from outside by using element
|
|
47
332
|
removed fixed again => not fit for the teaser, custom properties possible, but now handle this in SPAHelper header element
|
|
@@ -51,15 +336,24 @@ const _PdMenu = class _PdMenu extends LitElement {
|
|
|
51
336
|
*/
|
|
52
337
|
}
|
|
53
338
|
|
|
339
|
+
/* Remove border-radius, shadow when burger menu is expanded */
|
|
340
|
+
:host([burger-open]) {
|
|
341
|
+
box-shadow: none;
|
|
342
|
+
border-radius: 0;
|
|
343
|
+
}
|
|
344
|
+
|
|
54
345
|
.menu-container {
|
|
55
346
|
height: 100%;
|
|
56
|
-
padding-left:
|
|
57
|
-
padding-right:
|
|
347
|
+
padding-left: var(--pd-spacing-md, 1rem);
|
|
348
|
+
padding-right: var(--pd-spacing-md, 1rem);
|
|
58
349
|
display: flex;
|
|
59
350
|
justify-content: space-between;
|
|
60
351
|
align-items: center;
|
|
61
352
|
white-space: nowrap;
|
|
62
|
-
max-width: var(
|
|
353
|
+
max-width: var(
|
|
354
|
+
--pd-menu-max-width,
|
|
355
|
+
var(--pd-content-max-width, 1170px)
|
|
356
|
+
);
|
|
63
357
|
margin: 0 auto;
|
|
64
358
|
}
|
|
65
359
|
|
|
@@ -77,44 +371,19 @@ const _PdMenu = class _PdMenu extends LitElement {
|
|
|
77
371
|
z-index: -1;
|
|
78
372
|
position: absolute;
|
|
79
373
|
flex-direction: column;
|
|
374
|
+
align-items: stretch; /* Override .menu-ul center, stretch children to full width */
|
|
80
375
|
top: calc(var(--pd-menu-height, 100px) * -1);
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
--pd-menu-burger-bg-col,
|
|
84
|
-
var(--pd-default-light-col)
|
|
85
|
-
);
|
|
86
|
-
|
|
87
|
-
box-shadow: var(--pd-menu-shadow, 3px 3px 5px grey);
|
|
88
|
-
border-bottom: var(--pd-menu-burger-bottomborder);
|
|
89
|
-
padding: var(--pd-menu-burger-padding, 0);
|
|
90
|
-
width: 100%;
|
|
91
|
-
-moz-border-radius: var(--pd-border-radius);
|
|
92
|
-
border-radius: var(--pd-border-radius);
|
|
93
|
-
|
|
94
|
-
transition: 0.5s;
|
|
95
|
-
transition-timing-function: ease-out;
|
|
96
|
-
|
|
97
|
-
transform: translateY(0);
|
|
98
|
-
opacity: 0;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
.locale-ul {
|
|
102
|
-
visibility: hidden;
|
|
103
|
-
position: absolute;
|
|
104
|
-
flex-direction: column;
|
|
105
|
-
top: 10px;
|
|
106
|
-
right: 15px;
|
|
107
|
-
z-index: 100;
|
|
376
|
+
left: 0;
|
|
377
|
+
right: 0;
|
|
108
378
|
background-color: var(
|
|
109
379
|
--pd-menu-burger-bg-col,
|
|
110
|
-
var(--pd-default-
|
|
380
|
+
var(--pd-default-bg-col)
|
|
111
381
|
);
|
|
112
382
|
|
|
113
|
-
box-shadow: var(--pd-
|
|
383
|
+
box-shadow: var(--pd-shadow-xl);
|
|
114
384
|
border-bottom: var(--pd-menu-burger-bottomborder);
|
|
115
|
-
padding: var(--pd-
|
|
116
|
-
|
|
117
|
-
border-radius: var(--pd-border-radius);
|
|
385
|
+
padding: var(--pd-spacing-sm, 0.5rem) 0;
|
|
386
|
+
border-radius: 0 0 var(--pd-radius-lg) var(--pd-radius-lg);
|
|
118
387
|
|
|
119
388
|
transition: 0.5s;
|
|
120
389
|
transition-timing-function: ease-out;
|
|
@@ -123,41 +392,34 @@ const _PdMenu = class _PdMenu extends LitElement {
|
|
|
123
392
|
opacity: 0;
|
|
124
393
|
}
|
|
125
394
|
|
|
126
|
-
|
|
395
|
+
.burger-ul.burger-open {
|
|
127
396
|
visibility: visible;
|
|
128
397
|
opacity: 1;
|
|
129
398
|
top: var(--pd-menu-burger-top, var(--pd-menu-height, 100px));
|
|
130
399
|
transition-timing-function: ease-in;
|
|
131
400
|
}
|
|
132
401
|
|
|
133
|
-
:host([_activeLocaleMenu]) .locale-ul {
|
|
134
|
-
visibility: visible;
|
|
135
|
-
opacity: 1;
|
|
136
|
-
top: 40px;
|
|
137
|
-
transition-timing-function: ease-in;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
402
|
.menu-li {
|
|
141
403
|
display: flex;
|
|
142
404
|
align-items: center;
|
|
143
405
|
cursor: pointer;
|
|
144
|
-
border-radius: var(--pd-
|
|
406
|
+
border-radius: var(--pd-radius-md);
|
|
145
407
|
}
|
|
146
408
|
|
|
147
409
|
.burger-li {
|
|
148
|
-
border-radius:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
height: 1rem;
|
|
410
|
+
border-radius: 0;
|
|
411
|
+
margin: 0;
|
|
412
|
+
border-bottom: 1px solid var(--pd-default-lightest-col);
|
|
413
|
+
transition: background-color 0.2s ease;
|
|
153
414
|
}
|
|
154
415
|
|
|
155
|
-
.
|
|
156
|
-
|
|
416
|
+
.burger-li:last-child {
|
|
417
|
+
border-bottom: none;
|
|
157
418
|
}
|
|
158
419
|
|
|
159
420
|
.burger-li:hover {
|
|
160
|
-
background-color: var(--pd-default-
|
|
421
|
+
background-color: var(--pd-default-bg-light-col);
|
|
422
|
+
box-shadow: inset 4px 0 0 var(--pd-default-col);
|
|
161
423
|
}
|
|
162
424
|
|
|
163
425
|
.item {
|
|
@@ -172,11 +434,16 @@ const _PdMenu = class _PdMenu extends LitElement {
|
|
|
172
434
|
}
|
|
173
435
|
|
|
174
436
|
.burger-item {
|
|
175
|
-
color: var(--pd-menu-burger-font-col, var(--pd-default-
|
|
437
|
+
color: var(--pd-menu-burger-font-col, var(--pd-default-font-link-col));
|
|
438
|
+
font-size: var(--pd-default-font-content-size, 1rem);
|
|
439
|
+
font-weight: 500;
|
|
440
|
+
/* Override .item padding */
|
|
441
|
+
padding: 1.25rem var(--pd-spacing-lg, 2rem) 1.25rem 0.75rem;
|
|
176
442
|
}
|
|
177
443
|
|
|
178
|
-
.
|
|
179
|
-
|
|
444
|
+
.burger-item.active,
|
|
445
|
+
.burger-item:hover {
|
|
446
|
+
color: var(--pd-default-col);
|
|
180
447
|
}
|
|
181
448
|
|
|
182
449
|
.item.active,
|
|
@@ -205,8 +472,18 @@ const _PdMenu = class _PdMenu extends LitElement {
|
|
|
205
472
|
pointer-events: none;
|
|
206
473
|
}
|
|
207
474
|
|
|
475
|
+
.burger-li .topItemLogo {
|
|
476
|
+
--pd-icon-col: var(
|
|
477
|
+
--pd-menu-burger-font-col,
|
|
478
|
+
var(--pd-default-font-link-col)
|
|
479
|
+
);
|
|
480
|
+
--pd-icon-size: 1.2rem;
|
|
481
|
+
margin-right: 0.5rem;
|
|
482
|
+
}
|
|
483
|
+
|
|
208
484
|
.burgerLogo {
|
|
209
|
-
|
|
485
|
+
/* Match height of locale-selector button (min-height 44px) */
|
|
486
|
+
--pd-icon-size: 2.5rem;
|
|
210
487
|
--pd-icon-bg-col: transparent;
|
|
211
488
|
pointer-events: none;
|
|
212
489
|
}
|
|
@@ -226,7 +503,7 @@ const _PdMenu = class _PdMenu extends LitElement {
|
|
|
226
503
|
cursor: pointer;
|
|
227
504
|
|
|
228
505
|
--pd-icon-col: var(--pd-default-hover-col);
|
|
229
|
-
--pd-icon-col-active:
|
|
506
|
+
--pd-icon-col-active: var(--pd-menu-font-col, var(--pd-default-bg-col));
|
|
230
507
|
}
|
|
231
508
|
|
|
232
509
|
.burger-menu:hover {
|
|
@@ -234,239 +511,70 @@ const _PdMenu = class _PdMenu extends LitElement {
|
|
|
234
511
|
--pd-icon-col-active: var(--pd-default-hover-col);
|
|
235
512
|
}
|
|
236
513
|
|
|
237
|
-
.burger-menu .item {
|
|
238
|
-
padding: 0;
|
|
239
|
-
font-size: 1.5em;
|
|
240
|
-
transition: color ease 0.5s;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
.burger-menu:hover .item {
|
|
244
|
-
color: var(--pd-default-hover-col);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
514
|
/* Doppelt zum logo-container, pd-logo sonst nicht mehr funktional
|
|
248
515
|
*/
|
|
249
516
|
::slotted(.logo) {
|
|
250
517
|
width: 100%;
|
|
251
518
|
max-width: var(--pd-menu-logo-maxwidth, 8rem);
|
|
252
519
|
padding: var(--pd-menu-logo-padding, 2em);
|
|
253
|
-
width: 100%;
|
|
254
520
|
fill: var(--pd-menu-logo-color, #067394);
|
|
255
521
|
cursor: pointer;
|
|
256
522
|
}
|
|
257
523
|
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
--pd-
|
|
261
|
-
--pd-
|
|
262
|
-
--pd-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
`
|
|
267
|
-
];
|
|
268
|
-
}
|
|
269
|
-
firstUpdated() {
|
|
270
|
-
const updateActiveSection = (scrollPos) => {
|
|
271
|
-
let activeIndex = -1;
|
|
272
|
-
let closestDistance = scrollPos > 300 ? 5e3 : 300;
|
|
273
|
-
this.menuItems.forEach((item, index) => {
|
|
274
|
-
if (item.ref) {
|
|
275
|
-
const dist = Math.abs(item.ref.getBoundingClientRect().top);
|
|
276
|
-
if (dist < closestDistance) {
|
|
277
|
-
activeIndex = index;
|
|
278
|
-
closestDistance = dist;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
this._activeSecIndex = activeIndex >= 0 ? activeIndex + 1 : 0;
|
|
283
|
-
};
|
|
284
|
-
let ticking = false;
|
|
285
|
-
document.addEventListener("scroll", () => {
|
|
286
|
-
const scrollY = window.scrollY;
|
|
287
|
-
if (!ticking) {
|
|
288
|
-
window.requestAnimationFrame(() => {
|
|
289
|
-
updateActiveSection(scrollY);
|
|
290
|
-
ticking = false;
|
|
291
|
-
});
|
|
292
|
-
ticking = true;
|
|
524
|
+
/* Locale selector styling */
|
|
525
|
+
.locale-selector {
|
|
526
|
+
--pd-button-border-col: transparent;
|
|
527
|
+
--pd-button-bg-col: transparent;
|
|
528
|
+
--pd-button-font-col: var(--pd-menu-font-col, var(--pd-default-bg-col));
|
|
529
|
+
--pd-button-bg-col-hover: var(--pd-menu-item-bg-hover-col);
|
|
530
|
+
--pd-button-scale: 0.8;
|
|
293
531
|
}
|
|
294
|
-
});
|
|
295
|
-
installMediaQueryWatcher(`(max-width: 700px)`, (matches) => {
|
|
296
|
-
this._smallScreen = matches && !this.noBurgerMenu;
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
render() {
|
|
300
|
-
return html`
|
|
301
|
-
<div class="menu-container">
|
|
302
|
-
<slot name="slotLogo" @click="${this._logoClicked}"></slot>
|
|
303
532
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
)}
|
|
310
|
-
</ul>
|
|
533
|
+
/* Focus-visible styles for accessibility */
|
|
534
|
+
.menu-li:focus-visible {
|
|
535
|
+
outline: 2px solid var(--pd-focus-ring-col, var(--pd-default-hover-col));
|
|
536
|
+
outline-offset: 2px;
|
|
537
|
+
}
|
|
311
538
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
>
|
|
320
|
-
${this.selectedLocale}
|
|
321
|
-
<pd-icon
|
|
322
|
-
class="locale-selection-logo"
|
|
323
|
-
icon="${pdIcons.ICON_TOOGLE_ARROW}"
|
|
324
|
-
?activeIcon="${!this._activeLocaleMenu}"
|
|
325
|
-
></pd-icon>
|
|
326
|
-
<ul class="menu-ul locale-ul">
|
|
327
|
-
${this.locales.filter((l) => l !== this.selectedLocale).map(
|
|
328
|
-
(locale) => html`
|
|
329
|
-
<li
|
|
330
|
-
class="item menu-li burger-li burger-item locale-item"
|
|
331
|
-
data-key="${locale}"
|
|
332
|
-
@click="${this._localeClicked}"
|
|
333
|
-
>
|
|
334
|
-
${locale}
|
|
335
|
-
</li>
|
|
336
|
-
`
|
|
337
|
-
)}
|
|
338
|
-
</ul>
|
|
339
|
-
</li>
|
|
340
|
-
` : ""}
|
|
341
|
-
</ul>
|
|
342
|
-
` : html`
|
|
343
|
-
<div class="menu-wrapper">
|
|
344
|
-
<div class="burger-menu" @click="${this._toggleBurgerMenu}">
|
|
345
|
-
<pd-icon
|
|
346
|
-
class="burgerLogo"
|
|
347
|
-
icon="${pdIcons.ICON_BURGER_MENU}"
|
|
348
|
-
?activeIcon="${!this._activeBurgerMenu}"
|
|
349
|
-
></pd-icon>
|
|
350
|
-
<span class="item ${this._activeBurgerMenu ? "active" : ""}"
|
|
351
|
-
>${msg("Menü", { id: "pd.menu.label" })}</span
|
|
352
|
-
>
|
|
353
|
-
</div>
|
|
354
|
-
</div>
|
|
355
|
-
`}
|
|
356
|
-
</div>
|
|
357
|
-
`;
|
|
358
|
-
}
|
|
359
|
-
_renderItems(items, highlight, disableIcons = false) {
|
|
360
|
-
return html`
|
|
361
|
-
${items.map(
|
|
362
|
-
(item, index) => html`
|
|
363
|
-
<li
|
|
364
|
-
class="item menu-li ${this._smallScreen ? "burger-li burger-item" : ""}
|
|
365
|
-
${highlight && (this._activeSecIndex === index + 1 || item.route === this.activeRoute) ? "active" : ""}"
|
|
366
|
-
data-key="${item.key}"
|
|
367
|
-
@click="${this._menuItemClicked}"
|
|
368
|
-
>
|
|
369
|
-
${item.icon && !disableIcons ? html`<pd-icon
|
|
370
|
-
class="topItemLogo"
|
|
371
|
-
icon="${item.icon}"
|
|
372
|
-
></pd-icon>` : ""}
|
|
373
|
-
${item.name}
|
|
374
|
-
</li>
|
|
375
|
-
`
|
|
376
|
-
)}
|
|
377
|
-
`;
|
|
378
|
-
}
|
|
379
|
-
_toggleBurgerMenu() {
|
|
380
|
-
this._activeBurgerMenu = !this._activeBurgerMenu;
|
|
381
|
-
}
|
|
382
|
-
_toggleLocaleSelection() {
|
|
383
|
-
this._activeLocaleMenu = !this._activeLocaleMenu;
|
|
384
|
-
}
|
|
385
|
-
_localeClicked(e) {
|
|
386
|
-
const locale = e.target.dataset.key;
|
|
387
|
-
this.dispatchEvent(new CustomEvent("locale-change", { detail: locale }));
|
|
388
|
-
}
|
|
389
|
-
_menuItemClicked(e) {
|
|
390
|
-
const key = e.target.dataset.key;
|
|
391
|
-
const item = [...this.menuItems, ...this.topMenuItems].find(
|
|
392
|
-
(i) => i.key === key
|
|
393
|
-
);
|
|
394
|
-
if (!item) return;
|
|
395
|
-
if (item.sec && item.ref) {
|
|
396
|
-
const rect = item.ref.getBoundingClientRect();
|
|
397
|
-
window.scrollBy({
|
|
398
|
-
top: rect.top - this.headerSize,
|
|
399
|
-
behavior: "smooth"
|
|
400
|
-
});
|
|
401
|
-
} else if (item.route) {
|
|
402
|
-
this.dispatchEvent(
|
|
403
|
-
new CustomEvent("route-event", {
|
|
404
|
-
detail: { route: item.route === "back" ? "" : item.route },
|
|
405
|
-
bubbles: true,
|
|
406
|
-
composed: true
|
|
407
|
-
})
|
|
408
|
-
);
|
|
409
|
-
} else if (item.action) {
|
|
410
|
-
item.action();
|
|
411
|
-
}
|
|
412
|
-
if (this._activeBurgerMenu) {
|
|
413
|
-
this._activeBurgerMenu = false;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
_logoClicked() {
|
|
417
|
-
_PdMenu._scrollToTop();
|
|
418
|
-
if (this.logoRoute) {
|
|
419
|
-
this.dispatchEvent(
|
|
420
|
-
new CustomEvent("route-event", {
|
|
421
|
-
detail: {
|
|
422
|
-
route: this.logoRoute
|
|
423
|
-
},
|
|
424
|
-
bubbles: true,
|
|
425
|
-
composed: true
|
|
426
|
-
})
|
|
427
|
-
);
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
static _scrollToTop() {
|
|
431
|
-
window.scrollTo({ top: 0, behavior: "smooth" });
|
|
432
|
-
}
|
|
433
|
-
};
|
|
539
|
+
.burger-menu:focus-visible {
|
|
540
|
+
outline: 2px solid var(--pd-focus-ring-col, var(--pd-default-hover-col));
|
|
541
|
+
outline-offset: 2px;
|
|
542
|
+
border-radius: var(--pd-radius-md);
|
|
543
|
+
}
|
|
544
|
+
`
|
|
545
|
+
];
|
|
434
546
|
__decorateClass([
|
|
435
547
|
property({ type: String })
|
|
436
|
-
],
|
|
548
|
+
], PdMenu.prototype, "activeRoute", 2);
|
|
437
549
|
__decorateClass([
|
|
438
550
|
property({ type: String })
|
|
439
|
-
],
|
|
551
|
+
], PdMenu.prototype, "selectedLocale", 2);
|
|
440
552
|
__decorateClass([
|
|
441
553
|
property({ type: String })
|
|
442
|
-
],
|
|
554
|
+
], PdMenu.prototype, "logoRoute", 2);
|
|
443
555
|
__decorateClass([
|
|
444
556
|
property({ type: Array })
|
|
445
|
-
],
|
|
557
|
+
], PdMenu.prototype, "locales", 2);
|
|
446
558
|
__decorateClass([
|
|
447
559
|
property({ type: Array })
|
|
448
|
-
],
|
|
560
|
+
], PdMenu.prototype, "menuItems", 2);
|
|
449
561
|
__decorateClass([
|
|
450
562
|
property({ type: Array })
|
|
451
|
-
],
|
|
563
|
+
], PdMenu.prototype, "topMenuItems", 2);
|
|
452
564
|
__decorateClass([
|
|
453
565
|
property({ type: Boolean })
|
|
454
|
-
],
|
|
455
|
-
__decorateClass([
|
|
456
|
-
property({ type: Number })
|
|
457
|
-
], _PdMenu.prototype, "headerSize");
|
|
458
|
-
__decorateClass([
|
|
459
|
-
state()
|
|
460
|
-
], _PdMenu.prototype, "_activeSecIndex");
|
|
566
|
+
], PdMenu.prototype, "noBurgerMenu", 2);
|
|
461
567
|
__decorateClass([
|
|
462
568
|
state()
|
|
463
|
-
],
|
|
569
|
+
], PdMenu.prototype, "_activeSecIndex", 2);
|
|
464
570
|
__decorateClass([
|
|
465
|
-
|
|
466
|
-
],
|
|
571
|
+
property({ type: Boolean, reflect: true, attribute: "burger-open" })
|
|
572
|
+
], PdMenu.prototype, "_activeBurgerMenu", 2);
|
|
467
573
|
__decorateClass([
|
|
468
574
|
state()
|
|
469
|
-
],
|
|
470
|
-
|
|
575
|
+
], PdMenu.prototype, "_smallScreen", 2);
|
|
576
|
+
PdMenu = __decorateClass([
|
|
577
|
+
localized()
|
|
578
|
+
], PdMenu);
|
|
471
579
|
|
|
472
580
|
export { PdMenu };
|