hr-design-system-handlebars 1.40.3 → 1.42.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/.storybook/preview-head.html +0 -5
- package/.storybook/preview.js +1 -1
- package/CHANGELOG.md +24 -0
- package/build/scripts/build.js +4 -1
- package/dist/assets/index.css +3 -3
- package/dist/assets/js/alpine.js +47 -0
- package/{src/assets/vendor/js → dist/assets/js/components/podcast}/podcast_player.alpine.js +0 -92
- package/dist/assets/js/components/site_header/dropdown.alpine.js +77 -0
- package/dist/assets/js/components/site_header/flyoutHandler.alpine.js +54 -0
- package/dist/assets/js/components/site_header/mainNavigationHandler.alpine.js +219 -0
- package/dist/assets/js/components/site_header/overlayHandler.alpine.js +20 -0
- package/dist/assets/js/empty.js +0 -0
- package/dist/views/components/base/image/responsive_image.hbs +4 -4
- package/dist/views/components/horizontal_scroll_container/horizontal_scroll_container.hbs +0 -1
- package/dist/views/components/podcast/podcast_player.hbs +2 -3
- package/dist/views/components/podcast/podcast_playlist_player-inline.hbs +2 -3
- package/dist/views/components/podcast/podcast_playlist_player.hbs +2 -3
- package/dist/views/components/podcast/podcast_playlist_player_all_episodes.hbs +2 -3
- package/dist/views_static/components/base/image/responsive_image.hbs +4 -4
- package/dist/views_static/components/horizontal_scroll_container/horizontal_scroll_container.hbs +0 -1
- package/dist/views_static/components/podcast/podcast_player.hbs +2 -3
- package/dist/views_static/components/podcast/podcast_playlist_player-inline.hbs +2 -3
- package/dist/views_static/components/podcast/podcast_playlist_player.hbs +2 -3
- package/dist/views_static/components/podcast/podcast_playlist_player_all_episodes.hbs +2 -3
- package/package.json +1 -1
- package/src/assets/js/alpine.js +47 -0
- package/src/stories/views/components/base/image/responsive_image.hbs +4 -4
- package/src/stories/views/components/horizontal_scroll_container/horizontal_scroll_container.hbs +0 -1
- package/src/stories/views/components/podcast/podcast_player.alpine.js +194 -0
- package/src/stories/views/components/podcast/podcast_player.hbs +2 -3
- package/src/stories/views/components/podcast/podcast_playlist_player-inline.hbs +2 -3
- package/src/stories/views/components/podcast/podcast_playlist_player.hbs +2 -3
- package/src/stories/views/components/podcast/podcast_playlist_player_all_episodes.hbs +2 -3
- package/src/stories/views/components/site_header/dropdown.alpine.js +77 -0
- package/src/stories/views/components/site_header/flyoutHandler.alpine.js +54 -0
- package/src/stories/views/components/site_header/mainNavigationHandler.alpine.js +219 -0
- package/src/stories/views/components/site_header/overlayHandler.alpine.js +20 -0
- package/dist/assets/vendor/js/header.alpine.js +0 -414
- package/src/assets/vendor/js/header.alpine.js +0 -414
- /package/dist/assets/{vendor/js → js/components/horizontal_scroll_container}/horizontal_scroll_container.alpine.js +0 -0
- /package/src/{assets/vendor/js → stories/views/components/horizontal_scroll_container}/horizontal_scroll_container.alpine.js +0 -0
- /package/{dist/assets/vendor/js/podcast_player.alpine.js → src/stories/views/components/podcast/podcast_player.alpine.new.js} +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export default () => ({
|
|
2
|
+
init() {
|
|
3
|
+
//Initial: x-collapse only on mobile/tablet
|
|
4
|
+
if (window.innerWidth < 1024) {
|
|
5
|
+
this.$el.setAttribute('x-collapse', '')
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
|
|
9
|
+
//Adds scrollheight of the flyout to sectionNav container to make sure all following items stay visible
|
|
10
|
+
sectionNavFlyoutWatcher() {
|
|
11
|
+
this.$watch('dropped', (value) => {
|
|
12
|
+
let a = this.$refs.sectionnavigation.scrollHeight + this.$el.scrollHeight
|
|
13
|
+
let brandNavHeight = this.percent > 0 ? 40 : 0
|
|
14
|
+
if (window.innerWidth < 1024) {
|
|
15
|
+
if (value == true) {
|
|
16
|
+
if (a < window.innerHeight - this.$refs.sectionnavigation.offsetTop) {
|
|
17
|
+
this.$refs.sectionnavigation.style.maxHeight = a + 'px'
|
|
18
|
+
this.$refs.sectionnavigation.style.overflowY = 'hidden'
|
|
19
|
+
} else {
|
|
20
|
+
this.$refs.sectionnavigation.style.maxHeight =
|
|
21
|
+
window.innerHeight -
|
|
22
|
+
this.$refs.sectionnavigation.offsetTop +
|
|
23
|
+
brandNavHeight +
|
|
24
|
+
'px'
|
|
25
|
+
this.$refs.sectionnavigation.style.overflowY = 'scroll'
|
|
26
|
+
}
|
|
27
|
+
} else {
|
|
28
|
+
if (a < window.innerHeight - this.$refs.sectionnavigation.offsetTop) {
|
|
29
|
+
this.$refs.sectionnavigation.style.overflowY = 'hidden'
|
|
30
|
+
} else {
|
|
31
|
+
this.$refs.sectionnavigation.style.overflowY = 'scroll'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
})
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
//sets/cleansup the x-collapse attributes depending on window.innerWidth, gets fired @resize.window in NavigationFlyout.hbs
|
|
39
|
+
setFlyoutAnimationStyle() {
|
|
40
|
+
if (window.innerWidth > 1023) {
|
|
41
|
+
if (this.$el.hasAttribute('x-collapse.duration.500ms')) {
|
|
42
|
+
this.$el.removeAttribute('x-collapse.duration.500ms')
|
|
43
|
+
delete this.$el._x_transition
|
|
44
|
+
this.$el.style.removeProperty('overflow')
|
|
45
|
+
this.$el.style.removeProperty('height')
|
|
46
|
+
if (!this.$el._x_isShown) this.$el.style.display = 'none'
|
|
47
|
+
if (this.$el.hasAttribute('hidden')) this.$el.removeAttribute('hidden')
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
if (!this.$el.hasAttribute('x-collapse.duration.500ms'))
|
|
51
|
+
this.$el.setAttribute('x-collapse.duration.500ms', '')
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
})
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
export default () => ({
|
|
2
|
+
debounce(callback, wait) {
|
|
3
|
+
let timeoutId = null
|
|
4
|
+
return (...args) => {
|
|
5
|
+
window.clearTimeout(timeoutId)
|
|
6
|
+
timeoutId = window.setTimeout(() => {
|
|
7
|
+
callback.apply(null, args)
|
|
8
|
+
}, wait)
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
start() {
|
|
12
|
+
let lastScrollTop = 0
|
|
13
|
+
let height = window.innerHeight
|
|
14
|
+
|
|
15
|
+
//Globale Variable, true = user initiated scroll / false = programmatic scroll via JS (e.g. click on Anchor Link)
|
|
16
|
+
let userScroll = false
|
|
17
|
+
window.userScroll = userScroll
|
|
18
|
+
|
|
19
|
+
// 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.
|
|
20
|
+
const mouseEvent = () => {
|
|
21
|
+
userScroll = true
|
|
22
|
+
window.userScroll = true
|
|
23
|
+
}
|
|
24
|
+
// detect if the user clicked/dragged the scrollbar manually
|
|
25
|
+
const clickedOnScrollbar = (mouseX) => {
|
|
26
|
+
return document.documentElement.offsetWidth <= mouseX ? true : false
|
|
27
|
+
}
|
|
28
|
+
// if clicked on scrollbar, fire user initiated mouse event
|
|
29
|
+
const mouseDownHandler = (e) => {
|
|
30
|
+
clickedOnScrollbar(e.clientX) ? mouseEvent() : null
|
|
31
|
+
}
|
|
32
|
+
// main scroll handler, defines scroll direction, percent of viewport scrolled, visibility of navigation and subnavigation
|
|
33
|
+
const scrollHandler = () => {
|
|
34
|
+
let winScroll = document.body.scrollTop || document.documentElement.scrollTop
|
|
35
|
+
winScroll > lastScrollTop ? (this.scrollingDown = true) : (this.scrollingDown = false)
|
|
36
|
+
this.percent = Math.round((winScroll / height) * 100)
|
|
37
|
+
lastScrollTop = winScroll
|
|
38
|
+
this.$store.navIsVisible = !this.isNavHidden()
|
|
39
|
+
this.$store.subNavIsVisible = !this.isSubNavHidden()
|
|
40
|
+
//console.log('winscroll: '+winScroll+' screen height: '+height + ' percent scrolled: '+ this.percent)
|
|
41
|
+
//console.log('Scroll initiated by ' + (window.userScroll == true ? "user" : "browser"));
|
|
42
|
+
}
|
|
43
|
+
// Listeners
|
|
44
|
+
window.addEventListener('mousedown', mouseDownHandler, false)
|
|
45
|
+
window.addEventListener('wheel', mouseEvent, false)
|
|
46
|
+
window.addEventListener('touchmove', mouseEvent, false)
|
|
47
|
+
window.addEventListener('scroll', this.debounce(scrollHandler, 50), { passive: true })
|
|
48
|
+
},
|
|
49
|
+
//Holds the percentage of scrolled viewport
|
|
50
|
+
percent: 0,
|
|
51
|
+
|
|
52
|
+
//defines the scroll direction
|
|
53
|
+
scrollingDown: true,
|
|
54
|
+
|
|
55
|
+
//returns true if section navigation is hidden on desktop OR service navigation is hidden on mobile
|
|
56
|
+
isNavHidden() {
|
|
57
|
+
if (this.$screen('lg')) {
|
|
58
|
+
return this.shouldSectionNavBeHidden()
|
|
59
|
+
} else {
|
|
60
|
+
return this.shouldServiceNavBeHidden()
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
|
|
64
|
+
//returns false if subnav is visible and true if subnav is hidden
|
|
65
|
+
isSubNavHidden() {
|
|
66
|
+
if (this.$screen('lg')) {
|
|
67
|
+
if (document.querySelector('.isSelectedAndOpen') !== null) {
|
|
68
|
+
return false
|
|
69
|
+
} else {
|
|
70
|
+
return true
|
|
71
|
+
}
|
|
72
|
+
} else {
|
|
73
|
+
return true
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
// returns true if the user scrolled at least 1px from top
|
|
78
|
+
shouldBrandNavBeHidden() {
|
|
79
|
+
return this.percent > 0
|
|
80
|
+
},
|
|
81
|
+
|
|
82
|
+
// 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.
|
|
83
|
+
shouldSectionNavBeHidden() {
|
|
84
|
+
if (window.userScroll == true) {
|
|
85
|
+
return (
|
|
86
|
+
this.percent > 50 &&
|
|
87
|
+
this.scrollingDown &&
|
|
88
|
+
this.$store.burgeropen == false &&
|
|
89
|
+
this.$screen('lg')
|
|
90
|
+
)
|
|
91
|
+
} else {
|
|
92
|
+
return this.percent > 50 && this.$store.burgeropen == false && this.$screen('lg')
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
|
|
96
|
+
// 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.
|
|
97
|
+
shouldServiceNavBeHidden() {
|
|
98
|
+
if (window.userScroll == true) {
|
|
99
|
+
return (
|
|
100
|
+
this.percent > 90 &&
|
|
101
|
+
!this.$screen('lg') &&
|
|
102
|
+
this.scrollingDown &&
|
|
103
|
+
this.$store.burgeropen == false
|
|
104
|
+
)
|
|
105
|
+
} else {
|
|
106
|
+
return this.percent > 90 && !this.$screen('lg') && this.$store.burgeropen == false
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
//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.
|
|
111
|
+
shouldServiceIconsBeHidden() {
|
|
112
|
+
return (
|
|
113
|
+
(this.percent > 50 &&
|
|
114
|
+
!this.$screen('md') &&
|
|
115
|
+
this.$store.burgeropen == false &&
|
|
116
|
+
this.$store.serviceNavIsOpen == false &&
|
|
117
|
+
this.scrollingDown == true) ||
|
|
118
|
+
(this.percent > 50 &&
|
|
119
|
+
!this.$screen('md') &&
|
|
120
|
+
this.$store.burgeropen == false &&
|
|
121
|
+
this.$store.serviceNavIsOpen == false &&
|
|
122
|
+
this.scrollingDown == false)
|
|
123
|
+
)
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
// returns true if user scrolled >50% and scrolls further down and is a desktop viewport
|
|
127
|
+
shouldFlyoutBeHidden() {
|
|
128
|
+
return this.percent > 50 && this.scrollingDown && this.$screen('lg')
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
// resets the navigation back to the initial state. Happens f.ex. on resize of window.
|
|
132
|
+
resetNav() {
|
|
133
|
+
if (window.innerWidth > 1023) {
|
|
134
|
+
this.$refs.sectionnavigation.setAttribute('style', '')
|
|
135
|
+
} else {
|
|
136
|
+
// todo vasco: checken ob das wieder rein sollte
|
|
137
|
+
// hidden needs to be set here to avoid flickering of the sectionNav on viewport change, gets removed in timeout
|
|
138
|
+
// this.$refs.sectionnavigation.classList.add('hidden')
|
|
139
|
+
// this.$refs.sectionnavigation.style.maxHeight="0px"
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
let nowClientHeight = document.documentElement.clientHeight || document.body.clientHeight
|
|
143
|
+
let nowClientWidth = document.documentElement.clientWidth || document.body.clientWidth
|
|
144
|
+
let nextNowClientHeight = this.$store.clientHeight
|
|
145
|
+
if (nextNowClientHeight >= nowClientHeight && this.$store.clientWidth == nowClientWidth) {
|
|
146
|
+
// Event handling of keyboard pop-up
|
|
147
|
+
nextNowClientHeight = nowClientHeight
|
|
148
|
+
this.$store.clientWidth = nowClientWidth
|
|
149
|
+
} else {
|
|
150
|
+
// timeout is used to dispatch events after the resize is done
|
|
151
|
+
let timeout
|
|
152
|
+
clearTimeout(timeout)
|
|
153
|
+
timeout = setTimeout(() => {
|
|
154
|
+
this.$refs.sectionnavigation.classList.remove('hidden')
|
|
155
|
+
this.$store.burgeropen == true ? this.$dispatch('burger-close') : null
|
|
156
|
+
this.$store.searchFieldOpen === true
|
|
157
|
+
? this.$dispatch('search-mobile-click-outside')
|
|
158
|
+
: null
|
|
159
|
+
this.$store.searchFieldOpen === true ? this.$dispatch('search-close') : null
|
|
160
|
+
this.$store.serviceNavIsOpen === true ? this.$dispatch('close-servicemenu') : null
|
|
161
|
+
this.toggleScrolling(true)
|
|
162
|
+
}, 250)
|
|
163
|
+
// Event handling of keyboard pop-up
|
|
164
|
+
nextNowClientHeight = nowClientHeight
|
|
165
|
+
this.$store.clientWidth = nowClientWidth
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
|
|
169
|
+
// toggles the maxHeight of the section nav and makes sure there is enough space to display all items.
|
|
170
|
+
toggleSectionNav() {
|
|
171
|
+
//false = sectionNav schließt ( mobile/tablet? --> maxHeight = 0 /// desktop? just clear maxHeight attribute )
|
|
172
|
+
//true = sectionNav öffnet (maxheight = scrollheight)
|
|
173
|
+
console.log('toggleSectionNav, Event: ' + this.$event.detail)
|
|
174
|
+
if (this.$event.detail === false) {
|
|
175
|
+
if (window.innerWidth < 1024) {
|
|
176
|
+
this.$refs.sectionnavigation.style.maxHeight = '0px'
|
|
177
|
+
} else {
|
|
178
|
+
this.$refs.sectionnavigation.style.maxHeight = ''
|
|
179
|
+
}
|
|
180
|
+
} else {
|
|
181
|
+
let winheightcorr =
|
|
182
|
+
parseInt(window.innerHeight) - this.$refs.sectionnavigation.offsetTop
|
|
183
|
+
let navheight = parseInt(this.$refs.sectionnavigation.scrollHeight)
|
|
184
|
+
let brandNavHeight = this.percent > 0 ? 40 : 0
|
|
185
|
+
|
|
186
|
+
if (navheight > winheightcorr) {
|
|
187
|
+
this.$refs.sectionnavigation.style.overflowY = 'scroll'
|
|
188
|
+
this.$refs.sectionnavigation.style.maxHeight = winheightcorr + brandNavHeight + 'px'
|
|
189
|
+
} else {
|
|
190
|
+
this.$refs.sectionnavigation.style.overflowY = 'hidden'
|
|
191
|
+
this.$refs.sectionnavigation.style.maxHeight = this.$el.scrollHeight + 'px'
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
|
|
196
|
+
// no scrolling when overlay is visible
|
|
197
|
+
disableScrolling() {
|
|
198
|
+
document.body.classList.add('overflow-hidden', 'h-full', 'w-full')
|
|
199
|
+
this.$refs.myOverlay.ontouchmove = (e) => e.preventDefault()
|
|
200
|
+
console.log('disableScrolling')
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
//only scroll when no overlay is visible
|
|
204
|
+
enableScrolling() {
|
|
205
|
+
document.body.classList.remove('overflow-hidden', 'h-full', 'w-full')
|
|
206
|
+
this.$refs.myOverlay.ontouchmove = (e) => true
|
|
207
|
+
console.log('enableScrolling')
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
// toggles scrolling ability
|
|
211
|
+
toggleScrolling(mode) {
|
|
212
|
+
if (this.$screen(0) && !this.$screen('lg')) {
|
|
213
|
+
mode == false ? this.disableScrolling() : this.enableScrolling()
|
|
214
|
+
}
|
|
215
|
+
if (this.$screen('lg') && mode == true) {
|
|
216
|
+
this.enableScrolling()
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export default () => ({
|
|
2
|
+
// show the overlay on mobile and tablet if burger menu is open OR service nav is open OR search field is open
|
|
3
|
+
shouldOverlayBeShown() {
|
|
4
|
+
return (
|
|
5
|
+
!this.$screen('lg') &&
|
|
6
|
+
(this.$store.burgeropen == true ||
|
|
7
|
+
this.$store.serviceNavIsOpen == true ||
|
|
8
|
+
this.$store.searchFieldOpen == true)
|
|
9
|
+
)
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
// on click on overlay change global var for servicenav, dispatch events to close burger and service menu, re-enable scrolling.
|
|
13
|
+
overlayWasClicked() {
|
|
14
|
+
this.$store.serviceNavIsOpen ? (this.$store.serviceNavIsOpen = false) : null
|
|
15
|
+
this.$dispatch('burger-close')
|
|
16
|
+
this.$dispatch('close-servicemenu')
|
|
17
|
+
// this.$dispatch('toggleScrolling', true )
|
|
18
|
+
this.toggleScrolling(true)
|
|
19
|
+
},
|
|
20
|
+
})
|