@thecb/components 11.0.2 → 11.0.3

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": "11.0.2",
3
+ "version": "11.0.3",
4
4
  "description": "Common lib for CityBase react components",
5
5
  "main": "dist/index.cjs.js",
6
6
  "typings": "dist/index.d.ts",
@@ -107,3 +107,17 @@ export const WhiteSecondary = {
107
107
  ...Primary.args,
108
108
  variant: "whiteSecondary"
109
109
  };
110
+
111
+ export const GreenPrimary = {
112
+ args: {
113
+ ...Primary.args,
114
+ variant: "greenPrimary"
115
+ }
116
+ };
117
+
118
+ export const GreenSecondary = {
119
+ args: {
120
+ ...Primary.args,
121
+ variant: "greenSecondary"
122
+ }
123
+ };
@@ -1,4 +1,5 @@
1
1
  import { colors, styleConstants } from "../../../constants";
2
+ import { adjustHexColor } from "../../../util/general";
2
3
 
3
4
  const {
4
5
  WHITE,
@@ -7,6 +8,8 @@ const {
7
8
  PEACOCK_BLUE,
8
9
  MANATEE_GREY,
9
10
  MATISSE_BLUE,
11
+ HINT_GREEN,
12
+ SEA_GREEN,
10
13
  RASPBERRY,
11
14
  ERROR_COLOR
12
15
  } = colors;
@@ -24,8 +27,10 @@ const disabledBorderColor = {
24
27
  tertiary: TRANSPARENT,
25
28
  danger: MANATEE_GREY,
26
29
  dangerSecondary: MANATEE_GREY,
30
+ whitePrimary: MANATEE_GREY,
27
31
  whiteSecondary: MANATEE_GREY,
28
- whitePrimary: MANATEE_GREY
32
+ greenPrimary: SEA_GREEN,
33
+ greenSecondary: SEA_GREEN
29
34
  };
30
35
 
31
36
  const disabledColor = {
@@ -39,8 +44,10 @@ const disabledColor = {
39
44
  tertiary: MANATEE_GREY,
40
45
  danger: WHITE,
41
46
  dangerSecondary: MANATEE_GREY,
47
+ whitePrimary: MANATEE_GREY,
42
48
  whiteSecondary: MANATEE_GREY,
43
- whitePrimary: MANATEE_GREY
49
+ greenPrimary: WHITE,
50
+ greenSecondary: SEA_GREEN
44
51
  };
45
52
 
46
53
  const disabledBackgroundColor = {
@@ -54,8 +61,10 @@ const disabledBackgroundColor = {
54
61
  tertiary: TRANSPARENT,
55
62
  danger: MANATEE_GREY,
56
63
  dangerSecondary: TRANSPARENT,
64
+ whitePrimary: TRANSPARENT,
57
65
  whiteSecondary: TRANSPARENT,
58
- whitePrimary: TRANSPARENT
66
+ greenPrimary: SEA_GREEN,
67
+ greenSecondary: TRANSPARENT
59
68
  };
60
69
 
61
70
  const padding = {
@@ -69,8 +78,10 @@ const padding = {
69
78
  ghost: "0.65rem 0",
70
79
  danger: "0.75rem 1.5rem",
71
80
  dangerSecondary: "0.75rem 1.5rem",
81
+ whitePrimary: "1.125rem 0.75rem",
72
82
  whiteSecondary: "0.75rem 2rem",
73
- whitePrimary: "1.125rem 0.75rem"
83
+ greenPrimary: "0.75rem 1.5rem",
84
+ greenSecondary: "0.75rem 1.5rem"
74
85
  };
75
86
 
76
87
  const color = {
@@ -84,8 +95,10 @@ const color = {
84
95
  tertiary: MATISSE_BLUE,
85
96
  danger: WHITE,
86
97
  dangerSecondary: ERROR_COLOR,
98
+ whitePrimary: WHITE,
87
99
  whiteSecondary: WHITE,
88
- whitePrimary: WHITE
100
+ greenPrimary: WHITE,
101
+ greenSecondary: SEA_GREEN
89
102
  };
90
103
 
91
104
  const fontSizeVariant = {
@@ -100,7 +113,9 @@ const fontSizeVariant = {
100
113
  danger: "pS",
101
114
  dangerSecondary: "pS",
102
115
  whiteSecondary: "pS",
103
- whitePrimary: "pS"
116
+ whitePrimary: "pS",
117
+ greenPrimary: "pS",
118
+ greenSecondary: "pS"
104
119
  };
105
120
 
106
121
  const fontWeight = {
@@ -115,7 +130,9 @@ const fontWeight = {
115
130
  danger: "600",
116
131
  dangerSecondary: "600",
117
132
  whiteSecondary: "600",
118
- whitePrimary: "600"
133
+ whitePrimary: "600",
134
+ greenPrimary: "600",
135
+ greenSecondary: "600"
119
136
  };
120
137
 
121
138
  const height = {
@@ -129,8 +146,10 @@ const height = {
129
146
  tertiary: "3rem",
130
147
  danger: "3rem",
131
148
  dangerSecondary: "3rem",
149
+ whitePrimary: "auto",
132
150
  whiteSecondary: "3rem",
133
- whitePrimary: "auto"
151
+ greenPrimary: "3rem",
152
+ greenSecondary: "3rem"
134
153
  };
135
154
 
136
155
  const minWidth = {
@@ -144,8 +163,10 @@ const minWidth = {
144
163
  tertiary: "130px",
145
164
  danger: "130px",
146
165
  dangerSecondary: "157px",
166
+ whitePrimary: "130px",
147
167
  whiteSecondary: "160px",
148
- whitePrimary: "130px"
168
+ greenPrimary: "130px",
169
+ greenSecondary: "130px"
149
170
  };
150
171
 
151
172
  const textDecoration = {
@@ -159,8 +180,10 @@ const textDecoration = {
159
180
  tertiary: "none",
160
181
  danger: "none",
161
182
  dangerSecondary: "none",
183
+ whitePrimary: "none",
162
184
  whiteSecondary: "none",
163
- whitePrimary: "none"
185
+ greenPrimary: "none",
186
+ greenSecondary: "none"
164
187
  };
165
188
 
166
189
  const backgroundColor = {
@@ -174,8 +197,10 @@ const backgroundColor = {
174
197
  tertiary: TRANSPARENT,
175
198
  danger: RASPBERRY,
176
199
  dangerSecondary: TRANSPARENT,
200
+ whitePrimary: TRANSPARENT,
177
201
  whiteSecondary: TRANSPARENT,
178
- whitePrimary: TRANSPARENT
202
+ greenPrimary: SEA_GREEN,
203
+ greenSecondary: TRANSPARENT
179
204
  };
180
205
 
181
206
  const border = {
@@ -189,8 +214,10 @@ const border = {
189
214
  tertiary: "none",
190
215
  danger: "2px solid " + RASPBERRY,
191
216
  dangerSecondary: "2px solid " + ERROR_COLOR,
217
+ whitePrimary: "2px solid " + TRANSPARENT,
192
218
  whiteSecondary: "2px solid " + WHITE,
193
- whitePrimary: "2px solid " + TRANSPARENT
219
+ greenPrimary: "2px solid " + SEA_GREEN,
220
+ greenSecondary: "2px solid " + SEA_GREEN
194
221
  };
195
222
 
196
223
  const hoverBackgroundColor = {
@@ -204,8 +231,10 @@ const hoverBackgroundColor = {
204
231
  tertiary: TRANSPARENT,
205
232
  danger: "#BA002C",
206
233
  dangerSecondary: "#FAE7EE",
234
+ whitePrimary: TRANSPARENT,
207
235
  whiteSecondary: TRANSPARENT,
208
- whitePrimary: TRANSPARENT
236
+ greenPrimary: adjustHexColor(SEA_GREEN, 10, "darken"),
237
+ greenSecondary: HINT_GREEN
209
238
  };
210
239
 
211
240
  const hoverBorderColor = {
@@ -219,8 +248,10 @@ const hoverBorderColor = {
219
248
  tertiary: TRANSPARENT,
220
249
  danger: "#BA002C",
221
250
  dangerSecondary: "#B10541",
251
+ whitePrimary: "2px solid " + TRANSPARENT,
222
252
  whiteSecondary: "2px solid " + TRANSPARENT,
223
- whitePrimary: "2px solid " + TRANSPARENT
253
+ greenPrimary: SEA_GREEN,
254
+ greenSecondary: SEA_GREEN
224
255
  };
225
256
 
226
257
  const hoverColor = {
@@ -234,8 +265,10 @@ const hoverColor = {
234
265
  tertiary: SAPPHIRE_BLUE,
235
266
  danger: WHITE,
236
267
  dangerSecondary: "#B10541",
268
+ whitePrimary: WHITE,
237
269
  whiteSecondary: WHITE,
238
- whitePrimary: WHITE
270
+ greenPrimary: WHITE,
271
+ greenSecondary: SEA_GREEN
239
272
  };
240
273
 
241
274
  const activeBackgroundColor = {
@@ -249,8 +282,10 @@ const activeBackgroundColor = {
249
282
  tertiary: TRANSPARENT,
250
283
  danger: "#870000",
251
284
  dangerSecondary: "#FAE7EE",
285
+ whitePrimary: TRANSPARENT,
252
286
  whiteSecondary: TRANSPARENT,
253
- whitePrimary: TRANSPARENT
287
+ greenPrimary: adjustHexColor(SEA_GREEN, 20, "darken"),
288
+ greenSecondary: adjustHexColor(HINT_GREEN, 5, "darken")
254
289
  };
255
290
 
256
291
  const activeBorderColor = {
@@ -264,8 +299,10 @@ const activeBorderColor = {
264
299
  tertiary: TRANSPARENT,
265
300
  danger: "#870000",
266
301
  dangerSecondary: "#910029",
302
+ whitePrimary: "2px solid " + TRANSPARENT,
267
303
  whiteSecondary: "2px solid " + TRANSPARENT,
268
- whitePrimary: "2px solid " + TRANSPARENT
304
+ greenPrimary: SEA_GREEN,
305
+ greenSecondary: SEA_GREEN
269
306
  };
270
307
 
271
308
  const activeColor = {
@@ -279,8 +316,10 @@ const activeColor = {
279
316
  tertiary: PEACOCK_BLUE,
280
317
  danger: WHITE,
281
318
  dangerSecondary: "#910029",
319
+ whitePrimary: WHITE,
282
320
  whiteSecondary: WHITE,
283
- whitePrimary: WHITE
321
+ greenPrimary: WHITE,
322
+ greenSecondary: SEA_GREEN
284
323
  };
285
324
 
286
325
  export const fallbackValues = {
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
+ import { SEA_GREEN } from "../../../constants/colors";
2
3
 
3
- const SuccessfulIconMedium = ({ iconIndex = 0 }) => {
4
+ const SuccessfulIconMedium = ({ iconIndex = 0, fill = SEA_GREEN }) => {
4
5
  const mask0ID = `SuccessfulIconMedium-mask0-${iconIndex}`;
5
6
  const mask1ID = `SuccessfulIconMedium-mask1-${iconIndex}`;
6
7
  return (
@@ -11,7 +12,7 @@ const SuccessfulIconMedium = ({ iconIndex = 0 }) => {
11
12
  fill="none"
12
13
  xmlns="http://www.w3.org/2000/svg"
13
14
  >
14
- <circle cx="12" cy="12" r="12" fill="#317D4F" />
15
+ <circle cx="12" cy="12" r="12" fill={fill} />
15
16
  <mask
16
17
  id={mask0ID}
17
18
  style={{ maskType: "luminance" }}
@@ -173,3 +173,43 @@ export const wrapIndex = (index, length) => {
173
173
  return index;
174
174
  }
175
175
  };
176
+
177
+ /**
178
+ * Adjusts a hex color by lightening or darkening it.
179
+ *
180
+ * Intended for use when a satisfactory color is not available in the design system.
181
+ *
182
+ * @param {string} hex - The original hex color (e.g., "#3498db").
183
+ * @param {number} percent - The percentage to adjust the color (0-100).
184
+ * @param {string} action - The action to perform: 'lighten' or 'darken'.
185
+ * @returns {string} - The adjusted hex color.
186
+ * @throws {Error} - Throws an error if the action is not 'lighten' or 'darken'.
187
+ */
188
+ export const adjustHexColor = (hex, percent, action) => {
189
+ // Remove hash at the start if present
190
+ hex = hex.replace(/^\s*#/, "");
191
+
192
+ // Parse r, g, b values
193
+ let r = parseInt(hex.substring(0, 2), 16);
194
+ let g = parseInt(hex.substring(2, 4), 16);
195
+ let b = parseInt(hex.substring(4, 6), 16);
196
+
197
+ // Adjust RGB values based on the action
198
+ if (action === "darken") {
199
+ r = Math.max(0, Math.floor(r * (1 - percent / 100)));
200
+ g = Math.max(0, Math.floor(g * (1 - percent / 100)));
201
+ b = Math.max(0, Math.floor(b * (1 - percent / 100)));
202
+ } else if (action === "lighten") {
203
+ r = Math.min(255, Math.floor(r + (255 - r) * (percent / 100)));
204
+ g = Math.min(255, Math.floor(g + (255 - g) * (percent / 100)));
205
+ b = Math.min(255, Math.floor(b + (255 - b) * (percent / 100)));
206
+ } else {
207
+ throw new Error("Action must be either 'lighten' or 'darken'");
208
+ }
209
+
210
+ // Convert back to hex
211
+ return `#${((1 << 24) + (r << 16) + (g << 8) + b)
212
+ .toString(16)
213
+ .slice(1)
214
+ .padStart(6, "0")}`;
215
+ };