@orangesk/orange-design-system 3.8.0 → 3.10.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/README.md +0 -6
- package/build/components/AnchorNavigation/style.css +1 -1
- package/build/components/AnchorNavigation/style.css.map +1 -1
- package/build/components/Carousel/style.css +1 -1
- package/build/components/Carousel/style.css.map +1 -1
- package/build/components/Footer/style.css +1 -1
- package/build/components/Footer/style.css.map +1 -1
- 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/types/index.d.ts +6 -2
- package/build/lib/base.css.map +1 -1
- package/build/lib/components.css +1 -1
- package/build/lib/components.css.map +1 -1
- package/build/lib/footer.css +1 -1
- package/build/lib/footer.css.map +1 -1
- package/build/lib/megamenu.css +1 -1
- package/build/lib/megamenu.css.map +1 -1
- package/build/lib/reset.css +2 -0
- package/build/lib/reset.css.map +1 -0
- package/build/lib/reset.js +3 -0
- package/build/lib/scripts.js +1 -1
- package/build/lib/scripts.js.map +1 -1
- package/build/lib/style.css +1 -1
- package/build/lib/style.css.map +1 -1
- package/build/megamenu-sprite-dark.svg +1 -0
- package/build/megamenu-sprite-light.svg +1 -0
- package/package.json +26 -33
- package/src/assets/megamenu/input-search.svg +1 -0
- package/src/assets/megamenu/input-valid.svg +1 -0
- package/src/assets/megamenu/logo-line.svg +5 -0
- package/src/assets/megamenu/megamenu-logo.svg +61 -0
- package/src/assets/megamenu/store-apple--white.svg +5 -0
- package/src/assets/megamenu/store-apple.svg +4 -0
- package/src/assets/megamenu/store-huawei--white.svg +5 -0
- package/src/assets/megamenu/store-huawei.svg +4 -0
- package/src/assets/megamenu/store-play--white.svg +7 -0
- package/src/assets/megamenu/store-play.svg +7 -0
- package/src/components/AnchorNavigation/styles/mixins.scss +7 -9
- package/src/components/BlockAction/CloneElementWithClassName.tsx +10 -7
- package/src/components/BlockAction/tests/CloneElementWithClassName.unit.test.jsx +28 -1
- package/src/components/Carousel/Carousel.static.ts +49 -0
- package/src/components/Carousel/Carousel.tsx +35 -12
- package/src/components/Carousel/constants.ts +2 -0
- package/src/components/Carousel/styles/mixins.scss +61 -0
- package/src/components/Carousel/styles/style.scss +7 -0
- package/src/components/Footer/Footer.tsx +1 -4
- package/src/components/Footer/styles/mixins.scss +3 -1
- package/src/components/Footer/styles/style.scss +31 -0
- package/src/components/Footer/tests/Footer.styles.unit.test.jsx +62 -0
- package/src/components/Forms/TextInput/styles/mixins.scss +4 -2
- package/src/components/Megamenu/Logo.tsx +7 -7
- package/src/components/Megamenu/LogoJeTu.tsx +6 -58
- package/src/components/Megamenu/MegaMenuIcon.tsx +20 -11
- package/src/components/Megamenu/Megamenu.tsx +58 -48
- package/src/components/Megamenu/MegamenuBlog.tsx +14 -2
- package/src/components/Megamenu/MegamenuSearchContent.tsx +13 -0
- package/src/components/Megamenu/MyOrangeMobilePanel.tsx +3 -9
- package/src/components/Megamenu/styles/mixins.scss +30 -38
- package/src/components/Megamenu/tests/Megamenu.unit.test.jsx +158 -0
- package/src/components/Alert/tests/Alert.visual.test.jsx +0 -137
- 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/CarouselHero/tests/CarouselHero.visual.test.jsx +0 -90
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
CLASS_TAG_TRANSPARENT,
|
|
31
31
|
} from "./constants";
|
|
32
32
|
import { getMegamenuIds } from "./ids";
|
|
33
|
-
import { MegamenuIcon } from "./MegaMenuIcon";
|
|
33
|
+
import { MegamenuIcon, MegamenuSpritePathProvider } from "./MegaMenuIcon";
|
|
34
34
|
import type { MegamenuProps } from "./Megamenu";
|
|
35
35
|
import { MegamenuSearchContent } from "./MegamenuSearchContent";
|
|
36
36
|
import { MyOrangeMobilePanel } from "./MyOrangeMobilePanel";
|
|
@@ -63,7 +63,7 @@ export const MegamenuBlog = ({
|
|
|
63
63
|
const { hasSearchEmpty, hasSearchFilled, showSearchState, searchValue } =
|
|
64
64
|
getMegamenuSearchState(searchEmpty, searchFilled);
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
const content = (
|
|
67
67
|
<header>
|
|
68
68
|
<nav
|
|
69
69
|
className={cx(CLASS_ROOT, className, {
|
|
@@ -392,4 +392,16 @@ export const MegamenuBlog = ({
|
|
|
392
392
|
<div className={CLASS_SPACER_SMALL} aria-hidden="true" />
|
|
393
393
|
</header>
|
|
394
394
|
);
|
|
395
|
+
|
|
396
|
+
return (
|
|
397
|
+
<MegamenuSpritePathProvider
|
|
398
|
+
value={
|
|
399
|
+
isB2B || className?.split(/\s+/).includes("is-dark")
|
|
400
|
+
? "/megamenu-sprite-dark.svg"
|
|
401
|
+
: "/megamenu-sprite-light.svg"
|
|
402
|
+
}
|
|
403
|
+
>
|
|
404
|
+
{content}
|
|
405
|
+
</MegamenuSpritePathProvider>
|
|
406
|
+
);
|
|
395
407
|
};
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
CLASS_TAG,
|
|
13
13
|
} from "./constants";
|
|
14
14
|
import { searchResultItems, searchTerms } from "./data";
|
|
15
|
+
import { MegamenuIcon } from "./MegaMenuIcon";
|
|
15
16
|
|
|
16
17
|
type MegamenuSearchContentProps = {
|
|
17
18
|
inputId: string;
|
|
@@ -43,6 +44,12 @@ export const MegamenuSearchContent = ({
|
|
|
43
44
|
CLASS_INPUT_WRAPPER_SEARCH_ICON_WITH_PLACEHOLDER,
|
|
44
45
|
)}
|
|
45
46
|
>
|
|
47
|
+
<MegamenuIcon
|
|
48
|
+
name="input-search"
|
|
49
|
+
className="megamenu__input-search-icon"
|
|
50
|
+
width={20}
|
|
51
|
+
height={20}
|
|
52
|
+
/>
|
|
46
53
|
<input
|
|
47
54
|
className={CLASS_INPUT}
|
|
48
55
|
id={inputId}
|
|
@@ -51,6 +58,12 @@ export const MegamenuSearchContent = ({
|
|
|
51
58
|
name="search"
|
|
52
59
|
defaultValue={searchValue}
|
|
53
60
|
/>
|
|
61
|
+
<MegamenuIcon
|
|
62
|
+
name="input-valid"
|
|
63
|
+
className="megamenu__input-status-icon"
|
|
64
|
+
width={16}
|
|
65
|
+
height={16}
|
|
66
|
+
/>
|
|
54
67
|
</span>
|
|
55
68
|
|
|
56
69
|
{hasSearchEmpty ? (
|
|
@@ -133,27 +133,21 @@ export const MyOrangeMobilePanel = ({
|
|
|
133
133
|
className={CLASS_MOBILE_APP_CARD_STORE}
|
|
134
134
|
aria-label="Stiahnuť aplikáciu z App Store"
|
|
135
135
|
>
|
|
136
|
-
<
|
|
137
|
-
src={isB2B ? "/apple--white.svg" : "/apple.svg"}
|
|
138
|
-
alt=""
|
|
139
|
-
/>
|
|
136
|
+
<MegamenuIcon name="store-apple" width={24} height={25} />
|
|
140
137
|
</a>
|
|
141
138
|
<a
|
|
142
139
|
href="#"
|
|
143
140
|
className={CLASS_MOBILE_APP_CARD_STORE}
|
|
144
141
|
aria-label="Stiahnuť aplikáciu z Google Play"
|
|
145
142
|
>
|
|
146
|
-
<
|
|
143
|
+
<MegamenuIcon name="store-play" width={24} height={24} />
|
|
147
144
|
</a>
|
|
148
145
|
<a
|
|
149
146
|
href="#"
|
|
150
147
|
className={CLASS_MOBILE_APP_CARD_STORE}
|
|
151
148
|
aria-label="Stiahnuť aplikáciu z Huawei AppGallery"
|
|
152
149
|
>
|
|
153
|
-
<
|
|
154
|
-
src={isB2B ? "/huawei--white.svg" : "/huawei.svg"}
|
|
155
|
-
alt=""
|
|
156
|
-
/>
|
|
150
|
+
<MegamenuIcon name="store-huawei" width={24} height={24} />
|
|
157
151
|
</a>
|
|
158
152
|
</div>
|
|
159
153
|
</div>
|
|
@@ -102,11 +102,16 @@
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
* {
|
|
105
|
-
box-sizing: border-box;
|
|
106
105
|
letter-spacing: convert.to-rem(-0.1px);
|
|
107
106
|
line-height: convert.to-rem(18px);
|
|
108
107
|
}
|
|
109
108
|
|
|
109
|
+
*,
|
|
110
|
+
*::before,
|
|
111
|
+
*::after {
|
|
112
|
+
box-sizing: border-box;
|
|
113
|
+
}
|
|
114
|
+
|
|
110
115
|
::selection {
|
|
111
116
|
background-color: base.$selection-background;
|
|
112
117
|
color: base.$text-color;
|
|
@@ -263,7 +268,7 @@
|
|
|
263
268
|
}
|
|
264
269
|
|
|
265
270
|
@mixin nav-item-lead {
|
|
266
|
-
margin-right:
|
|
271
|
+
margin-right: 0;
|
|
267
272
|
}
|
|
268
273
|
|
|
269
274
|
@mixin nav-item-push {
|
|
@@ -418,7 +423,7 @@
|
|
|
418
423
|
}
|
|
419
424
|
|
|
420
425
|
&.is-active {
|
|
421
|
-
color: var(--color-border-accent);
|
|
426
|
+
color: var(--color-border-accent) !important;
|
|
422
427
|
}
|
|
423
428
|
}
|
|
424
429
|
|
|
@@ -523,6 +528,7 @@
|
|
|
523
528
|
&:focus,
|
|
524
529
|
&:active,
|
|
525
530
|
&.is-active {
|
|
531
|
+
color: var(--color-text-default) !important;
|
|
526
532
|
box-shadow: config.$active-line;
|
|
527
533
|
}
|
|
528
534
|
|
|
@@ -637,7 +643,7 @@
|
|
|
637
643
|
min-width: 0;
|
|
638
644
|
}
|
|
639
645
|
|
|
640
|
-
> #{config.$class-root}__nav:last-child {
|
|
646
|
+
> #{config.$class-root}__nav:last-child:not(:first-child) {
|
|
641
647
|
flex: 0 0 auto;
|
|
642
648
|
width: auto;
|
|
643
649
|
}
|
|
@@ -946,7 +952,8 @@
|
|
|
946
952
|
align-items: center;
|
|
947
953
|
height: convert.to-rem(40px);
|
|
948
954
|
|
|
949
|
-
img
|
|
955
|
+
img,
|
|
956
|
+
svg {
|
|
950
957
|
display: block;
|
|
951
958
|
width: auto;
|
|
952
959
|
max-width: convert.to-rem(52px);
|
|
@@ -1102,34 +1109,6 @@
|
|
|
1102
1109
|
fill: currentColor;
|
|
1103
1110
|
display: inline-block;
|
|
1104
1111
|
vertical-align: middle;
|
|
1105
|
-
|
|
1106
|
-
&__use {
|
|
1107
|
-
display: inline;
|
|
1108
|
-
|
|
1109
|
-
// Light theme (default) - show only light version
|
|
1110
|
-
&--light {
|
|
1111
|
-
display: inline;
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
&--dark {
|
|
1115
|
-
display: none;
|
|
1116
|
-
}
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
// Dark theme context - show only dark version
|
|
1120
|
-
.is-dark &,
|
|
1121
|
-
[data-theme="dark"] &,
|
|
1122
|
-
.dark & {
|
|
1123
|
-
&__use {
|
|
1124
|
-
&--light {
|
|
1125
|
-
display: none;
|
|
1126
|
-
}
|
|
1127
|
-
|
|
1128
|
-
&--dark {
|
|
1129
|
-
display: inline;
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
1132
|
-
}
|
|
1133
1112
|
}
|
|
1134
1113
|
|
|
1135
1114
|
@mixin overlay {
|
|
@@ -1265,7 +1244,7 @@
|
|
|
1265
1244
|
|
|
1266
1245
|
@mixin input {
|
|
1267
1246
|
@include input.base();
|
|
1268
|
-
@include input.states();
|
|
1247
|
+
@include input.states($valid-icon: false);
|
|
1269
1248
|
max-width: unset !important;
|
|
1270
1249
|
margin-bottom: convert.to-rem(30px);
|
|
1271
1250
|
|
|
@@ -1296,16 +1275,14 @@
|
|
|
1296
1275
|
&--search-icon-with-placeholder {
|
|
1297
1276
|
isolation: isolate;
|
|
1298
1277
|
|
|
1299
|
-
|
|
1300
|
-
content: "";
|
|
1278
|
+
.megamenu__input-search-icon {
|
|
1301
1279
|
position: absolute;
|
|
1302
1280
|
top: 50%;
|
|
1303
1281
|
left: convert.to-rem(8px);
|
|
1304
1282
|
width: convert.to-rem(20px);
|
|
1305
1283
|
height: convert.to-rem(20px);
|
|
1306
1284
|
transform: translateY(-50%);
|
|
1307
|
-
|
|
1308
|
-
background-repeat: no-repeat;
|
|
1285
|
+
color: #f15e00;
|
|
1309
1286
|
pointer-events: none;
|
|
1310
1287
|
z-index: 2;
|
|
1311
1288
|
}
|
|
@@ -1315,6 +1292,21 @@
|
|
|
1315
1292
|
padding-left: convert.to-rem(40px);
|
|
1316
1293
|
margin-bottom: 0;
|
|
1317
1294
|
}
|
|
1295
|
+
|
|
1296
|
+
.megamenu__input-status-icon {
|
|
1297
|
+
position: absolute;
|
|
1298
|
+
top: 50%;
|
|
1299
|
+
right: convert.to-rem(10px);
|
|
1300
|
+
width: convert.to-rem(16px);
|
|
1301
|
+
height: convert.to-rem(16px);
|
|
1302
|
+
transform: translateY(-50%);
|
|
1303
|
+
pointer-events: none;
|
|
1304
|
+
z-index: 2;
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
#{config.$class-root}__input:not(.is-valid) ~ .megamenu__input-status-icon {
|
|
1308
|
+
display: none;
|
|
1309
|
+
}
|
|
1318
1310
|
}
|
|
1319
1311
|
|
|
1320
1312
|
&--search-responsive {
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import { existsSync, readdirSync, readFileSync } from "node:fs";
|
|
2
|
+
|
|
1
3
|
import { render } from "@testing-library/react";
|
|
2
4
|
import "@testing-library/jest-dom/vitest";
|
|
3
5
|
|
|
4
6
|
import { Megamenu, MegamenuBlog } from "../";
|
|
7
|
+
import MegamenuController from "../Megamenu.static";
|
|
5
8
|
|
|
6
9
|
describe("Megamenu logo markup", () => {
|
|
7
10
|
it("separates top links from the language switcher without a spacer item", () => {
|
|
@@ -148,6 +151,56 @@ describe("Megamenu logo markup", () => {
|
|
|
148
151
|
expect(container).not.toHaveTextContent("0905 123 456");
|
|
149
152
|
});
|
|
150
153
|
|
|
154
|
+
it.each([false, true])(
|
|
155
|
+
"renders My Orange as SSO links without account panel markup (B2B: %s)",
|
|
156
|
+
(isB2B) => {
|
|
157
|
+
const { container } = render(
|
|
158
|
+
<Megamenu
|
|
159
|
+
isLoggedIn={false}
|
|
160
|
+
myOrangeHref="/sso"
|
|
161
|
+
isB2B={isB2B}
|
|
162
|
+
notSticky
|
|
163
|
+
/>,
|
|
164
|
+
);
|
|
165
|
+
const links = container.querySelectorAll('a[href="/sso"]');
|
|
166
|
+
|
|
167
|
+
expect(links).toHaveLength(2);
|
|
168
|
+
for (const link of links) {
|
|
169
|
+
expect(link).toHaveTextContent("Môj Orange");
|
|
170
|
+
expect(link).not.toHaveAttribute("data-megamenu-mobile-toggle");
|
|
171
|
+
expect(link).not.toHaveAttribute("aria-haspopup");
|
|
172
|
+
expect(link).not.toHaveAttribute("aria-expanded");
|
|
173
|
+
}
|
|
174
|
+
expect(
|
|
175
|
+
container.querySelector('[data-megamenu-mobile-target="my-orange"]'),
|
|
176
|
+
).toBeNull();
|
|
177
|
+
expect(
|
|
178
|
+
container.querySelector('[data-megamenu-mobile-panel="my-orange"]'),
|
|
179
|
+
).toBeNull();
|
|
180
|
+
expect(container.querySelector(".megamenu__mobile-account")).toBeNull();
|
|
181
|
+
expect(
|
|
182
|
+
container.querySelector('[data-megamenu-mobile-panel="main"]'),
|
|
183
|
+
).toBeInTheDocument();
|
|
184
|
+
|
|
185
|
+
const controller = new MegamenuController(
|
|
186
|
+
container.querySelector("[data-megamenu]"),
|
|
187
|
+
);
|
|
188
|
+
try {
|
|
189
|
+
container.querySelector('[data-megamenu-mobile-target="main"]').click();
|
|
190
|
+
expect(
|
|
191
|
+
container.querySelector('[data-megamenu-mobile-panel="main"]'),
|
|
192
|
+
).toHaveAttribute("aria-hidden", "false");
|
|
193
|
+
expect(links[0]).toHaveAttribute("href", "/sso");
|
|
194
|
+
controller.closeMobileMenu();
|
|
195
|
+
expect(
|
|
196
|
+
container.querySelector('[data-megamenu-mobile-panel="main"]'),
|
|
197
|
+
).toHaveAttribute("aria-hidden", "true");
|
|
198
|
+
} finally {
|
|
199
|
+
controller.destroy();
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
);
|
|
203
|
+
|
|
151
204
|
it("renders optional cart item count", () => {
|
|
152
205
|
const { container } = render(<Megamenu cartItems={3} notSticky />);
|
|
153
206
|
|
|
@@ -175,3 +228,108 @@ describe("Megamenu logo markup", () => {
|
|
|
175
228
|
expect(cart?.nextElementSibling).not.toBeInTheDocument();
|
|
176
229
|
});
|
|
177
230
|
});
|
|
231
|
+
|
|
232
|
+
describe("Megamenu vendor sprite markup", () => {
|
|
233
|
+
it.each([
|
|
234
|
+
["main B2C", Megamenu, false],
|
|
235
|
+
["main B2B", Megamenu, true],
|
|
236
|
+
["blog B2C", MegamenuBlog, false],
|
|
237
|
+
["blog B2B", MegamenuBlog, true],
|
|
238
|
+
])(
|
|
239
|
+
"resolves every SVG in %s through the external sprite",
|
|
240
|
+
(_, Component, isB2B) => {
|
|
241
|
+
const spritePath = `/megamenu-sprite-${isB2B ? "dark" : "light"}.svg`;
|
|
242
|
+
const sprite = new DOMParser().parseFromString(
|
|
243
|
+
readFileSync(`public${spritePath}`, "utf8"),
|
|
244
|
+
"image/svg+xml",
|
|
245
|
+
);
|
|
246
|
+
const { container } = render(
|
|
247
|
+
<Component isB2B={isB2B} className={isB2B ? "is-dark" : undefined} />,
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
expect(
|
|
251
|
+
container.querySelector("svg path, svg rect, svg circle"),
|
|
252
|
+
).toBeNull();
|
|
253
|
+
expect(container.querySelector('img[src$=".svg"]')).toBeNull();
|
|
254
|
+
for (const use of container.querySelectorAll("svg use")) {
|
|
255
|
+
const href = use.getAttribute("href") || use.getAttribute("xlink:href");
|
|
256
|
+
expect(href).toMatch(new RegExp(`^${spritePath}#`));
|
|
257
|
+
expect(use.parentElement.querySelectorAll("use")).toHaveLength(1);
|
|
258
|
+
expect(sprite.getElementById(href.split("#")[1])).not.toBeNull();
|
|
259
|
+
}
|
|
260
|
+
for (const wrapper of container.querySelectorAll(
|
|
261
|
+
".megamenu__input-wrapper",
|
|
262
|
+
)) {
|
|
263
|
+
expect(
|
|
264
|
+
wrapper.querySelector(".megamenu__input-search-icon use"),
|
|
265
|
+
).not.toBeNull();
|
|
266
|
+
expect(
|
|
267
|
+
wrapper.querySelector(".megamenu__input-status-icon use"),
|
|
268
|
+
).not.toBeNull();
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
describe("Megamenu dedicated sprites", () => {
|
|
275
|
+
it("keeps megamenu-owned sources and symbols out of the global sprite", () => {
|
|
276
|
+
const globalSprite = new DOMParser().parseFromString(
|
|
277
|
+
readFileSync("public/sprite.svg", "utf8"),
|
|
278
|
+
"image/svg+xml",
|
|
279
|
+
);
|
|
280
|
+
const sources = readdirSync("src/assets/megamenu").filter((file) =>
|
|
281
|
+
file.endsWith(".svg"),
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
expect(sources.length).toBeGreaterThan(0);
|
|
285
|
+
for (const file of sources) {
|
|
286
|
+
expect(existsSync(`src/assets/icons/${file}`), file).toBe(false);
|
|
287
|
+
expect(globalSprite.getElementById(file.slice(0, -4)), file).toBeNull();
|
|
288
|
+
}
|
|
289
|
+
expect(globalSprite.getElementById("rewards-accent")).toBeNull();
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
it("ships matching symbol IDs with theme colors and no unrelated global icons", () => {
|
|
293
|
+
const parse = (theme) =>
|
|
294
|
+
new DOMParser().parseFromString(
|
|
295
|
+
readFileSync(`public/megamenu-sprite-${theme}.svg`, "utf8"),
|
|
296
|
+
"image/svg+xml",
|
|
297
|
+
);
|
|
298
|
+
const light = parse("light");
|
|
299
|
+
const dark = parse("dark");
|
|
300
|
+
const ids = (doc) =>
|
|
301
|
+
Array.from(doc.querySelectorAll("symbol"), (s) => s.id);
|
|
302
|
+
expect(ids(light)).toEqual(ids(dark));
|
|
303
|
+
expect(ids(light)).toHaveLength(20);
|
|
304
|
+
expect(light.getElementById("user").getAttribute("fill")).toBe("#000");
|
|
305
|
+
expect(dark.getElementById("user").getAttribute("fill")).toBe("#fff");
|
|
306
|
+
expect(light.getElementById("linkedin")).toBeNull();
|
|
307
|
+
expect(light.getElementById("megamenu-logo").outerHTML).not.toEqual(
|
|
308
|
+
dark.getElementById("megamenu-logo").outerHTML,
|
|
309
|
+
);
|
|
310
|
+
expect(light.getElementById("store-apple").outerHTML).not.toEqual(
|
|
311
|
+
dark.getElementById("store-apple").outerHTML,
|
|
312
|
+
);
|
|
313
|
+
for (const doc of [light, dark]) {
|
|
314
|
+
expect(doc.querySelector("parsererror")).toBeNull();
|
|
315
|
+
for (const element of doc.querySelectorAll("[clip-path]")) {
|
|
316
|
+
const id = element
|
|
317
|
+
.getAttribute("clip-path")
|
|
318
|
+
.match(/url\(#([^)]+)\)/)?.[1];
|
|
319
|
+
expect(doc.getElementById(id)).not.toBeNull();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it.each([Megamenu, MegamenuBlog])(
|
|
326
|
+
"uses the dark sprite for an explicit dark navigation class",
|
|
327
|
+
(Component) => {
|
|
328
|
+
const { container } = render(<Component className="is-dark" />);
|
|
329
|
+
for (const use of container.querySelectorAll("use")) {
|
|
330
|
+
expect(use.getAttribute("xlink:href")).toMatch(
|
|
331
|
+
/^\/megamenu-sprite-dark\.svg#/,
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
},
|
|
335
|
+
);
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, test } from "vitest";
|
|
2
|
-
import { page } from "vitest/browser";
|
|
3
|
-
import { render } from "vitest-browser-react";
|
|
4
|
-
import { Button } from "../../Button";
|
|
5
|
-
import { Alert } from "../";
|
|
6
|
-
|
|
7
|
-
describe("Alert visual regression", () => {
|
|
8
|
-
beforeEach(async () => {
|
|
9
|
-
await page.viewport(1280, 720);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
test("Preview: title", async () => {
|
|
13
|
-
render(
|
|
14
|
-
<Alert data-testid="alert-title" title="Toto je jednoduchá sprava" />,
|
|
15
|
-
);
|
|
16
|
-
|
|
17
|
-
await expect(page.getByTestId("alert-title")).toMatchScreenshot(
|
|
18
|
-
"alert-preview-title",
|
|
19
|
-
);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
test("Preview: title and description", async () => {
|
|
23
|
-
render(
|
|
24
|
-
<Alert
|
|
25
|
-
data-testid="alert-title-description"
|
|
26
|
-
title="Dobre vediet!"
|
|
27
|
-
description="Popis toho co by bolo dobre vysvetlit. Aj na viac riadkov."
|
|
28
|
-
/>,
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
await expect(page.getByTestId("alert-title-description")).toMatchScreenshot(
|
|
32
|
-
"alert-preview-title-description",
|
|
33
|
-
);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
test("Preview: title and buttons", async () => {
|
|
37
|
-
render(
|
|
38
|
-
<Alert
|
|
39
|
-
data-testid="alert-title-buttons"
|
|
40
|
-
title="Prosim prihlaste sa."
|
|
41
|
-
actionButtons={[
|
|
42
|
-
<Button key="login">Prihlasit sa</Button>,
|
|
43
|
-
<Button key="hide">Skryt</Button>,
|
|
44
|
-
]}
|
|
45
|
-
/>,
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
await expect(page.getByTestId("alert-title-buttons")).toMatchScreenshot(
|
|
49
|
-
"alert-preview-title-buttons",
|
|
50
|
-
);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
test("Preview: title, description and buttons", async () => {
|
|
54
|
-
render(
|
|
55
|
-
<Alert
|
|
56
|
-
data-testid="alert-title-description-buttons"
|
|
57
|
-
title="Prihlasit sa je jednoduche a rozumne"
|
|
58
|
-
description="Napr. prihlaseni pouzivatelia vidia krajsie ceny."
|
|
59
|
-
actionButtons={<Button>Prihlasit sa</Button>}
|
|
60
|
-
/>,
|
|
61
|
-
);
|
|
62
|
-
|
|
63
|
-
await expect(
|
|
64
|
-
page.getByTestId("alert-title-description-buttons"),
|
|
65
|
-
).toMatchScreenshot("alert-preview-title-description-buttons");
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
test("Preview: success type", async () => {
|
|
69
|
-
render(
|
|
70
|
-
<Alert
|
|
71
|
-
data-testid="alert-success"
|
|
72
|
-
type="success"
|
|
73
|
-
title="Vyborne. Vsetko prebehlo rychlo a hladko"
|
|
74
|
-
/>,
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
await expect(page.getByTestId("alert-success")).toMatchScreenshot(
|
|
78
|
-
"alert-preview-success",
|
|
79
|
-
);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
test("Preview: warning type", async () => {
|
|
83
|
-
render(
|
|
84
|
-
<Alert
|
|
85
|
-
data-testid="alert-warning"
|
|
86
|
-
type="warning"
|
|
87
|
-
title="Na toto si daj pozor!"
|
|
88
|
-
/>,
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
await expect(page.getByTestId("alert-warning")).toMatchScreenshot(
|
|
92
|
-
"alert-preview-warning",
|
|
93
|
-
);
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
test("Preview: danger type", async () => {
|
|
97
|
-
render(
|
|
98
|
-
<Alert data-testid="alert-danger" type="danger" title="Stala sa chyba" />,
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
await expect(page.getByTestId("alert-danger")).toMatchScreenshot(
|
|
102
|
-
"alert-preview-danger",
|
|
103
|
-
);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
test("Preview: custom title renderer", async () => {
|
|
107
|
-
render(
|
|
108
|
-
<Alert
|
|
109
|
-
data-testid="alert-custom-title"
|
|
110
|
-
title="Prihlasit sa je jednoduche a rozumne"
|
|
111
|
-
renderTitle={(props) => (
|
|
112
|
-
<h3 className="alert__title mb-medium">{props.title}</h3>
|
|
113
|
-
)}
|
|
114
|
-
description="Popis toho co by bolo dobre vysvetlit. Aj na viac riadkov."
|
|
115
|
-
/>,
|
|
116
|
-
);
|
|
117
|
-
|
|
118
|
-
await expect(page.getByTestId("alert-custom-title")).toMatchScreenshot(
|
|
119
|
-
"alert-preview-custom-title",
|
|
120
|
-
);
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
test("Preview: full width", async () => {
|
|
124
|
-
render(
|
|
125
|
-
<Alert
|
|
126
|
-
data-testid="alert-full-width"
|
|
127
|
-
isFullWidth
|
|
128
|
-
title="Dobre vediet!"
|
|
129
|
-
description="Popis toho co by bolo dobre vysvetlit. Aj na viac riadkov."
|
|
130
|
-
/>,
|
|
131
|
-
);
|
|
132
|
-
|
|
133
|
-
await expect(page.getByTestId("alert-full-width")).toMatchScreenshot(
|
|
134
|
-
"alert-preview-full-width",
|
|
135
|
-
);
|
|
136
|
-
});
|
|
137
|
-
});
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, test } from "vitest";
|
|
2
|
-
import { page } from "vitest/browser";
|
|
3
|
-
import { render } from "vitest-browser-react";
|
|
4
|
-
|
|
5
|
-
import { CarouselHero, CarouselHeroItem } from "../";
|
|
6
|
-
|
|
7
|
-
const slides = (
|
|
8
|
-
<>
|
|
9
|
-
<CarouselHeroItem image="https://placehold.co/720x560?text=Slide+1">
|
|
10
|
-
<h2>Slide 1</h2>
|
|
11
|
-
<p>First slide content</p>
|
|
12
|
-
</CarouselHeroItem>
|
|
13
|
-
<CarouselHeroItem image="https://placehold.co/720x560?text=Slide+2">
|
|
14
|
-
<h2>Slide 2</h2>
|
|
15
|
-
<p>Second slide content</p>
|
|
16
|
-
</CarouselHeroItem>
|
|
17
|
-
<CarouselHeroItem image="https://placehold.co/720x560?text=Slide+3">
|
|
18
|
-
<h2>Slide 3</h2>
|
|
19
|
-
<p>Third slide content</p>
|
|
20
|
-
</CarouselHeroItem>
|
|
21
|
-
<CarouselHeroItem image="https://placehold.co/720x560?text=Slide+4">
|
|
22
|
-
<h2>Slide 4</h2>
|
|
23
|
-
<p>Fourth slide content</p>
|
|
24
|
-
</CarouselHeroItem>
|
|
25
|
-
<CarouselHeroItem image="https://placehold.co/720x560?text=Slide+5">
|
|
26
|
-
<h2>Slide 5</h2>
|
|
27
|
-
<p>Fifth slide content</p>
|
|
28
|
-
</CarouselHeroItem>
|
|
29
|
-
</>
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const tabs = [
|
|
33
|
-
{ label: "Motorola Edge 50 Fusion" },
|
|
34
|
-
{ label: "3 mesiace zadarmo" },
|
|
35
|
-
{ label: "Nekonečné dáta" },
|
|
36
|
-
{ label: "iPhone16 Pro" },
|
|
37
|
-
{ label: "HONOR 200" },
|
|
38
|
-
];
|
|
39
|
-
|
|
40
|
-
async function getCarouselState() {
|
|
41
|
-
return page.evaluate(() => {
|
|
42
|
-
const element = document.getElementById("carousel-hero-regression");
|
|
43
|
-
const instance = element?.ODS_CarouselHero?.instance;
|
|
44
|
-
|
|
45
|
-
return {
|
|
46
|
-
activeIndex: instance?.activeIndex,
|
|
47
|
-
realIndex: instance?.realIndex,
|
|
48
|
-
transform: instance?.wrapperEl?.style.transform ?? "",
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
describe("CarouselHero visual flow", () => {
|
|
54
|
-
beforeEach(async () => {
|
|
55
|
-
await page.viewport(1280, 720);
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
test("wraps and keeps adjacent tab navigation short", async () => {
|
|
59
|
-
render(
|
|
60
|
-
<CarouselHero id="carousel-hero-regression" tabs={tabs}>
|
|
61
|
-
{slides}
|
|
62
|
-
</CarouselHero>,
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
await expect(page.getByRole("tab", { name: "HONOR 200" })).toBeVisible();
|
|
66
|
-
|
|
67
|
-
await page.getByRole("tab", { name: "HONOR 200" }).click();
|
|
68
|
-
await page.waitForTimeout(500);
|
|
69
|
-
|
|
70
|
-
let state = await getCarouselState();
|
|
71
|
-
expect(state.realIndex).toBe(4);
|
|
72
|
-
expect(state.activeIndex).toBe(4);
|
|
73
|
-
|
|
74
|
-
await page.getByRole("button", { name: "Nasledujúci snímok" }).click();
|
|
75
|
-
await page.waitForTimeout(500);
|
|
76
|
-
|
|
77
|
-
state = await getCarouselState();
|
|
78
|
-
expect(state.realIndex).toBe(0);
|
|
79
|
-
expect(state.activeIndex).toBe(0);
|
|
80
|
-
|
|
81
|
-
await page.getByRole("tab", { name: "3 mesiace zadarmo" }).click();
|
|
82
|
-
await page.waitForTimeout(500);
|
|
83
|
-
|
|
84
|
-
state = await getCarouselState();
|
|
85
|
-
expect(state.realIndex).toBe(1);
|
|
86
|
-
expect(state.activeIndex).toBe(1);
|
|
87
|
-
expect(state.transform).toContain("translate3d");
|
|
88
|
-
expect(state.transform).toContain("-");
|
|
89
|
-
});
|
|
90
|
-
});
|