@orangesk/orange-design-system 2.0.0-beta.35 → 2.0.0-beta.36
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/README.md +6 -0
- package/build/components/Megamenu/style.css +1 -1
- package/build/components/Megamenu/style.css.map +1 -1
- package/build/components/index.js +1 -1
- package/build/components/index.js.map +1 -1
- package/build/components/tsconfig.tsbuildinfo +1 -1
- package/build/components/types/src/components/Carousel/Carousel.static.d.ts +2 -0
- package/build/components/types/src/components/Megamenu/constants.d.ts +1 -0
- package/build/lib/megamenu.css +1 -1
- package/build/lib/megamenu.css.map +1 -1
- package/build/lib/megamenu.js.map +1 -1
- package/build/lib/scripts.js +1 -1
- package/build/lib/scripts.js.map +1 -1
- package/build/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +11 -3
- package/src/components/Alert/tests/Alert.visual.test.jsx +138 -0
- package/src/components/Alert/tests/__screenshots__/Alert.visual.test.jsx/alert-preview-custom-title-chromium-linux.png +0 -0
- package/src/components/Alert/tests/__screenshots__/Alert.visual.test.jsx/alert-preview-danger-chromium-linux.png +0 -0
- package/src/components/Alert/tests/__screenshots__/Alert.visual.test.jsx/alert-preview-full-width-chromium-linux.png +0 -0
- package/src/components/Alert/tests/__screenshots__/Alert.visual.test.jsx/alert-preview-success-chromium-linux.png +0 -0
- package/src/components/Alert/tests/__screenshots__/Alert.visual.test.jsx/alert-preview-title-buttons-chromium-linux.png +0 -0
- package/src/components/Alert/tests/__screenshots__/Alert.visual.test.jsx/alert-preview-title-chromium-linux.png +0 -0
- package/src/components/Alert/tests/__screenshots__/Alert.visual.test.jsx/alert-preview-title-description-buttons-chromium-linux.png +0 -0
- package/src/components/Alert/tests/__screenshots__/Alert.visual.test.jsx/alert-preview-title-description-chromium-linux.png +0 -0
- package/src/components/Alert/tests/__screenshots__/Alert.visual.test.jsx/alert-preview-warning-chromium-linux.png +0 -0
- package/src/components/Carousel/Carousel.static.ts +40 -0
- package/src/components/Carousel/tests/Carousel.static.test.jsx +29 -4
- package/src/components/Megamenu/MegamenuBlog.tsx +5 -1
- package/src/components/Megamenu/constants.ts +1 -0
- package/src/components/Megamenu/styles/mixins.scss +15 -1
- package/src/components/Megamenu/styles/style.scss +4 -0
|
@@ -92,6 +92,7 @@ export default class Carousel {
|
|
|
92
92
|
track!: HTMLElement;
|
|
93
93
|
instance!: Swiper;
|
|
94
94
|
carouselId?: string;
|
|
95
|
+
private resizeObserver?: ResizeObserver;
|
|
95
96
|
|
|
96
97
|
constructor(element: HTMLElement, config?: Partial<SwiperOptions>) {
|
|
97
98
|
this.element = element;
|
|
@@ -153,6 +154,8 @@ export default class Carousel {
|
|
|
153
154
|
});
|
|
154
155
|
}
|
|
155
156
|
|
|
157
|
+
this.observeVisibilityChanges();
|
|
158
|
+
|
|
156
159
|
this.initExternalControls();
|
|
157
160
|
|
|
158
161
|
// Trigger a final update to notify listeners (like SameHeight) that carousel is ready
|
|
@@ -175,6 +178,29 @@ export default class Carousel {
|
|
|
175
178
|
});
|
|
176
179
|
}
|
|
177
180
|
|
|
181
|
+
private observeVisibilityChanges(): void {
|
|
182
|
+
if (typeof ResizeObserver === "undefined") {
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
this.resizeObserver?.disconnect();
|
|
187
|
+
this.resizeObserver = new ResizeObserver(() => {
|
|
188
|
+
if (!this.instance || !this.viewport) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (this.viewport.clientWidth <= 0) {
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
this.instance.update();
|
|
197
|
+
this.updateCarouselEnabledState();
|
|
198
|
+
this.instance.scrollbar?.updateSize();
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
this.resizeObserver.observe(this.viewport);
|
|
202
|
+
}
|
|
203
|
+
|
|
178
204
|
/**
|
|
179
205
|
* Fix scrollbar drag size and position for bleed-right carousels.
|
|
180
206
|
* Overrides Swiper's default scrollbar calculations to work correctly with bleed-right layouts.
|
|
@@ -301,6 +327,13 @@ export default class Carousel {
|
|
|
301
327
|
this.instance.disable();
|
|
302
328
|
}
|
|
303
329
|
|
|
330
|
+
const scrollbarEl = this.element.querySelector(
|
|
331
|
+
SELECTOR_SCROLLBAR,
|
|
332
|
+
) as HTMLElement | null;
|
|
333
|
+
if (scrollbarEl) {
|
|
334
|
+
scrollbarEl.style.display = this.instance.enabled ? "" : "none";
|
|
335
|
+
}
|
|
336
|
+
|
|
304
337
|
this.applyTrackMarginCompensation();
|
|
305
338
|
}
|
|
306
339
|
|
|
@@ -641,6 +674,13 @@ export default class Carousel {
|
|
|
641
674
|
if (this.instance) {
|
|
642
675
|
this.instance.destroy();
|
|
643
676
|
}
|
|
677
|
+
|
|
678
|
+
this.resizeObserver?.disconnect();
|
|
679
|
+
this.resizeObserver = undefined;
|
|
680
|
+
|
|
681
|
+
if ((this.element as any).ODS_Carousel === this) {
|
|
682
|
+
delete (this.element as any).ODS_Carousel;
|
|
683
|
+
}
|
|
644
684
|
}
|
|
645
685
|
|
|
646
686
|
update() {
|
|
@@ -8,14 +8,22 @@ import Carousel from "../Carousel.static";
|
|
|
8
8
|
// Mock Swiper
|
|
9
9
|
vi.mock("swiper", () => ({
|
|
10
10
|
Swiper: vi.fn().mockImplementation(function () {
|
|
11
|
+
let enabled = true;
|
|
11
12
|
return {
|
|
12
13
|
slideNext: vi.fn(),
|
|
13
14
|
slidePrev: vi.fn(),
|
|
14
15
|
destroy: vi.fn(),
|
|
15
16
|
update: vi.fn(),
|
|
16
17
|
on: vi.fn(),
|
|
17
|
-
enable: vi.fn()
|
|
18
|
-
|
|
18
|
+
enable: vi.fn(() => {
|
|
19
|
+
enabled = true;
|
|
20
|
+
}),
|
|
21
|
+
disable: vi.fn(() => {
|
|
22
|
+
enabled = false;
|
|
23
|
+
}),
|
|
24
|
+
get enabled() {
|
|
25
|
+
return enabled;
|
|
26
|
+
},
|
|
19
27
|
activeIndex: 0,
|
|
20
28
|
isBeginning: true,
|
|
21
29
|
isEnd: false,
|
|
@@ -23,6 +31,10 @@ vi.mock("swiper", () => ({
|
|
|
23
31
|
params: {
|
|
24
32
|
slidesPerView: 1,
|
|
25
33
|
},
|
|
34
|
+
scrollbar: {
|
|
35
|
+
updateSize: vi.fn(),
|
|
36
|
+
el: document.createElement("div"),
|
|
37
|
+
},
|
|
26
38
|
};
|
|
27
39
|
}),
|
|
28
40
|
}));
|
|
@@ -47,14 +59,23 @@ describe("Carousel Static - External Controls", () => {
|
|
|
47
59
|
vi.clearAllMocks();
|
|
48
60
|
|
|
49
61
|
// Create mock Swiper instance
|
|
62
|
+
let enabled = true;
|
|
63
|
+
|
|
50
64
|
mockSwiperInstance = {
|
|
51
65
|
slideNext: vi.fn(),
|
|
52
66
|
slidePrev: vi.fn(),
|
|
53
67
|
destroy: vi.fn(),
|
|
54
68
|
update: vi.fn(),
|
|
55
69
|
on: vi.fn(),
|
|
56
|
-
enable: vi.fn()
|
|
57
|
-
|
|
70
|
+
enable: vi.fn(() => {
|
|
71
|
+
enabled = true;
|
|
72
|
+
}),
|
|
73
|
+
disable: vi.fn(() => {
|
|
74
|
+
enabled = false;
|
|
75
|
+
}),
|
|
76
|
+
get enabled() {
|
|
77
|
+
return enabled;
|
|
78
|
+
},
|
|
58
79
|
activeIndex: 0,
|
|
59
80
|
isBeginning: true,
|
|
60
81
|
isEnd: false,
|
|
@@ -62,6 +83,10 @@ describe("Carousel Static - External Controls", () => {
|
|
|
62
83
|
params: {
|
|
63
84
|
slidesPerView: 1,
|
|
64
85
|
},
|
|
86
|
+
scrollbar: {
|
|
87
|
+
updateSize: vi.fn(),
|
|
88
|
+
el: document.createElement("div"),
|
|
89
|
+
},
|
|
65
90
|
};
|
|
66
91
|
|
|
67
92
|
Swiper.mockImplementation(function () {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
CLASS_NAV_BUTTON,
|
|
14
14
|
CLASS_NAV_DROPDOWN,
|
|
15
15
|
CLASS_NAV_ICON,
|
|
16
|
+
CLASS_NAV_ICON_NO_GAP_MD_DOWN,
|
|
16
17
|
CLASS_NAV_ITEM,
|
|
17
18
|
CLASS_NAV_VERTICAL,
|
|
18
19
|
CLASS_NAV_ITEM_MAIN,
|
|
@@ -158,7 +159,10 @@ export const MegamenuBlog = ({
|
|
|
158
159
|
width={24}
|
|
159
160
|
height={24}
|
|
160
161
|
name="user"
|
|
161
|
-
className={
|
|
162
|
+
className={cx(
|
|
163
|
+
CLASS_NAV_ICON,
|
|
164
|
+
CLASS_NAV_ICON_NO_GAP_MD_DOWN,
|
|
165
|
+
)}
|
|
162
166
|
aria-hidden="true"
|
|
163
167
|
/>
|
|
164
168
|
<span className={CLASS_HIDE_MD_DOWN}>Môj Orange</span>
|
|
@@ -19,6 +19,7 @@ export const CLASS_NAV_LINK_NO_LINE = `${CLASS_ROOT}__nav-link--no-line`;
|
|
|
19
19
|
export const CLASS_NAV_CART_ICON = `${CLASS_ROOT}__nav-cart-icon`;
|
|
20
20
|
export const CLASS_NAV_SPACER = `${CLASS_ROOT}__nav-spacer`;
|
|
21
21
|
export const CLASS_NAV_ICON = `${CLASS_ROOT}__nav-icon`;
|
|
22
|
+
export const CLASS_NAV_ICON_NO_GAP_MD_DOWN = `${CLASS_NAV_ICON}--no-gap-md-down`;
|
|
22
23
|
export const CLASS_NAV_LOGO = `${CLASS_ROOT}__nav-logo`;
|
|
23
24
|
export const CLASS_NAV_BUTTON = `${CLASS_ROOT}__nav-button`;
|
|
24
25
|
export const CLASS_NAV_BUTTON_INDICATOR = `${CLASS_ROOT}__nav-button--indicator`;
|
|
@@ -445,6 +445,12 @@
|
|
|
445
445
|
margin-right: convert.to-rem(5px);
|
|
446
446
|
}
|
|
447
447
|
|
|
448
|
+
@mixin nav-icon-no-gap-md-down {
|
|
449
|
+
@include breakpoint.get("md", "down") {
|
|
450
|
+
margin-right: 0;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
448
454
|
@mixin nav-spacer {
|
|
449
455
|
display: flex;
|
|
450
456
|
flex: 1 0 1px;
|
|
@@ -637,8 +643,16 @@
|
|
|
637
643
|
margin-bottom: convert.to-rem(40px);
|
|
638
644
|
text-decoration: none !important;
|
|
639
645
|
|
|
646
|
+
&:hover {
|
|
647
|
+
color: var(--color-text-inverse) !important;
|
|
648
|
+
background-color: var(--color-fill-contrast) !important;
|
|
649
|
+
border-color: transparent !important;
|
|
650
|
+
}
|
|
651
|
+
|
|
640
652
|
&:active {
|
|
641
|
-
color: color
|
|
653
|
+
color: var(--color-fill-contrast) !important;
|
|
654
|
+
background-color: transparent !important;
|
|
655
|
+
border-color: var(--color-border-contrast) !important;
|
|
642
656
|
}
|
|
643
657
|
}
|
|
644
658
|
|