@thecb/components 10.5.5 → 10.5.6-beta.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/dist/index.cjs.js +59 -46
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +59 -46
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/.DS_Store +0 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/atoms/.DS_Store +0 -0
- package/src/components/atoms/toggle-switch/ToggleSwitch.js +61 -33
- package/src/components/atoms/toggle-switch/ToggleSwitch.stories.js +3 -2
- package/src/components/atoms/toggle-switch/ToggleSwitch.theme.js +5 -5
- package/src/components/molecules/link-card/LinkCard.theme.js +7 -21
package/package.json
CHANGED
package/src/.DS_Store
ADDED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -20,9 +20,9 @@ const HiddenToggleSwitchBox = styled.input`
|
|
|
20
20
|
`;
|
|
21
21
|
|
|
22
22
|
const VisibleSwitchComponent = styled.label`
|
|
23
|
-
width:
|
|
23
|
+
width: 48px;
|
|
24
24
|
height: 24px;
|
|
25
|
-
border-radius:
|
|
25
|
+
border-radius: 48px;
|
|
26
26
|
border: none;
|
|
27
27
|
position: relative;
|
|
28
28
|
box-sizing: border-box;
|
|
@@ -41,15 +41,27 @@ const VisibleSwitchComponent = styled.label`
|
|
|
41
41
|
${({ isMobile }) => (isMobile ? `transform: scale(0.75)` : ``)}
|
|
42
42
|
`;
|
|
43
43
|
|
|
44
|
-
const
|
|
44
|
+
const ToggleSwitchMiddleRingComponent = styled.div`
|
|
45
45
|
position: absolute;
|
|
46
|
-
width:
|
|
47
|
-
height:
|
|
46
|
+
width: 20px;
|
|
47
|
+
height: 20px;
|
|
48
48
|
border: none;
|
|
49
49
|
border-radius: 50%;
|
|
50
50
|
box-sizing: border-box;
|
|
51
51
|
`;
|
|
52
52
|
|
|
53
|
+
const ToggleSwitchInnerRingComponent = styled.div`
|
|
54
|
+
position: absolute;
|
|
55
|
+
width: 14px;
|
|
56
|
+
height: 14px;
|
|
57
|
+
top: 3px;
|
|
58
|
+
left: 3px;
|
|
59
|
+
right: 3px;
|
|
60
|
+
bottom: 3px;
|
|
61
|
+
border-radius: 50%;
|
|
62
|
+
box-sizing: border-box;
|
|
63
|
+
`;
|
|
64
|
+
|
|
53
65
|
const ToggleSwitch = ({
|
|
54
66
|
isOn = false,
|
|
55
67
|
onToggle = noop,
|
|
@@ -61,28 +73,51 @@ const ToggleSwitch = ({
|
|
|
61
73
|
isMobile,
|
|
62
74
|
dataQa
|
|
63
75
|
}) => {
|
|
64
|
-
const
|
|
76
|
+
const ToggleSwitchInnerRing = posed(ToggleSwitchInnerRingComponent)({
|
|
77
|
+
off: {
|
|
78
|
+
backgroundColor: themeValues.offBackground,
|
|
79
|
+
transition: {
|
|
80
|
+
ease: "easeOut"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
on: {
|
|
84
|
+
backgroundColor: themeValues.onBackground,
|
|
85
|
+
transition: {
|
|
86
|
+
ease: "easeIn"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
disabled: {
|
|
90
|
+
backgroundColor: themeValues.disabledBackground
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const ToggleSwitchMiddleRing = posed(ToggleSwitchMiddleRingComponent)({
|
|
65
95
|
off: {
|
|
66
|
-
backgroundColor:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
bottom: "3px",
|
|
72
|
-
right: "20px",
|
|
96
|
+
backgroundColor: themeValues.white,
|
|
97
|
+
left: "2px",
|
|
98
|
+
top: "2px",
|
|
99
|
+
bottom: "2px",
|
|
100
|
+
right: "24px",
|
|
73
101
|
transition: {
|
|
74
102
|
ease: "backIn"
|
|
75
103
|
}
|
|
76
104
|
},
|
|
77
105
|
on: {
|
|
78
106
|
backgroundColor: themeValues.white,
|
|
79
|
-
right: "
|
|
80
|
-
top: "
|
|
81
|
-
bottom: "
|
|
82
|
-
left: "
|
|
107
|
+
right: "1px",
|
|
108
|
+
top: "2px",
|
|
109
|
+
bottom: "2px",
|
|
110
|
+
left: "25px",
|
|
83
111
|
transition: {
|
|
84
112
|
ease: "backIn"
|
|
85
113
|
}
|
|
114
|
+
},
|
|
115
|
+
disabled: {
|
|
116
|
+
backgroundColor: themeValues.white,
|
|
117
|
+
left: "2px",
|
|
118
|
+
top: "2px",
|
|
119
|
+
bottom: "2px",
|
|
120
|
+
right: "24px"
|
|
86
121
|
}
|
|
87
122
|
});
|
|
88
123
|
|
|
@@ -98,28 +133,19 @@ const ToggleSwitch = ({
|
|
|
98
133
|
boxShadow: "0px 2px 5px 0px rgba(0,0,0,0.5)"
|
|
99
134
|
},
|
|
100
135
|
off: {
|
|
101
|
-
|
|
102
|
-
backgroundColor: disabled
|
|
103
|
-
? themeValues.disabledBackgroundLight
|
|
104
|
-
: themeValues.white,
|
|
105
|
-
borderColor: disabled
|
|
106
|
-
? themeValues.disabledBackground
|
|
107
|
-
: themeValues.onBackground,
|
|
136
|
+
backgroundColor: themeValues.offBackground,
|
|
108
137
|
transition: {
|
|
109
138
|
ease: "easeOut"
|
|
110
139
|
}
|
|
111
140
|
},
|
|
112
141
|
on: {
|
|
113
|
-
|
|
114
|
-
backgroundColor: disabled
|
|
115
|
-
? themeValues.disabledBackground
|
|
116
|
-
: themeValues.onBackground,
|
|
117
|
-
borderColor: disabled
|
|
118
|
-
? themeValues.disabledBackground
|
|
119
|
-
: themeValues.onBackground,
|
|
142
|
+
backgroundColor: themeValues.onBackground,
|
|
120
143
|
transition: {
|
|
121
144
|
ease: "easeIn"
|
|
122
145
|
}
|
|
146
|
+
},
|
|
147
|
+
disabled: {
|
|
148
|
+
backgroundColor: themeValues.disabledBackground
|
|
123
149
|
}
|
|
124
150
|
});
|
|
125
151
|
|
|
@@ -158,12 +184,14 @@ const ToggleSwitch = ({
|
|
|
158
184
|
htmlFor={`#toggle-${name}`}
|
|
159
185
|
onClick={disabled ? noop : onToggle}
|
|
160
186
|
onKeyDown={disabled ? noop : handleKeyDown}
|
|
161
|
-
pose={isOn ? "on" : "off"}
|
|
187
|
+
pose={disabled ? "disabled" : isOn ? "on" : "off"}
|
|
162
188
|
tabIndex={disabled ? -1 : 0}
|
|
163
189
|
disabled={disabled}
|
|
164
190
|
isMobile={isMobile}
|
|
165
191
|
>
|
|
166
|
-
<
|
|
192
|
+
<ToggleSwitchMiddleRing>
|
|
193
|
+
<ToggleSwitchInnerRing />
|
|
194
|
+
</ToggleSwitchMiddleRing>
|
|
167
195
|
</VisibleSwitch>
|
|
168
196
|
</Box>
|
|
169
197
|
</Cover>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState, Fragment } from "react";
|
|
2
|
-
import { boolean
|
|
2
|
+
import { boolean } from "@storybook/addon-knobs";
|
|
3
3
|
import ToggleSwitch from "./ToggleSwitch";
|
|
4
4
|
import page from "../../../../.storybook/page";
|
|
5
5
|
|
|
@@ -7,11 +7,12 @@ export const toggleSwitchDefault = () => {
|
|
|
7
7
|
const [isOn, onToggle] = useState(false);
|
|
8
8
|
|
|
9
9
|
const disabled = boolean("disabled", false, "props");
|
|
10
|
+
|
|
10
11
|
return (
|
|
11
12
|
<Fragment>
|
|
12
13
|
<ToggleSwitch
|
|
13
14
|
name="toggle-switch"
|
|
14
|
-
label=
|
|
15
|
+
label="Toggle Switch Label"
|
|
15
16
|
isOn={isOn}
|
|
16
17
|
onToggle={() => onToggle(!isOn)}
|
|
17
18
|
disabled={disabled}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WHITE,
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
REGENT_GREY,
|
|
4
|
+
IRON_GREY,
|
|
5
5
|
MATISSE_BLUE
|
|
6
6
|
} from "../../../constants/colors";
|
|
7
7
|
|
|
8
8
|
const onBackground = `${MATISSE_BLUE}`;
|
|
9
|
-
const disabledBackground = `${
|
|
10
|
-
const disabledBackgroundLight = `${ATHENS_GREY}`;
|
|
9
|
+
const disabledBackground = `${IRON_GREY}`;
|
|
11
10
|
const white = `${WHITE}`;
|
|
11
|
+
const offBackground = `${REGENT_GREY}`;
|
|
12
12
|
|
|
13
13
|
const labelStyles = `
|
|
14
14
|
display: flex;
|
|
@@ -29,8 +29,8 @@ const leftLabelStyles = `
|
|
|
29
29
|
export const fallbackValues = {
|
|
30
30
|
onBackground,
|
|
31
31
|
disabledBackground,
|
|
32
|
-
disabledBackgroundLight,
|
|
33
32
|
white,
|
|
33
|
+
offBackground,
|
|
34
34
|
rightLabelStyles,
|
|
35
35
|
leftLabelStyles
|
|
36
36
|
};
|
|
@@ -8,27 +8,13 @@ import {
|
|
|
8
8
|
TRANSPARENT
|
|
9
9
|
} from "../../../constants/colors";
|
|
10
10
|
|
|
11
|
-
const disabledBackgroundColor =
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const
|
|
18
|
-
primary: MANATEE_GREY
|
|
19
|
-
};
|
|
20
|
-
const activeBackgroundColor = {
|
|
21
|
-
primary: CORNFLOWER_BLUE
|
|
22
|
-
};
|
|
23
|
-
const backgroundColor = {
|
|
24
|
-
primary: LINK_WATER
|
|
25
|
-
};
|
|
26
|
-
const borderColor = {
|
|
27
|
-
primary: MOON_RAKER
|
|
28
|
-
};
|
|
29
|
-
const color = {
|
|
30
|
-
primary: ROYAL_BLUE_VIVID
|
|
31
|
-
};
|
|
11
|
+
const disabledBackgroundColor = TRANSPARENT;
|
|
12
|
+
const disabledBorderColor = GHOST_GREY;
|
|
13
|
+
const disabledColor = MANATEE_GREY;
|
|
14
|
+
const activeBackgroundColor = CORNFLOWER_BLUE;
|
|
15
|
+
const backgroundColor = LINK_WATER;
|
|
16
|
+
const borderColor = MOON_RAKER;
|
|
17
|
+
const color = ROYAL_BLUE_VIVID;
|
|
32
18
|
|
|
33
19
|
export const fallbackValues = {
|
|
34
20
|
disabledBackgroundColor,
|