@thecb/components 10.5.4 → 10.5.5

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