@orangesk/orange-design-system 2.0.0-beta.41 → 2.0.0-beta.43

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 (51) hide show
  1. package/build/components/AnchorNavigation/style.css +1 -1
  2. package/build/components/AnchorNavigation/style.css.map +1 -1
  3. package/build/components/BlockAction/style.css +1 -1
  4. package/build/components/BlockAction/style.css.map +1 -1
  5. package/build/components/Buttons/style.css +1 -1
  6. package/build/components/Buttons/style.css.map +1 -1
  7. package/build/components/Carousel/style.css +1 -1
  8. package/build/components/Carousel/style.css.map +1 -1
  9. package/build/components/Grid/style.css +1 -1
  10. package/build/components/Grid/style.css.map +1 -1
  11. package/build/components/Link/style.css +1 -1
  12. package/build/components/Link/style.css.map +1 -1
  13. package/build/components/Megamenu/style.css +1 -1
  14. package/build/components/Megamenu/style.css.map +1 -1
  15. package/build/components/Modal/style.css +1 -1
  16. package/build/components/Modal/style.css.map +1 -1
  17. package/build/components/index.js +1 -1
  18. package/build/components/index.js.map +1 -1
  19. package/build/components/tsconfig.tsbuildinfo +1 -1
  20. package/build/components/types/src/components/AnchorNavigation/AnchorNavigation.static.d.ts +40 -0
  21. package/build/components/types/src/components/Carousel/Carousel.static.d.ts +0 -5
  22. package/build/components/types/src/components/Megamenu/Megamenu.static.d.ts +3 -0
  23. package/build/components/types/src/components/Modal/Modal.static.d.ts +1 -0
  24. package/build/lib/components.css +1 -1
  25. package/build/lib/components.css.map +1 -1
  26. package/build/lib/megamenu.css +1 -1
  27. package/build/lib/megamenu.css.map +1 -1
  28. package/build/lib/megamenu.js +1 -1
  29. package/build/lib/megamenu.js.map +1 -1
  30. package/build/lib/scripts.js +1 -1
  31. package/build/lib/scripts.js.map +1 -1
  32. package/build/lib/style.css +1 -1
  33. package/build/lib/style.css.map +1 -1
  34. package/build/lib/tsconfig.tsbuildinfo +1 -1
  35. package/build/sprite.svg +1 -1
  36. package/package.json +23 -23
  37. package/src/assets/icons/youtube.svg +3 -1
  38. package/src/components/AnchorNavigation/AnchorNavigation.static.ts +385 -77
  39. package/src/components/AnchorNavigation/styles/mixins.scss +18 -2
  40. package/src/components/AnchorNavigation/tests/AnchorNavigation.unit.test.jsx +266 -8
  41. package/src/components/BlockAction/styles/mixins.scss +1 -1
  42. package/src/components/Buttons/styles/mixins.scss +8 -13
  43. package/src/components/Carousel/Carousel.static.ts +5 -26
  44. package/src/components/Carousel/styles/mixins.scss +1 -1
  45. package/src/components/Carousel/tests/Carousel.static.test.jsx +117 -0
  46. package/src/components/Grid/styles/mixins.scss +14 -6
  47. package/src/components/Link/styles/mixins.scss +0 -1
  48. package/src/components/Megamenu/Megamenu.static.ts +27 -1
  49. package/src/components/Megamenu/styles/mixins.scss +4 -0
  50. package/src/components/Modal/Modal.static.ts +29 -7
  51. package/src/components/Modal/styles/mixins.scss +4 -0
@@ -15,6 +15,9 @@ interface MegamenuConfig {
15
15
  removeOnDestroy?: boolean;
16
16
  }
17
17
 
18
+ const MODAL_OPEN_CLASS = "has-modal";
19
+ const LOCKED_SCROLL_TOP_ATTR = "data-lock-scrolltop";
20
+
18
21
  const defaultConfig: Required<MegamenuConfig> = {
19
22
  dataToggle: "data-toggle",
20
23
  activeClass: "is-active",
@@ -44,6 +47,27 @@ export default class Megamenu {
44
47
  touchstartHandler!: () => void;
45
48
  instanceName!: string;
46
49
 
50
+ private isModalOpen(): boolean {
51
+ return document.body.classList.contains(MODAL_OPEN_CLASS);
52
+ }
53
+
54
+ private getLockedScrollTop(): number | null {
55
+ const lockedScrollTopRaw = document.body.getAttribute(
56
+ LOCKED_SCROLL_TOP_ATTR,
57
+ );
58
+ const lockedScrollTop = Number.parseInt(lockedScrollTopRaw || "", 10);
59
+
60
+ return Number.isFinite(lockedScrollTop) ? lockedScrollTop : null;
61
+ }
62
+
63
+ private getEffectiveScrollY(): number {
64
+ if (!this.isModalOpen()) {
65
+ return window.scrollY;
66
+ }
67
+
68
+ return this.getLockedScrollTop() ?? window.scrollY;
69
+ }
70
+
47
71
  constructor(element: HTMLElement, config: MegamenuConfig = {}) {
48
72
  if ((element as any).ODS_Megamenu) {
49
73
  return (element as any).ODS_Megamenu;
@@ -179,6 +203,7 @@ export default class Megamenu {
179
203
 
180
204
  // Set initial tab indices for accessibility
181
205
  this.updateTabIndices();
206
+ this.handleScroll();
182
207
  }
183
208
 
184
209
  shouldUseMobileTrigger(button: HTMLButtonElement) {
@@ -407,9 +432,10 @@ export default class Megamenu {
407
432
  const topElement = this.element.querySelector(
408
433
  '[data-hide-when-sticky="true"]',
409
434
  ) as HTMLElement;
435
+ const effectiveScrollY = this.getEffectiveScrollY();
410
436
 
411
437
  if (topElement) {
412
- if (window.scrollY > 15) {
438
+ if (effectiveScrollY > 15) {
413
439
  topElement.classList.add("is-hidden");
414
440
  this.element.classList.add("top-hidden");
415
441
  } else {
@@ -148,6 +148,10 @@
148
148
  &.is-sticky {
149
149
  position: fixed;
150
150
 
151
+ body.has-modal & {
152
+ padding-right: var(--ods-modal-scrollbar-width, 0px);
153
+ }
154
+
151
155
  #{config.$class-root}__main {
152
156
  position: sticky;
153
157
  top: 0;
@@ -25,6 +25,9 @@ const defaultConfig = (): ModalConfig => ({
25
25
  modalsRoot: "#root-modals",
26
26
  });
27
27
 
28
+ const MODAL_SCROLLBAR_WIDTH_VAR = "--ods-modal-scrollbar-width";
29
+ const BODY_LOCK_SCROLL_TOP_ATTR = "data-lock-scrolltop";
30
+
28
31
  interface HTMLElementWithModal extends HTMLElement {
29
32
  ODS_Modal?: Modal;
30
33
  }
@@ -172,15 +175,27 @@ export default class Modal {
172
175
  // Track if body is locked
173
176
  private static isLocked = false;
174
177
 
178
+ private static resolveBodyLockClassName(
179
+ className?: string,
180
+ context?: unknown,
181
+ ): string {
182
+ const modalContext = context as Modal | undefined;
183
+
184
+ return (
185
+ className ||
186
+ modalContext?.config?.classModalIsOpenBody ||
187
+ defaultConfig().classModalIsOpenBody
188
+ );
189
+ }
190
+
175
191
  static lockBody(className?: string, root?: string): void {
176
192
  if (Modal.isLocked) return;
177
193
 
178
- const actualClassName =
179
- className || (this as unknown as Modal).config?.classModalIsOpenBody;
194
+ const actualClassName = Modal.resolveBodyLockClassName(className, this);
180
195
 
181
196
  // Store scroll position
182
197
  const scrollY = window.scrollY;
183
- document.body.setAttribute("data-lock-scrolltop", scrollY.toString());
198
+ document.body.setAttribute(BODY_LOCK_SCROLL_TOP_ATTR, scrollY.toString());
184
199
 
185
200
  const scrollbarWidth =
186
201
  window.innerWidth - document.documentElement.clientWidth;
@@ -191,6 +206,10 @@ export default class Modal {
191
206
  document.body.style.left = "0";
192
207
  document.body.style.right = "0";
193
208
  document.body.style.paddingRight = `${scrollbarWidth}px`;
209
+ document.body.style.setProperty(
210
+ MODAL_SCROLLBAR_WIDTH_VAR,
211
+ `${scrollbarWidth}px`,
212
+ );
194
213
 
195
214
  // add modal class
196
215
  document.body.classList.add(actualClassName);
@@ -200,9 +219,11 @@ export default class Modal {
200
219
  static unlockBody(className?: string, root?: string): void {
201
220
  if (!Modal.isLocked) return;
202
221
 
203
- const actualClassName =
204
- className || (this as unknown as Modal).config?.classModalIsOpenBody;
205
- const scrollTop = document.body.getAttribute("data-lock-scrolltop") || "0";
222
+ const actualClassName = Modal.resolveBodyLockClassName(className, this);
223
+ const scrollTop = Number.parseInt(
224
+ document.body.getAttribute(BODY_LOCK_SCROLL_TOP_ATTR) || "0",
225
+ 10,
226
+ );
206
227
 
207
228
  // Remove lock styles
208
229
  document.body.style.position = "";
@@ -210,13 +231,14 @@ export default class Modal {
210
231
  document.body.style.left = "";
211
232
  document.body.style.right = "";
212
233
  document.body.style.paddingRight = "";
234
+ document.body.style.removeProperty(MODAL_SCROLLBAR_WIDTH_VAR);
213
235
 
214
236
  // remove modal class
215
237
  document.body.classList.remove(actualClassName);
216
238
 
217
239
  // Restore scroll position instantly (ignore scroll-behavior: smooth)
218
240
  window.scrollTo({
219
- top: parseInt(scrollTop, 10),
241
+ top: Number.isFinite(scrollTop) ? scrollTop : 0,
220
242
  left: 0,
221
243
  behavior: "instant",
222
244
  });
@@ -97,6 +97,10 @@
97
97
  .divider {
98
98
  padding: 0;
99
99
  }
100
+
101
+ &:has(.divider) {
102
+ padding-bottom: 0;
103
+ }
100
104
  }
101
105
 
102
106
  @mixin close {