@luscii-healthtech/web-ui 0.5.2 → 0.6.2

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.5.2",
2
+ "version": "0.6.2",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -24,7 +24,8 @@
24
24
  "build-tailwind": "NODE_ENV=production yarn run tailwindcss build tailwind.css -o ./dist/web-ui-tailwind.css"
25
25
  },
26
26
  "peerDependencies": {
27
- "react": ">=16"
27
+ "react": ">=16",
28
+ "react-tooltip": "^4.2.21"
28
29
  },
29
30
  "husky": {
30
31
  "hooks": {
@@ -82,6 +83,7 @@
82
83
  "react": "^18.2.0",
83
84
  "react-dom": "^18.2.0",
84
85
  "react-is": "^18.2.0",
86
+ "react-tooltip": "^4.2.21",
85
87
  "rollup-plugin-postcss": "^4.0.2",
86
88
  "rollup-plugin-scss": "^3.0.0",
87
89
  "rollup-plugin-svg": "^2.0.0",
@@ -1,8 +1,12 @@
1
1
  import { IconProps } from "../Icons/types/IconProps.type";
2
+ import { TextColor, TextHoverColor } from "../Text/Text";
2
3
 
3
- export interface BaseButtonProps extends React.HTMLAttributes<HTMLButtonElement> {
4
+ export interface BaseButtonProps
5
+ extends React.HTMLAttributes<HTMLButtonElement> {
4
6
  onClick: (event: React.MouseEvent<HTMLButtonElement>) => void;
5
7
  text?: string;
8
+ textColor?: TextColor;
9
+ textHoverColor?: TextHoverColor;
6
10
  icon?: React.FunctionComponent<IconProps>;
7
11
  isDisabled?: boolean;
8
12
  className?: string;
@@ -2,12 +2,15 @@ import classNames from "classnames";
2
2
  import React from "react";
3
3
 
4
4
  import { Spinner } from "../Spinner/Spinner";
5
+ import Text from "../Text/Text";
5
6
 
6
7
  import { ButtonProps } from "./ButtonProps.type";
7
8
 
8
9
  export const ButtonV2 = ({
9
10
  onClick,
10
11
  text,
12
+ textColor,
13
+ textHoverColor,
11
14
  icon,
12
15
  isDisabled,
13
16
  isPending,
@@ -32,6 +35,7 @@ export const ButtonV2 = ({
32
35
  "shadow-sm",
33
36
  "cursor-pointer",
34
37
  "focus:outline-primary",
38
+ "group",
35
39
  ],
36
40
  {
37
41
  "w-11": !text && icon,
@@ -72,14 +76,16 @@ export const ButtonV2 = ({
72
76
  )}
73
77
 
74
78
  {text && (
75
- <span
76
- className={classNames("text-sm font-medium", {
79
+ <Text
80
+ className={classNames({
77
81
  invisible: isPending,
78
82
  "ml-1": icon,
79
83
  })}
80
- >
81
- {text}
82
- </span>
84
+ text={text}
85
+ color={textColor}
86
+ hoverColor={textHoverColor}
87
+ hoverInGroup
88
+ />
83
89
  )}
84
90
  </button>
85
91
  );
@@ -17,6 +17,7 @@ export const PrimaryButton = (props: ButtonProps): JSX.Element => {
17
17
  ],
18
18
  props.className
19
19
  )}
20
+ textColor="white"
20
21
  />
21
22
  );
22
23
  };
@@ -19,6 +19,8 @@ export const SecondaryButton = (props: BaseButtonProps): JSX.Element => {
19
19
  ],
20
20
  props.className
21
21
  )}
22
+ textColor="blue-800"
23
+ textHoverColor="blue-900"
22
24
  />
23
25
  );
24
26
  };
@@ -19,6 +19,8 @@ export const TertiaryButton = (props: BaseButtonProps): JSX.Element => {
19
19
  ],
20
20
  props.className
21
21
  )}
22
+ textColor="blue-800"
23
+ textHoverColor="blue-900"
22
24
  />
23
25
  );
24
26
  };
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import classNames from "classnames";
3
+
4
+ import { ListItem, ListItemProps } from "./ListItem";
5
+
6
+ export interface ListProps {
7
+ items: ListItemProps[];
8
+ }
9
+
10
+ export const List = ({ items }: ListProps): JSX.Element => {
11
+ return (
12
+ <ul className={classNames("list-none")}>
13
+ {items.map(item => (
14
+ <ListItem {...item} key={item.itemId} />
15
+ ))}
16
+ </ul>
17
+ );
18
+ };
19
+
20
+ export default List;
@@ -0,0 +1,45 @@
1
+ import React from "react";
2
+ import classNames from "classnames";
3
+
4
+ import { IconProps } from "../Icons/types/IconProps.type";
5
+ import Text from "../Text/Text";
6
+
7
+ export interface ListItemProps {
8
+ itemId: string | number;
9
+ title: string;
10
+ subTitle?: string;
11
+ icon?: React.FunctionComponent<IconProps> | null;
12
+ accessories?: JSX.Element[];
13
+ handleItemClick?: () => void;
14
+ tooltipId?: string;
15
+ }
16
+
17
+ export const ListItem = ({
18
+ icon,
19
+ subTitle,
20
+ title,
21
+ accessories,
22
+ tooltipId,
23
+ ...restProps
24
+ }: ListItemProps): JSX.Element => (
25
+ <li
26
+ className={classNames(
27
+ "flex flex-row items-center space-x-4",
28
+ "p-4 border-b last:border-b-0 border-slate-200",
29
+ { "cursor-pointer": restProps.handleItemClick }
30
+ )}
31
+ onClick={restProps.handleItemClick}
32
+ data-tip={restProps.itemId}
33
+ data-for={tooltipId}
34
+ >
35
+ {icon && React.createElement(icon, { className: "w-6 h-6" })}
36
+ <div className={classNames({ "pl-10": icon === null })}>
37
+ <Text text={title} />
38
+ {subTitle && <Text text={subTitle} type={"sm"} />}
39
+ </div>
40
+ <div className={"flex-grow"} />
41
+ {accessories}
42
+ </li>
43
+ );
44
+
45
+ export default ListItem;
@@ -51,19 +51,20 @@ export function Table<Item>({
51
51
  )}
52
52
  {...otherAttributes}
53
53
  >
54
- {showHeader && (
54
+ {showHeader ? (
55
55
  <TableHeader
56
56
  className="border-b border-slate-100"
57
57
  fieldConfigurations={fieldConfigurations}
58
58
  />
59
- )}
59
+ ) : null}
60
60
 
61
61
  <TableBody
62
62
  className={classNames({
63
63
  "border-b border-slate-100":
64
64
  !showEmptyView &&
65
65
  paginationMenuProps &&
66
- paginationMenuProps.pageCount > 1,
66
+ paginationMenuProps.currentPageNumber > 0 &&
67
+ paginationMenuProps.pageCount > 0,
67
68
  })}
68
69
  items={items}
69
70
  fieldConfigurations={fieldConfigurations}
@@ -75,13 +76,14 @@ export function Table<Item>({
75
76
  />
76
77
 
77
78
  {!showEmptyView &&
78
- paginationMenuProps &&
79
- paginationMenuProps.pageCount > 1 && (
80
- <TableFooter
81
- colSpan={fieldConfigurations.length}
82
- paginationMenuProps={paginationMenuProps}
83
- />
84
- )}
79
+ paginationMenuProps &&
80
+ paginationMenuProps.currentPageNumber > 0 &&
81
+ paginationMenuProps.pageCount > 0 ? (
82
+ <TableFooter
83
+ colSpan={fieldConfigurations.length}
84
+ paginationMenuProps={paginationMenuProps}
85
+ />
86
+ ) : null}
85
87
  </table>
86
88
  );
87
89
  }
package/src/index.tsx CHANGED
@@ -35,6 +35,7 @@ export {
35
35
  LoadingIndicatorProps,
36
36
  } from "./components/LoadingIndicator/LoadingIndicator";
37
37
  export { default as Menu } from "./components/Menu/Menu";
38
+ export { List } from "./components/List/List";
38
39
  export { MultiSelect } from "./components/MultiSelect/MultiSelect";
39
40
  export { NavLayout, NavMenuLayoutProps } from "./components/NavMenu/NavLayout";
40
41
  export { NavMenu, NavMenuElement } from "./components/NavMenu/NavMenu";