@orangesk/orange-design-system 2.0.0-beta.11 → 2.0.0-beta.13
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 +4 -4
- package/build/components/index.js.map +1 -1
- package/build/components/tsconfig.tsbuildinfo +1 -1
- package/build/components/types/index.d.ts +14 -8
- 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/Modal/Modal.d.ts +0 -2
- package/build/components/types/src/components/Modal/index.d.ts +0 -1
- 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/components/types/src/components/Tag/Tag.d.ts +0 -2
- package/build/components/types/src/components/index.d.ts +2 -2
- package/build/fonts/HelveticaNeue-Bold.woff2 +0 -0
- package/build/fonts/HelveticaNeue-Light.woff2 +0 -0
- package/build/fonts/HelveticaNeue-Roman.woff2 +0 -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 +9 -9
- package/public/fonts/HelveticaNeue-Bold.woff2 +0 -0
- package/public/fonts/HelveticaNeue-Light.woff2 +0 -0
- package/public/fonts/HelveticaNeue-Roman.woff2 +0 -0
- package/src/components/AnchorNavigation/AnchorNavigation.static.ts +3 -0
- package/src/components/AnchorNavigation/styles/mixins.scss +4 -4
- 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/Modal/Modal.tsx +1 -9
- package/src/components/Modal/index.ts +0 -1
- package/src/components/Modal/styles/config.scss +4 -4
- package/src/components/Modal/styles/mixins.scss +13 -59
- package/src/components/Modal/styles/style.scss +0 -16
- package/src/components/Modal/tests/Modal.unit.test.js +0 -37
- package/src/components/Pill/Pill.tsx +13 -2
- package/src/components/Pill/styles/config.scss +2 -21
- package/src/components/Pill/styles/style.scss +18 -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/Tag/Tag.tsx +0 -2
- package/src/components/Tag/styles/style.scss +32 -0
- package/src/components/Tooltip/InfoTooltip.tsx +1 -5
- package/src/components/index.ts +2 -0
- package/src/styles/tokens/color.scss +1 -1
- package/build/components/types/src/components/Modal/ModalProductBody.d.ts +0 -10
- package/src/components/Modal/ModalProductBody.tsx +0 -52
|
@@ -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) {
|
|
@@ -53,8 +53,6 @@ interface ModalProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
53
53
|
colorScheme?: "dark" | "light";
|
|
54
54
|
/** Disables header paddings */
|
|
55
55
|
disableHeaderSpacing?: boolean;
|
|
56
|
-
/** Disables body paddings */
|
|
57
|
-
disableBodySpacing?: boolean;
|
|
58
56
|
/** Disables footer paddings */
|
|
59
57
|
disableFooterSpacing?: boolean;
|
|
60
58
|
}
|
|
@@ -85,7 +83,6 @@ const Modal: React.FC<ModalProps> = ({
|
|
|
85
83
|
fullHeight,
|
|
86
84
|
colorScheme,
|
|
87
85
|
disableHeaderSpacing,
|
|
88
|
-
disableBodySpacing,
|
|
89
86
|
disableFooterSpacing,
|
|
90
87
|
...other
|
|
91
88
|
}) => {
|
|
@@ -149,12 +146,7 @@ const Modal: React.FC<ModalProps> = ({
|
|
|
149
146
|
{renderBody ? (
|
|
150
147
|
renderBody()
|
|
151
148
|
) : (
|
|
152
|
-
<ModalBody
|
|
153
|
-
disableSpacing={disableBodySpacing}
|
|
154
|
-
withTopPadding={!disableBodySpacing && !!renderHeader}
|
|
155
|
-
>
|
|
156
|
-
{children}
|
|
157
|
-
</ModalBody>
|
|
149
|
+
<ModalBody withTopPadding={!!renderHeader}>{children}</ModalBody>
|
|
158
150
|
)}
|
|
159
151
|
<div
|
|
160
152
|
className={cx(`${CLASS_ROOT}__footer`, {
|
|
@@ -4,4 +4,3 @@ export { ModalTitle } from "./ModalTitle";
|
|
|
4
4
|
export { ModalCloseButton } from "./ModalCloseButton";
|
|
5
5
|
export { ModalProductHeader } from "./ModalProductHeader";
|
|
6
6
|
export { ModalProductFooter } from "./ModalProductFooter";
|
|
7
|
-
export { ModalProductBody } from "./ModalProductBody";
|
|
@@ -42,7 +42,7 @@ $spacing: (
|
|
|
42
42
|
|
|
43
43
|
$spacing-product-footer: (
|
|
44
44
|
default: (
|
|
45
|
-
default: space.get("medium")
|
|
46
|
-
md: space.get("
|
|
47
|
-
)
|
|
48
|
-
)
|
|
45
|
+
default: space.get("medium"),
|
|
46
|
+
md: space.get("large"),
|
|
47
|
+
),
|
|
48
|
+
);
|
|
@@ -33,8 +33,9 @@
|
|
|
33
33
|
z-index: config.$overlay-z-index;
|
|
34
34
|
opacity: 0;
|
|
35
35
|
transform: scale(1.1, 1.1);
|
|
36
|
-
transition:
|
|
37
|
-
|
|
36
|
+
transition:
|
|
37
|
+
opacity config.$overlay-e,
|
|
38
|
+
transform config.$overlay-e;
|
|
38
39
|
backface-visibility: hidden;
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -205,7 +206,7 @@
|
|
|
205
206
|
|
|
206
207
|
@at-root {
|
|
207
208
|
.modal__body--colorful + .modal__footer {
|
|
208
|
-
padding: $space
|
|
209
|
+
padding: $space;
|
|
209
210
|
}
|
|
210
211
|
}
|
|
211
212
|
}
|
|
@@ -214,11 +215,17 @@
|
|
|
214
215
|
}
|
|
215
216
|
|
|
216
217
|
@mixin sticky-footer() {
|
|
218
|
+
z-index: 1;
|
|
219
|
+
|
|
217
220
|
@media screen and (min-height: 500px) {
|
|
218
221
|
position: sticky;
|
|
219
222
|
bottom: 0;
|
|
220
223
|
background-color: var(--color-surface-primary);
|
|
221
224
|
}
|
|
225
|
+
|
|
226
|
+
&.modal__footer--no-spacing {
|
|
227
|
+
padding: 0 !important;
|
|
228
|
+
}
|
|
222
229
|
}
|
|
223
230
|
|
|
224
231
|
@mixin modal-product-header($spacing) {
|
|
@@ -248,7 +255,9 @@
|
|
|
248
255
|
flex-direction: column;
|
|
249
256
|
}
|
|
250
257
|
|
|
251
|
-
@each $breakpoint,
|
|
258
|
+
@each $breakpoint,
|
|
259
|
+
$value in map.get(config.$spacing-product-footer, "default")
|
|
260
|
+
{
|
|
252
261
|
@include breakpoint.get($breakpoint) {
|
|
253
262
|
padding: $value;
|
|
254
263
|
}
|
|
@@ -284,58 +293,3 @@
|
|
|
284
293
|
object-position: left;
|
|
285
294
|
max-width: convert.to-rem(125px);
|
|
286
295
|
}
|
|
287
|
-
|
|
288
|
-
@mixin modal-product-body-subtitle-section() {
|
|
289
|
-
padding: convert.to-rem(15px) space.get();
|
|
290
|
-
|
|
291
|
-
@include breakpoint.get('md') {
|
|
292
|
-
padding: convert.to-rem(20px) space.get('large');
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
@mixin modal-product-body-list-section() {
|
|
297
|
-
padding: 0 space.get();
|
|
298
|
-
|
|
299
|
-
@include breakpoint.get('md') {
|
|
300
|
-
padding: space.get('small') space.get('large');
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
ul {
|
|
304
|
-
margin-bottom: 0;
|
|
305
|
-
padding: space.get('small') space.get() space.get('small') convert.to-rem(18px);
|
|
306
|
-
@include breakpoint.get('md') {
|
|
307
|
-
padding-right: 0;
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
li {
|
|
312
|
-
margin-bottom: convert.to-rem(15px);
|
|
313
|
-
|
|
314
|
-
&:last-child {
|
|
315
|
-
margin-bottom: 0;
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
@mixin modal-product-body-accordion-section() {
|
|
321
|
-
padding: convert.to-rem(15px) space.get();
|
|
322
|
-
|
|
323
|
-
.accordion__body {
|
|
324
|
-
padding: 0 space.get() convert.to-rem(15px) space.get('small');
|
|
325
|
-
margin-bottom: 0;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
@include breakpoint.get('md') {
|
|
329
|
-
padding: space.get('small') space.get('large');
|
|
330
|
-
|
|
331
|
-
.accordion__body {
|
|
332
|
-
padding: 0 space.get('large') convert.to-rem(15px) space.get('small');
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
@mixin modal-product-body-section-title() {
|
|
338
|
-
margin-bottom: 0 !important;
|
|
339
|
-
|
|
340
|
-
padding: space.get('small') 0;
|
|
341
|
-
}
|
|
@@ -132,20 +132,4 @@
|
|
|
132
132
|
.modal__product-footer-button {
|
|
133
133
|
@include mixins.modal-product-footer-button();
|
|
134
134
|
}
|
|
135
|
-
|
|
136
|
-
.modal__product-body-subtitle-section {
|
|
137
|
-
@include mixins.modal-product-body-subtitle-section();
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
.modal__product-body-list-section {
|
|
141
|
-
@include mixins.modal-product-body-list-section();
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
.modal__product-body-accordion-section {
|
|
145
|
-
@include mixins.modal-product-body-accordion-section();
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
.modal__product-body-section-title {
|
|
149
|
-
@include mixins.modal-product-body-section-title();
|
|
150
|
-
}
|
|
151
135
|
}
|
|
@@ -111,41 +111,4 @@ describe("rendering Modal", () => {
|
|
|
111
111
|
expect(child[0]).toHaveClass("modal__footer--no-spacing");
|
|
112
112
|
});
|
|
113
113
|
});
|
|
114
|
-
describe("disableBodySpacing prop", () => {
|
|
115
|
-
it("should have modal__body--no-spacing class when disableBodySpacing is true", () => {
|
|
116
|
-
const { getByTestId } = render(
|
|
117
|
-
<div id="root">
|
|
118
|
-
<Modal
|
|
119
|
-
id="modal-no-body-spacing"
|
|
120
|
-
data-testid="modal-no-body-spacing"
|
|
121
|
-
disableBodySpacing
|
|
122
|
-
/>
|
|
123
|
-
</div>,
|
|
124
|
-
);
|
|
125
|
-
const child = getByTestId("modal-no-body-spacing").getElementsByClassName(
|
|
126
|
-
"modal__body--no-spacing",
|
|
127
|
-
);
|
|
128
|
-
expect(child.length).toBe(1);
|
|
129
|
-
expect(child[0]).toHaveClass("modal__body--no-spacing");
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it("should not apply with-top-padding class on body when custom header renderer is present with disableBodySpacing prop", () => {
|
|
133
|
-
const { getByTestId } = render(
|
|
134
|
-
<div id="root">
|
|
135
|
-
<Modal
|
|
136
|
-
id="modal-no-body-spacing"
|
|
137
|
-
data-testid="modal-no-body-spacing"
|
|
138
|
-
disableBodySpacing
|
|
139
|
-
renderHeader={() => <div>Custom Header</div>}
|
|
140
|
-
/>
|
|
141
|
-
</div>,
|
|
142
|
-
);
|
|
143
|
-
const child = getByTestId("modal-no-body-spacing").getElementsByClassName(
|
|
144
|
-
"modal__body",
|
|
145
|
-
);
|
|
146
|
-
expect(child.length).toBe(1);
|
|
147
|
-
expect(child[0]).not.toHaveClass("with-top-padding");
|
|
148
|
-
expect(child[0]).toHaveClass("modal__body--no-spacing");
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
114
|
});
|
|
@@ -3,7 +3,18 @@ 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-contrast",
|
|
13
|
+
"surface-accent",
|
|
14
|
+
"fill-moderate",
|
|
15
|
+
"fill-disabled",
|
|
16
|
+
"transparent",
|
|
17
|
+
] as const;
|
|
7
18
|
export type PillColor = (typeof pillColors)[number];
|
|
8
19
|
|
|
9
20
|
interface PillProps extends HTMLAttributes<HTMLSpanElement> {
|
|
@@ -26,11 +37,11 @@ const Pill: React.FC<PillProps> = ({
|
|
|
26
37
|
className={cx(
|
|
27
38
|
CLASS_ROOT,
|
|
28
39
|
{
|
|
29
|
-
[`${CLASS_ROOT}--${color}`]: color, // Only apply modifier if color is specified
|
|
30
40
|
"is-light": colorScheme === "light",
|
|
31
41
|
"is-dark": colorScheme === "dark",
|
|
32
42
|
[CLASS_ROOT + "--" + size]: size,
|
|
33
43
|
},
|
|
44
|
+
color,
|
|
34
45
|
className,
|
|
35
46
|
)}
|
|
36
47
|
{...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,23 @@
|
|
|
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
|
+
&.fill-moderate,
|
|
22
|
+
&.fill-disabled {
|
|
23
|
+
color: color.$white;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&.transparent {
|
|
27
|
+
background-color: rgba(#ffffff, 0.5);
|
|
28
|
+
color: var(--color-text-default);
|
|
17
29
|
}
|
|
18
30
|
}
|
|
19
31
|
}
|
|
@@ -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
|
|