hr-design-system-handlebars 1.41.0 → 1.42.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 (42) hide show
  1. package/.storybook/preview-head.html +0 -5
  2. package/.storybook/preview.js +1 -1
  3. package/CHANGELOG.md +24 -0
  4. package/build/scripts/build.js +4 -1
  5. package/dist/assets/index.css +3 -3
  6. package/dist/assets/js/alpine.js +47 -0
  7. package/{src/assets/vendor/js → dist/assets/js/components/podcast}/podcast_player.alpine.js +0 -92
  8. package/dist/assets/js/components/site_header/dropdown.alpine.js +77 -0
  9. package/dist/assets/js/components/site_header/flyoutHandler.alpine.js +54 -0
  10. package/dist/assets/js/components/site_header/mainNavigationHandler.alpine.js +219 -0
  11. package/dist/assets/js/components/site_header/overlayHandler.alpine.js +20 -0
  12. package/dist/assets/js/empty.js +0 -0
  13. package/dist/views/components/content_nav/content_nav_item.hbs +3 -3
  14. package/dist/views/components/horizontal_scroll_container/horizontal_scroll_container.hbs +0 -1
  15. package/dist/views/components/podcast/podcast_player.hbs +2 -3
  16. package/dist/views/components/podcast/podcast_playlist_player-inline.hbs +2 -3
  17. package/dist/views/components/podcast/podcast_playlist_player.hbs +2 -3
  18. package/dist/views/components/podcast/podcast_playlist_player_all_episodes.hbs +2 -3
  19. package/dist/views_static/components/content_nav/content_nav_item.hbs +3 -3
  20. package/dist/views_static/components/horizontal_scroll_container/horizontal_scroll_container.hbs +0 -1
  21. package/dist/views_static/components/podcast/podcast_player.hbs +2 -3
  22. package/dist/views_static/components/podcast/podcast_playlist_player-inline.hbs +2 -3
  23. package/dist/views_static/components/podcast/podcast_playlist_player.hbs +2 -3
  24. package/dist/views_static/components/podcast/podcast_playlist_player_all_episodes.hbs +2 -3
  25. package/package.json +1 -1
  26. package/src/assets/js/alpine.js +47 -0
  27. package/src/stories/views/components/content_nav/content_nav_item.hbs +3 -3
  28. package/src/stories/views/components/horizontal_scroll_container/horizontal_scroll_container.hbs +0 -1
  29. package/src/stories/views/components/podcast/podcast_player.alpine.js +194 -0
  30. package/src/stories/views/components/podcast/podcast_player.hbs +2 -3
  31. package/src/stories/views/components/podcast/podcast_playlist_player-inline.hbs +2 -3
  32. package/src/stories/views/components/podcast/podcast_playlist_player.hbs +2 -3
  33. package/src/stories/views/components/podcast/podcast_playlist_player_all_episodes.hbs +2 -3
  34. package/src/stories/views/components/site_header/dropdown.alpine.js +77 -0
  35. package/src/stories/views/components/site_header/flyoutHandler.alpine.js +54 -0
  36. package/src/stories/views/components/site_header/mainNavigationHandler.alpine.js +219 -0
  37. package/src/stories/views/components/site_header/overlayHandler.alpine.js +20 -0
  38. package/dist/assets/vendor/js/header.alpine.js +0 -414
  39. package/src/assets/vendor/js/header.alpine.js +0 -414
  40. /package/dist/assets/{vendor/js → js/components/horizontal_scroll_container}/horizontal_scroll_container.alpine.js +0 -0
  41. /package/src/{assets/vendor/js → stories/views/components/horizontal_scroll_container}/horizontal_scroll_container.alpine.js +0 -0
  42. /package/{dist/assets/vendor/js/podcast_player.alpine.js → src/stories/views/components/podcast/podcast_player.alpine.new.js} +0 -0
@@ -1,414 +0,0 @@
1
- //Main Alpine Init Listener
2
- document.addEventListener('alpine:init', () => {
3
- // Alpine.stores for global variables
4
- Alpine.store(
5
- 'clientHeight',
6
- document.documentElement.clientHeight || document.body.clientHeight
7
- )
8
- Alpine.store('clientWidth', document.documentElement.clientWidth || document.body.clientWidth)
9
- Alpine.store('burgeropen', false)
10
- Alpine.store('searchFieldOpen', false)
11
- Alpine.store('serviceNavIsOpen', false)
12
-
13
- Alpine.store('searchID', {
14
- current: '{{nextRandom}}',
15
- })
16
- Alpine.store('serviceID', {
17
- open: false,
18
- current: '0',
19
- })
20
- Alpine.store('navIsVisible', true)
21
- Alpine.store('subNavIsVisible', false)
22
-
23
- // context for the main header element
24
- Alpine.data('mainNavigationHandler', () => ({
25
- debounce(callback, wait) {
26
- let timeoutId = null
27
- return (...args) => {
28
- window.clearTimeout(timeoutId)
29
- timeoutId = window.setTimeout(() => {
30
- callback.apply(null, args)
31
- }, wait)
32
- }
33
- },
34
- start() {
35
- let lastScrollTop = 0
36
- let height = window.innerHeight
37
-
38
- //Globale Variable, true = user initiated scroll / false = programmatic scroll via JS (e.g. click on Anchor Link)
39
- let userScroll = false
40
- window.userScroll = userScroll
41
-
42
- // gets fired when user initated scroll happened, global variable is used in Ticker-Topnews and other anchor links to prevent expanding of the navigation if scrollposition gets corrected by JS.
43
- const mouseEvent = () => {
44
- userScroll = true
45
- window.userScroll = true
46
- }
47
- // detect if the user clicked/dragged the scrollbar manually
48
- const clickedOnScrollbar = (mouseX) => {
49
- return document.documentElement.offsetWidth <= mouseX ? true : false
50
- }
51
- // if clicked on scrollbar, fire user initiated mouse event
52
- const mouseDownHandler = (e) => {
53
- clickedOnScrollbar(e.clientX) ? mouseEvent() : null
54
- }
55
- // main scroll handler, defines scroll direction, percent of viewport scrolled, visibility of navigation and subnavigation
56
- const scrollHandler = () => {
57
- let winScroll = document.body.scrollTop || document.documentElement.scrollTop
58
- winScroll > lastScrollTop
59
- ? (this.scrollingDown = true)
60
- : (this.scrollingDown = false)
61
- this.percent = Math.round((winScroll / height) * 100)
62
- lastScrollTop = winScroll
63
- this.$store.navIsVisible = !this.isNavHidden()
64
- this.$store.subNavIsVisible = !this.isSubNavHidden()
65
- //console.log('winscroll: '+winScroll+' screen height: '+height + ' percent scrolled: '+ this.percent)
66
- //console.log('Scroll initiated by ' + (window.userScroll == true ? "user" : "browser"));
67
- }
68
- // Listeners
69
- window.addEventListener('mousedown', mouseDownHandler, false)
70
- window.addEventListener('wheel', mouseEvent, false)
71
- window.addEventListener('touchmove', mouseEvent, false)
72
- window.addEventListener('scroll', this.debounce(scrollHandler, 50), { passive: true })
73
- },
74
- //Holds the percentage of scrolled viewport
75
- percent: 0,
76
-
77
- //defines the scroll direction
78
- scrollingDown: true,
79
-
80
- //returns true if section navigation is hidden on desktop OR service navigation is hidden on mobile
81
- isNavHidden() {
82
- if (this.$screen('lg')) {
83
- return this.shouldSectionNavBeHidden()
84
- } else {
85
- return this.shouldServiceNavBeHidden()
86
- }
87
- },
88
-
89
- //returns false if subnav is visible and true if subnav is hidden
90
- isSubNavHidden() {
91
- if (this.$screen('lg')) {
92
- if (document.querySelector('.isSelectedAndOpen') !== null) {
93
- return false
94
- } else {
95
- return true
96
- }
97
- } else {
98
- return true
99
- }
100
- },
101
-
102
- // returns true if the user scrolled at least 1px from top
103
- shouldBrandNavBeHidden() {
104
- return this.percent > 0
105
- },
106
-
107
- // returns true if user scrolled >50% and scrolls down, no burger menu is open and the screen size is desktop. If scroll was initiated by script, ignore scroll direction.
108
- shouldSectionNavBeHidden() {
109
- if (window.userScroll == true) {
110
- return (
111
- this.percent > 50 &&
112
- this.scrollingDown &&
113
- this.$store.burgeropen == false &&
114
- this.$screen('lg')
115
- )
116
- } else {
117
- return this.percent > 50 && this.$store.burgeropen == false && this.$screen('lg')
118
- }
119
- },
120
-
121
- // returns true if user scrolled >90% and scrolls further down, no burger menu is open and the screen is NOT desktop. If scroll was initiated by script, ignore scroll direction.
122
- shouldServiceNavBeHidden() {
123
- if (window.userScroll == true) {
124
- return (
125
- this.percent > 90 &&
126
- !this.$screen('lg') &&
127
- this.scrollingDown &&
128
- this.$store.burgeropen == false
129
- )
130
- } else {
131
- return this.percent > 90 && !this.$screen('lg') && this.$store.burgeropen == false
132
- }
133
- },
134
-
135
- //returns true if user scrolled >50% and scrolls further down, no burger menu is open, no serviceNav is open and screen is not larger than mobile. OR: same same, but scrolling up.
136
- shouldServiceIconsBeHidden() {
137
- return (
138
- (this.percent > 50 &&
139
- !this.$screen('md') &&
140
- this.$store.burgeropen == false &&
141
- this.$store.serviceNavIsOpen == false &&
142
- this.scrollingDown == true) ||
143
- (this.percent > 50 &&
144
- !this.$screen('md') &&
145
- this.$store.burgeropen == false &&
146
- this.$store.serviceNavIsOpen == false &&
147
- this.scrollingDown == false)
148
- )
149
- },
150
-
151
- // returns true if user scrolled >50% and scrolls further down and is a desktop viewport
152
- shouldFlyoutBeHidden() {
153
- return this.percent > 50 && this.scrollingDown && this.$screen('lg')
154
- },
155
-
156
- // resets the navigation back to the initial state. Happens f.ex. on resize of window.
157
- resetNav() {
158
- if (window.innerWidth > 1023) {
159
- this.$refs.sectionnavigation.setAttribute('style', '')
160
- } else {
161
- // todo vasco: checken ob das wieder rein sollte
162
- // hidden needs to be set here to avoid flickering of the sectionNav on viewport change, gets removed in timeout
163
- // this.$refs.sectionnavigation.classList.add('hidden')
164
- // this.$refs.sectionnavigation.style.maxHeight="0px"
165
- }
166
-
167
- let nowClientHeight =
168
- document.documentElement.clientHeight || document.body.clientHeight
169
- let nowClientWidth = document.documentElement.clientWidth || document.body.clientWidth
170
- let nextNowClientHeight = this.$store.clientHeight
171
- if (
172
- nextNowClientHeight >= nowClientHeight &&
173
- this.$store.clientWidth == nowClientWidth
174
- ) {
175
- // Event handling of keyboard pop-up
176
- nextNowClientHeight = nowClientHeight
177
- this.$store.clientWidth = nowClientWidth
178
- } else {
179
- // timeout is used to dispatch events after the resize is done
180
- let timeout
181
- clearTimeout(timeout)
182
- timeout = setTimeout(() => {
183
- this.$refs.sectionnavigation.classList.remove('hidden')
184
- this.$store.burgeropen == true ? this.$dispatch('burger-close') : null
185
- this.$store.searchFieldOpen === true
186
- ? this.$dispatch('search-mobile-click-outside')
187
- : null
188
- this.$store.searchFieldOpen === true ? this.$dispatch('search-close') : null
189
- this.$store.serviceNavIsOpen === true
190
- ? this.$dispatch('close-servicemenu')
191
- : null
192
- this.toggleScrolling(true)
193
- }, 250)
194
- // Event handling of keyboard pop-up
195
- nextNowClientHeight = nowClientHeight
196
- this.$store.clientWidth = nowClientWidth
197
- }
198
- },
199
-
200
- // toggles the maxHeight of the section nav and makes sure there is enough space to display all items.
201
- toggleSectionNav() {
202
- //false = sectionNav schließt ( mobile/tablet? --> maxHeight = 0 /// desktop? just clear maxHeight attribute )
203
- //true = sectionNav öffnet (maxheight = scrollheight)
204
- console.log('toggleSectionNav, Event: ' + this.$event.detail)
205
- if (this.$event.detail === false) {
206
- if (window.innerWidth < 1024) {
207
- this.$refs.sectionnavigation.style.maxHeight = '0px'
208
- } else {
209
- this.$refs.sectionnavigation.style.maxHeight = ''
210
- }
211
- } else {
212
- let winheightcorr =
213
- parseInt(window.innerHeight) - this.$refs.sectionnavigation.offsetTop
214
- let navheight = parseInt(this.$refs.sectionnavigation.scrollHeight)
215
- let brandNavHeight = this.percent > 0 ? 40 : 0
216
-
217
- if (navheight > winheightcorr) {
218
- this.$refs.sectionnavigation.style.overflowY = 'scroll'
219
- this.$refs.sectionnavigation.style.maxHeight =
220
- winheightcorr + brandNavHeight + 'px'
221
- } else {
222
- this.$refs.sectionnavigation.style.overflowY = 'hidden'
223
- this.$refs.sectionnavigation.style.maxHeight = this.$el.scrollHeight + 'px'
224
- }
225
- }
226
- },
227
-
228
- // no scrolling when overlay is visible
229
- disableScrolling() {
230
- document.body.classList.add('overflow-hidden', 'h-full', 'w-full')
231
- this.$refs.myOverlay.ontouchmove = (e) => e.preventDefault()
232
- console.log('disableScrolling')
233
- },
234
-
235
- //only scroll when no overlay is visible
236
- enableScrolling() {
237
- document.body.classList.remove('overflow-hidden', 'h-full', 'w-full')
238
- this.$refs.myOverlay.ontouchmove = (e) => true
239
- console.log('enableScrolling')
240
- },
241
-
242
- // toggles scrolling ability
243
- toggleScrolling(mode) {
244
- if (this.$screen(0) && !this.$screen('lg')) {
245
- mode == false ? this.disableScrolling() : this.enableScrolling()
246
- }
247
- if (this.$screen('lg') && mode == true) {
248
- this.enableScrolling()
249
- }
250
- },
251
- }))
252
-
253
- // context for the overlay
254
- Alpine.data('overlayHandler', () => ({
255
- // show the overlay on mobile and tablet if burger menu is open OR service nav is open OR search field is open
256
- shouldOverlayBeShown() {
257
- return (
258
- !this.$screen('lg') &&
259
- (this.$store.burgeropen == true ||
260
- this.$store.serviceNavIsOpen == true ||
261
- this.$store.searchFieldOpen == true)
262
- )
263
- },
264
-
265
- // on click on overlay change global var for servicenav, dispatch events to close burger and service menu, re-enable scrolling.
266
- overlayWasClicked() {
267
- this.$store.serviceNavIsOpen ? (this.$store.serviceNavIsOpen = false) : null
268
- this.$dispatch('burger-close')
269
- this.$dispatch('close-servicemenu')
270
- // this.$dispatch('toggleScrolling', true )
271
- this.toggleScrolling(true)
272
- },
273
- }))
274
-
275
- // context for all dropdowns, used in section nav submenus and service nav flyout submenus
276
- Alpine.data('dropdown', () => ({
277
- // state of the dropdown
278
- dropped: false,
279
- preventDefault(prevDefault, e){
280
- if(prevDefault){
281
- e.preventDefault();
282
- }
283
- },
284
- isDesktopView(){
285
- return this.$screen('lg')
286
- },
287
- // toggle() interpolates state
288
- toggle() {
289
- this.dropped = !this.dropped
290
- },
291
- correctFlyoutPos(){
292
- if(this.$screen('lg')){
293
- let elementBoundingClientRec = this.$el.getBoundingClientRect()
294
- let parentElementBoundingClientRec = this.$el.closest(".relative").getBoundingClientRect()
295
- this.$el.parentNode.querySelector('.sb-navigation-flyout').style.left = (elementBoundingClientRec.left - Math.abs(parentElementBoundingClientRec.left))+"px";
296
- } else {
297
- this.$el.parentNode.querySelector('.sb-navigation-flyout').style.left = "0px";
298
- }
299
- },
300
- // toggles visibility of service nav and sets global variables in stores
301
- toggleServiceNav() {
302
- this.dropped = !this.dropped
303
-
304
- // close search if open
305
- this.$store.searchFieldOpen = false
306
-
307
- // if clicked element is not the current serviceID, leave the servicenav open, else interpolate servicenav state
308
- this.$el.id != this.$store.serviceID.current
309
- ? (this.$store.serviceNavIsOpen = true)
310
- : this.$el.id == this.$store.serviceID.current
311
- ? (this.$store.serviceNavIsOpen = !this.$store.serviceNavIsOpen)
312
- : null
313
-
314
- //if burger is open, dispatch event to close it
315
- this.$store.burgeropen == true ? this.$dispatch('burger-close') : null
316
-
317
- console.log('currentID: ' + this.$store.serviceID.current)
318
- console.log('target-id: ' + this.$event.target.id)
319
- console.log('element-id: ' + this.$el.id)
320
- console.log('serviceNav is open:' + this.$store.serviceNavIsOpen)
321
-
322
- //set the serviceID to the current element´s ID.
323
- this.$store.serviceID.current = this.$el.id
324
-
325
- //enable/disable scrolling
326
- this.toggleScrolling(!this.$store.serviceNavIsOpen)
327
-
328
- //defines behaviour for servicenav on mobile viewports, taking care of viewport sizes
329
- let myFlyout = document.querySelector('#flyout-' + this.$el.id)
330
- let brandNavHeight = this.percent > 0 ? 40 : 0
331
-
332
- if (this.$store.serviceNavIsOpen == true && this.dropped == true) {
333
- window.setTimeout(function () {
334
- if (myFlyout.scrollHeight > window.innerHeight - myFlyout.offsetTop) {
335
- myFlyout.style.height = 'auto'
336
- window.innerWidth < 768
337
- ? (myFlyout.style.maxHeight =
338
- window.innerHeight -
339
- myFlyout.offsetTop -
340
- 80 +
341
- brandNavHeight +
342
- 'px')
343
- : (myFlyout.style.maxHeight =
344
- window.innerHeight -
345
- myFlyout.offsetTop -
346
- 40 +
347
- brandNavHeight +
348
- 'px')
349
- myFlyout.style.overflowY = 'scroll'
350
- } else {
351
- myFlyout.style.maxHeight = ''
352
- //myFlyout.style.overflowY = 'hidden'
353
- }
354
- }, 150)
355
- }
356
- },
357
- }))
358
-
359
- // There are several Flyouts sharing the same functionality and context, so put the data in an Alpine.data to make it reusable
360
- Alpine.data('flyoutHandler', () => ({
361
- init() {
362
- //Initial: x-collapse only on mobile/tablet
363
- if (window.innerWidth < 1024) {
364
- this.$el.setAttribute('x-collapse', '')
365
- }
366
- },
367
-
368
- //Adds scrollheight of the flyout to sectionNav container to make sure all following items stay visible
369
- sectionNavFlyoutWatcher() {
370
- this.$watch('dropped', (value) => {
371
- let a = this.$refs.sectionnavigation.scrollHeight + this.$el.scrollHeight
372
- let brandNavHeight = this.percent > 0 ? 40 : 0
373
- if (window.innerWidth < 1024) {
374
- if (value == true) {
375
- if (a < window.innerHeight - this.$refs.sectionnavigation.offsetTop) {
376
- this.$refs.sectionnavigation.style.maxHeight = a + 'px'
377
- this.$refs.sectionnavigation.style.overflowY = 'hidden'
378
- } else {
379
- this.$refs.sectionnavigation.style.maxHeight =
380
- window.innerHeight -
381
- this.$refs.sectionnavigation.offsetTop +
382
- brandNavHeight +
383
- 'px'
384
- this.$refs.sectionnavigation.style.overflowY = 'scroll'
385
- }
386
- } else {
387
- if (a < window.innerHeight - this.$refs.sectionnavigation.offsetTop) {
388
- this.$refs.sectionnavigation.style.overflowY = 'hidden'
389
- } else {
390
- this.$refs.sectionnavigation.style.overflowY = 'scroll'
391
- }
392
- }
393
- }
394
- })
395
- },
396
-
397
- //sets/cleansup the x-collapse attributes depending on window.innerWidth, gets fired @resize.window in NavigationFlyout.hbs
398
- setFlyoutAnimationStyle() {
399
- if (window.innerWidth > 1023) {
400
- if (this.$el.hasAttribute('x-collapse.duration.500ms')) {
401
- this.$el.removeAttribute('x-collapse.duration.500ms')
402
- delete this.$el._x_transition
403
- this.$el.style.removeProperty('overflow')
404
- this.$el.style.removeProperty('height')
405
- if (!this.$el._x_isShown) this.$el.style.display = 'none'
406
- if (this.$el.hasAttribute('hidden')) this.$el.removeAttribute('hidden')
407
- }
408
- } else {
409
- if (!this.$el.hasAttribute('x-collapse.duration.500ms'))
410
- this.$el.setAttribute('x-collapse.duration.500ms', '')
411
- }
412
- },
413
- }))
414
- })