@thecb/components 10.4.7-beta.1 → 10.4.8-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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thecb/components",
3
- "version": "10.4.7-beta.1",
3
+ "version": "10.4.8-beta.0",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1,10 +1,10 @@
1
1
  import React from "react";
2
2
 
3
- const IconAdd = () => (
3
+ const IconAdd = ({ strokeWidth = 1 }) => (
4
4
  <svg
5
5
  xmlns="http://www.w3.org/2000/svg"
6
6
  xmlnsXlink="http://www.w3.org/1999/xlink"
7
- width="18"
7
+ width={"18"}
8
8
  height="18"
9
9
  viewBox="0 0 18 18"
10
10
  className="icon"
@@ -12,10 +12,11 @@ const IconAdd = () => (
12
12
  <defs>
13
13
  <path
14
14
  id="path-1"
15
+ strokeWidth={strokeWidth}
15
16
  d="M7.91666623 4.78508747L4.78508747 4.78508747 4.78508747 7.91666623 3.74122788 7.91666623 3.74122788 4.78508747 0.609649123 4.78508747 0.609649123 3.74122788 3.74122788 3.74122788 3.74122788 0.609649123 4.78508747 0.609649123 4.78508747 3.74122788 7.91666623 3.74122788z"
16
17
  ></path>
17
18
  </defs>
18
- <g fill="none" fillRule="evenodd" stroke="none" strokeWidth="1">
19
+ <g fill="none" fillRule="evenodd" stroke="none" strokeWidth={strokeWidth}>
19
20
  <g transform="translate(-407 -563)">
20
21
  <g transform="translate(408 562)">
21
22
  <g transform="translate(0 2)">
@@ -25,7 +26,13 @@ const IconAdd = () => (
25
26
  </mask>
26
27
  <use className="fill" xlinkHref="#path-1"></use>
27
28
  </g>
28
- <circle className="stroke" cx="8.155" cy="8.072" r="8"></circle>
29
+ <circle
30
+ className="stroke"
31
+ strokeWidth={strokeWidth}
32
+ cx="8.155"
33
+ cy="8.072"
34
+ r={strokeWidth == 1 ? "8" : "7"}
35
+ ></circle>
29
36
  </g>
30
37
  </g>
31
38
  </g>
@@ -16,7 +16,7 @@ import {
16
16
  IconAdd,
17
17
  PaymentMethodAddIcon
18
18
  } from "../icons";
19
- import { FONT_WEIGHT_REGULAR } from "../../../constants/style_constants";
19
+ import { FONT_WEIGHT_SEMIBOLD } from "../../../constants/style_constants";
20
20
 
21
21
  const getLargeIcon = iconName => {
22
22
  switch (iconName) {
@@ -123,7 +123,7 @@ const Placeholder = ({
123
123
  stroke: ${
124
124
  variant === "large" ? CHARADE_GREY : themeValues.color
125
125
  };
126
- }`}
126
+ } `}
127
127
  >
128
128
  {variant === "large" ? (
129
129
  <Center intrinsic>
@@ -131,7 +131,7 @@ const Placeholder = ({
131
131
  <Text
132
132
  variant="pS"
133
133
  color={themeValues.color}
134
- weight={FONT_WEIGHT_REGULAR}
134
+ weight={FONT_WEIGHT_SEMIBOLD}
135
135
  extraStyles={`text-align: center;`}
136
136
  >
137
137
  {text}
@@ -140,12 +140,12 @@ const Placeholder = ({
140
140
  ) : (
141
141
  <Cover singleChild minHeight="100%">
142
142
  <Cluster justify="center" align="center">
143
- <IconAdd />
143
+ <IconAdd strokeWidth="2" />
144
144
  <Center intrinsic>
145
145
  <Text
146
146
  variant="pS"
147
147
  color={themeValues.color}
148
- weight={FONT_WEIGHT_REGULAR}
148
+ weight={FONT_WEIGHT_SEMIBOLD}
149
149
  extraStyles={`padding: 0 0 0 8px; text-align: center;`}
150
150
  >
151
151
  {text}
@@ -13,7 +13,8 @@ const groupId = "props";
13
13
 
14
14
  const icons = {
15
15
  accounts: "accounts",
16
- properties: "properties"
16
+ properties: "properties",
17
+ payments: "payments"
17
18
  };
18
19
 
19
20
  const iconLabel = "largeIcon";
@@ -20,9 +20,9 @@ const HiddenToggleSwitchBox = styled.input`
20
20
  `;
21
21
 
22
22
  const VisibleSwitchComponent = styled.label`
23
- width: 44px;
23
+ width: 48px;
24
24
  height: 24px;
25
- border-radius: 12px;
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 ToggleSwitchRingComponent = styled.div`
44
+ const ToggleSwitchMiddleRingComponent = styled.div`
45
45
  position: absolute;
46
- width: 16px;
47
- height: 16px;
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,32 +73,54 @@ const ToggleSwitch = ({
61
73
  isMobile,
62
74
  dataQa
63
75
  }) => {
64
- const ToggleSwitchRing = posed(ToggleSwitchRingComponent)({
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: disabled
67
- ? themeValues.disabledBackground
68
- : themeValues.onBackground,
69
- left: "4px",
70
- top: "3px",
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: "8px",
80
- top: "3px",
81
- bottom: "4px",
82
- left: "23px",
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
 
89
- // to do: for disabled, background color should not be white (should be lighter disabled background)
90
124
  const VisibleSwitch = posed(VisibleSwitchComponent)({
91
125
  focusable: true,
92
126
  hoverable: true,
@@ -99,28 +133,19 @@ const ToggleSwitch = ({
99
133
  boxShadow: "0px 2px 5px 0px rgba(0,0,0,0.5)"
100
134
  },
101
135
  off: {
102
- border: "1px solid",
103
- backgroundColor: disabled
104
- ? themeValues.disabledBackgroundLight
105
- : themeValues.white,
106
- borderColor: disabled
107
- ? themeValues.disabledBackground
108
- : themeValues.onBackground,
136
+ backgroundColor: themeValues.offBackground,
109
137
  transition: {
110
138
  ease: "easeOut"
111
139
  }
112
140
  },
113
141
  on: {
114
- border: "1px solid",
115
- backgroundColor: disabled
116
- ? themeValues.disabledBackground
117
- : themeValues.onBackground,
118
- borderColor: disabled
119
- ? themeValues.disabledBackground
120
- : themeValues.onBackground,
142
+ backgroundColor: themeValues.onBackground,
121
143
  transition: {
122
144
  ease: "easeIn"
123
145
  }
146
+ },
147
+ disabled: {
148
+ backgroundColor: themeValues.disabledBackground
124
149
  }
125
150
  });
126
151
 
@@ -159,12 +184,14 @@ const ToggleSwitch = ({
159
184
  htmlFor={`#toggle-${name}`}
160
185
  onClick={disabled ? noop : onToggle}
161
186
  onKeyDown={disabled ? noop : handleKeyDown}
162
- pose={isOn ? "on" : "off"}
187
+ pose={disabled ? "disabled" : isOn ? "on" : "off"}
163
188
  tabIndex={disabled ? -1 : 0}
164
189
  disabled={disabled}
165
190
  isMobile={isMobile}
166
191
  >
167
- <ToggleSwitchRing />
192
+ <ToggleSwitchMiddleRing>
193
+ <ToggleSwitchInnerRing />
194
+ </ToggleSwitchMiddleRing>
168
195
  </VisibleSwitch>
169
196
  </Box>
170
197
  </Cover>
@@ -1,5 +1,5 @@
1
1
  import React, { useState, Fragment } from "react";
2
- import { boolean, text } from "@storybook/addon-knobs";
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={text("label", "Toggle Switch Label", "props")}
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
- ATHENS_GREY,
4
- MANATEE_GREY,
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 = `${MANATEE_GREY}`;
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
  };