@pushwoosh/dumb-components 2.9.6 → 2.9.8
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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { Button } from '../Button';
|
|
4
|
+
describe('Button disabled colors', () => {
|
|
5
|
+
it('keeps white text on the red background for a disabled danger button', () => {
|
|
6
|
+
render(_jsx(Button, {
|
|
7
|
+
color: "danger",
|
|
8
|
+
isDisabled: true,
|
|
9
|
+
children: "Delete"
|
|
10
|
+
}));
|
|
11
|
+
const style = getComputedStyle(screen.getByRole('button'));
|
|
12
|
+
expect(style.color).toContain('--danger-shape-base-color');
|
|
13
|
+
expect(style.backgroundColor).toContain('--danger-shape-base-bg-color');
|
|
14
|
+
});
|
|
15
|
+
it('paints background, not text color, behind a disabled link-button', () => {
|
|
16
|
+
render(_jsx(Button, {
|
|
17
|
+
as: "a",
|
|
18
|
+
color: "primary",
|
|
19
|
+
isDisabled: true,
|
|
20
|
+
children: "Open"
|
|
21
|
+
}));
|
|
22
|
+
const style = getComputedStyle(screen.getByText('Open').closest('a'));
|
|
23
|
+
expect(style.color).toContain('--primary-shape-base-color');
|
|
24
|
+
expect(style.backgroundColor).toContain('--primary-shape-disabled-bg-color');
|
|
25
|
+
expect(style.borderColor).toBe('transparent');
|
|
26
|
+
});
|
|
27
|
+
});
|
package/Button/colors.js
CHANGED
|
@@ -64,9 +64,7 @@ export const colors = {
|
|
|
64
64
|
color: `var(--danger-shape-base-color, ${Color.CLEAR})`,
|
|
65
65
|
bgColor: `var(--danger-shape-base-bg-color, ${Color.DANGER})`
|
|
66
66
|
},
|
|
67
|
-
disabled: {
|
|
68
|
-
color: `var(--danger-shape-disabled-color, ${Color.LOCKED})`
|
|
69
|
-
},
|
|
67
|
+
disabled: {},
|
|
70
68
|
hover: {
|
|
71
69
|
bgColor: `var(--danger-shape-hover-bg-color, ${Color.DANGER_HOVER})`
|
|
72
70
|
}
|
|
@@ -115,7 +113,7 @@ export function createColors(buttonColors) {
|
|
|
115
113
|
if ($isOpen) {
|
|
116
114
|
return Color.MAIN;
|
|
117
115
|
}
|
|
118
|
-
return $isDisabled ? disabled.
|
|
116
|
+
return $isDisabled ? disabled.bgColor : base.bgColor;
|
|
119
117
|
}, ({
|
|
120
118
|
$isOpen,
|
|
121
119
|
$isDisabled
|
|
@@ -123,7 +121,7 @@ export function createColors(buttonColors) {
|
|
|
123
121
|
if ($isOpen) {
|
|
124
122
|
return Color.MAIN;
|
|
125
123
|
}
|
|
126
|
-
return $isDisabled ? disabled.
|
|
124
|
+
return $isDisabled ? disabled.borderColor : base.borderColor;
|
|
127
125
|
}, disabled.color, disabled.bgColor, disabled.borderColor, ({
|
|
128
126
|
$isOpen
|
|
129
127
|
}) => $isOpen ? '' : hoverCss /* sc-custom "display: none;" */, hover.color, hover.bgColor, hover.borderColor);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { CircularSkeleton, RectangularSkeleton } from '../styles';
|
|
4
|
+
describe('RectangularSkeleton', () => {
|
|
5
|
+
it('keeps style props off the DOM and still paints them', () => {
|
|
6
|
+
render(_jsx(RectangularSkeleton, {
|
|
7
|
+
"data-testid": "rect",
|
|
8
|
+
width: 120,
|
|
9
|
+
height: 16,
|
|
10
|
+
color: "red",
|
|
11
|
+
borderRadius: 4
|
|
12
|
+
}));
|
|
13
|
+
const node = screen.getByTestId('rect');
|
|
14
|
+
expect(node).not.toHaveAttribute('width');
|
|
15
|
+
expect(node).not.toHaveAttribute('height');
|
|
16
|
+
expect(node).not.toHaveAttribute('color');
|
|
17
|
+
expect(node).not.toHaveAttribute('borderradius');
|
|
18
|
+
expect(getComputedStyle(node)).toMatchObject({
|
|
19
|
+
width: '120px',
|
|
20
|
+
height: '16px',
|
|
21
|
+
backgroundColor: 'rgb(255, 0, 0)',
|
|
22
|
+
borderRadius: '4px'
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
it('still forwards regular attributes', () => {
|
|
26
|
+
render(_jsx(RectangularSkeleton, {
|
|
27
|
+
"data-testid": "rect",
|
|
28
|
+
title: "loading",
|
|
29
|
+
"aria-busy": "true",
|
|
30
|
+
width: 1,
|
|
31
|
+
height: 1
|
|
32
|
+
}));
|
|
33
|
+
const node = screen.getByTestId('rect');
|
|
34
|
+
expect(node).toHaveAttribute('title', 'loading');
|
|
35
|
+
expect(node).toHaveAttribute('aria-busy', 'true');
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
describe('CircularSkeleton', () => {
|
|
39
|
+
it('keeps style props off the DOM and still paints them', () => {
|
|
40
|
+
render(_jsx(CircularSkeleton, {
|
|
41
|
+
"data-testid": "circle",
|
|
42
|
+
"aria-label": "avatar",
|
|
43
|
+
diameter: 32,
|
|
44
|
+
color: "red"
|
|
45
|
+
}));
|
|
46
|
+
const node = screen.getByTestId('circle');
|
|
47
|
+
expect(node).not.toHaveAttribute('diameter');
|
|
48
|
+
expect(node).not.toHaveAttribute('color');
|
|
49
|
+
expect(node).toHaveAttribute('aria-label', 'avatar');
|
|
50
|
+
expect(getComputedStyle(node)).toMatchObject({
|
|
51
|
+
width: '32px',
|
|
52
|
+
height: '32px',
|
|
53
|
+
backgroundColor: 'rgb(255, 0, 0)'
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
package/Skeleton/styles.js
CHANGED
|
@@ -15,6 +15,8 @@ const skeletonCommonCss = css(["background-color:", ";animation:", " 1.5s ease-i
|
|
|
15
15
|
}) => !color && accentCycleCss);
|
|
16
16
|
/** Pulsing rectangular loading placeholder of a fixed `width`/`height`. */
|
|
17
17
|
export const RectangularSkeleton = styled.div.withConfig({
|
|
18
|
+
shouldForwardProp: prop => !['width', 'height', 'color', 'borderRadius'].includes(prop)
|
|
19
|
+
}).withConfig({
|
|
18
20
|
displayName: "RectangularSkeleton",
|
|
19
21
|
componentId: "sc-mdyfd6-0"
|
|
20
22
|
})(["width:", ";height:", ";", " ", ""], ({
|
|
@@ -24,6 +26,8 @@ export const RectangularSkeleton = styled.div.withConfig({
|
|
|
24
26
|
}) => toCssValue(height), skeletonCommonCss, borderRadiusCss);
|
|
25
27
|
/** Pulsing circular loading placeholder of a given `diameter` (e.g. for avatars). */
|
|
26
28
|
export const CircularSkeleton = styled.div.withConfig({
|
|
29
|
+
shouldForwardProp: prop => !['diameter', 'color'].includes(prop)
|
|
30
|
+
}).withConfig({
|
|
27
31
|
displayName: "CircularSkeleton",
|
|
28
32
|
componentId: "sc-mdyfd6-1"
|
|
29
33
|
})(["width:", ";height:", ";border-radius:100%;", ""], ({
|