@swisspost/internet-header 1.9.1 → 1.11.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 (225) hide show
  1. package/dist/cjs/{language.service-9334ca5d.js → language.service-0864d021.js} +7 -2
  2. package/dist/cjs/language.service-0864d021.js.map +1 -0
  3. package/dist/cjs/loader.cjs.js +1 -1
  4. package/dist/cjs/post-klp-login-widget.cjs.entry.js +1 -1
  5. package/dist/cjs/post-klp-login-widget.cjs.entry.js.map +1 -1
  6. package/dist/cjs/post-language-switch.cjs.entry.js +2 -2
  7. package/dist/cjs/post-language-switch.cjs.entry.js.map +1 -1
  8. package/dist/cjs/post-logo.cjs.entry.js +1 -1
  9. package/dist/cjs/post-logo.cjs.entry.js.map +1 -1
  10. package/dist/cjs/post-main-navigation.cjs.entry.js +2 -2
  11. package/dist/cjs/post-main-navigation.cjs.entry.js.map +1 -1
  12. package/dist/cjs/post-meta-navigation.cjs.entry.js +1 -1
  13. package/dist/cjs/post-meta-navigation.cjs.entry.js.map +1 -1
  14. package/dist/cjs/post-search.cjs.entry.js +25 -2
  15. package/dist/cjs/post-search.cjs.entry.js.map +1 -1
  16. package/dist/cjs/post-skiplinks.cjs.entry.js +2 -2
  17. package/dist/cjs/post-skiplinks.cjs.entry.js.map +1 -1
  18. package/dist/cjs/swisspost-internet-breadcrumbs.cjs.entry.js +1329 -8
  19. package/dist/cjs/swisspost-internet-breadcrumbs.cjs.entry.js.map +1 -1
  20. package/dist/cjs/swisspost-internet-footer.cjs.entry.js +2 -2
  21. package/dist/cjs/swisspost-internet-footer.cjs.entry.js.map +1 -1
  22. package/dist/cjs/swisspost-internet-header.cjs.entry.js +67 -37
  23. package/dist/cjs/swisspost-internet-header.cjs.entry.js.map +1 -1
  24. package/dist/cjs/swisspost-internet-header.cjs.js +1 -1
  25. package/dist/collection/assets/i18n/translations.js +5 -0
  26. package/dist/collection/assets/i18n/translations.js.map +1 -1
  27. package/dist/collection/components/post-internet-breadcrumbs/post-internet-breadcrumbs.css +2 -2480
  28. package/dist/collection/components/post-internet-breadcrumbs/post-internet-breadcrumbs.js +77 -7
  29. package/dist/collection/components/post-internet-breadcrumbs/post-internet-breadcrumbs.js.map +1 -1
  30. package/dist/collection/components/post-internet-footer/post-internet-footer.css +1 -2300
  31. package/dist/collection/components/post-internet-header/logo-animation/logo-animation.js +6 -3
  32. package/dist/collection/components/post-internet-header/logo-animation/logo-animation.js.map +1 -1
  33. package/dist/collection/components/post-internet-header/post-internet-header.css +1 -403
  34. package/dist/collection/components/post-internet-header/post-internet-header.js +33 -26
  35. package/dist/collection/components/post-internet-header/post-internet-header.js.map +1 -1
  36. package/dist/collection/components/post-klp-login-widget/post-klp-login-widget.css +2 -1447
  37. package/dist/collection/components/post-klp-login-widget/post-klp-login-widget.js +1 -1
  38. package/dist/collection/components/post-klp-login-widget/post-klp-login-widget.js.map +1 -1
  39. package/dist/collection/components/post-language-switch/post-language-switch.css +1 -370
  40. package/dist/collection/components/post-language-switch/post-language-switch.js +2 -2
  41. package/dist/collection/components/post-language-switch/post-language-switch.js.map +1 -1
  42. package/dist/collection/components/post-logo/post-logo.css +1 -265
  43. package/dist/collection/components/post-main-navigation/post-main-navigation.css +1 -637
  44. package/dist/collection/components/post-main-navigation/post-main-navigation.js +1 -1
  45. package/dist/collection/components/post-main-navigation/post-main-navigation.js.map +1 -1
  46. package/dist/collection/components/post-meta-navigation/post-meta-navigation.css +1 -345
  47. package/dist/collection/components/post-search/post-search.css +4 -2927
  48. package/dist/collection/components/post-search/post-search.js +28 -5
  49. package/dist/collection/components/post-search/post-search.js.map +1 -1
  50. package/dist/collection/components/post-skiplinks/post-skiplinks.css +1 -21
  51. package/dist/collection/components/post-skiplinks/post-skiplinks.js +1 -1
  52. package/dist/collection/components/post-skiplinks/post-skiplinks.js.map +1 -1
  53. package/dist/collection/services/language.service.js +1 -1
  54. package/dist/collection/services/language.service.js.map +1 -1
  55. package/dist/collection/utils/scrollparent.js +21 -0
  56. package/dist/collection/utils/scrollparent.js.map +1 -0
  57. package/dist/components/language.service.js +6 -1
  58. package/dist/components/language.service.js.map +1 -1
  59. package/dist/components/post-klp-login-widget2.js +1 -1
  60. package/dist/components/post-klp-login-widget2.js.map +1 -1
  61. package/dist/components/post-language-switch2.js +1 -1
  62. package/dist/components/post-language-switch2.js.map +1 -1
  63. package/dist/components/post-logo2.js +1 -1
  64. package/dist/components/post-logo2.js.map +1 -1
  65. package/dist/components/post-main-navigation2.js +1 -1
  66. package/dist/components/post-main-navigation2.js.map +1 -1
  67. package/dist/components/post-meta-navigation2.js +1 -1
  68. package/dist/components/post-meta-navigation2.js.map +1 -1
  69. package/dist/components/post-search2.js +25 -2
  70. package/dist/components/post-search2.js.map +1 -1
  71. package/dist/components/post-skiplinks2.js +1 -1
  72. package/dist/components/post-skiplinks2.js.map +1 -1
  73. package/dist/components/swisspost-internet-breadcrumbs.js +1331 -8
  74. package/dist/components/swisspost-internet-breadcrumbs.js.map +1 -1
  75. package/dist/components/swisspost-internet-footer.js +1 -1
  76. package/dist/components/swisspost-internet-footer.js.map +1 -1
  77. package/dist/components/swisspost-internet-header.js +68 -38
  78. package/dist/components/swisspost-internet-header.js.map +1 -1
  79. package/dist/docs.json +51 -4
  80. package/dist/esm/{language.service-bd0f3b6f.js → language.service-109c485e.js} +7 -2
  81. package/dist/esm/language.service-109c485e.js.map +1 -0
  82. package/dist/esm/loader.js +1 -1
  83. package/dist/esm/post-klp-login-widget.entry.js +1 -1
  84. package/dist/esm/post-klp-login-widget.entry.js.map +1 -1
  85. package/dist/esm/post-language-switch.entry.js +2 -2
  86. package/dist/esm/post-language-switch.entry.js.map +1 -1
  87. package/dist/esm/post-logo.entry.js +1 -1
  88. package/dist/esm/post-logo.entry.js.map +1 -1
  89. package/dist/esm/post-main-navigation.entry.js +2 -2
  90. package/dist/esm/post-main-navigation.entry.js.map +1 -1
  91. package/dist/esm/post-meta-navigation.entry.js +1 -1
  92. package/dist/esm/post-meta-navigation.entry.js.map +1 -1
  93. package/dist/esm/post-search.entry.js +25 -2
  94. package/dist/esm/post-search.entry.js.map +1 -1
  95. package/dist/esm/post-skiplinks.entry.js +2 -2
  96. package/dist/esm/post-skiplinks.entry.js.map +1 -1
  97. package/dist/esm/swisspost-internet-breadcrumbs.entry.js +1329 -8
  98. package/dist/esm/swisspost-internet-breadcrumbs.entry.js.map +1 -1
  99. package/dist/esm/swisspost-internet-footer.entry.js +2 -2
  100. package/dist/esm/swisspost-internet-footer.entry.js.map +1 -1
  101. package/dist/esm/swisspost-internet-header.entry.js +67 -37
  102. package/dist/esm/swisspost-internet-header.entry.js.map +1 -1
  103. package/dist/esm/swisspost-internet-header.js +1 -1
  104. package/dist/esm-es5/language.service-109c485e.js +2 -0
  105. package/dist/esm-es5/language.service-109c485e.js.map +1 -0
  106. package/dist/esm-es5/loader.js +1 -1
  107. package/dist/esm-es5/loader.js.map +1 -1
  108. package/dist/esm-es5/post-klp-login-widget.entry.js +1 -1
  109. package/dist/esm-es5/post-klp-login-widget.entry.js.map +1 -1
  110. package/dist/esm-es5/post-language-switch.entry.js +1 -1
  111. package/dist/esm-es5/post-language-switch.entry.js.map +1 -1
  112. package/dist/esm-es5/post-logo.entry.js +1 -1
  113. package/dist/esm-es5/post-logo.entry.js.map +1 -1
  114. package/dist/esm-es5/post-main-navigation.entry.js +1 -1
  115. package/dist/esm-es5/post-main-navigation.entry.js.map +1 -1
  116. package/dist/esm-es5/post-meta-navigation.entry.js +1 -1
  117. package/dist/esm-es5/post-meta-navigation.entry.js.map +1 -1
  118. package/dist/esm-es5/post-search.entry.js +1 -1
  119. package/dist/esm-es5/post-search.entry.js.map +1 -1
  120. package/dist/esm-es5/post-skiplinks.entry.js +1 -1
  121. package/dist/esm-es5/post-skiplinks.entry.js.map +1 -1
  122. package/dist/esm-es5/swisspost-internet-breadcrumbs.entry.js +2 -2
  123. package/dist/esm-es5/swisspost-internet-breadcrumbs.entry.js.map +1 -1
  124. package/dist/esm-es5/swisspost-internet-footer.entry.js +1 -1
  125. package/dist/esm-es5/swisspost-internet-footer.entry.js.map +1 -1
  126. package/dist/esm-es5/swisspost-internet-header.entry.js +1 -1
  127. package/dist/esm-es5/swisspost-internet-header.entry.js.map +1 -1
  128. package/dist/esm-es5/swisspost-internet-header.js +1 -1
  129. package/dist/esm-es5/swisspost-internet-header.js.map +1 -1
  130. package/dist/swisspost-internet-header/p-0216631b.system.entry.js +2 -0
  131. package/dist/swisspost-internet-header/{p-e2df6e93.system.entry.js.map → p-0216631b.system.entry.js.map} +1 -1
  132. package/dist/swisspost-internet-header/p-0352b702.system.entry.js +7 -0
  133. package/dist/swisspost-internet-header/p-0352b702.system.entry.js.map +1 -0
  134. package/dist/swisspost-internet-header/p-0e4299a3.entry.js +2 -0
  135. package/dist/swisspost-internet-header/{p-6bb07a80.entry.js.map → p-0e4299a3.entry.js.map} +1 -1
  136. package/dist/swisspost-internet-header/p-10bfe973.system.entry.js +2 -0
  137. package/dist/swisspost-internet-header/p-10bfe973.system.entry.js.map +1 -0
  138. package/dist/swisspost-internet-header/p-142627fa.entry.js +2 -0
  139. package/dist/swisspost-internet-header/{p-9ab24fb3.entry.js.map → p-142627fa.entry.js.map} +1 -1
  140. package/dist/swisspost-internet-header/p-194475b8.system.js +2 -0
  141. package/dist/swisspost-internet-header/p-194475b8.system.js.map +1 -0
  142. package/dist/swisspost-internet-header/p-1a526dc3.system.entry.js +2 -0
  143. package/dist/swisspost-internet-header/p-1a526dc3.system.entry.js.map +1 -0
  144. package/dist/swisspost-internet-header/p-28bcc0a1.entry.js +2 -0
  145. package/dist/swisspost-internet-header/p-28bcc0a1.entry.js.map +1 -0
  146. package/dist/swisspost-internet-header/p-312fcf55.system.entry.js +2 -0
  147. package/dist/swisspost-internet-header/{p-fed8d74d.system.entry.js.map → p-312fcf55.system.entry.js.map} +1 -1
  148. package/dist/swisspost-internet-header/p-334412b2.entry.js +2 -0
  149. package/dist/swisspost-internet-header/p-334412b2.entry.js.map +1 -0
  150. package/dist/swisspost-internet-header/p-334616bc.system.entry.js +2 -0
  151. package/dist/swisspost-internet-header/{p-0bfadd54.system.entry.js.map → p-334616bc.system.entry.js.map} +1 -1
  152. package/dist/swisspost-internet-header/p-37872478.entry.js +7 -0
  153. package/dist/swisspost-internet-header/p-37872478.entry.js.map +1 -0
  154. package/dist/swisspost-internet-header/p-4da084d9.entry.js +2 -0
  155. package/dist/swisspost-internet-header/{p-273fd39b.entry.js.map → p-4da084d9.entry.js.map} +1 -1
  156. package/dist/swisspost-internet-header/p-5d893017.system.js +1 -1
  157. package/dist/swisspost-internet-header/p-5d893017.system.js.map +1 -1
  158. package/dist/swisspost-internet-header/p-77426673.entry.js +2 -0
  159. package/dist/swisspost-internet-header/{p-0dd2de97.entry.js.map → p-77426673.entry.js.map} +1 -1
  160. package/dist/swisspost-internet-header/p-7ddfd160.entry.js +2 -0
  161. package/dist/swisspost-internet-header/p-7ddfd160.entry.js.map +1 -0
  162. package/dist/swisspost-internet-header/p-8120031d.system.entry.js +2 -0
  163. package/dist/swisspost-internet-header/{p-3c8504b4.system.entry.js.map → p-8120031d.system.entry.js.map} +1 -1
  164. package/dist/swisspost-internet-header/p-935c70e1.js +2 -0
  165. package/dist/swisspost-internet-header/p-935c70e1.js.map +1 -0
  166. package/dist/swisspost-internet-header/p-95a1384f.system.entry.js +2 -0
  167. package/dist/swisspost-internet-header/p-95a1384f.system.entry.js.map +1 -0
  168. package/dist/swisspost-internet-header/p-b5937320.entry.js +2 -0
  169. package/dist/swisspost-internet-header/p-b5937320.entry.js.map +1 -0
  170. package/dist/swisspost-internet-header/p-c291d766.system.entry.js +2 -0
  171. package/dist/swisspost-internet-header/{p-131078ce.system.entry.js.map → p-c291d766.system.entry.js.map} +1 -1
  172. package/dist/swisspost-internet-header/p-cfc4dbfd.entry.js +2 -0
  173. package/dist/swisspost-internet-header/{p-51c15273.entry.js.map → p-cfc4dbfd.entry.js.map} +1 -1
  174. package/dist/swisspost-internet-header/p-d4106bf6.system.entry.js +2 -0
  175. package/dist/swisspost-internet-header/{p-a366648c.system.entry.js.map → p-d4106bf6.system.entry.js.map} +1 -1
  176. package/dist/swisspost-internet-header/swisspost-internet-header.css +2 -4
  177. package/dist/swisspost-internet-header/swisspost-internet-header.esm.js +1 -1
  178. package/dist/swisspost-internet-header/swisspost-internet-header.esm.js.map +1 -1
  179. package/dist/types/assets/i18n/translations.d.ts +5 -0
  180. package/dist/types/components/post-internet-breadcrumbs/post-internet-breadcrumbs.d.ts +13 -4
  181. package/dist/types/components/post-internet-header/post-internet-header.d.ts +4 -3
  182. package/dist/types/components/post-klp-login-widget/post-klp-login-widget.d.ts +1 -1
  183. package/dist/types/components/post-search/post-search.d.ts +6 -0
  184. package/dist/types/components/post-skiplinks/post-skiplinks.d.ts +1 -1
  185. package/dist/types/components.d.ts +19 -6
  186. package/dist/types/services/language.service.d.ts +7 -5
  187. package/dist/types/utils/scrollparent.d.ts +1 -0
  188. package/package.json +13 -12
  189. package/dist/cjs/language.service-9334ca5d.js.map +0 -1
  190. package/dist/esm/language.service-bd0f3b6f.js.map +0 -1
  191. package/dist/esm-es5/language.service-bd0f3b6f.js +0 -2
  192. package/dist/esm-es5/language.service-bd0f3b6f.js.map +0 -1
  193. package/dist/swisspost-internet-header/p-06d32a28.entry.js +0 -7
  194. package/dist/swisspost-internet-header/p-06d32a28.entry.js.map +0 -1
  195. package/dist/swisspost-internet-header/p-0bfadd54.system.entry.js +0 -2
  196. package/dist/swisspost-internet-header/p-0dd2de97.entry.js +0 -2
  197. package/dist/swisspost-internet-header/p-1078e964.system.entry.js +0 -2
  198. package/dist/swisspost-internet-header/p-1078e964.system.entry.js.map +0 -1
  199. package/dist/swisspost-internet-header/p-131078ce.system.entry.js +0 -2
  200. package/dist/swisspost-internet-header/p-262611f7.entry.js +0 -2
  201. package/dist/swisspost-internet-header/p-262611f7.entry.js.map +0 -1
  202. package/dist/swisspost-internet-header/p-273fd39b.entry.js +0 -2
  203. package/dist/swisspost-internet-header/p-3c8504b4.system.entry.js +0 -2
  204. package/dist/swisspost-internet-header/p-4099b274.system.js +0 -2
  205. package/dist/swisspost-internet-header/p-4099b274.system.js.map +0 -1
  206. package/dist/swisspost-internet-header/p-51c15273.entry.js +0 -2
  207. package/dist/swisspost-internet-header/p-5baac371.system.entry.js +0 -2
  208. package/dist/swisspost-internet-header/p-5baac371.system.entry.js.map +0 -1
  209. package/dist/swisspost-internet-header/p-64e1182b.entry.js +0 -2
  210. package/dist/swisspost-internet-header/p-64e1182b.entry.js.map +0 -1
  211. package/dist/swisspost-internet-header/p-6bb07a80.entry.js +0 -2
  212. package/dist/swisspost-internet-header/p-6f69aff4.system.entry.js +0 -2
  213. package/dist/swisspost-internet-header/p-6f69aff4.system.entry.js.map +0 -1
  214. package/dist/swisspost-internet-header/p-7bed0797.js +0 -2
  215. package/dist/swisspost-internet-header/p-7bed0797.js.map +0 -1
  216. package/dist/swisspost-internet-header/p-97c90e22.system.entry.js +0 -7
  217. package/dist/swisspost-internet-header/p-97c90e22.system.entry.js.map +0 -1
  218. package/dist/swisspost-internet-header/p-9ab24fb3.entry.js +0 -2
  219. package/dist/swisspost-internet-header/p-9ec1f474.entry.js +0 -2
  220. package/dist/swisspost-internet-header/p-9ec1f474.entry.js.map +0 -1
  221. package/dist/swisspost-internet-header/p-a366648c.system.entry.js +0 -2
  222. package/dist/swisspost-internet-header/p-e2df6e93.system.entry.js +0 -2
  223. package/dist/swisspost-internet-header/p-f531c1ea.entry.js +0 -2
  224. package/dist/swisspost-internet-header/p-f531c1ea.entry.js.map +0 -1
  225. package/dist/swisspost-internet-header/p-fed8d74d.system.entry.js +0 -2
@@ -1,6 +1,8 @@
1
1
  import { debounce } from 'throttle-debounce';
2
2
  import { state } from '../../../data/store';
3
+ import { getScrollParent } from '../../../utils/scrollparent';
3
4
  export const registerLogoAnimationObserver = (target, headerRef) => {
5
+ const scrollParent = getScrollParent(headerRef);
4
6
  /**
5
7
  * Set intersection ratio as CSS custom property
6
8
  */
@@ -9,7 +11,8 @@ export const registerLogoAnimationObserver = (target, headerRef) => {
9
11
  let scale = 1;
10
12
  // Minus 1px border at the bottom that the logo is not covering
11
13
  const adjustedHeaderHeight = headerRef.clientHeight - 1;
12
- const scrollY = fullStickyness ? 0 : window.scrollY;
14
+ const scrollDistance = scrollParent instanceof Element ? scrollParent.scrollTop : scrollParent.documentElement.scrollTop;
15
+ const scrollY = fullStickyness ? 0 : scrollDistance;
13
16
  // If meta navigation is not visible (mobile, not configured), scale should just be 1
14
17
  if (target.clientHeight > 0) {
15
18
  scale = Math.max((adjustedHeaderHeight - Math.max(scrollY, 0)) /
@@ -25,13 +28,13 @@ export const registerLogoAnimationObserver = (target, headerRef) => {
25
28
  const observer = new IntersectionObserver(entries => {
26
29
  entries.forEach(entry => {
27
30
  if (entry.isIntersecting && entry.intersectionRatio > 0) {
28
- window.addEventListener('scroll', handleScroll, { passive: true });
31
+ scrollParent.addEventListener('scroll', handleScroll, { passive: true });
29
32
  window.addEventListener('resize', debounced);
30
33
  // Ensure callback is called at least once in case main thread is too busy while scrolling up
31
34
  window.requestAnimationFrame(handleScroll);
32
35
  }
33
36
  else {
34
- window.removeEventListener('scroll', handleScroll);
37
+ scrollParent.removeEventListener('scroll', handleScroll);
35
38
  window.removeEventListener('resize', debounced);
36
39
  window.requestAnimationFrame(handleScroll);
37
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"logo-animation.js","sourceRoot":"","sources":["../../../../../src/components/post-internet-header/logo-animation/logo-animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,MAAmB,EACnB,SAA6C,EAC7C,EAAE;EACF;;KAEG;EACH,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,KAAK,MAAM,CAAC;IACnD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,+DAA+D;IAC/D,MAAM,oBAAoB,GAAG,SAAS,CAAC,YAAY,GAAG,CAAC,CAAC;IACxD,MAAM,OAAO,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;IAEpD,qFAAqF;IACrF,IAAI,MAAM,CAAC,YAAY,GAAG,CAAC,EAAE;MAC3B,KAAK,GAAG,IAAI,CAAC,GAAG,CACd,CAAC,oBAAoB,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC3C,CAAC,oBAAoB,GAAG,MAAM,CAAC,YAAY,CAAC,EAC9C,CAAC,CACF,CAAC;KACH;IACD,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,cAAc,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;EAChE,CAAC,CAAC;EAEF,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;EAE9C;;;KAGG;EACH,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CACvC,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;MACtB,IAAI,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC,iBAAiB,GAAG,CAAC,EAAE;QACvD,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACnE,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAE7C,6FAA6F;QAC7F,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;OAC5C;WAAM;QACL,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QACnD,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAChD,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;OAC5C;IACH,CAAC,CAAC,CAAC;EACL,CAAC,EACD;IACE,kFAAkF;IAClF,SAAS,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC;GACtB,CACF,CAAC;EACF,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;EAEzB,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC","sourcesContent":["import { debounce } from 'throttle-debounce';\nimport { state } from '../../../data/store';\n\nexport const registerLogoAnimationObserver = (\n target: HTMLElement,\n headerRef: HTMLSwisspostInternetHeaderElement,\n) => {\n /**\n * Set intersection ratio as CSS custom property\n */\n const handleScroll = () => {\n const fullStickyness = state.stickyness === 'full';\n let scale = 1;\n // Minus 1px border at the bottom that the logo is not covering\n const adjustedHeaderHeight = headerRef.clientHeight - 1;\n const scrollY = fullStickyness ? 0 : window.scrollY;\n\n // If meta navigation is not visible (mobile, not configured), scale should just be 1\n if (target.clientHeight > 0) {\n scale = Math.max(\n (adjustedHeaderHeight - Math.max(scrollY, 0)) /\n (adjustedHeaderHeight - target.clientHeight),\n 1,\n );\n }\n headerRef.style.setProperty('--logo-scale', scale.toString());\n };\n\n const debounced = debounce(150, handleScroll);\n\n /**\n * Observe the meta navigation in order to not track scroll events throughout the whole page.\n * This ensures that the scroll listener is only active while the meta navigation is visible.\n */\n const observer = new IntersectionObserver(\n entries => {\n entries.forEach(entry => {\n if (entry.isIntersecting && entry.intersectionRatio > 0) {\n window.addEventListener('scroll', handleScroll, { passive: true });\n window.addEventListener('resize', debounced);\n\n // Ensure callback is called at least once in case main thread is too busy while scrolling up\n window.requestAnimationFrame(handleScroll);\n } else {\n window.removeEventListener('scroll', handleScroll);\n window.removeEventListener('resize', debounced);\n window.requestAnimationFrame(handleScroll);\n }\n });\n },\n {\n // Fires when element leaves viewport (0) and when it just about enters it (0.001)\n threshold: [0, 0.001],\n },\n );\n observer.observe(target);\n\n return handleScroll;\n};\n"]}
1
+ {"version":3,"file":"logo-animation.js","sourceRoot":"","sources":["../../../../../src/components/post-internet-header/logo-animation/logo-animation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D,MAAM,CAAC,MAAM,6BAA6B,GAAG,CAC3C,MAAmB,EACnB,SAA6C,EAC7C,EAAE;EACF,MAAM,YAAY,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;EAEhD;;KAEG;EACH,MAAM,YAAY,GAAG,GAAG,EAAE;IACxB,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,KAAK,MAAM,CAAC;IACnD,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,+DAA+D;IAC/D,MAAM,oBAAoB,GAAG,SAAS,CAAC,YAAY,GAAG,CAAC,CAAC;IACxD,MAAM,cAAc,GAAG,YAAY,YAAY,OAAO,CAAE,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,CAAC,eAAe,CAAC,SAAS,CAAC;IAC1H,MAAM,OAAO,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;IAEpD,qFAAqF;IACrF,IAAI,MAAM,CAAC,YAAY,GAAG,CAAC,EAAE;MAC3B,KAAK,GAAG,IAAI,CAAC,GAAG,CACd,CAAC,oBAAoB,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QAC3C,CAAC,oBAAoB,GAAG,MAAM,CAAC,YAAY,CAAC,EAC9C,CAAC,CACF,CAAC;KACH;IACD,SAAS,CAAC,KAAK,CAAC,WAAW,CAAC,cAAc,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;EAChE,CAAC,CAAC;EAEF,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;EAE9C;;;KAGG;EACH,MAAM,QAAQ,GAAG,IAAI,oBAAoB,CACvC,OAAO,CAAC,EAAE;IACR,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE;MACtB,IAAI,KAAK,CAAC,cAAc,IAAI,KAAK,CAAC,iBAAiB,GAAG,CAAC,EAAE;QACvD,YAAY,CAAC,gBAAgB,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QACzE,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAE7C,6FAA6F;QAC7F,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;OAC5C;WAAM;QACL,YAAY,CAAC,mBAAmB,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QACzD,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;QAChD,MAAM,CAAC,qBAAqB,CAAC,YAAY,CAAC,CAAC;OAC5C;IACH,CAAC,CAAC,CAAC;EACL,CAAC,EACD;IACE,kFAAkF;IAClF,SAAS,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC;GACtB,CACF,CAAC;EACF,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;EAEzB,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC","sourcesContent":["import { debounce } from 'throttle-debounce';\nimport { state } from '../../../data/store';\nimport { getScrollParent } from '../../../utils/scrollparent';\n\nexport const registerLogoAnimationObserver = (\n target: HTMLElement,\n headerRef: HTMLSwisspostInternetHeaderElement,\n) => {\n const scrollParent = getScrollParent(headerRef);\n\n /**\n * Set intersection ratio as CSS custom property\n */\n const handleScroll = () => {\n const fullStickyness = state.stickyness === 'full';\n let scale = 1;\n // Minus 1px border at the bottom that the logo is not covering\n const adjustedHeaderHeight = headerRef.clientHeight - 1;\n const scrollDistance = scrollParent instanceof Element ? scrollParent.scrollTop : scrollParent.documentElement.scrollTop;\n const scrollY = fullStickyness ? 0 : scrollDistance;\n\n // If meta navigation is not visible (mobile, not configured), scale should just be 1\n if (target.clientHeight > 0) {\n scale = Math.max(\n (adjustedHeaderHeight - Math.max(scrollY, 0)) /\n (adjustedHeaderHeight - target.clientHeight),\n 1,\n );\n }\n headerRef.style.setProperty('--logo-scale', scale.toString());\n };\n\n const debounced = debounce(150, handleScroll);\n\n /**\n * Observe the meta navigation in order to not track scroll events throughout the whole page.\n * This ensures that the scroll listener is only active while the meta navigation is visible.\n */\n const observer = new IntersectionObserver(\n entries => {\n entries.forEach(entry => {\n if (entry.isIntersecting && entry.intersectionRatio > 0) {\n scrollParent.addEventListener('scroll', handleScroll, { passive: true });\n window.addEventListener('resize', debounced);\n\n // Ensure callback is called at least once in case main thread is too busy while scrolling up\n window.requestAnimationFrame(handleScroll);\n } else {\n scrollParent.removeEventListener('scroll', handleScroll);\n window.removeEventListener('resize', debounced);\n window.requestAnimationFrame(handleScroll);\n }\n });\n },\n {\n // Fires when element leaves viewport (0) and when it just about enters it (0.001)\n threshold: [0, 0.001],\n },\n );\n observer.observe(target);\n\n return handleScroll;\n};\n"]}
@@ -1,403 +1 @@
1
- /**
2
- * Colors used by the post style guide
3
- */
4
- /**
5
- * Maps. Allow maps to have custom colors from the project
6
- * by always merging into a default empty map
7
- */
8
- @font-face {
9
- font-display: swap;
10
- font-family: "Frutiger Neue For Post";
11
- font-weight: 700;
12
- src: url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Bold.woff2") format("woff2"), url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Bold.woff") format("woff");
13
- }
14
- @font-face {
15
- font-display: swap;
16
- font-family: "Frutiger Neue For Post";
17
- font-weight: 700;
18
- font-style: italic;
19
- src: url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-BdIt.woff2") format("woff2"), url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-BdIt.woff") format("woff");
20
- }
21
- @font-face {
22
- font-display: swap;
23
- font-family: "Frutiger Neue For Post";
24
- font-weight: 400;
25
- src: url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Rg.woff2") format("woff2"), url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Rg.woff") format("woff");
26
- }
27
- @font-face {
28
- font-display: swap;
29
- font-family: "Frutiger Neue For Post";
30
- font-weight: 400;
31
- font-style: italic;
32
- src: url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-It.woff2") format("woff2"), url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-It.woff") format("woff");
33
- }
34
- @font-face {
35
- font-display: swap;
36
- font-family: "Frutiger Neue For Post";
37
- font-weight: 300;
38
- src: url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Lt.woff2") format("woff2"), url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Lt.woff") format("woff");
39
- }
40
- @font-face {
41
- font-display: swap;
42
- font-family: "Frutiger Neue For Post";
43
- font-weight: 300;
44
- font-style: italic;
45
- src: url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-LtIt.woff2") format("woff2"), url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-LtIt.woff") format("woff");
46
- }
47
- .visually-hidden {
48
- position: absolute;
49
- width: 1px;
50
- height: 1px;
51
- border: 0;
52
- padding: 0;
53
- margin: -1px;
54
- overflow: hidden;
55
- clip: rect(0 0 0 0);
56
- }
57
-
58
- .btn-blank {
59
- background-color: transparent;
60
- border: none;
61
- border-radius: 0;
62
- padding: 0;
63
- }
64
-
65
- .nav-link {
66
- outline: none;
67
- outline-offset: 2px;
68
- /* Compatibility with button-group */
69
- text-decoration: none;
70
- color: rgba(0, 0, 0, 0.8);
71
- transition: color 200ms;
72
- background-color: transparent;
73
- box-shadow: none;
74
- border: 0;
75
- margin: 0;
76
- cursor: pointer;
77
- display: flex;
78
- align-items: center;
79
- gap: 0.5rem;
80
- }
81
- .nav-link:is(:focus-visible, :focus-within, .pretend-focus) {
82
- outline: 2px solid var(--post-contrast-color);
83
- }
84
- .nav-link:hover, .nav-link:focus {
85
- color: black;
86
- }
87
- .nav-link:focus-visible {
88
- z-index: 1;
89
- position: relative;
90
- }
91
- .nav-link > svg {
92
- width: 1.4em;
93
- height: 1.4em;
94
- flex-shrink: 0;
95
- }
96
- .nav-link > span {
97
- flex-shrink: 1;
98
- }
99
-
100
- .no-list {
101
- list-style: none;
102
- padding-left: 0;
103
- margin-top: 0;
104
- margin-bottom: 0;
105
- }
106
-
107
- *,
108
- :host,
109
- *::before,
110
- *::after {
111
- box-sizing: border-box;
112
- }
113
-
114
- :host {
115
- font-family: "Frutiger Neue For Post", system-ui, sans-serif;
116
- }
117
-
118
- button {
119
- font: inherit;
120
- padding: 0;
121
- }
122
-
123
- a,
124
- button {
125
- border-radius: 4px;
126
- outline: none;
127
- outline-offset: 2px;
128
- /* Compatibility with button-group */
129
- }
130
- a:is(:focus-visible, :focus-within, .pretend-focus),
131
- button:is(:focus-visible, :focus-within, .pretend-focus) {
132
- outline: 2px solid var(--post-contrast-color);
133
- border-radius: 4px;
134
- }
135
-
136
- img,
137
- svg {
138
- max-width: 100%;
139
- max-height: 100%;
140
- }
141
-
142
- @media (forced-colors: active) {
143
- svg {
144
- color: white;
145
- }
146
- }
147
-
148
- .box > *:first-child {
149
- margin-top: 0;
150
- }
151
- .box > *:last-child {
152
- margin-bottom: 0;
153
- }
154
-
155
- .mirrored {
156
- transform: scaleX(-1);
157
- }
158
-
159
- .rotate-270 {
160
- transform: rotate(270deg);
161
- }
162
-
163
- .bold {
164
- font-weight: 700;
165
- }
166
-
167
- .light {
168
- font-weight: 300;
169
- }
170
-
171
- .d-flex {
172
- display: flex;
173
- }
174
-
175
- .d-inline-flex {
176
- display: inline-flex;
177
- }
178
-
179
- .align-items-center {
180
- align-items: center;
181
- }
182
-
183
- @media (min-width: 1441px) {
184
- .wide-container {
185
- margin: 0 auto;
186
- max-width: 1440px;
187
- }
188
- }
189
-
190
- @media (max-width: 599.98px) {
191
- .container {
192
- padding-right: 16px;
193
- padding-left: 16px;
194
- }
195
- }
196
- @media (min-width: 600px) and (max-width: 1023.98px) {
197
- .container {
198
- padding-right: 32px;
199
- padding-left: 32px;
200
- }
201
- }
202
- @media (min-width: 1024px) {
203
- .container {
204
- padding-right: 40px;
205
- padding-left: 40px;
206
- }
207
- }
208
-
209
- @media (max-width: -0.02px) {
210
- .hidden-xs {
211
- display: none;
212
- }
213
- }
214
-
215
- @media (max-width: 399.98px) {
216
- .hidden-sm {
217
- display: none;
218
- }
219
- }
220
-
221
- @media (max-width: 599.98px) {
222
- .hidden-rg {
223
- display: none;
224
- }
225
- }
226
-
227
- @media (max-width: 779.98px) {
228
- .hidden-md {
229
- display: none;
230
- }
231
- }
232
-
233
- @media (max-width: 1023.98px) {
234
- .hidden-lg {
235
- display: none;
236
- }
237
- }
238
-
239
- @media (max-width: 1279.98px) {
240
- .hidden-xl {
241
- display: none;
242
- }
243
- }
244
-
245
- @media (max-width: 1440.98px) {
246
- .hidden-xxl {
247
- display: none;
248
- }
249
- }
250
-
251
- /**
252
- * Default position: scrolled
253
- * Logo is being scaled up for the initial view (scrollY = 0). This enables media queries to override
254
- * mobile behaviour without re-calculation
255
- */
256
- :host {
257
- --logo-scale: 1;
258
- }
259
- @media (max-width: 1023.98px) {
260
- :host {
261
- --logo-scale: 1 !important;
262
- }
263
- }
264
-
265
- post-logo {
266
- height: var(--header-height);
267
- transform-origin: bottom left;
268
- transform: scale(var(--logo-scale));
269
- }
270
-
271
- post-main-navigation {
272
- margin-left: calc(var(--header-height) * var(--logo-scale) - var(--header-height));
273
- }
274
-
275
- :host {
276
- display: block;
277
- position: relative;
278
- font-size: 1rem;
279
- font-weight: 300;
280
- z-index: var(--header-z-index, 10);
281
- --header-height: 3.5rem;
282
- --meta-header-height: 0px;
283
- --language-dropdown-margin-top: 0px;
284
- }
285
- @media (min-width: 1024px) {
286
- :host {
287
- --meta-header-height: 3rem;
288
- --header-height: 4rem;
289
- }
290
- }
291
- @media (min-width: 1280px) {
292
- :host {
293
- --header-height: 4.5rem;
294
- }
295
- }
296
-
297
- :host([meta=false]) {
298
- --meta-header-height: 0px;
299
- --language-dropdown-margin-top: 1px;
300
- }
301
-
302
- @supports (position: sticky) {
303
- :host(:not(.stickyness-none)) {
304
- position: sticky;
305
- }
306
- :host(.stickyness-full) {
307
- top: 0;
308
- }
309
- :host(.stickyness-main) {
310
- top: calc(var(--meta-header-height, 0px) * -1);
311
- }
312
- :host(.stickyness-minimal) {
313
- top: calc((var(--header-height, 0px) + var(--meta-header-height, 0px) + 1px) * -1);
314
- transition: top 200ms ease-in;
315
- }
316
- :host(.stickyness-minimal.scrolling-up),
317
- :host(.stickyness-minimal.dropdown-open) {
318
- top: calc(var(--meta-header-height, 0px) * -1);
319
- transition: top 200ms ease-out;
320
- }
321
- }
322
- .post-internet-header {
323
- border-bottom: 1px solid hsl(0, 0%, 90%);
324
- background-color: white;
325
- }
326
-
327
- .main-navigation-container {
328
- display: flex;
329
- }
330
- .main-navigation-container > .main-navigation-controls {
331
- flex: 0 0 auto;
332
- }
333
-
334
- .main-navigation {
335
- display: flex;
336
- }
337
-
338
- .sub-navigation-container {
339
- position: absolute;
340
- top: 100%;
341
- left: 0;
342
- width: 100%;
343
- display: flex;
344
- background: white;
345
- visibility: hidden;
346
- }
347
-
348
- .main-navigation-item:hover .sub-navigation-container {
349
- visibility: visible;
350
- }
351
-
352
- .main-navigation-controls {
353
- display: flex;
354
- margin-left: auto;
355
- }
356
- @media (max-width: 1023.98px) {
357
- .main-navigation-controls {
358
- font-weight: 400;
359
- }
360
- }
361
- @media (min-width: 1024px) {
362
- .main-navigation-controls {
363
- font-size: 1.0625rem;
364
- }
365
- }
366
- .main-navigation-controls > * {
367
- border-left: 1px solid hsl(0, 0%, 90%);
368
- }
369
-
370
- .menu-button {
371
- display: flex;
372
- align-items: center;
373
- padding: 0 calc(1rem - 1px);
374
- font-weight: 300;
375
- cursor: pointer;
376
- border-left: 1px solid hsl(0, 0%, 90%);
377
- order: 1; /* Display on the far right because of tab order */
378
- }
379
- @media (min-width: 1024px) {
380
- .menu-button {
381
- display: none;
382
- }
383
- }
384
- @media (min-width: 600px) and (max-width: 1023.98px) {
385
- .menu-button .visually-hidden {
386
- position: static;
387
- width: auto;
388
- height: auto;
389
- margin: auto;
390
- overflow: visible;
391
- clip: auto;
392
- visibility: visible;
393
- margin-right: 0.5rem;
394
- }
395
- }
396
- .menu-button svg {
397
- width: 1.5rem;
398
- height: 1.5rem;
399
- }
400
-
401
- .full-width .wide-container {
402
- max-width: none;
403
- }
1
+ @font-face{font-display:swap;font-family:"Frutiger Neue For Post";font-weight:700;src:url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Bold.woff2") format("woff2"),url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Bold.woff") format("woff")}@font-face{font-display:swap;font-family:"Frutiger Neue For Post";font-weight:700;font-style:italic;src:url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-BdIt.woff2") format("woff2"),url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-BdIt.woff") format("woff")}@font-face{font-display:swap;font-family:"Frutiger Neue For Post";font-weight:400;src:url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Rg.woff2") format("woff2"),url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Rg.woff") format("woff")}@font-face{font-display:swap;font-family:"Frutiger Neue For Post";font-weight:400;font-style:italic;src:url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-It.woff2") format("woff2"),url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-It.woff") format("woff")}@font-face{font-display:swap;font-family:"Frutiger Neue For Post";font-weight:300;src:url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Lt.woff2") format("woff2"),url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-Lt.woff") format("woff")}@font-face{font-display:swap;font-family:"Frutiger Neue For Post";font-weight:300;font-style:italic;src:url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-LtIt.woff2") format("woff2"),url("https://fonts.post.ch/frutigerneueforpost/v2/FrutigerNeueforPostW05-LtIt.woff") format("woff")}.visually-hidden{position:absolute;width:1px;height:1px;border:0;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0)}.btn-blank{background-color:rgba(0,0,0,0);border:none;border-radius:0;padding:0}.nav-link{outline:none;outline-offset:2px;text-decoration:none;color:rgba(0,0,0,.8);transition:color 200ms;background-color:rgba(0,0,0,0);box-shadow:none;border:0;margin:0;cursor:pointer;display:flex;align-items:center;gap:.5rem}.nav-link:is(:focus-visible,:focus-within,.pretend-focus){outline:2px solid var(--post-contrast-color)}.nav-link:hover,.nav-link:focus{color:#000}.nav-link:is(:focus-visible,:focus-within,.pretend-focus){z-index:1;position:relative}.nav-link>svg{width:1.4em;height:1.4em;flex-shrink:0}.nav-link>span{flex-shrink:1}.no-list{list-style:none;padding-left:0;margin-top:0;margin-bottom:0}*,:host,*::before,*::after{box-sizing:border-box}:host{font-family:"Frutiger Neue For Post",system-ui,sans-serif}button{font:inherit;padding:0}a,button{border-radius:4px;outline:none;outline-offset:2px}a:is(:focus-visible,:focus-within,.pretend-focus),button:is(:focus-visible,:focus-within,.pretend-focus){outline:2px solid var(--post-contrast-color);border-radius:4px}img,svg{max-width:100%;max-height:100%}@media(forced-colors: active){svg{color:#fff}}.box>*:first-child{margin-top:0}.box>*:last-child{margin-bottom:0}.mirrored{transform:scaleX(-1)}.rotate-270{transform:rotate(270deg)}.bold{font-weight:700}.light{font-weight:300}.d-flex{display:flex}.d-inline-flex{display:inline-flex}.align-items-center{align-items:center}@media(min-width: 1441px){.wide-container{margin:0 auto;max-width:1440px}}@media(max-width: 599.98px){.container{padding-right:16px;padding-left:16px}}@media(min-width: 600px)and (max-width: 1023.98px){.container{padding-right:32px;padding-left:32px}}@media(min-width: 1024px){.container{padding-right:40px;padding-left:40px}}@media(max-width: -0.02px){.hidden-xs{display:none}}@media(max-width: 399.98px){.hidden-sm{display:none}}@media(max-width: 599.98px){.hidden-rg{display:none}}@media(max-width: 779.98px){.hidden-md{display:none}}@media(max-width: 1023.98px){.hidden-lg{display:none}}@media(max-width: 1279.98px){.hidden-xl{display:none}}@media(max-width: 1440.98px){.hidden-xxl{display:none}}:host{--logo-scale: 1}@media(max-width: 1023.98px){:host{--logo-scale: 1 !important}}post-logo{height:var(--header-height);transform-origin:bottom left;transform:scale(var(--logo-scale))}post-main-navigation{margin-left:calc(var(--header-height)*var(--logo-scale) - var(--header-height))}:host{display:block;position:relative;font-size:1rem;font-weight:300;z-index:var(--header-z-index, 10);--header-height: 3.5rem;--meta-header-height: 0px;--language-dropdown-margin-top: 0px}@media(min-width: 1024px){:host{--meta-header-height: 3rem;--header-height: 4rem}}@media(min-width: 1280px){:host{--header-height: 4.5rem}}:host([meta=false]){--meta-header-height: 0px;--language-dropdown-margin-top: 1px}@supports(position: sticky){:host(:not(.stickyness-none)){position:sticky}:host(.stickyness-full){top:0}:host(.stickyness-main){top:calc(var(--meta-header-height, 0px)*-1)}:host(.stickyness-minimal){top:calc((var(--header-height, 0px) + var(--meta-header-height, 0px) + 1px)*-1);transition:top 200ms ease-in}:host(.stickyness-minimal.scrolling-up),:host(.stickyness-minimal.dropdown-open){top:calc(var(--meta-header-height, 0px)*-1);transition:top 200ms ease-out}}.post-internet-header{border-bottom:1px solid #e6e6e6;background-color:#fff}.main-navigation-container{display:flex}.main-navigation-container>.main-navigation-controls{flex:0 0 auto}.main-navigation{display:flex}.sub-navigation-container{position:absolute;top:100%;left:0;width:100%;display:flex;background:#fff;visibility:hidden}.main-navigation-item:hover .sub-navigation-container{visibility:visible}.main-navigation-controls{display:flex;margin-left:auto}@media(max-width: 1023.98px){.main-navigation-controls{font-weight:400}}@media(min-width: 1024px){.main-navigation-controls{font-size:1.0625rem}}.main-navigation-controls>*{border-left:1px solid #e6e6e6}.menu-button{display:flex;align-items:center;padding:0 calc(1rem - 1px);font-weight:300;cursor:pointer;border-left:1px solid #e6e6e6;order:1}@media(min-width: 1024px){.menu-button{display:none}}@media(min-width: 600px)and (max-width: 1023.98px){.menu-button .visually-hidden{position:static;width:auto;height:auto;margin:auto;overflow:visible;clip:auto;visibility:visible;margin-right:.5rem}}.menu-button svg{width:1.5rem;height:1.5rem}.full-width .wide-container{max-width:none}
@@ -1,13 +1,14 @@
1
- import { Host, h, } from '@stencil/core';
1
+ import { h, Host, } from '@stencil/core';
2
2
  import { debounce, throttle } from 'throttle-debounce';
3
3
  import { getLocalizedConfig, getLocalizedCustomConfig, isValidProjectId, } from '../../services/config.service';
4
- import { state, dispose } from '../../data/store';
4
+ import { dispose, state } from '../../data/store';
5
5
  import { SvgSprite } from '../../utils/svg-sprite.component';
6
6
  import { SvgIcon } from '../../utils/svg-icon.component';
7
- import { translate } from '../../services/language.service';
7
+ import { getUserLang, translate } from '../../services/language.service';
8
8
  import { If } from '../../utils/if.component';
9
9
  import packageJson from '../../../package.json';
10
10
  import { registerLogoAnimationObserver } from './logo-animation/logo-animation';
11
+ import { getScrollParent } from '../../utils/scrollparent';
11
12
  export class PostInternetHeader {
12
13
  /**
13
14
  * Get the currently set language as a two letter string ("de", "fr" "it" or "en")
@@ -46,16 +47,17 @@ export class PostInternetHeader {
46
47
  connectedCallback() {
47
48
  this.throttledScroll = throttle(300, () => this.handleScrollEvent());
48
49
  this.debouncedResize = debounce(200, () => this.handleResize());
49
- window.addEventListener('scroll', this.throttledScroll, { passive: true });
50
- window.addEventListener('resize', this.debouncedResize, { passive: true });
51
50
  }
52
51
  disconnectedCallback() {
53
- window.removeEventListener('scroll', this.throttledScroll);
54
- window.removeEventListener('resize', this.debouncedResize);
52
+ this.scrollParent.removeEventListener('scroll', this.throttledScroll);
53
+ this.scrollParent.removeEventListener('resize', this.debouncedResize);
55
54
  // Reset the store to its original state
56
55
  dispose();
57
56
  }
58
57
  async componentWillLoad() {
58
+ this.scrollParent = getScrollParent(this.host);
59
+ this.scrollParent.addEventListener('scroll', this.throttledScroll, { passive: true });
60
+ this.scrollParent.addEventListener('resize', this.debouncedResize, { passive: true });
59
61
  // Wait for the config to arrive, then render the header
60
62
  try {
61
63
  state.projectId = this.project;
@@ -71,8 +73,10 @@ export class PostInternetHeader {
71
73
  typeof this.osFlyoutOverrides === 'string'
72
74
  ? JSON.parse(this.osFlyoutOverrides)
73
75
  : this.osFlyoutOverrides;
74
- if (this.customConfig !== undefined && state.currentLanguage !== null) {
75
- state.localizedCustomConfig = getLocalizedCustomConfig(this.customConfig, state.currentLanguage);
76
+ if (this.customConfig !== undefined) {
77
+ const langs = Object.keys(typeof this.customConfig === 'string' ? JSON.parse(this.customConfig) : this.customConfig);
78
+ const lang = state.currentLanguage || getUserLang(langs, this.language);
79
+ state.localizedCustomConfig = getLocalizedCustomConfig(this.customConfig, lang);
76
80
  }
77
81
  state.localizedConfig = await getLocalizedConfig({
78
82
  projectId: this.project,
@@ -116,7 +120,7 @@ export class PostInternetHeader {
116
120
  if (this.customConfig)
117
121
  state.localizedCustomConfig = getLocalizedCustomConfig(this.customConfig, newValue);
118
122
  }
119
- handleAvailableLanguagesChage(newValue) {
123
+ handleAvailableLanguagesChange(newValue) {
120
124
  state.languageSwitchOverrides = typeof newValue === 'string' ? JSON.parse(newValue) : newValue;
121
125
  }
122
126
  async handleOsFlyoutOverrides(newValue) {
@@ -170,31 +174,34 @@ export class PostInternetHeader {
170
174
  state.meta = newValue;
171
175
  }
172
176
  handleLanguageChangeEvent(event) {
173
- this.handleLanguageChange(event.detail);
177
+ void this.handleLanguageChange(event.detail);
174
178
  }
175
179
  handleStickynessChange(newValue) {
176
180
  state.stickyness = newValue;
177
- this.updateLogoAnimation();
181
+ if (typeof this.updateLogoAnimation === 'function')
182
+ this.updateLogoAnimation();
178
183
  }
179
184
  handleClickOutside(event) {
180
185
  // Close active dropdown element on click outside of it
181
186
  if (this.activeDropdownElement && !event.composedPath().includes(this.activeDropdownElement)) {
182
- this.activeDropdownElement.toggleDropdown(false);
187
+ void this.activeDropdownElement.toggleDropdown(false);
183
188
  }
184
189
  }
185
190
  handleKeyUp(event) {
186
191
  if (event.key === 'Escape') {
187
192
  if (this.activeDropdownElement) {
188
- this.activeDropdownElement.toggleDropdown(false);
193
+ void this.activeDropdownElement.toggleDropdown(false);
189
194
  }
190
195
  if (this.activeFlyout !== null && this.mainNav) {
191
- this.mainNav.toggleDropdown(false);
196
+ void this.mainNav.toggleDropdown(false);
192
197
  }
193
198
  }
194
199
  }
195
200
  handleScrollEvent() {
196
201
  // Credits: "https://github.com/qeremy/so/blob/master/so.dom.js#L426"
197
- const st = window.scrollY || document.documentElement.scrollTop;
202
+ const st = this.scrollParent instanceof Document
203
+ ? this.scrollParent.documentElement.scrollTop
204
+ : this.scrollParent.scrollTop;
198
205
  // Toggle class without re-rendering the component if stickyness is minimal
199
206
  // the other stickyness modes do not need the class
200
207
  if (this.stickyness === 'minimal') {
@@ -223,13 +230,13 @@ export class PostInternetHeader {
223
230
  // a circle or an outdated state, we'll not handle this event
224
231
  return;
225
232
  }
226
- if (event.detail.open === true) {
233
+ if (event.detail.open) {
227
234
  if (this.activeDropdownElement) {
228
- this.activeDropdownElement.toggleDropdown(false);
235
+ void this.activeDropdownElement.toggleDropdown(false);
229
236
  }
230
237
  this.activeDropdownElement = event.detail.element;
231
238
  if (window.innerWidth >= 1024) {
232
- // Add event listener to close active dropdown element on click outsite of it
239
+ // Add event listener to close active dropdown element on click outside of it
233
240
  // Also adds 10ms delay in case of an external interaction:
234
241
  // Some button on the page calls toggleDropdown() -> dropdown opens
235
242
  // Click event bubbles to the window, this.handleClickOutsideBound closes dropdown again
@@ -238,7 +245,7 @@ export class PostInternetHeader {
238
245
  }, 10);
239
246
  }
240
247
  if (this.activeFlyout !== null && this.mainNav) {
241
- this.mainNav.setActiveFlyout(null);
248
+ void this.mainNav.setActiveFlyout(null);
242
249
  }
243
250
  }
244
251
  else {
@@ -254,7 +261,7 @@ export class PostInternetHeader {
254
261
  handleFlyoutToggled(event) {
255
262
  this.activeFlyout = event.detail;
256
263
  if (this.activeDropdownElement && event.detail && !this.isMainNavOpen()) {
257
- this.activeDropdownElement.toggleDropdown(false);
264
+ void this.activeDropdownElement.toggleDropdown(false);
258
265
  }
259
266
  }
260
267
  toggleMobileDropdown() {
@@ -276,7 +283,7 @@ export class PostInternetHeader {
276
283
  ((_b = config.header.navMeta) === null || _b === void 0 ? void 0 : _b.filter(meta => !meta.isHomeLink).length) > 0;
277
284
  const renderLogin = ((_c = this.login) !== null && _c !== void 0 ? _c : !config.header.isLoginWidgetHidden) && config.header.loginWidgetOptions;
278
285
  const renderLanguageSwitch = config.header.navLang.length > 1;
279
- return (h(Host, { class: `stickyness-${this.stickyness} ${this.activeDropdownElement || this.activeFlyout ? 'dropdown-open' : ''}`, "data-version": packageJson.version, onKeyup: (e) => this.handleKeyUp(e) }, h("header", { class: `post-internet-header${this.fullWidth ? ' full-width' : ''}` }, h(SvgSprite, null), h("h1", { class: "visually-hidden" }, translate('Navigate on post.ch')), h(If, { condition: this.skiplinks === true }, h("post-skiplinks", null)), h(If, { condition: renderMetaNavigation === true }, h("post-meta-navigation", { orientation: "horizontal", class: "hidden-lg", "full-width": this.fullWidth, ref: el => (this.metaNav = el) }, h(If, { condition: renderLanguageSwitch === true }, h("post-language-switch", { id: "post-language-switch-desktop", mode: "dropdown", onDropdownToggled: e => this.handleDropdownToggled(e) })))), h("div", { class: "main-navigation-container wide-container" }, h("post-logo", null), h("button", { class: "menu-button nav-link", onClick: () => this.toggleMobileDropdown(), "aria-haspopup": "menu", "aria-controls": "post-internet-header-main-navigation", "aria-expanded": this.activeDropdownElement ? 'true' : 'false' }, h("span", { class: "menu-button-text visually-hidden" }, config.header.mobileMenu.text), h(SvgIcon, { name: this.isMainNavOpen() ? 'pi-close' : 'pi-menu' })), h("post-main-navigation", { onDropdownToggled: e => this.handleDropdownToggled(e), onFlyoutToggled: e => this.handleFlyoutToggled(e), ref: el => (this.mainNav = el) }, h(If, { condition: renderMetaNavigation === true }, h("post-meta-navigation", { orientation: "vertical" }, h(If, { condition: renderLanguageSwitch === true }, h("post-language-switch", { id: "post-language-switch-mobile", mode: "list" }))))), h("div", { class: "main-navigation-controls" }, h(If, { condition: this.search !== false }, h("post-search", { onDropdownToggled: e => this.handleDropdownToggled(e) })), h(If, { condition: !!renderLogin }, h("post-klp-login-widget", null, h("slot", { name: "login-widget" }))), h(If, { condition: renderMetaNavigation === false && renderLanguageSwitch === true }, h("post-language-switch", { id: "post-language-switch-no-meta", onDropdownToggled: e => this.handleDropdownToggled(e), mode: "dropdown" })), h("slot", { name: "main" }))))));
286
+ return (h(Host, { class: `stickyness-${this.stickyness} ${Boolean(this.activeDropdownElement) || Boolean(this.activeFlyout) ? 'dropdown-open' : ''}`, "data-version": packageJson.version, onKeyup: (e) => this.handleKeyUp(e) }, h("header", { class: `post-internet-header${this.fullWidth ? ' full-width' : ''}` }, h(SvgSprite, null), h("h1", { class: "visually-hidden" }, translate('Navigate on post.ch')), h(If, { condition: this.skiplinks }, h("post-skiplinks", null)), h(If, { condition: renderMetaNavigation }, h("post-meta-navigation", { orientation: "horizontal", class: "hidden-lg", "full-width": this.fullWidth, ref: el => (this.metaNav = el) }, h(If, { condition: renderLanguageSwitch }, h("post-language-switch", { id: "post-language-switch-desktop", mode: "dropdown", onDropdownToggled: e => this.handleDropdownToggled(e) })))), h("div", { class: "main-navigation-container wide-container" }, h("post-logo", null), h("button", { class: "menu-button nav-link", onClick: () => this.toggleMobileDropdown(), "aria-haspopup": "menu", "aria-controls": "post-internet-header-main-navigation", "aria-expanded": this.activeDropdownElement ? 'true' : 'false' }, h("span", { class: "menu-button-text visually-hidden" }, config.header.mobileMenu.text), h(SvgIcon, { name: this.isMainNavOpen() ? 'pi-close' : 'pi-menu' })), h("post-main-navigation", { onDropdownToggled: e => this.handleDropdownToggled(e), onFlyoutToggled: e => this.handleFlyoutToggled(e), ref: el => (this.mainNav = el) }, h(If, { condition: renderMetaNavigation }, h("post-meta-navigation", { orientation: "vertical" }, h(If, { condition: renderLanguageSwitch }, h("post-language-switch", { id: "post-language-switch-mobile", mode: "list" }))))), h("div", { class: "main-navigation-controls" }, h(If, { condition: this.search }, h("post-search", { onDropdownToggled: e => this.handleDropdownToggled(e) })), h(If, { condition: !!renderLogin }, h("post-klp-login-widget", null, h("slot", { name: "login-widget" }))), h(If, { condition: !renderMetaNavigation && renderLanguageSwitch }, h("post-language-switch", { id: "post-language-switch-no-meta", onDropdownToggled: e => this.handleDropdownToggled(e), mode: "dropdown" })), h("slot", { name: "main" }))))));
280
287
  }
281
288
  static get is() { return "swisspost-internet-header"; }
282
289
  static get encapsulation() { return "shadow"; }
@@ -336,8 +343,8 @@ export class PostInternetHeader {
336
343
  "type": "string",
337
344
  "mutable": false,
338
345
  "complexType": {
339
- "original": "string",
340
- "resolved": "string | undefined",
346
+ "original": "'de' | 'fr' | 'it' | 'en'",
347
+ "resolved": "\"de\" | \"en\" | \"fr\" | \"it\" | undefined",
341
348
  "references": {}
342
349
  },
343
350
  "required": false,
@@ -478,7 +485,7 @@ export class PostInternetHeader {
478
485
  "optional": true,
479
486
  "docs": {
480
487
  "tags": [],
481
- "text": "Override the language switch links with custom URLs. Helpful when your application contains sub-pages and you\nwould like to stay on subpages when the user changes language."
488
+ "text": "Override the language switch links with custom URLs. Helpful when your application contains sub-pages, and you\nwould like to stay on subpages when the user changes language."
482
489
  },
483
490
  "attribute": "language-switch-overrides",
484
491
  "reflect": false
@@ -654,7 +661,7 @@ export class PostInternetHeader {
654
661
  "methodName": "handleLanguageChange"
655
662
  }, {
656
663
  "propName": "languageSwitchOverrides",
657
- "methodName": "handleAvailableLanguagesChage"
664
+ "methodName": "handleAvailableLanguagesChange"
658
665
  }, {
659
666
  "propName": "osFlyoutOverrides",
660
667
  "methodName": "handleOsFlyoutOverrides"