@luscii-healthtech/web-ui 0.2.2 → 0.4.1

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.
Files changed (40) hide show
  1. package/dist/components/Section/SectionItem.d.ts +9 -0
  2. package/dist/components/{TextListItem/TextListItem.d.ts → Section/SectionItemWithContent.d.ts} +3 -3
  3. package/dist/components/Steps/Step.d.ts +1 -1
  4. package/dist/components/Tag/Tag.d.ts +2 -2
  5. package/dist/components/Tag/Tag.utils.d.ts +4 -0
  6. package/dist/components/Tag/TagGroup.d.ts +2 -5
  7. package/dist/components/Text/Text.d.ts +5 -3
  8. package/dist/index.d.ts +2 -2
  9. package/dist/web-ui-tailwind.css +2111 -0
  10. package/dist/web-ui.cjs.development.css +58 -58
  11. package/dist/web-ui.cjs.development.js +99 -75
  12. package/dist/web-ui.cjs.development.js.map +1 -1
  13. package/dist/web-ui.cjs.production.min.css +58 -58
  14. package/dist/web-ui.cjs.production.min.js +1 -1
  15. package/dist/web-ui.cjs.production.min.js.map +1 -1
  16. package/dist/web-ui.esm.css +58 -58
  17. package/dist/web-ui.esm.js +98 -74
  18. package/dist/web-ui.esm.js.map +1 -1
  19. package/package.json +13 -5
  20. package/src/components/Checkbox/Checkbox.tsx +27 -13
  21. package/src/components/Dropdown/Dropdown.js +89 -37
  22. package/src/components/InfoField/InfoField.tsx +12 -4
  23. package/src/components/ListTable/ListTable.tsx +2 -1
  24. package/src/components/ListTable/ListTableCell.tsx +15 -4
  25. package/src/components/NavMenu/NavMenuItem.tsx +12 -6
  26. package/src/components/NotificationBanner/NotificationBanner.tsx +29 -9
  27. package/src/components/PaginationMenu/PaginationMenuLarge.tsx +1 -1
  28. package/src/components/PaginationMenu/PaginationMenuSmall.tsx +1 -1
  29. package/src/components/{ListItem/ListItem.scss → Section/SectionItem.scss} +0 -0
  30. package/src/components/{ListItem/ListItem.tsx → Section/SectionItem.tsx} +7 -7
  31. package/src/components/{TextListItem/TextListItem.js → Section/SectionItemWithContent.js} +10 -9
  32. package/src/components/{TextListItem/TextListItem.scss → Section/SectionItemWithContent.scss} +2 -2
  33. package/src/components/Steps/Step.tsx +12 -3
  34. package/src/components/Tag/Tag.tsx +31 -12
  35. package/src/components/Tag/Tag.utils.ts +4 -0
  36. package/src/components/Tag/TagGroup.tsx +12 -8
  37. package/src/components/Text/Text.tsx +87 -37
  38. package/src/components/ViewItem/ViewItem.tsx +21 -9
  39. package/src/index.tsx +4 -4
  40. package/dist/components/ListItem/ListItem.d.ts +0 -9
@@ -3,24 +3,25 @@ import PropTypes from "prop-types";
3
3
  import classNames from "classnames";
4
4
 
5
5
  import LegacyText from "../Text/LegacyText";
6
- import "./TextListItem.scss";
7
- import ListItem from "../ListItem/ListItem";
8
6
 
9
- function TextListItem(props) {
7
+ import "./SectionItemWithContent.scss";
8
+ import SectionItem from "./SectionItem";
9
+
10
+ function SectionItemWithContent(props) {
10
11
  const { text, icon, className, iconClass, onClick, ...rest } = props;
11
12
 
12
- const mergedClasses = classNames("cweb-text-list-item", className);
13
- const iconClasses = classNames("cweb-text-list-item-icon", iconClass);
13
+ const mergedClasses = classNames("cweb-section-text-item", className);
14
+ const iconClasses = classNames("cweb-section-text-item-icon", iconClass);
14
15
 
15
16
  return (
16
- <ListItem className={mergedClasses} onClick={onClick} {...rest}>
17
+ <SectionItem className={mergedClasses} onClick={onClick} {...rest}>
17
18
  {icon && <img className={iconClasses} src={icon} alt="" />}
18
19
  <LegacyText text={text} />
19
- </ListItem>
20
+ </SectionItem>
20
21
  );
21
22
  }
22
23
 
23
- TextListItem.propTypes = {
24
+ SectionItemWithContent.propTypes = {
24
25
  text: PropTypes.string.isRequired,
25
26
  icon: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
26
27
  className: PropTypes.string,
@@ -28,4 +29,4 @@ TextListItem.propTypes = {
28
29
  onClick: PropTypes.func,
29
30
  };
30
31
 
31
- export default TextListItem;
32
+ export default SectionItemWithContent;
@@ -1,8 +1,8 @@
1
1
  @import "../../styles/colors";
2
2
  @import "../../styles/layout";
3
3
 
4
- .cweb-text-list-item {
5
- .cweb-text-list-item-icon {
4
+ .cweb-section-text-item {
5
+ .cweb-section-text-item-icon {
6
6
  width: 24px;
7
7
  height: 24px;
8
8
  margin-right: 16px;
@@ -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,9 +1,9 @@
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
- import { TagSize } from "./TagGroup";
6
+ import { TagSize } from "./Tag.utils";
7
7
 
8
8
  export enum TagColorTheme {
9
9
  Red = "red",
@@ -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
  };
@@ -0,0 +1,4 @@
1
+ export enum TagSize {
2
+ "small" = "small",
3
+ "base" = "base",
4
+ }
@@ -2,11 +2,7 @@ import React from "react";
2
2
  import classNames from "classnames";
3
3
 
4
4
  import Tag, { TagProps } from "./Tag";
5
-
6
- export enum TagSize {
7
- "small" = "small",
8
- "base" = "base",
9
- }
5
+ import { TagSize } from "./Tag.utils";
10
6
 
11
7
  interface TagGroupProps {
12
8
  tags: TagProps[];
@@ -14,10 +10,18 @@ interface TagGroupProps {
14
10
  className?: string;
15
11
  }
16
12
 
17
- const TagGroup = ({ tags, tagSize = TagSize.base, className }: TagGroupProps): JSX.Element => (
13
+ const TagGroup = ({
14
+ tags,
15
+ tagSize = TagSize.base,
16
+ className,
17
+ }: TagGroupProps): JSX.Element => (
18
18
  <div className={classNames("flex flex-row flex-wrap", className)}>
19
- {tags.map((tag) => (
20
- <Tag size={tagSize} {...tag} className={classNames("mr-2 last:mr-0 mb-2")} />
19
+ {tags.map(tag => (
20
+ <Tag
21
+ size={tagSize}
22
+ {...tag}
23
+ className={classNames("mr-2 last:mr-0 mb-2")}
24
+ />
21
25
  ))}
22
26
  </div>
23
27
  );
@@ -5,17 +5,36 @@ import { RestPropped } from "../../types/general.types";
5
5
 
6
6
  import "./Text.scss";
7
7
 
8
- export type TextStyle = "sm" | "sm-strong" | "base" | "strong" | "lg" | "lg-strong" | "xl" | "xl-strong" | string;
8
+ export type TextStyle =
9
+ | "sm"
10
+ | "sm-strong"
11
+ | "base"
12
+ | "strong"
13
+ | "lg"
14
+ | "lg-strong"
15
+ | "xl"
16
+ | "xl-strong";
9
17
 
10
18
  //Extend with other colors that we want to enable for text
11
- export type TextColor = "base" | "gray-500" | "gray-200" | "white" | "blue" | "red" | "green" | "amber" | "inherit";
19
+ export type TextColor =
20
+ | "base"
21
+ | "slate-500"
22
+ | "slate-200"
23
+ | "white"
24
+ | "blue-800"
25
+ | "red"
26
+ | "green"
27
+ | "amber";
28
+
29
+ export type TextHoverColor = "blue-900" | "white";
12
30
 
13
31
  export interface TextProps extends RestPropped {
14
32
  text: string;
15
33
  type?: TextStyle; //defaults to "base"
16
34
  inline?: boolean; //defaults to false
17
35
  color?: TextColor; //defaults to "base"
18
- hoverColor?: TextColor; //defaults to "base"
36
+ hoverColor?: TextHoverColor; //defaults to "base"
37
+ hoverInGroup?: boolean;
19
38
  className?: string;
20
39
  containsDangerousHtml?: boolean; //defaults to false
21
40
  truncate?: boolean; //defaults to false
@@ -23,43 +42,74 @@ export interface TextProps extends RestPropped {
23
42
  }
24
43
 
25
44
  export const Text = (props: TextProps): JSX.Element => {
45
+ /**
46
+ * One might argue that we're duplicating strings in this file.
47
+ * That's how tailwind expects to detect used classes, so please do not make
48
+ * anything dynamic or try to string concat class names.
49
+ * https://v1.tailwindcss.com/docs/controlling-file-size
50
+ */
51
+
52
+ const allowedColors: Record<TextColor, string> = {
53
+ base: "text-slate-700",
54
+ "slate-500": "text-slate-500",
55
+ "slate-200": "text-slate-200",
56
+ red: "text-red-700",
57
+ green: "text-green-700",
58
+ amber: "text-yellow-700",
59
+ white: "text-white",
60
+ "blue-800": "text-blue-800",
61
+ };
62
+
63
+ const allowedHoverColors: Record<TextHoverColor, string> = {
64
+ "blue-900": "hover:text-blue-900",
65
+ white: "hover:text-white",
66
+ };
67
+
68
+ // What is a group hover? https://v1.tailwindcss.com/docs/pseudo-class-variants#group-hover
69
+ const allowedGroupHoverColors: Record<TextHoverColor, string> = {
70
+ "blue-900": "group-hover:text-blue-900",
71
+ white: "group-hover:text-white",
72
+ };
73
+
74
+ const selectedHoverColor =
75
+ props.hoverColor &&
76
+ !props.hoverInGroup &&
77
+ allowedHoverColors[props.hoverColor];
78
+
79
+ const selectedGroupHoverColor =
80
+ props.hoverColor &&
81
+ props.hoverInGroup &&
82
+ allowedGroupHoverColors[props.hoverColor];
83
+
26
84
  const containerProps = {
27
85
  "data-test-id": props["data-test-id"],
28
86
  className: classNames(
29
- // apply different style classes
30
- // for now we stick with font-size 16px on the body
31
- // so I am adjusting our styles accordingly (one step down)
32
- {
33
- "text-xs font-medium": props.type === "sm",
34
- "text-xs font-semibold": props.type === "sm-strong",
35
- "text-sm": props.type === "base",
36
- "text-sm font-semibold": props.type === "strong",
37
- "": props.type === "lg",
38
- "font-semibold": props.type === "lg-strong",
39
- "text-lg": props.type === "xl",
40
- "font-semibold text-lg": props.type === "xl-strong",
41
- },
42
- {
43
- inline: props.inline,
44
- // FIXME: this class doesn't do anything without a max-width
45
- truncate: props.truncate,
46
- },
47
- {
48
- "text-slate-700": props.color === "base",
49
- "text-slate-500": props.color === "gray-500",
50
- "text-slate-200": props.color === "gray-200",
51
- "text-red-700": props.color === "red",
52
- "text-green-700": props.color === "green",
53
- "text-yellow-700": props.color === "amber",
54
- "text-blue-700": props.color === "blue",
55
- "text-white": props.color === "white",
56
- "text-primary-dark": props.color === "blue",
57
- },
58
- {
59
- "in-html-link": props.containsDangerousHtml,
60
- },
61
- //can be used to overwrite other classes like the color
62
- props.className
87
+ // apply different style classes
88
+ // for now we stick with font-size 16px on the body
89
+ // so I am adjusting our styles accordingly (one step down)
90
+ {
91
+ "text-xs font-medium": props.type === "sm",
92
+ "text-xs font-semibold": props.type === "sm-strong",
93
+ "text-sm": props.type === "base",
94
+ "text-sm font-semibold": props.type === "strong",
95
+ "": props.type === "lg",
96
+ "font-semibold": props.type === "lg-strong",
97
+ "text-lg": props.type === "xl",
98
+ "font-semibold text-lg": props.type === "xl-strong",
99
+ },
100
+ {
101
+ inline: props.inline,
102
+ // FIXME: this class doesn't do anything without a max-width
103
+ truncate: props.truncate,
104
+ },
105
+ allowedColors[props.color || "base"],
106
+ selectedHoverColor,
107
+ selectedGroupHoverColor,
108
+ {
109
+ "in-html-link": props.containsDangerousHtml,
110
+ },
111
+ //can be used to overwrite other classes like the color
112
+ props.className
63
113
  ),
64
114
  };
65
115
 
@@ -6,7 +6,8 @@ import Button from "../Button/Button";
6
6
  import { RestPropped } from "../../types/general.types";
7
7
  import { ButtonProps } from "../Button/Button.types";
8
8
 
9
- export interface ViewItemProps<AccessoryType extends JSX.Element> extends RestPropped {
9
+ export interface ViewItemProps<AccessoryType extends JSX.Element>
10
+ extends RestPropped {
10
11
  titleProps?: TextProps;
11
12
  // deprecated: use titleProps instead
12
13
  title?: string;
@@ -22,7 +23,7 @@ export interface ViewItemProps<AccessoryType extends JSX.Element> extends RestPr
22
23
  buttons?: ButtonProps[];
23
24
  }
24
25
 
25
- export function ViewItem<AccessoryType extends JSX.Element> ({
26
+ export function ViewItem<AccessoryType extends JSX.Element>({
26
27
  titleProps,
27
28
  title,
28
29
  titleAccessory,
@@ -36,29 +37,40 @@ export function ViewItem<AccessoryType extends JSX.Element> ({
36
37
  const titlePropsMerged = titleProps ?? { text: title ?? defaultContent };
37
38
  const contentPropsMerged =
38
39
  contentProps ??
39
- content?.map((line) => {
40
+ content?.map(line => {
40
41
  return { text: line, className: "cweb-view-content-text" } as TextProps;
41
42
  });
42
43
 
43
44
  return (
44
45
  <div className={classNames("vitals-view-item", className)} {...restProps}>
45
- <div className={"vitals-view-item-title-line flex justify-start flex-row items-start"}>
46
+ <div
47
+ className={
48
+ "vitals-view-item-title-line flex justify-start flex-row items-start"
49
+ }
50
+ >
46
51
  {titlePropsMerged && (
47
52
  <Text
48
- className={classNames(titlePropsMerged.className, "vitals-view-item-title mb-1 mr-2")}
49
- color="gray-500"
53
+ className={classNames(
54
+ titlePropsMerged.className,
55
+ "vitals-view-item-title mb-1 mr-2"
56
+ )}
57
+ color="slate-500"
50
58
  {...titlePropsMerged}
51
59
  />
52
60
  )}
53
61
  {titleAccessory}
54
62
  </div>
55
63
  {contentPropsMerged &&
56
- contentPropsMerged?.map((textProps) => <Text {...textProps} key={textProps.key || textProps.text} />)}
57
- {(!contentPropsMerged || contentPropsMerged?.length === 0) && <Text text={defaultContent} key="empty-text" />}
64
+ contentPropsMerged?.map(textProps => (
65
+ <Text {...textProps} key={textProps.key || textProps.text} />
66
+ ))}
67
+ {(!contentPropsMerged || contentPropsMerged?.length === 0) && (
68
+ <Text text={defaultContent} key="empty-text" />
69
+ )}
58
70
 
59
71
  <div className="flex flex-row cweb-view-buttons" key="cweb-view-buttons">
60
72
  {buttons &&
61
- buttons.map((button) => (
73
+ buttons.map(button => (
62
74
  <Button
63
75
  {...button}
64
76
  className={classNames("cweb-view-button ml-3", button.className)}
package/src/index.tsx CHANGED
@@ -24,9 +24,9 @@ export { InfoField } from "./components/InfoField/InfoField";
24
24
  export { INPUT_TYPES, default as Input } from "./components/Input/Input";
25
25
  export { default as Line } from "./components/Line/Line";
26
26
  export {
27
- default as ListItem,
28
- ListItemProps,
29
- } from "./components/ListItem/ListItem";
27
+ default as SectionItem,
28
+ SectionItemProps,
29
+ } from "./components/Section/SectionItem";
30
30
  export {
31
31
  ListTable,
32
32
  ListTableProps,
@@ -75,7 +75,7 @@ export { default as TextArea } from "./components/Textarea/Textarea";
75
75
  export { default as TextEditor } from "./components/TextEditor/TextEditor";
76
76
  export { default as TextEditorV2 } from "./components/TextEditorV2/TextEditorV2";
77
77
  export { TextLink, TextLinkProps } from "./components/TextLink/TextLink";
78
- export { default as TextListItem } from "./components/TextListItem/TextListItem";
78
+ export { default as SectionItemWithContent } from "./components/Section/SectionItemWithContent";
79
79
  export { Title, TitleStyle } from "./components/Title/Title";
80
80
  export { ViewItem, ViewItemProps } from "./components/ViewItem/ViewItem";
81
81
 
@@ -1,9 +0,0 @@
1
- import React from "react";
2
- import "./ListItem.scss";
3
- export interface ListItemProps {
4
- className?: string;
5
- onClick?: any;
6
- children?: any;
7
- }
8
- export declare const ListItem: React.FC<ListItemProps>;
9
- export default ListItem;