@luscii-healthtech/web-ui 0.1.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/README.md +181 -0
- package/dist/components/Acknowledgement/Acknowledgement.d.ts +22 -0
- package/dist/components/Avatar/Avatar.d.ts +29 -0
- package/dist/components/Badge/Badge.d.ts +7 -0
- package/dist/components/Button/Button.d.ts +5 -0
- package/dist/components/Button/Button.types.d.ts +32 -0
- package/dist/components/Button/ButtonIcon.d.ts +7 -0
- package/dist/components/ButtonV2/ButtonV2.d.ts +13 -0
- package/dist/components/ButtonV2/PrimaryButton.d.ts +12 -0
- package/dist/components/ButtonV2/SecondaryButton.d.ts +8 -0
- package/dist/components/ButtonV2/TertiaryButton.d.ts +8 -0
- package/dist/components/Carousel/Carousel.d.ts +8 -0
- package/dist/components/Carousel/GliderContainer.d.ts +7 -0
- package/dist/components/CenteredHero/CenteredHero.d.ts +22 -0
- package/dist/components/Checkbox/Checkbox.d.ts +17 -0
- package/dist/components/ConfirmationDialog/ConfirmationDialog.d.ts +33 -0
- package/dist/components/Datepicker/Datepicker.d.ts +24 -0
- package/dist/components/Dropdown/Dropdown.d.ts +47 -0
- package/dist/components/EmptyListMessage/EmptyListMessage.d.ts +14 -0
- package/dist/components/ErrorBlock/ErrorBlock.d.ts +13 -0
- package/dist/components/Icons/AddIcon.d.ts +3 -0
- package/dist/components/Icons/AlertsIcon.d.ts +6 -0
- package/dist/components/Icons/BellIcon.d.ts +6 -0
- package/dist/components/Icons/ChartIcon.d.ts +3 -0
- package/dist/components/Icons/ChatBox.d.ts +5 -0
- package/dist/components/Icons/CheckIcon.d.ts +2 -0
- package/dist/components/Icons/ChevronIcon.d.ts +8 -0
- package/dist/components/Icons/CrossIcon.d.ts +7 -0
- package/dist/components/Icons/DeleteIcon.d.ts +6 -0
- package/dist/components/Icons/DownArrowIcon.d.ts +6 -0
- package/dist/components/Icons/DragIcon.d.ts +3 -0
- package/dist/components/Icons/EditIcon.d.ts +6 -0
- package/dist/components/Icons/EmptyStateDashboardIcon.d.ts +2 -0
- package/dist/components/Icons/ExclamationMarkIcon.d.ts +6 -0
- package/dist/components/Icons/EyeIcon.d.ts +3 -0
- package/dist/components/Icons/GearIcon.d.ts +3 -0
- package/dist/components/Icons/GroupIcon.d.ts +3 -0
- package/dist/components/Icons/HeartIcon.d.ts +6 -0
- package/dist/components/Icons/LeftArrowIcon.d.ts +6 -0
- package/dist/components/Icons/LightBulbIcon.d.ts +6 -0
- package/dist/components/Icons/LockIcon.d.ts +6 -0
- package/dist/components/Icons/MessagesIcon.d.ts +6 -0
- package/dist/components/Icons/NotesIcon.d.ts +6 -0
- package/dist/components/Icons/PinIcon.d.ts +6 -0
- package/dist/components/Icons/PrintIcon.d.ts +3 -0
- package/dist/components/Icons/RightArrowIcon.d.ts +6 -0
- package/dist/components/Icons/SmallCircleIcon.d.ts +6 -0
- package/dist/components/Icons/SmallDiamondIcon.d.ts +6 -0
- package/dist/components/Icons/SmallSquareIcon.d.ts +6 -0
- package/dist/components/Icons/SpaceRocketIcon.d.ts +6 -0
- package/dist/components/Icons/types/IconProps.type.d.ts +3 -0
- package/dist/components/InfoBlock/InfoBlock.d.ts +14 -0
- package/dist/components/InfoField/InfoField.d.ts +18 -0
- package/dist/components/Input/Input.d.ts +44 -0
- package/dist/components/Line/Line.d.ts +14 -0
- package/dist/components/ListItem/ListItem.d.ts +9 -0
- package/dist/components/ListTable/ListTable.d.ts +35 -0
- package/dist/components/ListTable/ListTableCell.d.ts +10 -0
- package/dist/components/ListTable/ListTableHeader.d.ts +7 -0
- package/dist/components/ListTable/ListTableRow.d.ts +9 -0
- package/dist/components/LoadingIndicator/LoadingIndicator.d.ts +11 -0
- package/dist/components/Menu/Menu.d.ts +14 -0
- package/dist/components/Modal/Modal.d.ts +31 -0
- package/dist/components/Modal/ModalWithButtons.d.ts +9 -0
- package/dist/components/MultiSelect/MultiSelect.d.ts +25 -0
- package/dist/components/MultiSelect/MultiSelectUtils.d.ts +1 -0
- package/dist/components/NavMenu/NavLayout.d.ts +20 -0
- package/dist/components/NavMenu/NavMenu.d.ts +1 -0
- package/dist/components/NavMenu/NavMenuContent.d.ts +7 -0
- package/dist/components/NavMenu/NavMenuItem.d.ts +15 -0
- package/dist/components/NotificationBanner/NotificationBanner.d.ts +22 -0
- package/dist/components/Page/CRUDPage.d.ts +43 -0
- package/dist/components/Page/Page.d.ts +58 -0
- package/dist/components/PaginationMenu/PaginationMenu.d.ts +20 -0
- package/dist/components/PaginationMenu/PaginationMenuLarge.d.ts +13 -0
- package/dist/components/PaginationMenu/PaginationMenuSmall.d.ts +8 -0
- package/dist/components/PreviewPhone/PreviewPhone.d.ts +7 -0
- package/dist/components/PreviewPhone/useWindowDimensions.d.ts +4 -0
- package/dist/components/Radio/Radio.d.ts +18 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +31 -0
- package/dist/components/Section/Section.d.ts +15 -0
- package/dist/components/Select/LegacySelect.d.ts +32 -0
- package/dist/components/Select/Select.d.ts +6 -0
- package/dist/components/Select/options.transformer.d.ts +14 -0
- package/dist/components/Select/select.utils.d.ts +7 -0
- package/dist/components/SettingsMenuButton/SettingsMenuButton.d.ts +16 -0
- package/dist/components/Spinner/Spinner.d.ts +6 -0
- package/dist/components/Steps/Step.d.ts +10 -0
- package/dist/components/Steps/Steps.d.ts +11 -0
- package/dist/components/Switcher/Switcher.d.ts +26 -0
- package/dist/components/Switcher/SwitcherItem.d.ts +24 -0
- package/dist/components/TabLinks/TabLinks.d.ts +14 -0
- package/dist/components/Tabbar/Tabbar.d.ts +10 -0
- package/dist/components/Tabbar/TabbarItem.d.ts +15 -0
- package/dist/components/Tag/Tag.d.ts +17 -0
- package/dist/components/Tag/TagGroup.d.ts +13 -0
- package/dist/components/Text/LegacyText.d.ts +37 -0
- package/dist/components/Text/Text.d.ts +27 -0
- package/dist/components/TextEditor/TextEditor.d.ts +14 -0
- package/dist/components/TextEditorV2/TextEditorV2.d.ts +6 -0
- package/dist/components/TextLink/TextLink.d.ts +11 -0
- package/dist/components/TextListItem/TextListItem.d.ts +12 -0
- package/dist/components/Textarea/Textarea.d.ts +22 -0
- package/dist/components/Title/LegacyTitle.d.ts +22 -0
- package/dist/components/Title/Title.d.ts +14 -0
- package/dist/components/ViewItem/ViewItem.d.ts +16 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +8 -0
- package/dist/types/general.types.d.ts +7 -0
- package/dist/utils/useOutsideClick.d.ts +2 -0
- package/dist/web-ui.cjs.development.js +23 -0
- package/dist/web-ui.cjs.development.js.map +1 -0
- package/dist/web-ui.cjs.production.min.js +2 -0
- package/dist/web-ui.cjs.production.min.js.map +1 -0
- package/dist/web-ui.esm.js +17 -0
- package/dist/web-ui.esm.js.map +1 -0
- package/package.json +122 -0
- package/src/assets/add.svg +5 -0
- package/src/assets/add_hover.svg +4 -0
- package/src/assets/big-menu-icon-hover.svg +6 -0
- package/src/assets/big-menu-icon.svg +6 -0
- package/src/assets/check-cross-icon.svg +7 -0
- package/src/assets/check-icon-primary.svg +5 -0
- package/src/assets/check-icon.svg +3 -0
- package/src/assets/chevron-double.svg +3 -0
- package/src/assets/close.svg +3 -0
- package/src/assets/color-variant-cross.svg +3 -0
- package/src/assets/cross-dark.svg +3 -0
- package/src/assets/delete.svg +4 -0
- package/src/assets/delete_hover.svg +4 -0
- package/src/assets/edit.svg +6 -0
- package/src/assets/edit_hover.svg +6 -0
- package/src/assets/error-icon.svg +7 -0
- package/src/assets/grid-view-icon-active.svg +6 -0
- package/src/assets/grid-view-icon.svg +6 -0
- package/src/assets/groups.svg +3 -0
- package/src/assets/hamburger.svg +5 -0
- package/src/assets/happy-star.svg +9 -0
- package/src/assets/hcps.svg +3 -0
- package/src/assets/info-icon.svg +6 -0
- package/src/assets/left-arrow-blue.svg +3 -0
- package/src/assets/left-arrow-grey.svg +3 -0
- package/src/assets/list-view-icon-active.svg +3 -0
- package/src/assets/list-view-icon.svg +3 -0
- package/src/assets/loading.svg +16 -0
- package/src/assets/modal-close-icon-active.svg +9 -0
- package/src/assets/modal-close-icon.svg +9 -0
- package/src/assets/no-open-alerts.svg +19 -0
- package/src/assets/patients.svg +3 -0
- package/src/assets/phone-mockup.svg +9 -0
- package/src/assets/programs.svg +3 -0
- package/src/assets/right-arrow-blue.svg +3 -0
- package/src/assets/right-arrow-grey.svg +3 -0
- package/src/assets/search-cancel.svg +3 -0
- package/src/assets/search-not-found.svg +70 -0
- package/src/assets/search.svg +3 -0
- package/src/assets/spinner-gray.svg +6 -0
- package/src/assets/spinner.svg +6 -0
- package/src/assets/starIcon.svg +3 -0
- package/src/assets/success-icon.svg +7 -0
- package/src/components/Acknowledgement/Acknowledgement.js +61 -0
- package/src/components/Acknowledgement/Acknowledgement.scss +49 -0
- package/src/components/Avatar/Avatar.js +81 -0
- package/src/components/Avatar/Avatar.scss +153 -0
- package/src/components/Badge/Badge.tsx +23 -0
- package/src/components/Button/Button.examples.md +46 -0
- package/src/components/Button/Button.tsx +200 -0
- package/src/components/Button/Button.types.ts +41 -0
- package/src/components/Button/ButtonIcon.tsx +42 -0
- package/src/components/ButtonV2/ButtonV2.tsx +91 -0
- package/src/components/ButtonV2/PrimaryButton.tsx +43 -0
- package/src/components/ButtonV2/SecondaryButton.tsx +31 -0
- package/src/components/ButtonV2/TertiaryButton.tsx +31 -0
- package/src/components/Carousel/Carousel.tsx +52 -0
- package/src/components/Carousel/GliderContainer.scss +13 -0
- package/src/components/Carousel/GliderContainer.tsx +22 -0
- package/src/components/CenteredHero/CenteredHero.js +50 -0
- package/src/components/Checkbox/Checkbox.scss +115 -0
- package/src/components/Checkbox/Checkbox.tsx +114 -0
- package/src/components/ConfirmationDialog/ConfirmationDialog.scss +15 -0
- package/src/components/ConfirmationDialog/ConfirmationDialog.tsx +84 -0
- package/src/components/Datepicker/Datepicker.js +96 -0
- package/src/components/Datepicker/Datepicker.scss +331 -0
- package/src/components/Dropdown/Dropdown.js +364 -0
- package/src/components/Dropdown/Dropdown.scss +83 -0
- package/src/components/EmptyListMessage/EmptyListMessage.tsx +34 -0
- package/src/components/ErrorBlock/ErrorBlock.js +24 -0
- package/src/components/ErrorBlock/ErrorBlock.scss +20 -0
- package/src/components/Icons/AddIcon.tsx +27 -0
- package/src/components/Icons/AlertsIcon.tsx +26 -0
- package/src/components/Icons/BellIcon.tsx +26 -0
- package/src/components/Icons/ChartIcon.tsx +20 -0
- package/src/components/Icons/ChatBox.tsx +23 -0
- package/src/components/Icons/CheckIcon.tsx +23 -0
- package/src/components/Icons/ChevronIcon.tsx +30 -0
- package/src/components/Icons/CrossIcon.tsx +26 -0
- package/src/components/Icons/DeleteIcon.tsx +23 -0
- package/src/components/Icons/DownArrowIcon.tsx +17 -0
- package/src/components/Icons/DragIcon.tsx +23 -0
- package/src/components/Icons/EditIcon.tsx +23 -0
- package/src/components/Icons/EmptyStateDashboardIcon.tsx +130 -0
- package/src/components/Icons/ExclamationMarkIcon.tsx +23 -0
- package/src/components/Icons/EyeIcon.tsx +21 -0
- package/src/components/Icons/GearIcon.tsx +21 -0
- package/src/components/Icons/GroupIcon.tsx +21 -0
- package/src/components/Icons/HeartIcon.tsx +23 -0
- package/src/components/Icons/LeftArrowIcon.tsx +23 -0
- package/src/components/Icons/LightBulbIcon.tsx +28 -0
- package/src/components/Icons/LockIcon.tsx +23 -0
- package/src/components/Icons/MessagesIcon.tsx +23 -0
- package/src/components/Icons/NotesIcon.tsx +23 -0
- package/src/components/Icons/PinIcon.tsx +23 -0
- package/src/components/Icons/PrintIcon.tsx +15 -0
- package/src/components/Icons/RightArrowIcon.tsx +23 -0
- package/src/components/Icons/SmallCircleIcon.tsx +21 -0
- package/src/components/Icons/SmallDiamondIcon.tsx +31 -0
- package/src/components/Icons/SmallSquareIcon.tsx +21 -0
- package/src/components/Icons/SpaceRocketIcon.tsx +23 -0
- package/src/components/Icons/types/IconProps.type.ts +3 -0
- package/src/components/InfoBlock/InfoBlock.js +24 -0
- package/src/components/InfoBlock/InfoBlock.scss +20 -0
- package/src/components/InfoField/InfoField.tsx +86 -0
- package/src/components/Input/Input.examples.md +94 -0
- package/src/components/Input/Input.js +141 -0
- package/src/components/Line/Line.js +38 -0
- package/src/components/ListItem/ListItem.scss +20 -0
- package/src/components/ListItem/ListItem.tsx +26 -0
- package/src/components/ListTable/ListTable.tsx +157 -0
- package/src/components/ListTable/ListTableCell.tsx +67 -0
- package/src/components/ListTable/ListTableHeader.tsx +33 -0
- package/src/components/ListTable/ListTableRow.tsx +46 -0
- package/src/components/LoadingIndicator/LoadingIndicator.scss +50 -0
- package/src/components/LoadingIndicator/LoadingIndicator.tsx +44 -0
- package/src/components/Menu/Menu.js +74 -0
- package/src/components/Menu/Menu.scss +27 -0
- package/src/components/Modal/Modal.scss +117 -0
- package/src/components/Modal/Modal.tsx +104 -0
- package/src/components/Modal/ModalWithButtons.tsx +34 -0
- package/src/components/MultiSelect/MultiSelect.js +117 -0
- package/src/components/MultiSelect/MultiSelect.scss +29 -0
- package/src/components/MultiSelect/MultiSelectUtils.js +23 -0
- package/src/components/NavMenu/NavLayout.tsx +40 -0
- package/src/components/NavMenu/NavMenu.js +35 -0
- package/src/components/NavMenu/NavMenuContent.tsx +23 -0
- package/src/components/NavMenu/NavMenuItem.tsx +96 -0
- package/src/components/NotificationBanner/NotificationBanner.tsx +57 -0
- package/src/components/Page/CRUDPage.js +123 -0
- package/src/components/Page/CRUDPage.scss +32 -0
- package/src/components/Page/Page.js +102 -0
- package/src/components/Page/Page.scss +59 -0
- package/src/components/PaginationMenu/PaginationMenu.js +31 -0
- package/src/components/PaginationMenu/PaginationMenuLarge.tsx +94 -0
- package/src/components/PaginationMenu/PaginationMenuSmall.tsx +40 -0
- package/src/components/PreviewPhone/PreviewPhone.tsx +53 -0
- package/src/components/PreviewPhone/useWindowDimensions.js +26 -0
- package/src/components/Radio/Radio.js +99 -0
- package/src/components/Radio/Radio.scss +58 -0
- package/src/components/RadioGroup/RadioGroup.js +63 -0
- package/src/components/RadioGroup/RadioGroup.scss +37 -0
- package/src/components/Section/Section.scss +74 -0
- package/src/components/Section/Section.tsx +67 -0
- package/src/components/Select/LegacySelect.js +114 -0
- package/src/components/Select/Select.examples.md +161 -0
- package/src/components/Select/Select.tsx +136 -0
- package/src/components/Select/options.transformer.ts +36 -0
- package/src/components/Select/select.utils.spec.ts +63 -0
- package/src/components/Select/select.utils.ts +45 -0
- package/src/components/SettingsMenuButton/SettingsMenuButton.tsx +111 -0
- package/src/components/Spinner/Spinner.tsx +23 -0
- package/src/components/Steps/Step.tsx +22 -0
- package/src/components/Steps/Steps.tsx +24 -0
- package/src/components/Switcher/Switcher.js +58 -0
- package/src/components/Switcher/SwitcherItem.js +61 -0
- package/src/components/Switcher/SwitcherItem.scss +67 -0
- package/src/components/TabLinks/TabLinks.tsx +63 -0
- package/src/components/Tabbar/Tabbar.tsx +29 -0
- package/src/components/Tabbar/TabbarItem.tsx +53 -0
- package/src/components/Tag/Tag.tsx +39 -0
- package/src/components/Tag/TagGroup.tsx +25 -0
- package/src/components/Text/LegacyText.js +78 -0
- package/src/components/Text/Text.scss +67 -0
- package/src/components/Text/Text.tsx +81 -0
- package/src/components/TextEditor/TextEditor.js +61 -0
- package/src/components/TextEditor/TextEditor.scss +14 -0
- package/src/components/TextEditorV2/TextEditorV2.js +58 -0
- package/src/components/TextEditorV2/TextEditorV2.scss +110 -0
- package/src/components/TextLink/TextLink.tsx +42 -0
- package/src/components/TextListItem/TextListItem.js +31 -0
- package/src/components/TextListItem/TextListItem.scss +10 -0
- package/src/components/Textarea/Textarea.js +108 -0
- package/src/components/Textarea/Textarea.scss +56 -0
- package/src/components/Title/LegacyTitle.js +64 -0
- package/src/components/Title/Title.scss +65 -0
- package/src/components/Title/Title.tsx +57 -0
- package/src/components/ViewItem/ViewItem.tsx +73 -0
- package/src/index.tsx +14 -0
- package/src/styles/_colors.scss +59 -0
- package/src/styles/_layout.scss +64 -0
- package/src/styles/_shadows.scss +19 -0
- package/src/styles/_typography.scss +8 -0
- package/src/styles/_utils.scss +45 -0
- package/src/styles/fonts/avenir/3A0AF8_0_0.eot +0 -0
- package/src/styles/fonts/avenir/3A0AF8_0_0.ttf +0 -0
- package/src/styles/fonts/avenir/3A0AF8_0_0.woff +0 -0
- package/src/styles/fonts/avenir/3A0AF8_0_0.woff2 +0 -0
- package/src/styles/fonts/avenir/3A0AF8_1_0.eot +0 -0
- package/src/styles/fonts/avenir/3A0AF8_1_0.ttf +0 -0
- package/src/styles/fonts/avenir/3A0AF8_1_0.woff +0 -0
- package/src/styles/fonts/avenir/3A0AF8_1_0.woff2 +0 -0
- package/src/types/general.types.ts +11 -0
- package/src/utils/useOutsideClick.js +19 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import classNames from "classnames";
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
|
+
|
|
4
|
+
import useOutsideClick from "../../utils/useOutsideClick";
|
|
5
|
+
import Button from "../Button/Button";
|
|
6
|
+
import Checkbox from "../Checkbox/Checkbox";
|
|
7
|
+
import { IconProps } from "../Icons/types/IconProps.type";
|
|
8
|
+
import Text from "../Text/Text";
|
|
9
|
+
|
|
10
|
+
export interface ConfigurationItem {
|
|
11
|
+
itemId: string;
|
|
12
|
+
itemName: string;
|
|
13
|
+
on: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface SettingsMenuButtonProps {
|
|
17
|
+
configuration: ConfigurationItem[];
|
|
18
|
+
onConfigurationChange: (newConfig: ConfigurationItem) => void;
|
|
19
|
+
shiftMenuTo?: "right" | "right-md" | "left" | "left-md";
|
|
20
|
+
buttonTitle?: string;
|
|
21
|
+
menuTitle?: string;
|
|
22
|
+
iconComponent: React.FunctionComponent<IconProps>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const SettingsMenuButton = (props: SettingsMenuButtonProps): JSX.Element => {
|
|
26
|
+
const {
|
|
27
|
+
configuration: configFromProps = [],
|
|
28
|
+
onConfigurationChange,
|
|
29
|
+
shiftMenuTo,
|
|
30
|
+
buttonTitle,
|
|
31
|
+
iconComponent,
|
|
32
|
+
menuTitle,
|
|
33
|
+
} = props;
|
|
34
|
+
const [innerConfiguration, setInnerConfiguration] = useState(configFromProps);
|
|
35
|
+
const [showMenu, setShowMenu] = useState(false);
|
|
36
|
+
|
|
37
|
+
const menuRef = useRef<HTMLDivElement | null>(null);
|
|
38
|
+
|
|
39
|
+
useOutsideClick(menuRef, () => {
|
|
40
|
+
if (showMenu) {
|
|
41
|
+
setShowMenu(false);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
setInnerConfiguration(configFromProps);
|
|
47
|
+
}, [configFromProps]);
|
|
48
|
+
|
|
49
|
+
const handleShowMenu = () => {
|
|
50
|
+
setShowMenu(true);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const handleOnVibilitySwitchChanged = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
54
|
+
const { id, name, checked } = event.currentTarget;
|
|
55
|
+
|
|
56
|
+
const newConfig = innerConfiguration.find((config) => config.itemId === id && config.itemName === name);
|
|
57
|
+
|
|
58
|
+
onConfigurationChange({ ...newConfig, on: checked });
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
if (!iconComponent) {
|
|
62
|
+
console.error("A an icon component is required to use this component, please make sure to pass it as a prop. ");
|
|
63
|
+
return <span>Invalid props passed to this component.</span>;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return (
|
|
67
|
+
<div onClick={handleShowMenu} className="relative">
|
|
68
|
+
<Button dynamicIcon={iconComponent} onClick={handleShowMenu} text={buttonTitle} role="tertiary" />
|
|
69
|
+
|
|
70
|
+
<div
|
|
71
|
+
ref={menuRef}
|
|
72
|
+
className={classNames(
|
|
73
|
+
"cursor-default transition-all transform duration-300",
|
|
74
|
+
"absolute -top-1 z-30",
|
|
75
|
+
"rounded w-80 max-h-78 overflow-y-auto",
|
|
76
|
+
"bg-white shadow-md",
|
|
77
|
+
"border border-slate-300",
|
|
78
|
+
{
|
|
79
|
+
"-left-54": shiftMenuTo === "left",
|
|
80
|
+
"-right-54": shiftMenuTo === "right",
|
|
81
|
+
"-left-68": shiftMenuTo === "left-md",
|
|
82
|
+
"-right-68": shiftMenuTo === "right-md",
|
|
83
|
+
"transform -translate-x-1/2 left-1/2": !shiftMenuTo, // centering the menu in the Y axis of the button
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"opacity-0 pointer-events-none": !showMenu,
|
|
87
|
+
"opacity-100": showMenu,
|
|
88
|
+
}
|
|
89
|
+
)}
|
|
90
|
+
>
|
|
91
|
+
{menuTitle && (
|
|
92
|
+
<div className="w-full p-3 h-11 bg-slate-50">
|
|
93
|
+
<Text type="sm" className="uppercase" text={menuTitle} />
|
|
94
|
+
</div>
|
|
95
|
+
)}
|
|
96
|
+
{innerConfiguration.map((innerConfig) => (
|
|
97
|
+
<div key={innerConfig.itemId} className="flex items-center justify-between w-full p-3 h-11">
|
|
98
|
+
<Text text={innerConfig.itemName} />
|
|
99
|
+
<Checkbox
|
|
100
|
+
name={innerConfig.itemName}
|
|
101
|
+
id={innerConfig.itemId}
|
|
102
|
+
type="switch"
|
|
103
|
+
isChecked={innerConfig.on}
|
|
104
|
+
onChange={handleOnVibilitySwitchChanged}
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
))}
|
|
108
|
+
</div>
|
|
109
|
+
</div>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
interface SpinnerProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const Spinner = (props: SpinnerProps): JSX.Element => {
|
|
8
|
+
return (
|
|
9
|
+
<svg
|
|
10
|
+
className={`w-5 h-5 animate-spin ${props.className}`}
|
|
11
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
12
|
+
fill="none"
|
|
13
|
+
viewBox="0 0 24 24"
|
|
14
|
+
>
|
|
15
|
+
<circle className="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" strokeWidth="4"></circle>
|
|
16
|
+
<path
|
|
17
|
+
className="opacity-75"
|
|
18
|
+
fill="currentColor"
|
|
19
|
+
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
20
|
+
/>
|
|
21
|
+
</svg>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { Text } from "../Text/Text";
|
|
4
|
+
|
|
5
|
+
export interface StepProps {
|
|
6
|
+
title: string;
|
|
7
|
+
stepNumber: number;
|
|
8
|
+
active: boolean;
|
|
9
|
+
localization: {step: string};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Step = ({ title, stepNumber, active, localization }: StepProps): JSX.Element => {
|
|
13
|
+
const barColor = active ? "bg-blue-800" : "bg-slate-200";
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<div className={"w-full"}>
|
|
17
|
+
<div className={`w-full h-1 mb-2 rounded ${barColor}`}></div>
|
|
18
|
+
<Text text={`${localization.step} ${stepNumber}`} type={"strong"} color={active ? "blue" : "gray-500"} />
|
|
19
|
+
<Text text={title} type={"strong"} />
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { Step } from "./Step";
|
|
4
|
+
|
|
5
|
+
interface StepsProps {
|
|
6
|
+
orderedStepTitles: Array<string>;
|
|
7
|
+
currentStep: number; //start count from 1
|
|
8
|
+
className?: string;
|
|
9
|
+
localization: {step: string};
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Steps = ({ orderedStepTitles, currentStep, className, localization }: StepsProps): JSX.Element => {
|
|
13
|
+
const renderedSteps = orderedStepTitles.map((stepTitle, index) => (
|
|
14
|
+
<Step
|
|
15
|
+
key={`step-${index}-${stepTitle.split(" ")[0]}`}
|
|
16
|
+
title={stepTitle}
|
|
17
|
+
stepNumber={index + 1}
|
|
18
|
+
active={index + 1 <= currentStep}
|
|
19
|
+
localization={localization}
|
|
20
|
+
/>
|
|
21
|
+
));
|
|
22
|
+
|
|
23
|
+
return <div className={`flex flex-row justify-items-stretch space-x-6 ${className}`}>{renderedSteps}</div>;
|
|
24
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
|
|
5
|
+
import SwitcherItem from "./SwitcherItem";
|
|
6
|
+
|
|
7
|
+
function Switcher({ selectedIndex = -1, onChange, className, itemClassName, items }) {
|
|
8
|
+
const [currentSelection, setCurrentSelection] = useState(selectedIndex);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
setCurrentSelection(selectedIndex);
|
|
12
|
+
}, [selectedIndex]);
|
|
13
|
+
|
|
14
|
+
const handleItemSelect = (index) => {
|
|
15
|
+
onChange(index);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<ul
|
|
20
|
+
className={classNames("cweb-switcher", className, "flex list-none p-0 m-0")}
|
|
21
|
+
data-test-id={"switcher-container"}
|
|
22
|
+
>
|
|
23
|
+
{items.map((item, index) => {
|
|
24
|
+
return (
|
|
25
|
+
<SwitcherItem
|
|
26
|
+
key={JSON.stringify(item)}
|
|
27
|
+
name={item.name}
|
|
28
|
+
icon={item.icon}
|
|
29
|
+
index={index}
|
|
30
|
+
isSelected={currentSelection === index}
|
|
31
|
+
onSelect={handleItemSelect}
|
|
32
|
+
className={itemClassName}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
})}
|
|
36
|
+
</ul>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
Switcher.propTypes = {
|
|
41
|
+
items: PropTypes.arrayOf(
|
|
42
|
+
PropTypes.shape({
|
|
43
|
+
name: PropTypes.string,
|
|
44
|
+
icon: PropTypes.shape({
|
|
45
|
+
default: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
46
|
+
active: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
47
|
+
showBadge: PropTypes.bool,
|
|
48
|
+
}),
|
|
49
|
+
key: PropTypes.string,
|
|
50
|
+
})
|
|
51
|
+
).isRequired,
|
|
52
|
+
onChange: PropTypes.func.isRequired,
|
|
53
|
+
selectedIndex: PropTypes.number,
|
|
54
|
+
className: PropTypes.string,
|
|
55
|
+
itemClassName: PropTypes.string,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default Switcher;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
|
|
5
|
+
import "./SwitcherItem.scss";
|
|
6
|
+
import { Text } from "../Text/Text";
|
|
7
|
+
|
|
8
|
+
SwitcherItem.propTypes = {
|
|
9
|
+
name: PropTypes.string,
|
|
10
|
+
icon: PropTypes.shape({
|
|
11
|
+
default: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
12
|
+
active: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
|
|
13
|
+
showBadge: PropTypes.bool,
|
|
14
|
+
}),
|
|
15
|
+
index: PropTypes.number.isRequired,
|
|
16
|
+
isSelected: PropTypes.bool,
|
|
17
|
+
onSelect: PropTypes.func.isRequired,
|
|
18
|
+
className: PropTypes.string,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
function SwitcherItem({ className, icon, index, isSelected = false, name, onSelect }) {
|
|
22
|
+
const handleItemClick = () => onSelect(index);
|
|
23
|
+
const itemClassName = classNames(
|
|
24
|
+
"",
|
|
25
|
+
className,
|
|
26
|
+
"flex flex-row h-11 p-2 items-center border-solid border-t border-b border-l border-slate-200 transition duration-300 cursor-pointer ",
|
|
27
|
+
"first:rounded-l-xl last:rounded-r-xl last:border-r",
|
|
28
|
+
{
|
|
29
|
+
"bg-slate-100 text-slate-500": isSelected,
|
|
30
|
+
"bg-slate-50 hover:bg-slate-100 hover:text-slate-500 text-slate-300": !isSelected,
|
|
31
|
+
}
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
let calculatedIcon;
|
|
35
|
+
if (icon && typeof icon.default === "string") {
|
|
36
|
+
calculatedIcon = isSelected ? (
|
|
37
|
+
<img alt="" className="" src={icon.active} />
|
|
38
|
+
) : (
|
|
39
|
+
<img alt="" className="" src={icon.default} />
|
|
40
|
+
);
|
|
41
|
+
} else if (icon) {
|
|
42
|
+
calculatedIcon = isSelected ? icon.active : icon.default;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return (
|
|
46
|
+
<li className={itemClassName} onClick={handleItemClick}>
|
|
47
|
+
{
|
|
48
|
+
<span className="relative block">
|
|
49
|
+
{icon?.showBadge && (
|
|
50
|
+
<div className={"absolute top-0 right-0 w-2.5 h-2.5 bg-red-400 rounded-xl border-slate-50 border-2 "} />
|
|
51
|
+
)}
|
|
52
|
+
{calculatedIcon}
|
|
53
|
+
</span>
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
{name && <Text text={name} color={isSelected ? "base" : "gray-500"} />}
|
|
57
|
+
</li>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default SwitcherItem;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
@import "../../styles/colors";
|
|
2
|
+
@import "../../styles/layout";
|
|
3
|
+
|
|
4
|
+
.cweb-switcher-item {
|
|
5
|
+
@include flexbox-layout(center, center);
|
|
6
|
+
|
|
7
|
+
.cweb-switcher-item-link {
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
text-decoration: none;
|
|
11
|
+
padding: 0.5rem 1rem;
|
|
12
|
+
cursor: pointer;
|
|
13
|
+
|
|
14
|
+
.cweb-switcher-item-link-icon {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
|
|
18
|
+
.cweb-switcher-item-link-icon-default,
|
|
19
|
+
.cweb-switcher-item-link-icon-active {
|
|
20
|
+
width: 20px;
|
|
21
|
+
height: 20px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.cweb-switcher-item-link-icon-active {
|
|
25
|
+
display: none;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.cweb-switcher-item-link-text {
|
|
30
|
+
color: $color-text-lighter;
|
|
31
|
+
transition: color 0.4s ease;
|
|
32
|
+
padding-bottom: 0;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.cweb-switcher-item-link-icon + .cweb-switcher-item-link-text {
|
|
36
|
+
margin-left: 8px;
|
|
37
|
+
padding: 0;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&.is-selected,
|
|
42
|
+
&:hover,
|
|
43
|
+
&:active {
|
|
44
|
+
border-color: $color-primary;
|
|
45
|
+
z-index: 1;
|
|
46
|
+
|
|
47
|
+
.cweb-switcher-item-link {
|
|
48
|
+
.cweb-switcher-item-link-icon {
|
|
49
|
+
.cweb-switcher-item-link-icon-default {
|
|
50
|
+
display: none;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.cweb-switcher-item-link-icon-active {
|
|
54
|
+
display: inherit;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
.cweb-switcher-item-link-text {
|
|
59
|
+
color: $color-primary;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
&.is-disabled {
|
|
65
|
+
pointer-events: none;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import {Link, LinkGetProps, NavigateFn, WindowLocation} from "@reach/router";
|
|
3
|
+
|
|
4
|
+
import Select from "../Select/Select";
|
|
5
|
+
|
|
6
|
+
interface TabLinkItem {
|
|
7
|
+
url: URL;
|
|
8
|
+
text: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface TabLinksProps {
|
|
12
|
+
patientUuid: string;
|
|
13
|
+
items: Array<TabLinkItem>;
|
|
14
|
+
navigate: NavigateFn;
|
|
15
|
+
location: WindowLocation;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const TabLinksSelect = ({ items, navigate, location }: { items: Array<TabLinkItem>, navigate: NavigateFn, location: WindowLocation }): JSX.Element => {
|
|
19
|
+
const options = items.map(({ url, text }) => ({ value: url, label: text }));
|
|
20
|
+
|
|
21
|
+
const handleChange = (selected: any) => {
|
|
22
|
+
navigate(selected?.value?.href);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Select
|
|
27
|
+
value={options.filter(({ value }) => location?.href === value?.href)}
|
|
28
|
+
options={options}
|
|
29
|
+
onChange={handleChange}
|
|
30
|
+
/>
|
|
31
|
+
);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const TabLinks = ({ patientUuid, items, navigate, location }: TabLinksProps): JSX.Element => {
|
|
35
|
+
const linkProps = ({ isCurrent }: LinkGetProps) => {
|
|
36
|
+
return isCurrent
|
|
37
|
+
? {
|
|
38
|
+
className:
|
|
39
|
+
"mr-2 bg-slate-100 is-selected py-3 px-4 rounded-lg text-sm font-semibold transition ease-in duration-150 text-slate-700 hover:text-slate-700 focus:text-slate-700 focus:outline-primary",
|
|
40
|
+
}
|
|
41
|
+
: {
|
|
42
|
+
className:
|
|
43
|
+
"mr-2 text-slate-500 py-3 px-4 text-sm hover:bg-slate-100 hover:text-slate-500 focus:text-slate-500 rounded-lg transition ease-in duration-150 focus:outline-primary",
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
<div className={"w-full block xl:hidden bg-white p-2"}>
|
|
50
|
+
<TabLinksSelect items={items} navigate={navigate} location={location}/>
|
|
51
|
+
</div>
|
|
52
|
+
<div className={"w-full hidden xl:flex bg-white p-2 rounded-xl"}>
|
|
53
|
+
{items.map(({ text, url }) => (
|
|
54
|
+
<Link key={`${patientUuid}_${text}`} to={url.pathname} getProps={linkProps}>
|
|
55
|
+
{text}
|
|
56
|
+
</Link>
|
|
57
|
+
))}
|
|
58
|
+
</div>
|
|
59
|
+
</>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default TabLinks;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import TabbarItem, { TabItemDetails } from "./TabbarItem";
|
|
4
|
+
|
|
5
|
+
interface TabbarProps {
|
|
6
|
+
tabs?: TabItemDetails[];
|
|
7
|
+
selectedIndex?: number;
|
|
8
|
+
onSelect?(index: number): void;
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Tabbar = ({ tabs, selectedIndex, onSelect, className = "" }: TabbarProps): JSX.Element => {
|
|
13
|
+
return (
|
|
14
|
+
<div className={`flex flex-row w-full bg-white rounded-xl ${className}`}>
|
|
15
|
+
{tabs.map((tabItemProps, index) => {
|
|
16
|
+
const itemProps = {
|
|
17
|
+
index,
|
|
18
|
+
onSelect,
|
|
19
|
+
isSelected: selectedIndex === index,
|
|
20
|
+
...tabItemProps,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return <TabbarItem key={tabItemProps.dataTestId ?? index} {...itemProps} />;
|
|
24
|
+
})}
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default Tabbar;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
|
|
4
|
+
import { Text } from "../Text/Text";
|
|
5
|
+
import Badge from "../Badge/Badge";
|
|
6
|
+
import LoadingIndicator from "../LoadingIndicator/LoadingIndicator";
|
|
7
|
+
|
|
8
|
+
export interface TabItemDetails {
|
|
9
|
+
title: string | JSX.Element;
|
|
10
|
+
badgeCount?: number;
|
|
11
|
+
isLoading?: boolean;
|
|
12
|
+
dataTestId?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface TabbarItemProps extends TabItemDetails {
|
|
16
|
+
index: number;
|
|
17
|
+
isSelected?: boolean;
|
|
18
|
+
onSelect(index: number): void;
|
|
19
|
+
className?: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const TabbarItem = ({
|
|
23
|
+
title,
|
|
24
|
+
index,
|
|
25
|
+
isSelected,
|
|
26
|
+
onSelect,
|
|
27
|
+
className,
|
|
28
|
+
badgeCount = null,
|
|
29
|
+
isLoading = false,
|
|
30
|
+
dataTestId = "",
|
|
31
|
+
}: TabbarItemProps): JSX.Element => {
|
|
32
|
+
const handleTabClick = () => onSelect(index);
|
|
33
|
+
|
|
34
|
+
const itemClassName = classNames(
|
|
35
|
+
"flex first:ml-0 ml-2 flex-row cursor-pointer py-2 px-3 rounded-lg focus:outline-primary transition ease-in duration-150",
|
|
36
|
+
className,
|
|
37
|
+
{
|
|
38
|
+
"bg-slate-100 text-slate-700 hover:text-slate-700 focus:text-slate-700": isSelected,
|
|
39
|
+
"bg-slate-50 text-slate-500 hover:bg-slate-100 hover:text-slate-500 focus:text-slate-500 opacity-75": !isSelected,
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<div className={itemClassName} onClick={handleTabClick} data-test-id={dataTestId}>
|
|
45
|
+
{typeof title === "string" && <Text text={title} type={isSelected ? "strong" : "base"} inline />}
|
|
46
|
+
{typeof title !== "string" && title}
|
|
47
|
+
{badgeCount > 0 && <Badge className="ml-1" badgeCount={badgeCount} />}
|
|
48
|
+
{isLoading && <LoadingIndicator asSpinner={true} spinnerColor={"gray"} className={"w-6"} />}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export default TabbarItem;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
|
|
4
|
+
import { Text } from "../Text/Text";
|
|
5
|
+
|
|
6
|
+
import { TagSize } from "./TagGroup";
|
|
7
|
+
|
|
8
|
+
export enum TagColorTheme {
|
|
9
|
+
Red = "red",
|
|
10
|
+
Amber = "amber",
|
|
11
|
+
Green = "green",
|
|
12
|
+
Gray = "gray",
|
|
13
|
+
Blue = "blue",
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface TagProps {
|
|
17
|
+
text: string;
|
|
18
|
+
colorTheme?: TagColorTheme;
|
|
19
|
+
size?: TagSize;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
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
|
+
});
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div className={containerClassName}>
|
|
34
|
+
<Text inline color={"inherit"} text={text} type={size === TagSize.small ? "sm" : "base"} />
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default Tag;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import classNames from "classnames";
|
|
3
|
+
|
|
4
|
+
import Tag, { TagProps } from "./Tag";
|
|
5
|
+
|
|
6
|
+
export enum TagSize {
|
|
7
|
+
"small" = "small",
|
|
8
|
+
"base" = "base",
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface TagGroupProps {
|
|
12
|
+
tags: TagProps[];
|
|
13
|
+
tagSize?: TagSize;
|
|
14
|
+
className?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const TagGroup = ({ tags, tagSize = TagSize.base, className }: TagGroupProps): JSX.Element => (
|
|
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")} />
|
|
21
|
+
))}
|
|
22
|
+
</div>
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
export default TagGroup;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import PropTypes from "prop-types";
|
|
3
|
+
import classNames from "classnames";
|
|
4
|
+
|
|
5
|
+
import "./Text.scss";
|
|
6
|
+
|
|
7
|
+
const TEXT_TYPE_OPTIONS = {
|
|
8
|
+
DEFAULT: "default",
|
|
9
|
+
STRONG: "strong",
|
|
10
|
+
EMPHASIZED: "emphasized",
|
|
11
|
+
FINEPRINT: "fineprint",
|
|
12
|
+
SMALL: "small",
|
|
13
|
+
SMALL_DARK: "small-dark",
|
|
14
|
+
SMALL_FINEPRINT: "small-fineprint",
|
|
15
|
+
MICRO: "micro",
|
|
16
|
+
ERROR: "error",
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const TEXT_LEVEL_OPTIONS = {
|
|
20
|
+
INLINE: "inline",
|
|
21
|
+
BLOCK: "block",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
LegacyText.propTypes = {
|
|
25
|
+
text: PropTypes.string.isRequired,
|
|
26
|
+
level: PropTypes.oneOf([TEXT_LEVEL_OPTIONS.INLINE, TEXT_LEVEL_OPTIONS.BLOCK]),
|
|
27
|
+
type: PropTypes.oneOf([
|
|
28
|
+
TEXT_TYPE_OPTIONS.DEFAULT,
|
|
29
|
+
TEXT_TYPE_OPTIONS.STRONG,
|
|
30
|
+
TEXT_TYPE_OPTIONS.EMPHASIZED,
|
|
31
|
+
TEXT_TYPE_OPTIONS.FINEPRINT,
|
|
32
|
+
TEXT_TYPE_OPTIONS.SMALL,
|
|
33
|
+
TEXT_TYPE_OPTIONS.SMALL_DARK,
|
|
34
|
+
TEXT_TYPE_OPTIONS.SMALL_FINEPRINT,
|
|
35
|
+
TEXT_TYPE_OPTIONS.MICRO,
|
|
36
|
+
TEXT_TYPE_OPTIONS.ERROR,
|
|
37
|
+
]),
|
|
38
|
+
className: PropTypes.string,
|
|
39
|
+
containsDangerousHtml: PropTypes.bool,
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated use TextV2
|
|
44
|
+
*/
|
|
45
|
+
function LegacyText({
|
|
46
|
+
text,
|
|
47
|
+
type = TEXT_TYPE_OPTIONS.DEFAULT,
|
|
48
|
+
level = TEXT_LEVEL_OPTIONS.BLOCK,
|
|
49
|
+
className = "",
|
|
50
|
+
containsDangerousHtml = false,
|
|
51
|
+
...otherProps
|
|
52
|
+
}) {
|
|
53
|
+
const containerClassName = classNames("cweb-text", className, {
|
|
54
|
+
"type-default": type === TEXT_TYPE_OPTIONS.DEFAULT,
|
|
55
|
+
"type-strong": type === TEXT_TYPE_OPTIONS.STRONG,
|
|
56
|
+
"type-emphasized": type === TEXT_TYPE_OPTIONS.EMPHASIZED,
|
|
57
|
+
"type-small": type === TEXT_TYPE_OPTIONS.SMALL,
|
|
58
|
+
"type-fineprint": type === TEXT_TYPE_OPTIONS.FINEPRINT,
|
|
59
|
+
"type-small-fineprint": type === TEXT_TYPE_OPTIONS.SMALL_FINEPRINT,
|
|
60
|
+
"level-inline": level === TEXT_LEVEL_OPTIONS.INLINE,
|
|
61
|
+
"level-block": level === TEXT_LEVEL_OPTIONS.BLOCK,
|
|
62
|
+
"type-small-dark": type === TEXT_LEVEL_OPTIONS.SMALL_DARK,
|
|
63
|
+
"type-error": type === TEXT_TYPE_OPTIONS.ERROR,
|
|
64
|
+
"text-xs": type === TEXT_TYPE_OPTIONS.MICRO,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
return containsDangerousHtml ? (
|
|
68
|
+
<p className={containerClassName} dangerouslySetInnerHTML={{ __html: text }} {...otherProps} />
|
|
69
|
+
) : (
|
|
70
|
+
<p className={containerClassName} {...otherProps}>
|
|
71
|
+
{text}
|
|
72
|
+
</p>
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export default LegacyText;
|
|
77
|
+
|
|
78
|
+
export { TEXT_TYPE_OPTIONS, TEXT_LEVEL_OPTIONS };
|