@orangesk/orange-design-system 2.0.0-beta.11 → 2.0.0-beta.12
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/index.js +5 -5
- package/build/components/index.js.map +1 -1
- package/build/components/tsconfig.tsbuildinfo +1 -1
- package/build/components/types/index.d.ts +5 -3
- package/build/components/types/src/components/Carousel/Carousel.static.d.ts +34 -1
- package/build/components/types/src/components/Cover/Cover.d.ts +3 -3
- package/build/components/types/src/components/Pill/Pill.d.ts +1 -1
- package/build/components/types/src/components/Table/Table.d.ts +2 -0
- package/build/components/types/src/components/Table/docsData.d.ts +2 -0
- package/build/components/types/src/components/Table/types.d.ts +1 -0
- package/build/lib/components.css +1 -1
- package/build/lib/components.css.map +1 -1
- package/build/lib/scripts.js +4 -4
- package/build/lib/scripts.js.map +1 -1
- package/build/lib/style.css +1 -1
- package/build/lib/style.css.map +1 -1
- package/package.json +5 -5
- package/src/components/AnchorNavigation/AnchorNavigation.static.ts +3 -0
- package/src/components/Button/styles/config.scss +5 -4
- package/src/components/Carousel/Carousel.static.ts +204 -1
- package/src/components/Carousel/tests/Carousel.static.test.js +403 -0
- package/src/components/Carousel/tests/Carousel.unit.test.js +68 -0
- package/src/components/Cover/Cover.tsx +22 -20
- package/src/components/Cover/styles/config.scss +23 -12
- package/src/components/Cover/styles/mixins.scss +6 -5
- package/src/components/Cover/tests/Cover.unit.test.js +52 -52
- package/src/components/Forms/Group/styles/mixins.scss +14 -0
- package/src/components/Pill/Pill.tsx +10 -2
- package/src/components/Pill/styles/config.scss +2 -21
- package/src/components/Pill/styles/style.scss +16 -6
- package/src/components/Pill/tests/Pill.conformance.test.js +8 -2
- package/src/components/Pill/tests/Pill.unit.test.js +69 -11
- package/src/components/Table/Row.tsx +9 -3
- package/src/components/Table/Table.tsx +11 -1
- package/src/components/Table/TableContext.ts +1 -0
- package/src/components/Table/docsData.ts +25 -0
- package/src/components/Table/styles/mixins.scss +37 -0
- package/src/components/Table/styles/style.scss +6 -0
- package/src/components/Table/types.ts +1 -0
- package/src/components/Tooltip/InfoTooltip.tsx +1 -5
- package/src/styles/tokens/color.scss +1 -1
|
@@ -1,113 +1,113 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { render } from
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@testing-library/react";
|
|
3
3
|
|
|
4
|
-
import { Cover } from
|
|
4
|
+
import { Cover } from "../Cover";
|
|
5
5
|
|
|
6
|
-
const image =
|
|
6
|
+
const image = "/test-image.jpg";
|
|
7
7
|
const picture = {
|
|
8
|
-
default:
|
|
9
|
-
md:
|
|
10
|
-
xl:
|
|
8
|
+
default: "/test-picture.jpg",
|
|
9
|
+
md: "/test-picture-md.jpg",
|
|
10
|
+
xl: "/test-picture-xl.jpg",
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
// bgSrc prop is required
|
|
14
|
-
describe(
|
|
15
|
-
describe(
|
|
16
|
-
it(
|
|
14
|
+
describe("rendering Cover", () => {
|
|
15
|
+
describe("initial state", () => {
|
|
16
|
+
it("has default class cover", () => {
|
|
17
17
|
const { container } = render(<Cover bgSrc={image} />);
|
|
18
|
-
expect(container.getElementsByClassName(
|
|
18
|
+
expect(container.getElementsByClassName("cover").length).toBe(1);
|
|
19
19
|
});
|
|
20
|
-
it(
|
|
20
|
+
it("has default class cover__image", () => {
|
|
21
21
|
const { container } = render(<Cover bgSrc={image} />);
|
|
22
|
-
expect(container.getElementsByClassName(
|
|
22
|
+
expect(container.getElementsByClassName("cover__image").length).toBe(1);
|
|
23
23
|
});
|
|
24
24
|
});
|
|
25
|
-
describe(
|
|
26
|
-
it(
|
|
25
|
+
describe("passed props", () => {
|
|
26
|
+
it("passes other props", () => {
|
|
27
27
|
const { getByTestId } = render(
|
|
28
|
-
<Cover data-testid="test" bgSrc={image}
|
|
28
|
+
<Cover data-testid="test" bgSrc={image} />,
|
|
29
29
|
);
|
|
30
|
-
expect(getByTestId(
|
|
30
|
+
expect(getByTestId("test")).toBeInTheDocument();
|
|
31
31
|
});
|
|
32
|
-
it(
|
|
32
|
+
it("renders children", () => {
|
|
33
33
|
const { getByText } = render(<Cover bgSrc={image}>test-text</Cover>);
|
|
34
|
-
expect(getByText(
|
|
34
|
+
expect(getByText("test-text")).toBeInTheDocument();
|
|
35
35
|
});
|
|
36
|
-
it(
|
|
36
|
+
it("has additional class when className is set", () => {
|
|
37
37
|
const { container } = render(
|
|
38
|
-
<Cover bgSrc={image} className="test-class"
|
|
38
|
+
<Cover bgSrc={image} className="test-class" />,
|
|
39
39
|
);
|
|
40
|
-
expect(container.getElementsByClassName(
|
|
41
|
-
expect(container.getElementsByClassName(
|
|
40
|
+
expect(container.getElementsByClassName("cover").length).toBe(1);
|
|
41
|
+
expect(container.getElementsByClassName("test-class").length).toBe(1);
|
|
42
42
|
});
|
|
43
|
-
it(
|
|
43
|
+
it("has class cover__content when children are set", () => {
|
|
44
44
|
const { container } = render(<Cover bgSrc={image}>test</Cover>);
|
|
45
|
-
expect(container.getElementsByClassName(
|
|
45
|
+
expect(container.getElementsByClassName("cover__content").length).toBe(1);
|
|
46
46
|
});
|
|
47
|
-
it(
|
|
47
|
+
it("has additional class when contentClass and children are set", () => {
|
|
48
48
|
const { container } = render(
|
|
49
49
|
<Cover bgSrc={image} contentClass="test-content-class">
|
|
50
50
|
test
|
|
51
|
-
</Cover
|
|
51
|
+
</Cover>,
|
|
52
52
|
);
|
|
53
53
|
expect(
|
|
54
|
-
container.getElementsByClassName(
|
|
54
|
+
container.getElementsByClassName("test-content-class").length,
|
|
55
55
|
).toBe(1);
|
|
56
56
|
});
|
|
57
|
-
[
|
|
57
|
+
["small", "medium", "large", "xlarge"].map((size) => {
|
|
58
58
|
it(`has cover--${size} class when size is set to ${size}`, () => {
|
|
59
59
|
const { container } = render(<Cover bgSrc={image} size={size} />);
|
|
60
60
|
expect(container.getElementsByClassName(`cover--${size}`).length).toBe(
|
|
61
|
-
1
|
|
61
|
+
1,
|
|
62
62
|
);
|
|
63
63
|
});
|
|
64
64
|
});
|
|
65
|
-
[
|
|
65
|
+
["top", "bottom"].map((position) => {
|
|
66
66
|
it(`has cover__image--${position} class when bgPosition is set to ${position}`, () => {
|
|
67
67
|
const { container } = render(
|
|
68
|
-
<Cover bgSrc={image} bgPosition={position}
|
|
68
|
+
<Cover bgSrc={image} bgPosition={position} />,
|
|
69
69
|
);
|
|
70
70
|
expect(
|
|
71
|
-
container.getElementsByClassName(`cover__image--${position}`).length
|
|
71
|
+
container.getElementsByClassName(`cover__image--${position}`).length,
|
|
72
72
|
).toBe(1);
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
|
-
it(
|
|
75
|
+
it("doesnt have cover__image--center class when bgPosition is set to center", () => {
|
|
76
76
|
const { container } = render(<Cover bgSrc={image} bgPosition="center" />);
|
|
77
77
|
expect(
|
|
78
|
-
container.getElementsByClassName(
|
|
78
|
+
container.getElementsByClassName("cover__image--center").length,
|
|
79
79
|
).toBe(0);
|
|
80
80
|
});
|
|
81
|
-
it(
|
|
81
|
+
it("renders img element, not picture, when bgSrc is set to string", () => {
|
|
82
82
|
const { container } = render(<Cover bgSrc={image} />);
|
|
83
|
-
expect(container.querySelectorAll(
|
|
84
|
-
expect(container.querySelectorAll(
|
|
83
|
+
expect(container.querySelectorAll("img").length).toBe(1);
|
|
84
|
+
expect(container.querySelectorAll("picture").length).toBe(0);
|
|
85
85
|
});
|
|
86
|
-
it(
|
|
86
|
+
it("img element has src set to bgSrc when bgSrc is string", () => {
|
|
87
87
|
const { container } = render(<Cover bgSrc={image} />);
|
|
88
|
-
expect(container.querySelector(
|
|
89
|
-
|
|
88
|
+
expect(container.querySelector("img").getAttribute("src")).toBe(
|
|
89
|
+
"/test-image.jpg",
|
|
90
90
|
);
|
|
91
91
|
});
|
|
92
|
-
it(
|
|
92
|
+
it("renders picture element with source and img elements when bgSrc is set to object with multiple properties", () => {
|
|
93
93
|
const { container } = render(<Cover bgSrc={picture} />);
|
|
94
|
-
expect(container.querySelectorAll(
|
|
95
|
-
expect(container.querySelectorAll(
|
|
96
|
-
expect(container.querySelectorAll(
|
|
94
|
+
expect(container.querySelectorAll("picture").length).toBe(1);
|
|
95
|
+
expect(container.querySelectorAll("img").length).toBe(1);
|
|
96
|
+
expect(container.querySelectorAll("source").length > 0).toBeTruthy();
|
|
97
97
|
});
|
|
98
|
-
it(
|
|
98
|
+
it("img element has src set to bgSrc.default when bgSrc is object", () => {
|
|
99
99
|
const { container } = render(<Cover bgSrc={picture} />);
|
|
100
|
-
expect(container.querySelector(
|
|
101
|
-
picture.default
|
|
100
|
+
expect(container.querySelector("img").getAttribute("src")).toBe(
|
|
101
|
+
picture.default,
|
|
102
102
|
);
|
|
103
103
|
});
|
|
104
104
|
Object.keys(picture)
|
|
105
|
-
.filter(el => el !==
|
|
106
|
-
.map(key => {
|
|
107
|
-
it(
|
|
105
|
+
.filter((el) => el !== "default")
|
|
106
|
+
.map((key) => {
|
|
107
|
+
it("srcSet of source element has correct value from bgSrc object", () => {
|
|
108
108
|
const { container } = render(<Cover bgSrc={picture} />);
|
|
109
109
|
const correctSource = container.querySelector(
|
|
110
|
-
`source[srcset="${picture[key]}"]
|
|
110
|
+
`source[srcset="${picture[key]}"]`,
|
|
111
111
|
);
|
|
112
112
|
expect(correctSource).toBeInTheDocument();
|
|
113
113
|
});
|
|
@@ -34,6 +34,20 @@
|
|
|
34
34
|
border-top-left-radius: 0;
|
|
35
35
|
border-bottom-left-radius: 0;
|
|
36
36
|
}
|
|
37
|
+
|
|
38
|
+
> *:not(:first-child):not(:last-child) {
|
|
39
|
+
border-radius: 0 !important;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
> *:first-child:not(:last-child) {
|
|
43
|
+
border-top-right-radius: 0 !important;
|
|
44
|
+
border-bottom-right-radius: 0 !important;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
> *:last-child:not(:first-child) {
|
|
48
|
+
border-top-left-radius: 0 !important;
|
|
49
|
+
border-bottom-left-radius: 0 !important;
|
|
50
|
+
}
|
|
37
51
|
}
|
|
38
52
|
|
|
39
53
|
@mixin item($config: config.$item) {
|
|
@@ -3,7 +3,15 @@ import cx from "classnames";
|
|
|
3
3
|
|
|
4
4
|
const CLASS_ROOT = "pill";
|
|
5
5
|
|
|
6
|
-
export const pillColors = [
|
|
6
|
+
export const pillColors = [
|
|
7
|
+
"surface-primary",
|
|
8
|
+
"surface-secondary",
|
|
9
|
+
"surface-tertiary",
|
|
10
|
+
"surface-subtle",
|
|
11
|
+
"surface-moderate",
|
|
12
|
+
"surface-accent",
|
|
13
|
+
"transparent",
|
|
14
|
+
] as const;
|
|
7
15
|
export type PillColor = (typeof pillColors)[number];
|
|
8
16
|
|
|
9
17
|
interface PillProps extends HTMLAttributes<HTMLSpanElement> {
|
|
@@ -26,11 +34,11 @@ const Pill: React.FC<PillProps> = ({
|
|
|
26
34
|
className={cx(
|
|
27
35
|
CLASS_ROOT,
|
|
28
36
|
{
|
|
29
|
-
[`${CLASS_ROOT}--${color}`]: color, // Only apply modifier if color is specified
|
|
30
37
|
"is-light": colorScheme === "light",
|
|
31
38
|
"is-dark": colorScheme === "dark",
|
|
32
39
|
[CLASS_ROOT + "--" + size]: size,
|
|
33
40
|
},
|
|
41
|
+
color,
|
|
34
42
|
className,
|
|
35
43
|
)}
|
|
36
44
|
{...other}
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
$base: (
|
|
6
6
|
font-weight: bold,
|
|
7
|
-
background-color:
|
|
8
|
-
color: color
|
|
7
|
+
background-color: var(--color-surface-contrast),
|
|
8
|
+
color: var(--color-text-inverse),
|
|
9
9
|
);
|
|
10
10
|
|
|
11
11
|
$sizes: (
|
|
@@ -21,22 +21,3 @@ $sizes: (
|
|
|
21
21
|
xxlarge: convert.to-rem(64px),
|
|
22
22
|
),
|
|
23
23
|
);
|
|
24
|
-
|
|
25
|
-
$colors: (
|
|
26
|
-
"white": (
|
|
27
|
-
background-color: color.$white,
|
|
28
|
-
color: color.$black,
|
|
29
|
-
),
|
|
30
|
-
"gray": (
|
|
31
|
-
background-color: var(--color-surface-subtle),
|
|
32
|
-
color: var(--color-text-default),
|
|
33
|
-
),
|
|
34
|
-
"orange": (
|
|
35
|
-
background-color: var(--color-icon-brand),
|
|
36
|
-
color: var(--color-text-inverse),
|
|
37
|
-
),
|
|
38
|
-
"transparent": (
|
|
39
|
-
background-color: rgba(#ffffff, 0.5),
|
|
40
|
-
color: var(--color-text-default),
|
|
41
|
-
),
|
|
42
|
-
);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@use "../../../styles/tokens/color";
|
|
1
2
|
@use "../../../styles/tools/generate";
|
|
2
3
|
@use "./config";
|
|
3
4
|
@use "./mixins";
|
|
@@ -8,12 +9,21 @@
|
|
|
8
9
|
@include mixins.base();
|
|
9
10
|
@include mixins.sizes();
|
|
10
11
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
&.surface-primary,
|
|
13
|
+
&.surface-subtle,
|
|
14
|
+
&.surface-moderate,
|
|
15
|
+
&.surface-accent {
|
|
16
|
+
color: var(--color-text-default);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
&.surface-secondary,
|
|
20
|
+
&.surface-tertiary {
|
|
21
|
+
color: color.$white;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
&.transparent {
|
|
25
|
+
background-color: rgba(#ffffff, 0.5);
|
|
26
|
+
color: var(--color-text-default);
|
|
17
27
|
}
|
|
18
28
|
}
|
|
19
29
|
}
|
|
@@ -19,13 +19,19 @@ const example = (
|
|
|
19
19
|
</p>
|
|
20
20
|
<p>
|
|
21
21
|
<Pill color="transparent">T</Pill>
|
|
22
|
-
<Pill color="
|
|
23
|
-
<Pill color="
|
|
22
|
+
<Pill color="surface-secondary">S</Pill>
|
|
23
|
+
<Pill color="surface-tertiary">T</Pill>
|
|
24
|
+
<Pill color="surface-subtle">Su</Pill>
|
|
25
|
+
<Pill color="surface-moderate">M</Pill>
|
|
26
|
+
<Pill color="surface-contrast">C</Pill>
|
|
27
|
+
<Pill color="surface-accent">A</Pill>
|
|
24
28
|
</p>
|
|
25
29
|
<p>
|
|
26
30
|
<Pill size="small">S</Pill>
|
|
27
31
|
<Pill size="medium">M</Pill>
|
|
28
32
|
<Pill size="large">L</Pill>
|
|
33
|
+
<Pill size="xlarge">XL</Pill>
|
|
34
|
+
<Pill size="xxlarge">XXL</Pill>
|
|
29
35
|
</p>
|
|
30
36
|
<p>
|
|
31
37
|
<Pill colorScheme="light">Light</Pill>
|
|
@@ -35,28 +35,78 @@ describe("rendering Pill", () => {
|
|
|
35
35
|
expect(getByTestId("test-id")).toHaveClass("pill--large");
|
|
36
36
|
});
|
|
37
37
|
|
|
38
|
-
it("
|
|
38
|
+
it("supports all available sizes", () => {
|
|
39
|
+
const sizes = ["small", "medium", "large", "xlarge", "xxlarge"];
|
|
40
|
+
|
|
41
|
+
sizes.forEach((size) => {
|
|
42
|
+
const { getByTestId } = render(
|
|
43
|
+
<Pill size={size} data-testid={`test-${size}`}>
|
|
44
|
+
{size}
|
|
45
|
+
</Pill>,
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
expect(getByTestId(`test-${size}`)).toHaveClass(`pill--${size}`);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it("has default styling without color modifier", () => {
|
|
39
53
|
const { getByTestId } = render(<Pill data-testid="test-id">pill</Pill>);
|
|
40
54
|
expect(getByTestId("test-id")).toHaveClass("pill");
|
|
41
|
-
expect(getByTestId("test-id")).not.toHaveClass("
|
|
55
|
+
expect(getByTestId("test-id")).not.toHaveClass("surface-secondary");
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("has surface-secondary class when color is surface-secondary", () => {
|
|
59
|
+
const { getByTestId } = render(
|
|
60
|
+
<Pill color="surface-secondary" data-testid="test-id">
|
|
61
|
+
pill
|
|
62
|
+
</Pill>,
|
|
63
|
+
);
|
|
64
|
+
expect(getByTestId("test-id")).toHaveClass("surface-secondary");
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("has surface-tertiary class when color is surface-tertiary", () => {
|
|
68
|
+
const { getByTestId } = render(
|
|
69
|
+
<Pill color="surface-tertiary" data-testid="test-id">
|
|
70
|
+
pill
|
|
71
|
+
</Pill>,
|
|
72
|
+
);
|
|
73
|
+
expect(getByTestId("test-id")).toHaveClass("surface-tertiary");
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it("has surface-subtle class when color is surface-subtle", () => {
|
|
77
|
+
const { getByTestId } = render(
|
|
78
|
+
<Pill color="surface-subtle" data-testid="test-id">
|
|
79
|
+
pill
|
|
80
|
+
</Pill>,
|
|
81
|
+
);
|
|
82
|
+
expect(getByTestId("test-id")).toHaveClass("surface-subtle");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("has surface-moderate class when color is surface-moderate", () => {
|
|
86
|
+
const { getByTestId } = render(
|
|
87
|
+
<Pill color="surface-moderate" data-testid="test-id">
|
|
88
|
+
pill
|
|
89
|
+
</Pill>,
|
|
90
|
+
);
|
|
91
|
+
expect(getByTestId("test-id")).toHaveClass("surface-moderate");
|
|
42
92
|
});
|
|
43
93
|
|
|
44
|
-
it("has
|
|
94
|
+
it("has surface-contrast class when color is surface-contrast", () => {
|
|
45
95
|
const { getByTestId } = render(
|
|
46
|
-
<Pill color="
|
|
96
|
+
<Pill color="surface-contrast" data-testid="test-id">
|
|
47
97
|
pill
|
|
48
98
|
</Pill>,
|
|
49
99
|
);
|
|
50
|
-
expect(getByTestId("test-id")).toHaveClass("
|
|
100
|
+
expect(getByTestId("test-id")).toHaveClass("surface-contrast");
|
|
51
101
|
});
|
|
52
102
|
|
|
53
|
-
it("has
|
|
103
|
+
it("has surface-accent class when color is surface-accent", () => {
|
|
54
104
|
const { getByTestId } = render(
|
|
55
|
-
<Pill color="
|
|
105
|
+
<Pill color="surface-accent" data-testid="test-id">
|
|
56
106
|
pill
|
|
57
107
|
</Pill>,
|
|
58
108
|
);
|
|
59
|
-
expect(getByTestId("test-id")).toHaveClass("
|
|
109
|
+
expect(getByTestId("test-id")).toHaveClass("surface-accent");
|
|
60
110
|
});
|
|
61
111
|
|
|
62
112
|
it("has transparent class when color is transparent", () => {
|
|
@@ -65,11 +115,19 @@ describe("rendering Pill", () => {
|
|
|
65
115
|
pill
|
|
66
116
|
</Pill>,
|
|
67
117
|
);
|
|
68
|
-
expect(getByTestId("test-id")).toHaveClass("
|
|
118
|
+
expect(getByTestId("test-id")).toHaveClass("transparent");
|
|
69
119
|
});
|
|
70
120
|
|
|
71
121
|
it("supports all available colors", () => {
|
|
72
|
-
const colors = [
|
|
122
|
+
const colors = [
|
|
123
|
+
"surface-secondary",
|
|
124
|
+
"surface-tertiary",
|
|
125
|
+
"surface-subtle",
|
|
126
|
+
"surface-moderate",
|
|
127
|
+
"surface-contrast",
|
|
128
|
+
"surface-accent",
|
|
129
|
+
"transparent",
|
|
130
|
+
];
|
|
73
131
|
|
|
74
132
|
colors.forEach((color) => {
|
|
75
133
|
const { getByTestId } = render(
|
|
@@ -78,7 +136,7 @@ describe("rendering Pill", () => {
|
|
|
78
136
|
</Pill>,
|
|
79
137
|
);
|
|
80
138
|
|
|
81
|
-
expect(getByTestId(`test-${color}`)).toHaveClass(
|
|
139
|
+
expect(getByTestId(`test-${color}`)).toHaveClass(color);
|
|
82
140
|
});
|
|
83
141
|
});
|
|
84
142
|
|
|
@@ -14,8 +14,9 @@ interface RowProps {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
const Row = ({ row }: RowProps) => {
|
|
17
|
-
const { headers, expandableRows } =
|
|
18
|
-
|
|
17
|
+
const { headers, expandableRows, isResponsive } =
|
|
18
|
+
React.useContext(TableContext);
|
|
19
|
+
return headers.map(({ key, label, cellProps }, index, array) => {
|
|
19
20
|
const cell = row[key];
|
|
20
21
|
const isObject = typeof cell === "object" && cell !== null;
|
|
21
22
|
const value = isObject && "value" in cell ? cell.value : cell;
|
|
@@ -26,9 +27,14 @@ const Row = ({ row }: RowProps) => {
|
|
|
26
27
|
.reduce((acc, [k, v]) => ({ ...acc, [k]: v }), {})
|
|
27
28
|
: {};
|
|
28
29
|
const rl = row?.expand?.length || 0;
|
|
30
|
+
|
|
29
31
|
return (
|
|
30
32
|
<React.Fragment key={key}>
|
|
31
|
-
<Cell
|
|
33
|
+
<Cell
|
|
34
|
+
{...cellProps}
|
|
35
|
+
{...props}
|
|
36
|
+
{...(isResponsive && { "data-label": label })}
|
|
37
|
+
>
|
|
32
38
|
{value ? (value as React.ReactNode) : ""}
|
|
33
39
|
</Cell>
|
|
34
40
|
{index === array.length - 1 &&
|
|
@@ -23,6 +23,8 @@ interface TableProps extends React.TableHTMLAttributes<HTMLTableElement> {
|
|
|
23
23
|
headers: TableHeader[];
|
|
24
24
|
/** Compact table only takes spaced needed to display its content */
|
|
25
25
|
isCompact?: boolean;
|
|
26
|
+
/** Enable responsive card layout below md breakpoint for better accessibility */
|
|
27
|
+
isResponsive?: boolean;
|
|
26
28
|
/** If table has horizontal scrollbar */
|
|
27
29
|
isScrollable?: boolean;
|
|
28
30
|
/** Different colors for even and odd rows. */
|
|
@@ -43,6 +45,7 @@ const Table: React.FC<TableProps> = ({
|
|
|
43
45
|
rows,
|
|
44
46
|
footers,
|
|
45
47
|
isCompact,
|
|
48
|
+
isResponsive,
|
|
46
49
|
isStriped,
|
|
47
50
|
isScrollable,
|
|
48
51
|
colorScheme,
|
|
@@ -60,6 +63,7 @@ const Table: React.FC<TableProps> = ({
|
|
|
60
63
|
{
|
|
61
64
|
[`${CLASS_ROOT}--striped`]: isStriped,
|
|
62
65
|
[`${CLASS_ROOT}--compact`]: isCompact,
|
|
66
|
+
[`${CLASS_ROOT}--responsive`]: isResponsive,
|
|
63
67
|
"is-dark": colorScheme === "dark",
|
|
64
68
|
"is-light": colorScheme === "light",
|
|
65
69
|
},
|
|
@@ -94,6 +98,7 @@ const Table: React.FC<TableProps> = ({
|
|
|
94
98
|
footers,
|
|
95
99
|
rows: customRows,
|
|
96
100
|
expandableRows,
|
|
101
|
+
isResponsive,
|
|
97
102
|
};
|
|
98
103
|
|
|
99
104
|
const table = (
|
|
@@ -108,7 +113,12 @@ const Table: React.FC<TableProps> = ({
|
|
|
108
113
|
/>
|
|
109
114
|
}
|
|
110
115
|
>
|
|
111
|
-
<table
|
|
116
|
+
<table
|
|
117
|
+
ref={tableRef}
|
|
118
|
+
className={classes}
|
|
119
|
+
{...(isResponsive && { "data-table": "responsive" })}
|
|
120
|
+
{...other}
|
|
121
|
+
>
|
|
112
122
|
{caption && (
|
|
113
123
|
<caption {...(isScrollable && { id: captionId })}>
|
|
114
124
|
{caption}
|
|
@@ -208,3 +208,28 @@ export const fillRows: TableRow[] = [
|
|
|
208
208
|
col2: "3",
|
|
209
209
|
},
|
|
210
210
|
];
|
|
211
|
+
|
|
212
|
+
export const responsiveHeaders: TableHeader[] = [
|
|
213
|
+
{
|
|
214
|
+
key: "account",
|
|
215
|
+
label: "Účel spracovania",
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
key: "legal",
|
|
219
|
+
label: "Právny základ a doba spracovania",
|
|
220
|
+
},
|
|
221
|
+
];
|
|
222
|
+
|
|
223
|
+
export const responsiveRows: TableRow[] = [
|
|
224
|
+
{
|
|
225
|
+
account: "Mesačný poplatok (bez Digitálnej odmeny)",
|
|
226
|
+
legal:
|
|
227
|
+
"Právny základ - Súhlas (čl. 6 ods. 1 písm. a) GDPR) a zmluva (čl. 6 ods. 1 písm. b) GDPR) a oprávnený záujem (čl. 6 ods. 1 písm. f) GDPR). Všeobecná doba uchovávania – Počas trvania zmluvného vzťahu.",
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
account:
|
|
231
|
+
"Online predaj tovarov a poskytovanie doplnkových a asistenčných služieb",
|
|
232
|
+
legal:
|
|
233
|
+
"Právny základ - Zmluva (čl. 6 ods. 1 písm. b) GDPR) a oprávnený záujem (čl. 6 ods. 1 písm. f) GDPR). Všeobecná doba uchovávania – Počas trvania zmluvného vzťahu a uplynutia záručnej doby na predaný tovar.",
|
|
234
|
+
},
|
|
235
|
+
];
|
|
@@ -112,3 +112,40 @@
|
|
|
112
112
|
@mixin compact {
|
|
113
113
|
width: auto;
|
|
114
114
|
}
|
|
115
|
+
|
|
116
|
+
@mixin responsive-table {
|
|
117
|
+
thead {
|
|
118
|
+
display: none;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
tbody,
|
|
122
|
+
tbody tr,
|
|
123
|
+
tbody td {
|
|
124
|
+
display: block;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
tbody tr {
|
|
128
|
+
padding: space.get("small") 0;
|
|
129
|
+
|
|
130
|
+
&:last-child {
|
|
131
|
+
margin-bottom: 0;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
tbody td {
|
|
136
|
+
padding: space.get("medium") 0;
|
|
137
|
+
border-bottom: none;
|
|
138
|
+
text-align: left !important;
|
|
139
|
+
|
|
140
|
+
&:before {
|
|
141
|
+
content: attr(data-label);
|
|
142
|
+
display: block;
|
|
143
|
+
font-weight: 700;
|
|
144
|
+
margin-bottom: space.get("xsmall");
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
&:first-child {
|
|
148
|
+
padding-left: 0;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
@@ -47,6 +47,12 @@
|
|
|
47
47
|
@include mixins.compact;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
+
&--responsive {
|
|
51
|
+
@include breakpoint.get("md", "down") {
|
|
52
|
+
@include mixins.responsive-table;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
50
56
|
@each $breakpoint in ("default", "sm", "md", "lg", "xl", "xxl") {
|
|
51
57
|
@include breakpoint.get($breakpoint, "down") {
|
|
52
58
|
&-scrollable#{generate.variant-name($breakpoint)} {
|
|
@@ -26,11 +26,7 @@ const InfoTooltip: React.FC<InfoTooltipProps> = ({
|
|
|
26
26
|
)}
|
|
27
27
|
{...other}
|
|
28
28
|
>
|
|
29
|
-
<Icon
|
|
30
|
-
name="assistance"
|
|
31
|
-
color="info"
|
|
32
|
-
className={cx(`${CLASS_ROOT}__icon`, className)}
|
|
33
|
-
/>
|
|
29
|
+
<Icon name="assistance" className={cx(`${CLASS_ROOT}__icon`, className)} />
|
|
34
30
|
<span className="sr-only">Info</span>
|
|
35
31
|
</Tooltip>
|
|
36
32
|
);
|
|
@@ -112,7 +112,7 @@ $colors-dark: (
|
|
|
112
112
|
$orange: map.get($colors-light, icon-brand);
|
|
113
113
|
$orange-dark: map.get($colors-light, surface-tertiary);
|
|
114
114
|
$black: map.get($colors-light, icon-default);
|
|
115
|
-
$white: map.get($colors-light,
|
|
115
|
+
$white: map.get($colors-light, text-inverse);
|
|
116
116
|
$blue: map.get($colors-light, fill-accent1);
|
|
117
117
|
$green: map.get($colors-light, fill-accent2);
|
|
118
118
|
$pink: map.get($colors-light, fill-accent3);
|