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