@luscii-healthtech/web-ui 0.2.2 → 0.3.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,5 +1,5 @@
1
1
  {
2
- "version": "0.2.2",
2
+ "version": "0.3.0",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -53,7 +53,7 @@ export const Checkbox = ({
53
53
  setChecked(isChecked);
54
54
  }, [isChecked]);
55
55
 
56
- const handleChange = (event) => {
56
+ const handleChange = event => {
57
57
  setChecked(!checked);
58
58
  if (onChange) {
59
59
  onChange(event);
@@ -66,7 +66,11 @@ export const Checkbox = ({
66
66
 
67
67
  return (
68
68
  <div className={containerClassName} data-test-id="checkbox">
69
- <label className="cweb-checkbox-label" data-test-id="checkbox-label" onClick={(e) => e.stopPropagation()}>
69
+ <label
70
+ className="cweb-checkbox-label"
71
+ data-test-id="checkbox-label"
72
+ onClick={e => e.stopPropagation()}
73
+ >
70
74
  <input
71
75
  id={id}
72
76
  data-test-id={`checkbox-${name}`}
@@ -82,26 +86,36 @@ export const Checkbox = ({
82
86
  />
83
87
 
84
88
  <span
85
- className={classNames("cweb-checkbox-icon-container", "transition-colors duration-300", {
86
- "bg-primary": checked,
87
- "bg-white": !checked,
88
- "hover:bg-primary-dark": checked,
89
- "outline-primary": isFocused,
90
- "cursor-not-allowed": isDisabled,
91
- "cursor-pointer": !isDisabled,
92
- })}
89
+ className={classNames(
90
+ "cweb-checkbox-icon-container",
91
+ "transition-colors duration-300",
92
+ {
93
+ "bg-primary": checked,
94
+ "bg-white": !checked,
95
+ "hover:bg-primary-dark": checked,
96
+ "outline-primary": isFocused,
97
+ "cursor-not-allowed": isDisabled,
98
+ "cursor-pointer": !isDisabled,
99
+ }
100
+ )}
93
101
  data-test-id="checkbox-span"
94
102
  >
95
103
  <span className="cweb-checkbox-icon" />
96
104
  </span>
97
105
 
98
106
  <div className="flex flex-col">
99
- {text && <Text className="ml-2 select-none text-left" text={text} data-test-id="checkbox-text" />}
107
+ {text && (
108
+ <Text
109
+ className="ml-2 text-left select-none"
110
+ text={text}
111
+ data-test-id="checkbox-text"
112
+ />
113
+ )}
100
114
  {explanation && (
101
115
  <Text
102
- className="ml-2 select-none text-left"
116
+ className="ml-2 text-left select-none"
103
117
  text={explanation}
104
- color={"gray-500"}
118
+ color={"slate-500"}
105
119
  data-test-id="checkbox-explanation"
106
120
  />
107
121
  )}
@@ -23,10 +23,10 @@ const keyCodes = {
23
23
  };
24
24
 
25
25
  class Dropdown extends PureComponent {
26
- static addHighlightIndexToItems = (items) => {
26
+ static addHighlightIndexToItems = items => {
27
27
  let index = 0;
28
28
 
29
- return items.map((item) => {
29
+ return items.map(item => {
30
30
  if (!item.subItems) {
31
31
  const currentIndex = index;
32
32
  index = index + 1;
@@ -38,7 +38,7 @@ class Dropdown extends PureComponent {
38
38
  } else {
39
39
  return {
40
40
  ...item,
41
- subItems: item.subItems.map((subItem) => {
41
+ subItems: item.subItems.map(subItem => {
42
42
  const currentIndex = index;
43
43
  index = index + 1;
44
44
 
@@ -52,7 +52,7 @@ class Dropdown extends PureComponent {
52
52
  });
53
53
  };
54
54
 
55
- static getTotalItemCount = (items) => {
55
+ static getTotalItemCount = items => {
56
56
  return items.reduce((acc, item) => {
57
57
  if (!item.subItems) {
58
58
  return acc + 1;
@@ -67,7 +67,11 @@ class Dropdown extends PureComponent {
67
67
 
68
68
  const items = Dropdown.addHighlightIndexToItems(props.items);
69
69
  const selectedItem = props.initialSelectedItemId
70
- ? this.findItem(items, ITEM_QUERY_FIELD_NAMES.ID, props.initialSelectedItemId)
70
+ ? this.findItem(
71
+ items,
72
+ ITEM_QUERY_FIELD_NAMES.ID,
73
+ props.initialSelectedItemId
74
+ )
71
75
  : null;
72
76
 
73
77
  this.state = {
@@ -97,13 +101,13 @@ class Dropdown extends PureComponent {
97
101
  document.removeEventListener("mousedown", this.handleClickOutside);
98
102
  }
99
103
 
100
- handleClickOutside = (event) => {
104
+ handleClickOutside = event => {
101
105
  if (this.rootRef && !this.rootRef.contains(event.target)) {
102
106
  this.closeDropdown();
103
107
  }
104
108
  };
105
109
 
106
- handleKeyDown = (event) => {
110
+ handleKeyDown = event => {
107
111
  const { items, isDropdownOpen, highlightIndex } = this.state;
108
112
 
109
113
  if (event.keyCode === keyCodes.ENTER) {
@@ -111,7 +115,13 @@ class Dropdown extends PureComponent {
111
115
 
112
116
  if (isDropdownOpen) {
113
117
  this.closeDropdown();
114
- this.setSelectedItem(this.findItem(items, ITEM_QUERY_FIELD_NAMES.HIGHLIGHT_INDEX, highlightIndex));
118
+ this.setSelectedItem(
119
+ this.findItem(
120
+ items,
121
+ ITEM_QUERY_FIELD_NAMES.HIGHLIGHT_INDEX,
122
+ highlightIndex
123
+ )
124
+ );
115
125
  this.rootRef.blur();
116
126
  } else {
117
127
  this.openDropdown();
@@ -153,7 +163,8 @@ class Dropdown extends PureComponent {
153
163
  const subItem = item.subItems[j];
154
164
 
155
165
  if (
156
- (fieldName === ITEM_QUERY_FIELD_NAMES.ID && subItem.key === fieldValue) ||
166
+ (fieldName === ITEM_QUERY_FIELD_NAMES.ID &&
167
+ subItem.key === fieldValue) ||
157
168
  subItem[fieldName] === fieldValue
158
169
  ) {
159
170
  selectedItem = subItem;
@@ -171,10 +182,12 @@ class Dropdown extends PureComponent {
171
182
  };
172
183
 
173
184
  openDropdown = () => {
174
- this.setState((prevState) => {
185
+ this.setState(prevState => {
175
186
  return {
176
187
  isDropdownOpen: true,
177
- highlightIndex: prevState.selectedItem ? prevState.selectedItem.highlightIndex : 0,
188
+ highlightIndex: prevState.selectedItem
189
+ ? prevState.selectedItem.highlightIndex
190
+ : 0,
178
191
  };
179
192
  });
180
193
  };
@@ -186,17 +199,17 @@ class Dropdown extends PureComponent {
186
199
  });
187
200
  };
188
201
 
189
- setSelectedItem = (item) => {
202
+ setSelectedItem = item => {
190
203
  this.setState({
191
204
  selectedItem: item,
192
205
  });
193
206
  };
194
207
 
195
- findSelectedItem = (selectedIndex) => {
208
+ findSelectedItem = selectedIndex => {
196
209
  return this.rootRef.querySelectorAll(".dropdown-list-item")[selectedIndex];
197
210
  };
198
211
 
199
- scrollToHighlightedItem = (selectedIndex) => {
212
+ scrollToHighlightedItem = selectedIndex => {
200
213
  const selectedItem = this.findSelectedItem(selectedIndex);
201
214
  if (this.dropdownListRef.scrollTo) {
202
215
  this.dropdownListRef.scrollTo(0, selectedItem.offsetTop);
@@ -204,7 +217,7 @@ class Dropdown extends PureComponent {
204
217
  };
205
218
 
206
219
  increaseHighlightIndexIfPossible = () => {
207
- this.setState((prevState) => {
220
+ this.setState(prevState => {
208
221
  const newHighlightIndex =
209
222
  prevState.highlightIndex < prevState.totalItemCount - 1
210
223
  ? prevState.highlightIndex + 1
@@ -221,8 +234,11 @@ class Dropdown extends PureComponent {
221
234
  };
222
235
 
223
236
  decreaseHighlightIndexIfPossible = () => {
224
- this.setState((prevState) => {
225
- const newHighlightIndex = prevState.highlightIndex > 0 ? prevState.highlightIndex - 1 : prevState.highlightIndex;
237
+ this.setState(prevState => {
238
+ const newHighlightIndex =
239
+ prevState.highlightIndex > 0
240
+ ? prevState.highlightIndex - 1
241
+ : prevState.highlightIndex;
226
242
 
227
243
  if (newHighlightIndex !== prevState.highlightIndex) {
228
244
  this.scrollToHighlightedItem(newHighlightIndex);
@@ -234,7 +250,7 @@ class Dropdown extends PureComponent {
234
250
  });
235
251
  };
236
252
 
237
- selectItem = (item) => {
253
+ selectItem = item => {
238
254
  const { onItemSelect } = this.props;
239
255
 
240
256
  this.closeDropdown();
@@ -243,7 +259,7 @@ class Dropdown extends PureComponent {
243
259
  onItemSelect(item);
244
260
  };
245
261
 
246
- renderIndividualItem = (item) => {
262
+ renderIndividualItem = item => {
247
263
  const { highlightIndex } = this.state;
248
264
  const isItemSelected = item.highlightIndex === highlightIndex;
249
265
 
@@ -254,14 +270,28 @@ class Dropdown extends PureComponent {
254
270
  const textType = isItemSelected ? "strong" : "base";
255
271
 
256
272
  return (
257
- <div className={itemClassName} key={item.id} tabIndex="0" onClick={() => this.selectItem(item)}>
258
- <Text data-test-id={item.text} text={item.text} type={textType} truncate />
259
- <img className={classNames({ hidden: !isItemSelected })} src={checkmark} alt="checked" />
273
+ <div
274
+ className={itemClassName}
275
+ key={item.id}
276
+ tabIndex="0"
277
+ onClick={() => this.selectItem(item)}
278
+ >
279
+ <Text
280
+ data-test-id={item.text}
281
+ text={item.text}
282
+ type={textType}
283
+ truncate
284
+ />
285
+ <img
286
+ className={classNames({ hidden: !isItemSelected })}
287
+ src={checkmark}
288
+ alt="checked"
289
+ />
260
290
  </div>
261
291
  );
262
292
  };
263
293
 
264
- renderGroupedItems = (item) => {
294
+ renderGroupedItems = item => {
265
295
  return (
266
296
  <div className="dropdown-list-item-group" key={item.groupKey}>
267
297
  {item.title && (
@@ -271,12 +301,12 @@ class Dropdown extends PureComponent {
271
301
  data-test-id={item.text}
272
302
  text={item.title}
273
303
  type="sm"
274
- color="gray-500"
304
+ color="slate-500"
275
305
  truncate
276
306
  />
277
307
  </div>
278
308
  )}
279
- {item.subItems.map((subItem) => this.renderIndividualItem(subItem))}
309
+ {item.subItems.map(subItem => this.renderIndividualItem(subItem))}
280
310
  </div>
281
311
  );
282
312
  };
@@ -287,9 +317,13 @@ class Dropdown extends PureComponent {
287
317
  return (
288
318
  <div
289
319
  className={classNames("dropdown-list", { wider: this.props.wider })}
290
- ref={(element) => (this.dropdownListRef = element)}
320
+ ref={element => (this.dropdownListRef = element)}
291
321
  >
292
- {items.map((item) => (item.subItems ? this.renderGroupedItems(item) : this.renderIndividualItem(item)))}
322
+ {items.map(item =>
323
+ item.subItems
324
+ ? this.renderGroupedItems(item)
325
+ : this.renderIndividualItem(item)
326
+ )}
293
327
  </div>
294
328
  );
295
329
  };
@@ -306,26 +340,41 @@ class Dropdown extends PureComponent {
306
340
  ...otherProps
307
341
  } = this.props;
308
342
  const { selectedItem, isDropdownOpen } = this.state;
309
- const containerClassName = classNames("cweb-dropdown", className, { "is-open": isDropdownOpen });
310
- const onDropdownClick = isDropdownOpen ? this.closeDropdown : this.openDropdown;
343
+ const containerClassName = classNames("cweb-dropdown", className, {
344
+ "is-open": isDropdownOpen,
345
+ });
346
+ const onDropdownClick = isDropdownOpen
347
+ ? this.closeDropdown
348
+ : this.openDropdown;
311
349
 
312
350
  return (
313
351
  <div
314
352
  className={classNames(containerClassName)}
315
353
  tabIndex="0"
316
- ref={(element) => (this.rootRef = element)}
354
+ ref={element => (this.rootRef = element)}
317
355
  onKeyDown={this.handleKeyDown}
318
356
  >
319
357
  <div
320
358
  {...otherProps}
321
- className={classNames("dropdown-header space-x-2 border border-solid p-3 cursor-pointer", {
322
- "border-primary-dark": isDropdownOpen,
323
- "border-input-border hover:border-input-border-dark": !isDropdownOpen,
324
- })}
359
+ className={classNames(
360
+ "dropdown-header space-x-2 border border-solid p-3 cursor-pointer",
361
+ {
362
+ "border-primary-dark": isDropdownOpen,
363
+ "border-input-border hover:border-input-border-dark": !isDropdownOpen,
364
+ }
365
+ )}
325
366
  onClick={onDropdownClick}
326
367
  >
327
- <Text className="dropdown-header-title" text={selectedItem ? selectedItem.text : placeholder} truncate />
328
- <img className="dropdown-header-icon" src={chevronDouble} alt="browse icon" />
368
+ <Text
369
+ className="dropdown-header-title"
370
+ text={selectedItem ? selectedItem.text : placeholder}
371
+ truncate
372
+ />
373
+ <img
374
+ className="dropdown-header-icon"
375
+ src={chevronDouble}
376
+ alt="browse icon"
377
+ />
329
378
  </div>
330
379
  {this.renderItems()}
331
380
  </div>
@@ -354,7 +403,10 @@ Dropdown.propTypes = {
354
403
  }),
355
404
  ])
356
405
  ).isRequired,
357
- initialSelectedItemId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
406
+ initialSelectedItemId: PropTypes.oneOfType([
407
+ PropTypes.number,
408
+ PropTypes.string,
409
+ ]),
358
410
  placeholder: PropTypes.string,
359
411
  className: PropTypes.string,
360
412
  onItemSelect: PropTypes.func.isRequired,
@@ -19,7 +19,7 @@ interface InfoFieldProps {
19
19
  export const InfoField = (props: InfoFieldProps): JSX.Element => {
20
20
  const clipboard = new ClipboardJS("button");
21
21
 
22
- clipboard.on("success", function (e) {
22
+ clipboard.on("success", function(e) {
23
23
  props.onCopyToClipboard && props.onCopyToClipboard();
24
24
  e.clearSelection();
25
25
  });
@@ -56,13 +56,21 @@ export const InfoField = (props: InfoFieldProps): JSX.Element => {
56
56
  }
57
57
 
58
58
  return (
59
- <div className={classNames("flex flex-row align-center items-center", props.className)}>
59
+ <div
60
+ className={classNames(
61
+ "flex flex-row align-center items-center",
62
+ props.className
63
+ )}
64
+ >
60
65
  {props.icon}
61
- <ContainerElement className={"flex flex-col overflow-hidden ml-3 first:ml-0"} {...containerProps}>
66
+ <ContainerElement
67
+ className={"flex flex-col overflow-hidden ml-3 first:ml-0"}
68
+ {...containerProps}
69
+ >
62
70
  <Text
63
71
  text={props.label}
64
72
  type={"sm"}
65
- color={"gray-500"}
73
+ color={"slate-500"}
66
74
  className={classNames(
67
75
  { "break-words": props.supportsMultiline },
68
76
  { "whitespace-no-wrap": !props.supportsMultiline }
@@ -145,8 +145,9 @@ export function ListTable<ItemType extends ListTableItem, CellType>({
145
145
  <Text
146
146
  className={classNames(
147
147
  "no-item-found-text",
148
- "w-56 text-base text-gray-600 text-center whitespace-pre-wrap"
148
+ "w-56 text-base text-center whitespace-pre-wrap"
149
149
  )}
150
+ color="slate-500"
150
151
  text={configuration.emptyListText}
151
152
  />
152
153
  </div>
@@ -6,7 +6,9 @@ import { Text } from "../Text/Text";
6
6
  import { ListTablePropsConfigurationField } from "./ListTable";
7
7
 
8
8
  function isEmpty(str: string) {
9
- return str === null || str === undefined || (isString(str) && str.trim() === "");
9
+ return (
10
+ str === null || str === undefined || (isString(str) && str.trim() === "")
11
+ );
10
12
  }
11
13
 
12
14
  function isString(obj?: string | any): obj is string {
@@ -29,15 +31,24 @@ export function ListTableCell<ItemType, CellType>({
29
31
  const { name, className, textProps } = configuration;
30
32
 
31
33
  const textClassName = classNames("text-left", textProps?.className);
32
- const cellClassName = classNames("cweb-list-table-content-cell", "py-0 px-3", className);
34
+ const cellClassName = classNames(
35
+ "cweb-list-table-content-cell",
36
+ "py-0 px-3",
37
+ className
38
+ );
33
39
 
34
- const hasValue = (isString(value) && isEmpty(value) || value !== undefined);
40
+ const hasValue = (isString(value) && isEmpty(value)) || value !== undefined;
35
41
 
36
42
  const returnChildren = () => {
37
43
  return (
38
44
  <>
39
45
  {!hasValue && isString(emptyValue) && (
40
- <Text text={emptyValue} {...textProps} className={textClassName} color={"gray-500"} />
46
+ <Text
47
+ text={emptyValue}
48
+ {...textProps}
49
+ className={textClassName}
50
+ color={"slate-500"}
51
+ />
41
52
  )}
42
53
  {hasValue && isString(value) && (
43
54
  <Text
@@ -3,7 +3,7 @@ import { useState } from "react";
3
3
  import { navigate } from "@reach/router";
4
4
  import classNames from "classnames";
5
5
 
6
- import { TextColor, Text } from "../Text/Text";
6
+ import { Text } from "../Text/Text";
7
7
 
8
8
  export interface NavMenuItemProps {
9
9
  href?: string;
@@ -20,8 +20,9 @@ export interface NavMenuItemProps {
20
20
  }
21
21
 
22
22
  export const NavMenuItem = (props: NavMenuItemProps): JSX.Element => {
23
- const [currentImg, setCurrentImg] = useState(props.isSelected ? props.imgOnHover : props.img);
24
- const [textColor, setTextColor] = useState<TextColor>(props.isSelected ? "white" : "gray-200");
23
+ const [currentImg, setCurrentImg] = useState(
24
+ props.isSelected ? props.imgOnHover : props.img
25
+ );
25
26
 
26
27
  const classes = classNames(
27
28
  [
@@ -40,6 +41,7 @@ export const NavMenuItem = (props: NavMenuItemProps): JSX.Element => {
40
41
  "duration-150",
41
42
  "lg:last:pb-2",
42
43
  "focus:outline-primary",
44
+ "group",
43
45
  ],
44
46
  {
45
47
  "bg-nav-menu": !props.isSelected,
@@ -50,14 +52,12 @@ export const NavMenuItem = (props: NavMenuItemProps): JSX.Element => {
50
52
  const handleOnMouseOver = () => {
51
53
  if (!props.isSelected) {
52
54
  setCurrentImg(props.imgOnHover);
53
- setTextColor("white");
54
55
  }
55
56
  };
56
57
 
57
58
  const handleOnMouseOut = () => {
58
59
  if (!props.isSelected) {
59
60
  setCurrentImg(props.img);
60
- setTextColor("gray-200");
61
61
  }
62
62
  };
63
63
 
@@ -71,7 +71,13 @@ export const NavMenuItem = (props: NavMenuItemProps): JSX.Element => {
71
71
  onClick={handleMenuClick}
72
72
  >
73
73
  <img src={currentImg} className={"mr-4 ml-0"} />
74
- <Text type={"strong"} text={props.title} color={textColor} />
74
+ <Text
75
+ type={"strong"}
76
+ text={props.title}
77
+ hoverInGroup
78
+ color="slate-200"
79
+ hoverColor="white"
80
+ />
75
81
  </a>
76
82
  );
77
83
 
@@ -1,10 +1,15 @@
1
1
  import React from "react";
2
2
  import classNames from "classnames";
3
3
 
4
- import { Text } from "../Text/Text";
4
+ import { Text, TextColor } from "../Text/Text";
5
5
  import { TextLink } from "../TextLink/TextLink";
6
6
 
7
- export type NotificationBannerColor = "base" | "blue" | "red" | "green" | "amber";
7
+ export type NotificationBannerColor =
8
+ | "base"
9
+ | "blue"
10
+ | "red"
11
+ | "green"
12
+ | "amber";
8
13
 
9
14
  export interface NotificationBannerLinkProps {
10
15
  text: string;
@@ -20,23 +25,38 @@ interface NotificationBannerProps {
20
25
  className?: string;
21
26
  }
22
27
 
23
- export const NotificationBanner = (props: NotificationBannerProps): JSX.Element => {
28
+ export const NotificationBanner = (
29
+ props: NotificationBannerProps
30
+ ): JSX.Element => {
24
31
  const classes = classNames(
25
32
  "w-full px-6 py-2 flex flex-row items-center border border-solid rounded",
26
33
  props.className,
27
34
  {
28
- "bg-slate-100 border-slate-700": props.color === "base",
29
- "bg-blue-100 border-blue-700": props.color === "blue",
30
- "bg-red-100 border-red-700": props.color === "red",
31
- "bg-green-100 border-green-700": props.color === "green",
32
- "bg-yellow-100 border-yellow-700": props.color === "amber",
35
+ "bg-slate-50 border-slate-700": props.color === "base",
36
+ "bg-blue-50 border-blue-700": props.color === "blue",
37
+ "bg-red-50 border-red-700": props.color === "red",
38
+ "bg-green-50 border-green-700": props.color === "green",
39
+ "bg-yellow-50 border-yellow-700": props.color === "amber",
33
40
  }
34
41
  );
35
42
 
43
+ const textColor: Record<NotificationBannerColor, TextColor> = {
44
+ red: "red",
45
+ amber: "amber",
46
+ green: "green",
47
+ base: "base",
48
+ // Blue must be 800 here to pass the contrast test
49
+ blue: "blue-800",
50
+ };
51
+
36
52
  return (
37
53
  <div className={classes}>
38
54
  {props.icon}
39
- <Text className="first:ml-0 ml-4" text={props.text} color={props.color} />
55
+ <Text
56
+ className="ml-4 first:ml-0"
57
+ text={props.text}
58
+ color={props.color ? textColor[props.color] : "base"}
59
+ />
40
60
  {props.linkProps && (
41
61
  <TextLink
42
62
  className="ml-4"
@@ -72,7 +72,7 @@ export const PaginationMenuLarge = (
72
72
  props.pageSize,
73
73
  props.resultCount
74
74
  )}
75
- color="gray-500"
75
+ color="slate-500"
76
76
  />
77
77
  <SecondaryButton
78
78
  data-test-id="prev-button"
@@ -28,7 +28,7 @@ export const PaginationMenuSmall = (
28
28
  className="ml-4"
29
29
  text={`${props.currentPageNumber} / ${props.pageCount}`}
30
30
  type="sm"
31
- color="gray-500"
31
+ color="slate-500"
32
32
  />
33
33
  <TertiaryButton
34
34
  className="ml-4"
@@ -6,16 +6,25 @@ export interface StepProps {
6
6
  title: string;
7
7
  stepNumber: number;
8
8
  active: boolean;
9
- localization: {step: string};
9
+ localization: { step: string };
10
10
  }
11
11
 
12
- export const Step = ({ title, stepNumber, active, localization }: StepProps): JSX.Element => {
12
+ export const Step = ({
13
+ title,
14
+ stepNumber,
15
+ active,
16
+ localization,
17
+ }: StepProps): JSX.Element => {
13
18
  const barColor = active ? "bg-blue-800" : "bg-slate-200";
14
19
 
15
20
  return (
16
21
  <div className={"w-full"}>
17
22
  <div className={`w-full h-1 mb-2 rounded ${barColor}`}></div>
18
- <Text text={`${localization.step} ${stepNumber}`} type={"strong"} color={active ? "blue" : "gray-500"} />
23
+ <Text
24
+ text={`${localization.step} ${stepNumber}`}
25
+ type={"strong"}
26
+ color={active ? "blue-800" : "slate-500"}
27
+ />
19
28
  <Text text={title} type={"strong"} />
20
29
  </div>
21
30
  );
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import classNames from "classnames";
3
3
 
4
- import { Text } from "../Text/Text";
4
+ import { Text, TextColor } from "../Text/Text";
5
5
 
6
6
  import { TagSize } from "./TagGroup";
7
7
 
@@ -20,18 +20,37 @@ export interface TagProps {
20
20
  className?: string;
21
21
  }
22
22
 
23
- const Tag = ({ text, colorTheme = TagColorTheme.Gray, className, size = TagSize.base }: TagProps): JSX.Element => {
24
- const containerClassName = classNames("inline py-1 px-2 rounded-lg", className, {
25
- "bg-red-100 text-red-700": colorTheme === TagColorTheme.Red,
26
- "bg-orange-100 text-amber-700": colorTheme === TagColorTheme.Amber,
27
- "bg-green-100 text-green-800": colorTheme === TagColorTheme.Green,
28
- "bg-slate-100 text-slate-600": colorTheme === TagColorTheme.Gray,
29
- "bg-blue-50 text-blue-800": colorTheme === TagColorTheme.Blue,
30
- });
23
+ const Tag = ({
24
+ text,
25
+ colorTheme = TagColorTheme.Gray,
26
+ className,
27
+ size = TagSize.base,
28
+ }: TagProps): JSX.Element => {
29
+ const textColor: Record<TagColorTheme, TextColor> = {
30
+ [TagColorTheme.Red]: "red",
31
+ [TagColorTheme.Amber]: "amber",
32
+ [TagColorTheme.Green]: "green",
33
+ [TagColorTheme.Gray]: "base",
34
+ // Blue must be 800 here to pass the contrast test
35
+ [TagColorTheme.Blue]: "blue-800",
36
+ };
31
37
 
32
38
  return (
33
- <div className={containerClassName}>
34
- <Text inline color={"inherit"} text={text} type={size === TagSize.small ? "sm" : "base"} />
39
+ <div
40
+ className={classNames("inline py-1 px-2 rounded-lg", className, {
41
+ "bg-red-50": colorTheme === TagColorTheme.Red,
42
+ "bg-orange-50": colorTheme === TagColorTheme.Amber,
43
+ "bg-green-50": colorTheme === TagColorTheme.Green,
44
+ "bg-slate-50": colorTheme === TagColorTheme.Gray,
45
+ "bg-blue-50": colorTheme === TagColorTheme.Blue,
46
+ })}
47
+ >
48
+ <Text
49
+ inline
50
+ color={textColor[colorTheme]}
51
+ text={text}
52
+ type={size === TagSize.small ? "sm" : "base"}
53
+ />
35
54
  </div>
36
55
  );
37
56
  };