@orangesk/orange-design-system 2.0.0-beta.42 → 2.0.0-beta.44
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/build/components/AnchorNavigation/style.css +1 -1
- package/build/components/AnchorNavigation/style.css.map +1 -1
- package/build/components/BlockAction/style.css +1 -1
- package/build/components/BlockAction/style.css.map +1 -1
- package/build/components/BodyBanner/style.css +1 -1
- package/build/components/BodyBanner/style.css.map +1 -1
- package/build/components/Breadcrumbs/style.css +1 -1
- package/build/components/Breadcrumbs/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/Expander/style.css +1 -1
- package/build/components/Expander/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/Grid/style.css +1 -1
- package/build/components/Grid/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/Tag/style.css +1 -1
- package/build/components/Tag/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/index.d.ts +4 -2
- package/build/components/types/src/components/AnchorNavigation/AnchorNavigation.static.d.ts +27 -0
- package/build/components/types/src/components/Carousel/Carousel.static.d.ts +7 -5
- package/build/components/types/src/components/Expander/Expander.d.ts +2 -0
- package/build/components/types/src/components/Grid/Grid.d.ts +2 -2
- package/build/components/types/src/components/Megamenu/Megamenu.static.d.ts +3 -0
- package/build/components/types/src/components/Modal/Modal.static.d.ts +1 -0
- package/build/lib/base.css +1 -1
- 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/megamenu.js +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/style.css +1 -1
- package/build/lib/style.css.map +1 -1
- package/build/lib/tsconfig.tsbuildinfo +1 -1
- package/build/search-index.json +2 -2
- package/package.json +13 -13
- package/src/components/AnchorNavigation/AnchorNavigation.static.ts +247 -40
- package/src/components/AnchorNavigation/styles/mixins.scss +8 -0
- package/src/components/AnchorNavigation/tests/AnchorNavigation.unit.test.jsx +72 -0
- package/src/components/BlockAction/styles/mixins.scss +1 -1
- package/src/components/BodyBanner/styles/mixins.scss +2 -12
- package/src/components/Carousel/Carousel.static.ts +110 -79
- package/src/components/Carousel/styles/mixins.scss +2 -2
- package/src/components/Carousel/tests/Carousel.static.test.jsx +203 -0
- package/src/components/Expander/Expander.tsx +4 -0
- package/src/components/Expander/styles/style.scss +12 -0
- package/src/components/Expander/tests/Expander.conformance.test.jsx +4 -0
- package/src/components/Expander/tests/Expander.unit.test.jsx +9 -0
- package/src/components/Grid/Grid.tsx +5 -2
- package/src/components/Grid/styles/config.scss +3 -2
- package/src/components/Grid/tests/Grid.unit.test.jsx +40 -10
- package/src/components/Megamenu/Megamenu.static.ts +27 -1
- package/src/components/Megamenu/styles/mixins.scss +4 -0
- package/src/components/Modal/Modal.static.ts +29 -7
- package/src/components/Tag/styles/config.scss +5 -1
- package/src/components/Tag/styles/mixins.scss +2 -1
- package/src/styles/base/globals.scss +1 -0
- package/src/styles/export/base.js +1 -1
- package/src/styles/tokens/base.scss +1 -1
|
@@ -51,6 +51,18 @@
|
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
&--placement-top {
|
|
55
|
+
&[open] {
|
|
56
|
+
display: flex;
|
|
57
|
+
flex-direction: column-reverse;
|
|
58
|
+
|
|
59
|
+
summary {
|
|
60
|
+
margin-top: space.get("large");
|
|
61
|
+
margin-bottom: 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
54
66
|
&[open] {
|
|
55
67
|
svg[data-summary-icon] {
|
|
56
68
|
transform: rotate(180deg) !important;
|
|
@@ -184,4 +184,13 @@ describe("Expander", () => {
|
|
|
184
184
|
);
|
|
185
185
|
expect(getByTestId("test-id")).toHaveClass("expander--fullwidth");
|
|
186
186
|
});
|
|
187
|
+
|
|
188
|
+
it("applies placement-top class when placement prop is top", () => {
|
|
189
|
+
const { getByTestId } = render(
|
|
190
|
+
<Expander data-testid="test-id" summary="Show details" placement="top">
|
|
191
|
+
Content
|
|
192
|
+
</Expander>,
|
|
193
|
+
);
|
|
194
|
+
expect(getByTestId("test-id")).toHaveClass("expander--placement-top");
|
|
195
|
+
});
|
|
187
196
|
});
|
|
@@ -5,17 +5,20 @@ import { genResponsiveClasses } from "../../utils";
|
|
|
5
5
|
export type GridVAlign = "stretch" | "start" | "end" | "center";
|
|
6
6
|
export type GridHAlign = "end" | "center" | "space-around" | "space-between";
|
|
7
7
|
export type GridRowGapSize =
|
|
8
|
+
| "none"
|
|
9
|
+
| "xsmall"
|
|
8
10
|
| "small"
|
|
9
11
|
| "medium"
|
|
10
12
|
| "large"
|
|
11
13
|
| "xlarge"
|
|
12
|
-
| Record<string, "small" | "medium" | "large" | "xlarge">;
|
|
14
|
+
| Record<string, "none" | "xsmall" | "small" | "medium" | "large" | "xlarge">;
|
|
13
15
|
export type GridColumnGapSize =
|
|
14
16
|
| "none"
|
|
15
17
|
| "small"
|
|
16
18
|
| "default"
|
|
17
19
|
| "large"
|
|
18
|
-
|
|
|
20
|
+
| "xlarge"
|
|
21
|
+
| Record<string, "none" | "small" | "default" | "large" | "xlarge">;
|
|
19
22
|
|
|
20
23
|
export interface GridProps extends React.HTMLAttributes<HTMLElement> {
|
|
21
24
|
vAlign?: GridVAlign;
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
$grid-base: 12 !default;
|
|
4
4
|
|
|
5
|
-
$grid-row-gap-sizes: ("small", "medium", "large", "xlarge");
|
|
6
|
-
$grid-column-gap-sizes: ("none", "small", "default", "large");
|
|
5
|
+
$grid-row-gap-sizes: ("none", "xsmall", "small", "medium", "large", "xlarge");
|
|
6
|
+
$grid-column-gap-sizes: ("none", "small", "default", "large", "xlarge");
|
|
7
7
|
|
|
8
8
|
$column-gap: (
|
|
9
9
|
none: 0,
|
|
10
10
|
small: space.get("xsmall"),
|
|
11
11
|
default: space.get("small"),
|
|
12
12
|
large: space.get("medium"),
|
|
13
|
+
xlarge: space.get("large"),
|
|
13
14
|
);
|
|
@@ -52,16 +52,20 @@ describe("Grid", () => {
|
|
|
52
52
|
expect(getByTestId("test-id")).toHaveClass("grid--justify-height");
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
["medium", "large", "xlarge"].forEach(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
["none", "xsmall", "small", "medium", "large", "xlarge"].forEach(
|
|
56
|
+
(rowGapSize) => {
|
|
57
|
+
it(`applies grid-row-gap--${rowGapSize} class when rowGapSize is ${rowGapSize}`, () => {
|
|
58
|
+
const { getByTestId } = render(
|
|
59
|
+
<Grid data-testid="test-id" rowGapSize={rowGapSize} />,
|
|
60
|
+
);
|
|
61
|
+
expect(getByTestId("test-id")).toHaveClass(
|
|
62
|
+
`grid-row-gap--${rowGapSize}`,
|
|
63
|
+
);
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
["small", "large", "xlarge", "none"].forEach((columnGapSize) => {
|
|
65
69
|
it(`applies grid-column-gap--${columnGapSize} class when columnGapSize is ${columnGapSize}`, () => {
|
|
66
70
|
const { getByTestId } = render(
|
|
67
71
|
<Grid data-testid="test-id" columnGapSize={columnGapSize} />,
|
|
@@ -72,6 +76,32 @@ describe("Grid", () => {
|
|
|
72
76
|
});
|
|
73
77
|
});
|
|
74
78
|
|
|
79
|
+
it("applies responsive row gap classes when rowGapSize is object", () => {
|
|
80
|
+
const { getByTestId } = render(
|
|
81
|
+
<Grid
|
|
82
|
+
data-testid="test-id"
|
|
83
|
+
rowGapSize={{ xs: "medium", md: "xlarge" }}
|
|
84
|
+
/>,
|
|
85
|
+
);
|
|
86
|
+
expect(getByTestId("test-id")).toHaveClass(
|
|
87
|
+
"grid-row-gap--medium",
|
|
88
|
+
"grid-row-gap--md-xlarge",
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("applies responsive column gap classes when columnGapSize is object", () => {
|
|
93
|
+
const { getByTestId } = render(
|
|
94
|
+
<Grid
|
|
95
|
+
data-testid="test-id"
|
|
96
|
+
columnGapSize={{ xs: "small", lg: "xlarge" }}
|
|
97
|
+
/>,
|
|
98
|
+
);
|
|
99
|
+
expect(getByTestId("test-id")).toHaveClass(
|
|
100
|
+
"grid-column-gap--small",
|
|
101
|
+
"grid-column-gap--lg-xlarge",
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
|
|
75
105
|
it("merges additional className", () => {
|
|
76
106
|
const { getByTestId } = render(
|
|
77
107
|
<Grid data-testid="test-id" className="test-class" />,
|
|
@@ -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 (
|
|
438
|
+
if (effectiveScrollY > 15) {
|
|
413
439
|
topElement.classList.add("is-hidden");
|
|
414
440
|
this.element.classList.add("top-hidden");
|
|
415
441
|
} else {
|
|
@@ -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(
|
|
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
|
-
|
|
205
|
-
|
|
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:
|
|
241
|
+
top: Number.isFinite(scrollTop) ? scrollTop : 0,
|
|
220
242
|
left: 0,
|
|
221
243
|
behavior: "instant",
|
|
222
244
|
});
|
|
@@ -15,18 +15,21 @@ $sizes: (
|
|
|
15
15
|
font-size: convert.to-rem(14px) "!important",
|
|
16
16
|
line-height: 1rem "!important",
|
|
17
17
|
font-weight: 700,
|
|
18
|
+
border-width: 1px,
|
|
18
19
|
),
|
|
19
20
|
small: (
|
|
20
21
|
padding: convert.to-rem(2px) convert.to-rem(8px),
|
|
21
22
|
font-size: convert.to-rem(12px) "!important",
|
|
22
23
|
line-height: convert.to-rem(14px) "!important",
|
|
23
24
|
font-weight: 400,
|
|
25
|
+
border-width: 2px,
|
|
24
26
|
),
|
|
25
27
|
large: (
|
|
26
28
|
padding: convert.to-rem(11px) convert.to-rem(15px),
|
|
27
29
|
font-size: convert.to-rem(16px) "!important",
|
|
28
30
|
line-height: convert.to-rem(18px) "!important",
|
|
29
31
|
font-weight: 700,
|
|
32
|
+
border-width: 2px,
|
|
30
33
|
),
|
|
31
34
|
);
|
|
32
35
|
|
|
@@ -83,7 +86,8 @@ $colors: (
|
|
|
83
86
|
"transparent": (
|
|
84
87
|
background-color: transparent,
|
|
85
88
|
color: var(--color-text-default),
|
|
86
|
-
border:
|
|
89
|
+
border-color: var(--color-border-strong),
|
|
90
|
+
border-style: solid,
|
|
87
91
|
),
|
|
88
92
|
);
|
|
89
93
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Do not edit this file directly - edit the SCSS source instead
|
|
3
3
|
|
|
4
4
|
export const exports = {
|
|
5
|
-
"font-family": "OrangeSK Neue,
|
|
5
|
+
"font-family": "OrangeSK Neue, Helvetica Neue, Helvetica, Arial, sans-serif",
|
|
6
6
|
"font-size": "16px",
|
|
7
7
|
"line-height": "1.25",
|
|
8
8
|
"background": "var(--color-background-primary)",
|