@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/dist/components/Steps/Step.d.ts +1 -1
- package/dist/components/Tag/Tag.d.ts +1 -1
- package/dist/components/Text/Text.d.ts +5 -3
- package/dist/web-ui.cjs.development.css +12 -12
- package/dist/web-ui.cjs.development.js +70 -46
- package/dist/web-ui.cjs.development.js.map +1 -1
- package/dist/web-ui.cjs.production.min.css +12 -12
- package/dist/web-ui.cjs.production.min.js +1 -1
- package/dist/web-ui.cjs.production.min.js.map +1 -1
- package/dist/web-ui.esm.css +12 -12
- package/dist/web-ui.esm.js +70 -46
- package/dist/web-ui.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Checkbox/Checkbox.tsx +27 -13
- package/src/components/Dropdown/Dropdown.js +89 -37
- package/src/components/InfoField/InfoField.tsx +12 -4
- package/src/components/ListTable/ListTable.tsx +2 -1
- package/src/components/ListTable/ListTableCell.tsx +15 -4
- package/src/components/NavMenu/NavMenuItem.tsx +12 -6
- package/src/components/NotificationBanner/NotificationBanner.tsx +29 -9
- package/src/components/PaginationMenu/PaginationMenuLarge.tsx +1 -1
- package/src/components/PaginationMenu/PaginationMenuSmall.tsx +1 -1
- package/src/components/Steps/Step.tsx +12 -3
- package/src/components/Tag/Tag.tsx +30 -11
- package/src/components/Text/Text.tsx +87 -37
- package/src/components/ViewItem/ViewItem.tsx +21 -9
|
@@ -5,17 +5,36 @@ import { RestPropped } from "../../types/general.types";
|
|
|
5
5
|
|
|
6
6
|
import "./Text.scss";
|
|
7
7
|
|
|
8
|
-
export type TextStyle =
|
|
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 =
|
|
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?:
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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>
|
|
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(
|
|
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
|
|
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(
|
|
49
|
-
|
|
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(
|
|
57
|
-
|
|
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(
|
|
73
|
+
buttons.map(button => (
|
|
62
74
|
<Button
|
|
63
75
|
{...button}
|
|
64
76
|
className={classNames("cweb-view-button ml-3", button.className)}
|