@takaro/lib-components 0.0.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.
- package/.babelrc +7 -0
- package/@types/files.d.ts +23 -0
- package/@types/react-table-config.d.ts +121 -0
- package/Dockerfile.dev +21 -0
- package/package.json +76 -0
- package/public/images/7-days-to-die/logo.png +0 -0
- package/public/images/csmm-icon.png +0 -0
- package/public/images/milk.png +0 -0
- package/public/images/placeholder-01.jpeg +0 -0
- package/public/images/placeholder-02.jpeg +0 -0
- package/public/images/placeholder-03.jpeg +0 -0
- package/public/images/rust/logo.png +0 -0
- package/readme.md +10 -0
- package/src/components/actions/Button/Button.stories.tsx +170 -0
- package/src/components/actions/Button/Button.test.tsx +7 -0
- package/src/components/actions/Button/Button.test.tsx.snap +89 -0
- package/src/components/actions/Button/index.tsx +99 -0
- package/src/components/actions/Button/style.ts +148 -0
- package/src/components/actions/ContextMenu/ContextMenu.stories.tsx +40 -0
- package/src/components/actions/ContextMenu/Group.tsx +34 -0
- package/src/components/actions/ContextMenu/MenuItem.tsx +66 -0
- package/src/components/actions/ContextMenu/index.tsx +217 -0
- package/src/components/actions/Dropdown/Dropdown.stories.tsx +88 -0
- package/src/components/actions/Dropdown/DropdownContext.tsx +21 -0
- package/src/components/actions/Dropdown/DropdownMenu.tsx +67 -0
- package/src/components/actions/Dropdown/DropdownMenuGroup.tsx +37 -0
- package/src/components/actions/Dropdown/DropdownMenuItem.tsx +128 -0
- package/src/components/actions/Dropdown/DropdownTrigger.tsx +89 -0
- package/src/components/actions/Dropdown/index.tsx +22 -0
- package/src/components/actions/Dropdown/useDropdown.tsx +82 -0
- package/src/components/actions/DropdownButton/DropdownButton.stories.tsx +88 -0
- package/src/components/actions/DropdownButton/index.tsx +113 -0
- package/src/components/actions/IconButton/IconButton.stories.tsx +54 -0
- package/src/components/actions/IconButton/IconButton.test.tsx +7 -0
- package/src/components/actions/IconButton/IconButton.test.tsx.snap +46 -0
- package/src/components/actions/IconButton/index.tsx +40 -0
- package/src/components/actions/IconButton/style.ts +75 -0
- package/src/components/actions/ToggleButton/ToggleButton.stories.tsx +84 -0
- package/src/components/actions/ToggleButton/ToggleButton.tsx +48 -0
- package/src/components/actions/ToggleButton/ToggleButtonGroup.tsx +99 -0
- package/src/components/actions/ToggleButton/index.tsx +2 -0
- package/src/components/actions/ToggleButton/style.ts +76 -0
- package/src/components/actions/index.ts +16 -0
- package/src/components/charts/AreaChart/AreaChart.stories.tsx +104 -0
- package/src/components/charts/AreaChart/index.tsx +379 -0
- package/src/components/charts/BarChart/BarChart.stories.tsx +32 -0
- package/src/components/charts/BarChart/index.tsx +287 -0
- package/src/components/charts/BrushHandle.tsx +21 -0
- package/src/components/charts/GeoMercator/GeoMercator.stories.tsx +65 -0
- package/src/components/charts/GeoMercator/index.tsx +141 -0
- package/src/components/charts/GeoMercator/world.d.ts +1 -0
- package/src/components/charts/GeoMercator/world.json +99485 -0
- package/src/components/charts/Heatmap/Heatmap.stories.tsx +55 -0
- package/src/components/charts/Heatmap/index.tsx +228 -0
- package/src/components/charts/LineChart/LineChart.stories.tsx +37 -0
- package/src/components/charts/LineChart/index.tsx +233 -0
- package/src/components/charts/PieChart/PieChart.stories.tsx +43 -0
- package/src/components/charts/PieChart/index.tsx +163 -0
- package/src/components/charts/PointHighlight.tsx +49 -0
- package/src/components/charts/RadarChart/RadarChart.stories.tsx +38 -0
- package/src/components/charts/RadarChart/generators.ts +30 -0
- package/src/components/charts/RadarChart/index.tsx +175 -0
- package/src/components/charts/RadialBarChart/RadialBarChart.stories.tsx +34 -0
- package/src/components/charts/RadialBarChart/index.tsx +165 -0
- package/src/components/charts/RadialLineChart/RadialLineChart.stories.tsx +26 -0
- package/src/components/charts/RadialLineChart/index.tsx +141 -0
- package/src/components/charts/index.tsx +20 -0
- package/src/components/charts/useGradients.tsx +37 -0
- package/src/components/charts/util.ts +40 -0
- package/src/components/data/Avatar/Avatar.stories.tsx +93 -0
- package/src/components/data/Avatar/context.tsx +20 -0
- package/src/components/data/Avatar/index.tsx +132 -0
- package/src/components/data/Avatar/style.ts +124 -0
- package/src/components/data/Avatar/useImageLoadingStatus.tsx +32 -0
- package/src/components/data/Chip/Chip.stories.tsx +67 -0
- package/src/components/data/Chip/Chip.test.tsx +7 -0
- package/src/components/data/Chip/Chip.test.tsx.snap +50 -0
- package/src/components/data/Chip/index.tsx +76 -0
- package/src/components/data/Chip/style.ts +84 -0
- package/src/components/data/Console/Console.stories.tsx +51 -0
- package/src/components/data/Console/Console.tsx +125 -0
- package/src/components/data/Console/ConsoleInput/index.tsx +87 -0
- package/src/components/data/Console/ConsoleInput/style.ts +41 -0
- package/src/components/data/Console/ConsoleLine/index.tsx +127 -0
- package/src/components/data/Console/ConsoleLine/style.ts +76 -0
- package/src/components/data/Console/MessageModel.ts +9 -0
- package/src/components/data/Console/index.tsx +4 -0
- package/src/components/data/Console/style.ts +31 -0
- package/src/components/data/Console/useConsoleLiveMode.ts +42 -0
- package/src/components/data/CopyId/CopyId.stories.tsx +36 -0
- package/src/components/data/CopyId/index.tsx +38 -0
- package/src/components/data/DateFormatter/DateFormatter.stories.tsx +26 -0
- package/src/components/data/DateFormatter/index.tsx +15 -0
- package/src/components/data/Drawer/Drawer.stories.tsx +144 -0
- package/src/components/data/Drawer/DrawerBody.tsx +22 -0
- package/src/components/data/Drawer/DrawerContent.tsx +110 -0
- package/src/components/data/Drawer/DrawerContext.tsx +21 -0
- package/src/components/data/Drawer/DrawerFooter.tsx +19 -0
- package/src/components/data/Drawer/DrawerHeading.tsx +49 -0
- package/src/components/data/Drawer/DrawerSkeleton.tsx +29 -0
- package/src/components/data/Drawer/index.tsx +25 -0
- package/src/components/data/Drawer/useDrawer.tsx +52 -0
- package/src/components/data/InfiniteScroll/InfiniteScroll.stories.tsx +33 -0
- package/src/components/data/InfiniteScroll/index.tsx +51 -0
- package/src/components/data/LinkCard/index.tsx +28 -0
- package/src/components/data/Stats/Stat.tsx +99 -0
- package/src/components/data/Stats/Stats.stories.tsx +72 -0
- package/src/components/data/Stats/context.tsx +11 -0
- package/src/components/data/Stats/index.tsx +50 -0
- package/src/components/data/Table/Table.stories.tsx +142 -0
- package/src/components/data/Table/index.tsx +365 -0
- package/src/components/data/Table/react-table.d.ts +11 -0
- package/src/components/data/Table/style.ts +75 -0
- package/src/components/data/Table/subcomponents/ColumnHeader/ColumnSettings.tsx +161 -0
- package/src/components/data/Table/subcomponents/ColumnHeader/index.tsx +207 -0
- package/src/components/data/Table/subcomponents/ColumnHeader/style.ts +89 -0
- package/src/components/data/Table/subcomponents/ColumnVisibility/index.tsx +61 -0
- package/src/components/data/Table/subcomponents/Filter/field.tsx +129 -0
- package/src/components/data/Table/subcomponents/Filter/index.tsx +239 -0
- package/src/components/data/Table/subcomponents/Filter/style.ts +26 -0
- package/src/components/data/Table/subcomponents/Pagination/index.tsx +108 -0
- package/src/components/data/Table/subcomponents/Pagination/style.ts +49 -0
- package/src/components/data/Table/subcomponents/index.ts +4 -0
- package/src/components/data/index.ts +28 -0
- package/src/components/dialogs/Dialog/Dialog.stories.tsx +74 -0
- package/src/components/dialogs/Dialog/DialogBody.tsx +62 -0
- package/src/components/dialogs/Dialog/DialogContent.tsx +46 -0
- package/src/components/dialogs/Dialog/DialogContext.tsx +21 -0
- package/src/components/dialogs/Dialog/DialogHeading.tsx +56 -0
- package/src/components/dialogs/Dialog/index.tsx +20 -0
- package/src/components/dialogs/Dialog/useDialog.tsx +50 -0
- package/src/components/feedback/Alert/Alert.stories.tsx +77 -0
- package/src/components/feedback/Alert/Alert.test.tsx +7 -0
- package/src/components/feedback/Alert/Alert.test.tsx.snap +146 -0
- package/src/components/feedback/Alert/index.tsx +109 -0
- package/src/components/feedback/Alert/style.ts +87 -0
- package/src/components/feedback/ErrorFallback/ErrorFallback.stories.tsx +10 -0
- package/src/components/feedback/ErrorFallback/index.tsx +48 -0
- package/src/components/feedback/ErrorPage/ErrorPage.stories.tsx +31 -0
- package/src/components/feedback/ErrorPage/index.tsx +193 -0
- package/src/components/feedback/FormError/FormError.stories.tsx +25 -0
- package/src/components/feedback/FormError/index.tsx +54 -0
- package/src/components/feedback/Loaders/Loaders.stories.tsx +28 -0
- package/src/components/feedback/Loaders/Loading.test.tsx +7 -0
- package/src/components/feedback/Loaders/Loading.test.tsx.snap +141 -0
- package/src/components/feedback/Loaders/Loading.tsx +107 -0
- package/src/components/feedback/Loaders/Spinner.test.tsx +7 -0
- package/src/components/feedback/Loaders/Spinner.test.tsx.snap +18 -0
- package/src/components/feedback/Loaders/Spinner.tsx +74 -0
- package/src/components/feedback/Loaders/index.ts +2 -0
- package/src/components/feedback/NetworkDetector/NetworkDetector.stories.tsx +21 -0
- package/src/components/feedback/NetworkDetector/NetworkDetector.test.tsx +7 -0
- package/src/components/feedback/NetworkDetector/NetworkDetector.test.tsx.snap +3 -0
- package/src/components/feedback/NetworkDetector/index.tsx +41 -0
- package/src/components/feedback/NotificationBanner/NotificationBanner.stories.tsx +13 -0
- package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx +14 -0
- package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx.snap +3 -0
- package/src/components/feedback/NotificationBanner/index.tsx +79 -0
- package/src/components/feedback/Popover/Popover.stories.tsx +33 -0
- package/src/components/feedback/Popover/PopoverContent.tsx +43 -0
- package/src/components/feedback/Popover/PopoverContext.tsx +21 -0
- package/src/components/feedback/Popover/PopoverTrigger.tsx +43 -0
- package/src/components/feedback/Popover/index.tsx +22 -0
- package/src/components/feedback/Popover/usePopover.tsx +87 -0
- package/src/components/feedback/ProgressBar/ProgressBar.stories.tsx +38 -0
- package/src/components/feedback/ProgressBar/index.tsx +103 -0
- package/src/components/feedback/QuestionTooltip/QuestionTooltip.stories.tsx +20 -0
- package/src/components/feedback/QuestionTooltip/index.tsx +36 -0
- package/src/components/feedback/Skeleton/Skeleton.stories.tsx +33 -0
- package/src/components/feedback/Skeleton/Skeleton.test.tsx +7 -0
- package/src/components/feedback/Skeleton/Skeleton.test.tsx.snap +35 -0
- package/src/components/feedback/Skeleton/index.tsx +62 -0
- package/src/components/feedback/Tooltip/Tooltip.stories.tsx +69 -0
- package/src/components/feedback/Tooltip/TooltipContent.tsx +50 -0
- package/src/components/feedback/Tooltip/TooltipContext.tsx +13 -0
- package/src/components/feedback/Tooltip/TooltipTrigger.tsx +39 -0
- package/src/components/feedback/Tooltip/index.tsx +26 -0
- package/src/components/feedback/Tooltip/useTooltip.tsx +79 -0
- package/src/components/feedback/index.ts +33 -0
- package/src/components/feedback/snacks/CookieConsent/index.tsx +122 -0
- package/src/components/feedback/snacks/CookieConsent/style.ts +100 -0
- package/src/components/feedback/snacks/Default/default.stories.tsx +72 -0
- package/src/components/feedback/snacks/Default/index.tsx +77 -0
- package/src/components/feedback/snacks/Default/style.ts +59 -0
- package/src/components/feedback/snacks/Drawer/Drawer.stories.tsx +46 -0
- package/src/components/feedback/snacks/Drawer/index.tsx +70 -0
- package/src/components/feedback/snacks/NetworkDetector/index.tsx +70 -0
- package/src/components/feedback/snacks/index.d.ts +15 -0
- package/src/components/feedback/snacks/index.ts +8 -0
- package/src/components/index.ts +9 -0
- package/src/components/inputs/CheckBox/CheckBox.stories.tsx +64 -0
- package/src/components/inputs/CheckBox/Controlled.tsx +124 -0
- package/src/components/inputs/CheckBox/Generic.tsx +96 -0
- package/src/components/inputs/CheckBox/index.tsx +4 -0
- package/src/components/inputs/CheckBox/style.ts +113 -0
- package/src/components/inputs/CodeField/CodeField.stories.tsx +87 -0
- package/src/components/inputs/CodeField/index.tsx +173 -0
- package/src/components/inputs/CodeField/style.ts +50 -0
- package/src/components/inputs/Date/DatePicker/Controlled.tsx +101 -0
- package/src/components/inputs/Date/DatePicker/DatePicker.stories.tsx +234 -0
- package/src/components/inputs/Date/DatePicker/Generic.tsx +253 -0
- package/src/components/inputs/Date/DatePicker/formats.tsx +32 -0
- package/src/components/inputs/Date/DatePicker/style.ts +43 -0
- package/src/components/inputs/Date/DateRangePicker/Context.tsx +112 -0
- package/src/components/inputs/Date/DateRangePicker/DateRangePicker.stories.tsx +32 -0
- package/src/components/inputs/Date/DateRangePicker/DateSelector/Absolute.tsx +98 -0
- package/src/components/inputs/Date/DateRangePicker/DateSelector/Relative.tsx +54 -0
- package/src/components/inputs/Date/DateRangePicker/DateSelector/index.tsx +49 -0
- package/src/components/inputs/Date/DateRangePicker/QuickSelect/index.tsx +270 -0
- package/src/components/inputs/Date/DateRangePicker/QuickSelect/style.ts +40 -0
- package/src/components/inputs/Date/DateRangePicker/index.tsx +134 -0
- package/src/components/inputs/Date/DateRangePicker/style.ts +51 -0
- package/src/components/inputs/Date/subcomponents/Calendar/index.tsx +150 -0
- package/src/components/inputs/Date/subcomponents/Calendar/style.ts +59 -0
- package/src/components/inputs/Date/subcomponents/RelativePicker/index.tsx +186 -0
- package/src/components/inputs/Date/subcomponents/RelativePicker/style.ts +50 -0
- package/src/components/inputs/Date/subcomponents/TimePicker/TimePicker.stories.tsx +25 -0
- package/src/components/inputs/Date/subcomponents/TimePicker/index.tsx +40 -0
- package/src/components/inputs/Date/subcomponents/TimePicker/style.ts +32 -0
- package/src/components/inputs/DurationField/Controlled.tsx +69 -0
- package/src/components/inputs/DurationField/Duration.stories.tsx +54 -0
- package/src/components/inputs/DurationField/Generic.tsx +200 -0
- package/src/components/inputs/DurationField/index.tsx +5 -0
- package/src/components/inputs/DurationField/style.ts +42 -0
- package/src/components/inputs/EditableField/EditableField.stories.tsx +65 -0
- package/src/components/inputs/EditableField/index.tsx +135 -0
- package/src/components/inputs/EditableField/style.ts +11 -0
- package/src/components/inputs/FileField/Controlled.tsx +104 -0
- package/src/components/inputs/FileField/FileField.stories.tsx +211 -0
- package/src/components/inputs/FileField/Generic.tsx +131 -0
- package/src/components/inputs/FileField/index.tsx +5 -0
- package/src/components/inputs/FileField/style.ts +34 -0
- package/src/components/inputs/InputProps.ts +61 -0
- package/src/components/inputs/RadioGroup/Controlled.tsx +46 -0
- package/src/components/inputs/RadioGroup/Generic.tsx +34 -0
- package/src/components/inputs/RadioGroup/RadioGroup.stories.tsx +116 -0
- package/src/components/inputs/RadioGroup/RadioItem.tsx +129 -0
- package/src/components/inputs/RadioGroup/context.tsx +20 -0
- package/src/components/inputs/RadioGroup/index.ts +5 -0
- package/src/components/inputs/RadioGroup/style.ts +3 -0
- package/src/components/inputs/Slider/Controlled.tsx +87 -0
- package/src/components/inputs/Slider/Generic.tsx +73 -0
- package/src/components/inputs/Slider/Slider.stories.tsx +101 -0
- package/src/components/inputs/Slider/handle.tsx +31 -0
- package/src/components/inputs/Slider/index.tsx +5 -0
- package/src/components/inputs/Slider/style.ts +140 -0
- package/src/components/inputs/Switch/Controlled.tsx +58 -0
- package/src/components/inputs/Switch/Generic.tsx +67 -0
- package/src/components/inputs/Switch/Switch.stories.tsx +91 -0
- package/src/components/inputs/Switch/index.ts +5 -0
- package/src/components/inputs/Switch/style.ts +56 -0
- package/src/components/inputs/TagField/Controlled.tsx +103 -0
- package/src/components/inputs/TagField/Generic.tsx +138 -0
- package/src/components/inputs/TagField/TagField.stories.tsx +68 -0
- package/src/components/inputs/TagField/index.ts +5 -0
- package/src/components/inputs/TagField/style.ts +25 -0
- package/src/components/inputs/TagField/util.ts +34 -0
- package/src/components/inputs/TextAreaField/Controlled.tsx +101 -0
- package/src/components/inputs/TextAreaField/Generic.tsx +56 -0
- package/src/components/inputs/TextAreaField/TextAreaField.stories.tsx +98 -0
- package/src/components/inputs/TextAreaField/index.ts +5 -0
- package/src/components/inputs/TextAreaField/style.ts +28 -0
- package/src/components/inputs/TextField/Controlled.tsx +120 -0
- package/src/components/inputs/TextField/Generic.tsx +113 -0
- package/src/components/inputs/TextField/TextField.stories.tsx +196 -0
- package/src/components/inputs/TextField/index.ts +5 -0
- package/src/components/inputs/TextField/style.ts +97 -0
- package/src/components/inputs/TextField/util.ts +19 -0
- package/src/components/inputs/ValueConfirmationField/ValueConfirmationField.stories.tsx +33 -0
- package/src/components/inputs/ValueConfirmationField/index.tsx +54 -0
- package/src/components/inputs/index.ts +67 -0
- package/src/components/inputs/layout/Description.tsx +40 -0
- package/src/components/inputs/layout/ErrorMessage/ErrorMessage.stories.tsx +28 -0
- package/src/components/inputs/layout/ErrorMessage/index.tsx +63 -0
- package/src/components/inputs/layout/InputWrapper.ts +6 -0
- package/src/components/inputs/layout/Label/index.tsx +71 -0
- package/src/components/inputs/layout/Label/style.ts +51 -0
- package/src/components/inputs/layout/index.ts +6 -0
- package/src/components/inputs/selects/SelectField/Controlled.tsx +130 -0
- package/src/components/inputs/selects/SelectField/Generic/FilterInput.tsx +45 -0
- package/src/components/inputs/selects/SelectField/Generic/index.tsx +302 -0
- package/src/components/inputs/selects/SelectField/SelectField.stories.tsx +253 -0
- package/src/components/inputs/selects/SelectField/index.ts +5 -0
- package/src/components/inputs/selects/SelectField/style.ts +29 -0
- package/src/components/inputs/selects/SelectQueryField/Controlled.tsx +100 -0
- package/src/components/inputs/selects/SelectQueryField/Generic/index.tsx +300 -0
- package/src/components/inputs/selects/SelectQueryField/SelectQueryField.stories.tsx +260 -0
- package/src/components/inputs/selects/SelectQueryField/index.tsx +5 -0
- package/src/components/inputs/selects/SelectQueryField/style.ts +14 -0
- package/src/components/inputs/selects/SubComponents/Option.tsx +114 -0
- package/src/components/inputs/selects/SubComponents/OptionGroup.tsx +16 -0
- package/src/components/inputs/selects/SubComponents/index.ts +10 -0
- package/src/components/inputs/selects/SubComponents/style.ts +39 -0
- package/src/components/inputs/selects/data.ts +123 -0
- package/src/components/inputs/selects/index.tsx +47 -0
- package/src/components/inputs/selects/sharedStyle.ts +78 -0
- package/src/components/layout/Container/index.ts +21 -0
- package/src/components/layout/index.ts +1 -0
- package/src/components/navigation/HorizontalNav/HorizontalNav.stories.tsx +45 -0
- package/src/components/navigation/HorizontalNav/index.tsx +40 -0
- package/src/components/navigation/HorizontalNav/style.ts +83 -0
- package/src/components/navigation/IconNav/IconNav.stories.tsx +46 -0
- package/src/components/navigation/IconNav/index.tsx +49 -0
- package/src/components/navigation/Steppers/SlimStepper/Stepper.stories.tsx +89 -0
- package/src/components/navigation/Steppers/SlimStepper/index.tsx +104 -0
- package/src/components/navigation/Steppers/SlimStepper/style.ts +86 -0
- package/src/components/navigation/Steppers/Stepper/Stepper.stories.tsx +87 -0
- package/src/components/navigation/Steppers/Stepper/index.tsx +114 -0
- package/src/components/navigation/Steppers/Stepper/style.ts +105 -0
- package/src/components/navigation/Steppers/context.tsx +49 -0
- package/src/components/navigation/Steppers/reducer.ts +51 -0
- package/src/components/navigation/Steppers/stepStates.ts +5 -0
- package/src/components/navigation/Tabs/Content.tsx +36 -0
- package/src/components/navigation/Tabs/Context.tsx +21 -0
- package/src/components/navigation/Tabs/List.tsx +17 -0
- package/src/components/navigation/Tabs/Tabs.stories.tsx +119 -0
- package/src/components/navigation/Tabs/Trigger.tsx +65 -0
- package/src/components/navigation/Tabs/index.tsx +35 -0
- package/src/components/navigation/Tabs/useTabs.tsx +28 -0
- package/src/components/navigation/index.ts +16 -0
- package/src/components/other/ActionMenu/ActionMenu.stories.tsx +86 -0
- package/src/components/other/ActionMenu/index.tsx +55 -0
- package/src/components/other/ActionMenu/style.ts +48 -0
- package/src/components/other/ClipBoard/ClipBoard.stories.tsx +14 -0
- package/src/components/other/ClipBoard/ClipBoard.test.tsx +7 -0
- package/src/components/other/ClipBoard/ClipBoard.test.tsx.snap +70 -0
- package/src/components/other/ClipBoard/index.tsx +70 -0
- package/src/components/other/CollapseList/CollapseList.stories.tsx +21 -0
- package/src/components/other/CollapseList/index.tsx +115 -0
- package/src/components/other/Collapsible/Collapsible.stories.tsx +19 -0
- package/src/components/other/Collapsible/CollapsibleContent.tsx +22 -0
- package/src/components/other/Collapsible/CollapsibleContext.tsx +17 -0
- package/src/components/other/Collapsible/CollapsibleTrigger.tsx +67 -0
- package/src/components/other/Collapsible/index.tsx +21 -0
- package/src/components/other/Company/index.tsx +45 -0
- package/src/components/other/Company/style.ts +58 -0
- package/src/components/other/Empty/Empty.stories.tsx +24 -0
- package/src/components/other/Empty/Empty.test.tsx +7 -0
- package/src/components/other/Empty/Empty.test.tsx.snap +85 -0
- package/src/components/other/Empty/index.tsx +87 -0
- package/src/components/other/PermissionsGuard/PermissionsGuard.stories.tsx +54 -0
- package/src/components/other/PermissionsGuard/index.tsx +43 -0
- package/src/components/other/index.ts +19 -0
- package/src/components/visual/Card/Card.stories.tsx +19 -0
- package/src/components/visual/Card/index.tsx +49 -0
- package/src/components/visual/Divider/Divider.stories.tsx +19 -0
- package/src/components/visual/Divider/Divider.test.tsx +7 -0
- package/src/components/visual/Divider/Divider.test.tsx.snap +35 -0
- package/src/components/visual/Divider/index.tsx +85 -0
- package/src/components/visual/index.ts +5 -0
- package/src/errors/base.ts +11 -0
- package/src/errors/errors.ts +109 -0
- package/src/errors/index.ts +14 -0
- package/src/helpers/camelCaseToSpaces.ts +5 -0
- package/src/helpers/getInitials.ts +15 -0
- package/src/helpers/getSnackbarProvider.tsx +57 -0
- package/src/helpers/getTransition.ts +9 -0
- package/src/helpers/index.ts +5 -0
- package/src/helpers/makeData.ts +34 -0
- package/src/helpers/regexprs.ts +7 -0
- package/src/hooks/index.ts +9 -0
- package/src/hooks/useCallbackRef.tsx +17 -0
- package/src/hooks/useDebounce.tsx +22 -0
- package/src/hooks/useFocus.tsx +10 -0
- package/src/hooks/useLocalStorage.tsx +38 -0
- package/src/hooks/useLockScroll.ts +26 -0
- package/src/hooks/useOnScreen.ts +24 -0
- package/src/hooks/useOutsideAlerter.tsx +15 -0
- package/src/hooks/useTableActions.ts +56 -0
- package/src/hooks/useTheme.tsx +7 -0
- package/src/images/company-icon-primary.svg +3 -0
- package/src/images/company-icon-secondary.svg +3 -0
- package/src/images/index.ts +4 -0
- package/src/index.ts +9 -0
- package/src/stories/Colors.stories.mdx +35 -0
- package/src/stories/Elevation.stories.mdx +56 -0
- package/src/stories/Introduction.stories.mdx +17 -0
- package/src/stories/Spacing.stories.mdx +25 -0
- package/src/styled/GlobalStyle.ts +207 -0
- package/src/styled/Snackbar.tsx +42 -0
- package/src/styled/animations.ts +36 -0
- package/src/styled/breakpoint.ts +7 -0
- package/src/styled/device.ts +10 -0
- package/src/styled/elevation.ts +20 -0
- package/src/styled/index.ts +11 -0
- package/src/styled/spacing.ts +38 -0
- package/src/styled/theme.ts +87 -0
- package/src/styled/types.ts +5 -0
- package/src/styled/zIndex.ts +31 -0
- package/src/test/__mocks__/fileMock.ts +2 -0
- package/src/test/setupTests.ts +3 -0
- package/src/test/snapshotResolver.js +21 -0
- package/src/test/testUtils.tsx +31 -0
- package/src/types/index.ts +1 -0
- package/src/types/json.ts +5 -0
- package/src/views/LoadingPage.tsx +36 -0
- package/src/views/index.ts +1 -0
- package/tsconfig.json +19 -0
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { forwardRef, HTMLProps, useId, useLayoutEffect } from 'react';
|
|
2
|
+
import { useDialogContext } from './DialogContext';
|
|
3
|
+
import { AiOutlineClose as CloseIcon } from 'react-icons/ai';
|
|
4
|
+
import { styled } from '../../../styled';
|
|
5
|
+
import { IconButton, Tooltip } from '../../../components';
|
|
6
|
+
|
|
7
|
+
const Container = styled.div`
|
|
8
|
+
display: flex;
|
|
9
|
+
justify-content: space-between;
|
|
10
|
+
align-items: center;
|
|
11
|
+
|
|
12
|
+
h4 {
|
|
13
|
+
font-size: ${({ theme }) => theme.fontSize.tiny};
|
|
14
|
+
}
|
|
15
|
+
margin-bottom: ${({ theme }) => theme.spacing[2]};
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
interface DialogHeadingProps extends HTMLProps<HTMLHeadingElement> {
|
|
19
|
+
hasClose?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export const DialogHeading = forwardRef<HTMLHeadingElement, DialogHeadingProps>(function DialogHeading(
|
|
23
|
+
{ children, hasClose = true, ...props },
|
|
24
|
+
ref
|
|
25
|
+
) {
|
|
26
|
+
const { setLabelId, setOpen } = useDialogContext();
|
|
27
|
+
const id = useId();
|
|
28
|
+
|
|
29
|
+
useLayoutEffect(() => {
|
|
30
|
+
setLabelId(id);
|
|
31
|
+
return () => setLabelId(undefined);
|
|
32
|
+
}, [id, setLabelId]);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Container>
|
|
36
|
+
<h4 {...props} ref={ref} id={id}>
|
|
37
|
+
{children}
|
|
38
|
+
</h4>
|
|
39
|
+
{hasClose && (
|
|
40
|
+
<Tooltip>
|
|
41
|
+
<Tooltip.Trigger asChild>
|
|
42
|
+
<IconButton
|
|
43
|
+
onClick={(e) => {
|
|
44
|
+
e.stopPropagation();
|
|
45
|
+
setOpen(false);
|
|
46
|
+
}}
|
|
47
|
+
ariaLabel="Close dialog"
|
|
48
|
+
icon={<CloseIcon cursor="pointer" />}
|
|
49
|
+
/>
|
|
50
|
+
</Tooltip.Trigger>
|
|
51
|
+
<Tooltip.Content>Close dialog</Tooltip.Content>
|
|
52
|
+
</Tooltip>
|
|
53
|
+
)}
|
|
54
|
+
</Container>
|
|
55
|
+
);
|
|
56
|
+
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DialogOptions, useDialog } from './useDialog';
|
|
2
|
+
import { FC, PropsWithChildren } from 'react';
|
|
3
|
+
import { DialogContext } from './DialogContext';
|
|
4
|
+
import { DialogContent } from './DialogContent';
|
|
5
|
+
import { DialogBody } from './DialogBody';
|
|
6
|
+
import { DialogHeading } from './DialogHeading';
|
|
7
|
+
|
|
8
|
+
interface SubComponentTypes {
|
|
9
|
+
Content: typeof DialogContent;
|
|
10
|
+
Body: typeof DialogBody;
|
|
11
|
+
Heading: typeof DialogHeading;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const Dialog: FC<PropsWithChildren<DialogOptions>> & SubComponentTypes = ({ children, ...options }) => {
|
|
15
|
+
return <DialogContext.Provider value={useDialog(options)}>{children}</DialogContext.Provider>;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
Dialog.Content = DialogContent;
|
|
19
|
+
Dialog.Body = DialogBody;
|
|
20
|
+
Dialog.Heading = DialogHeading;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { useMemo, useState } from 'react';
|
|
2
|
+
import { useClick, useDismiss, useFloating, useInteractions, useRole } from '@floating-ui/react';
|
|
3
|
+
|
|
4
|
+
export interface DialogOptions {
|
|
5
|
+
open?: boolean;
|
|
6
|
+
initialOpen?: boolean;
|
|
7
|
+
onOpenChange?: (open: boolean) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function useDialog({
|
|
11
|
+
initialOpen = false,
|
|
12
|
+
open: controlledOpen,
|
|
13
|
+
onOpenChange: setControlledOpen,
|
|
14
|
+
}: DialogOptions) {
|
|
15
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(initialOpen);
|
|
16
|
+
const [labelId, setLabelId] = useState<string | undefined>();
|
|
17
|
+
const [descriptionId, setDescriptionId] = useState<string | undefined>();
|
|
18
|
+
|
|
19
|
+
const open = controlledOpen ?? uncontrolledOpen;
|
|
20
|
+
const setOpen = setControlledOpen ?? setUncontrolledOpen;
|
|
21
|
+
|
|
22
|
+
const data = useFloating({
|
|
23
|
+
open,
|
|
24
|
+
onOpenChange: setOpen,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
const context = data.context;
|
|
28
|
+
|
|
29
|
+
const interactions = useInteractions([
|
|
30
|
+
useClick(context, {
|
|
31
|
+
enabled: controlledOpen == null,
|
|
32
|
+
}),
|
|
33
|
+
useDismiss(context, { outsidePressEvent: 'mousedown', bubbles: false }),
|
|
34
|
+
useRole(context, { role: 'dialog' }),
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
return useMemo(
|
|
38
|
+
() => ({
|
|
39
|
+
open,
|
|
40
|
+
setOpen,
|
|
41
|
+
...interactions,
|
|
42
|
+
...data,
|
|
43
|
+
labelId,
|
|
44
|
+
descriptionId,
|
|
45
|
+
setLabelId,
|
|
46
|
+
setDescriptionId,
|
|
47
|
+
}),
|
|
48
|
+
[open, setOpen, interactions, data, labelId, descriptionId]
|
|
49
|
+
);
|
|
50
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn, StoryObj } from '@storybook/react';
|
|
3
|
+
import { Alert, AlertProps } from '.';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Feedback/Alert',
|
|
7
|
+
component: Alert,
|
|
8
|
+
args: {
|
|
9
|
+
text: 'This is the title',
|
|
10
|
+
variant: 'info',
|
|
11
|
+
},
|
|
12
|
+
} as Meta<AlertProps>;
|
|
13
|
+
|
|
14
|
+
export const Default: StoryFn<AlertProps> = (args) => <Alert {...args} />;
|
|
15
|
+
|
|
16
|
+
export const Success: StoryObj<AlertProps> = {
|
|
17
|
+
args: {
|
|
18
|
+
title: 'Order complete',
|
|
19
|
+
text: 'Your order has been sucessfully processed. We are completing the report.',
|
|
20
|
+
variant: 'success',
|
|
21
|
+
dismiss: true,
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export const Error: StoryObj<AlertProps> = {
|
|
26
|
+
args: {
|
|
27
|
+
title: 'There were errors with your submission',
|
|
28
|
+
text: [
|
|
29
|
+
'Your password must be at least 8 characters',
|
|
30
|
+
'Your password must include at least one pro wrestling finishing move',
|
|
31
|
+
],
|
|
32
|
+
variant: 'error',
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const Warning: StoryObj<AlertProps> = {
|
|
37
|
+
args: {
|
|
38
|
+
title: 'Attention required',
|
|
39
|
+
text: 'This is a warning! Please read this carefully before you continue!',
|
|
40
|
+
variant: 'warning',
|
|
41
|
+
action: {
|
|
42
|
+
execute: () => {
|
|
43
|
+
/* */
|
|
44
|
+
},
|
|
45
|
+
text: 'View status',
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export const SingleLine: StoryObj<AlertProps> = {
|
|
51
|
+
args: {
|
|
52
|
+
text: 'This is a single line now',
|
|
53
|
+
variant: 'info',
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const SingleLineWithAction: StoryObj<AlertProps> = {
|
|
58
|
+
args: {
|
|
59
|
+
text: 'This is a single line now',
|
|
60
|
+
variant: 'error',
|
|
61
|
+
action: {
|
|
62
|
+
execute: () => {},
|
|
63
|
+
text: 'details',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const SingleLineLongWithAction: StoryObj<AlertProps> = {
|
|
69
|
+
args: {
|
|
70
|
+
text: 'This is a very very very very very very very very very very long line that stretches to 2 lines',
|
|
71
|
+
variant: 'error',
|
|
72
|
+
action: {
|
|
73
|
+
execute: () => {},
|
|
74
|
+
text: 'details',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Should render <Alert/> 1`] = `
|
|
4
|
+
.c0 {
|
|
5
|
+
width: 100%;
|
|
6
|
+
padding: 1rem 1.2rem;
|
|
7
|
+
border-radius: 1rem;
|
|
8
|
+
margin: 1.5rem auto 1.5rem auto;
|
|
9
|
+
background-color: #d9d2f9;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.c0 h2 {
|
|
13
|
+
font-size: 1.825rem;
|
|
14
|
+
display: -webkit-box;
|
|
15
|
+
display: -webkit-flex;
|
|
16
|
+
display: -ms-flexbox;
|
|
17
|
+
display: flex;
|
|
18
|
+
-webkit-align-items: center;
|
|
19
|
+
-webkit-box-align: center;
|
|
20
|
+
-ms-flex-align: center;
|
|
21
|
+
align-items: center;
|
|
22
|
+
font-weight: 700;
|
|
23
|
+
-webkit-box-pack: start;
|
|
24
|
+
-webkit-justify-content: flex-start;
|
|
25
|
+
-ms-flex-pack: start;
|
|
26
|
+
justify-content: flex-start;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.c0 p {
|
|
30
|
+
margin-top: 1.5rem;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.c0 p,
|
|
34
|
+
.c0 li {
|
|
35
|
+
font-size: 1.325rem;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.c0 ul {
|
|
39
|
+
margin-left: 15px;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.c0 ul li {
|
|
43
|
+
list-style-type: disc;
|
|
44
|
+
margin-top: 0.5rem;
|
|
45
|
+
margin-bottom: 0.5rem;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.c0 h2 {
|
|
49
|
+
color: #331ab2;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.c0 p,
|
|
53
|
+
.c0 li {
|
|
54
|
+
color: #331ab2;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.c0::marker {
|
|
58
|
+
color: #331ab2;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.c1 {
|
|
62
|
+
display: grid;
|
|
63
|
+
grid-template-columns: 40px 1fr;
|
|
64
|
+
-webkit-align-items: center;
|
|
65
|
+
-webkit-box-align: center;
|
|
66
|
+
-ms-flex-align: center;
|
|
67
|
+
align-items: center;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.c2 {
|
|
71
|
+
display: -webkit-box;
|
|
72
|
+
display: -webkit-flex;
|
|
73
|
+
display: -ms-flexbox;
|
|
74
|
+
display: flex;
|
|
75
|
+
-webkit-align-items: center;
|
|
76
|
+
-webkit-box-align: center;
|
|
77
|
+
-ms-flex-align: center;
|
|
78
|
+
align-items: center;
|
|
79
|
+
-webkit-box-pack: center;
|
|
80
|
+
-webkit-justify-content: center;
|
|
81
|
+
-ms-flex-pack: center;
|
|
82
|
+
justify-content: center;
|
|
83
|
+
margin-right: 1.4rem;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.c2 svg {
|
|
87
|
+
fill: #664DE5;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.c3 {
|
|
91
|
+
display: none;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.c3 button {
|
|
95
|
+
margin-top: 2rem;
|
|
96
|
+
margin-right: 2rem;
|
|
97
|
+
padding: 0.8rem 0.5rem 0.8rem 0.5rem;
|
|
98
|
+
border-radius: 0.5rem;
|
|
99
|
+
background-color: #b2a6f2;
|
|
100
|
+
font-size: 1.3rem;
|
|
101
|
+
border: none;
|
|
102
|
+
cursor: pointer;
|
|
103
|
+
font-weight: 700;
|
|
104
|
+
color: #331ab2;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
<div>
|
|
108
|
+
<div
|
|
109
|
+
class="c0"
|
|
110
|
+
style="opacity: 0;"
|
|
111
|
+
>
|
|
112
|
+
<div
|
|
113
|
+
class="c1"
|
|
114
|
+
>
|
|
115
|
+
<div
|
|
116
|
+
class="c2"
|
|
117
|
+
>
|
|
118
|
+
<svg
|
|
119
|
+
fill="currentColor"
|
|
120
|
+
height="24"
|
|
121
|
+
stroke="currentColor"
|
|
122
|
+
stroke-width="0"
|
|
123
|
+
viewBox="0 0 1024 1024"
|
|
124
|
+
width="24"
|
|
125
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
126
|
+
>
|
|
127
|
+
<path
|
|
128
|
+
d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm32 664c0 4.4-3.6 8-8 8h-48c-4.4 0-8-3.6-8-8V456c0-4.4 3.6-8 8-8h48c4.4 0 8 3.6 8 8v272zm-32-344a48.01 48.01 0 0 1 0-96 48.01 48.01 0 0 1 0 96z"
|
|
129
|
+
/>
|
|
130
|
+
</svg>
|
|
131
|
+
</div>
|
|
132
|
+
<h2>
|
|
133
|
+
Alert title
|
|
134
|
+
</h2>
|
|
135
|
+
<div />
|
|
136
|
+
<p>
|
|
137
|
+
Alert text
|
|
138
|
+
</p>
|
|
139
|
+
<div />
|
|
140
|
+
<div
|
|
141
|
+
class="c3"
|
|
142
|
+
/>
|
|
143
|
+
</div>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
`;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { forwardRef, MouseEvent, useState } from 'react';
|
|
2
|
+
import { Container, Grid, IconContainer, ButtonContainer } from './style';
|
|
3
|
+
import {
|
|
4
|
+
AiFillCheckCircle as Success,
|
|
5
|
+
AiFillCloseCircle as Error,
|
|
6
|
+
AiOutlineWarning as Warning,
|
|
7
|
+
AiFillInfoCircle as Info,
|
|
8
|
+
} from 'react-icons/ai';
|
|
9
|
+
import { AnimatePresence } from 'framer-motion';
|
|
10
|
+
import { Elevation } from '../../../styled/';
|
|
11
|
+
import { Button } from '../../../components';
|
|
12
|
+
|
|
13
|
+
export type AlertVariants = 'success' | 'error' | 'warning' | 'info';
|
|
14
|
+
|
|
15
|
+
type Action = {
|
|
16
|
+
execute: () => void;
|
|
17
|
+
text: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export interface AlertProps {
|
|
21
|
+
variant: AlertVariants;
|
|
22
|
+
title?: string;
|
|
23
|
+
text?: string | string[];
|
|
24
|
+
elevation?: Elevation;
|
|
25
|
+
dismiss?: boolean;
|
|
26
|
+
action?: Action;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const Alert = forwardRef<HTMLDivElement, AlertProps>(
|
|
30
|
+
({ variant, title, text, dismiss = false, elevation = 4, action }, ref) => {
|
|
31
|
+
const [visible, setVisible] = useState(true);
|
|
32
|
+
|
|
33
|
+
const hasTitle = title ? true : false;
|
|
34
|
+
|
|
35
|
+
const handleExecute = (e: MouseEvent<HTMLButtonElement>) => {
|
|
36
|
+
e.preventDefault();
|
|
37
|
+
e.stopPropagation();
|
|
38
|
+
action?.execute();
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const handleDismiss = (e: MouseEvent<HTMLButtonElement>) => {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
e.stopPropagation();
|
|
44
|
+
setVisible(false);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
function getIcon() {
|
|
48
|
+
switch (variant) {
|
|
49
|
+
case 'success':
|
|
50
|
+
return <Success size={24} />;
|
|
51
|
+
case 'error':
|
|
52
|
+
return <Error size={24} />;
|
|
53
|
+
case 'warning':
|
|
54
|
+
return <Warning size={24} />;
|
|
55
|
+
case 'info':
|
|
56
|
+
return <Info size={24} />;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return (
|
|
60
|
+
<AnimatePresence>
|
|
61
|
+
{visible && (
|
|
62
|
+
<Container
|
|
63
|
+
animate={{ opacity: 1 }}
|
|
64
|
+
exit={{ opacity: 0 }}
|
|
65
|
+
$hasTitle={hasTitle}
|
|
66
|
+
initial={{ opacity: 0 }}
|
|
67
|
+
$variant={variant}
|
|
68
|
+
$elevation={elevation}
|
|
69
|
+
transition={{ duration: 0.2 }}
|
|
70
|
+
ref={ref}
|
|
71
|
+
role="status"
|
|
72
|
+
>
|
|
73
|
+
<Grid hasTitle={hasTitle}>
|
|
74
|
+
<IconContainer variant={variant}>{getIcon()}</IconContainer>
|
|
75
|
+
|
|
76
|
+
{/* If title is declared set title, otherwise put everything on single line */}
|
|
77
|
+
{title && (
|
|
78
|
+
<>
|
|
79
|
+
<h2>{title}</h2>
|
|
80
|
+
<div />
|
|
81
|
+
</>
|
|
82
|
+
)}
|
|
83
|
+
{typeof text === 'string' ? (
|
|
84
|
+
<p>{text}</p>
|
|
85
|
+
) : (
|
|
86
|
+
text && (
|
|
87
|
+
<ul>
|
|
88
|
+
{text.map((message) => (
|
|
89
|
+
<li>{message}</li>
|
|
90
|
+
))}
|
|
91
|
+
</ul>
|
|
92
|
+
)
|
|
93
|
+
)}
|
|
94
|
+
{hasTitle ? <div /> : null}
|
|
95
|
+
<ButtonContainer hasTitle={hasTitle} show={dismiss || action ? true : false} variant={variant}>
|
|
96
|
+
{action && (
|
|
97
|
+
<Button size="small" variant="outline" onClick={handleExecute} text={action.text} color={variant} />
|
|
98
|
+
)}
|
|
99
|
+
{dismiss && (
|
|
100
|
+
<Button size="small" color="white" variant="outline" onClick={handleDismiss} text="Dismiss" />
|
|
101
|
+
)}
|
|
102
|
+
</ButtonContainer>
|
|
103
|
+
</Grid>
|
|
104
|
+
</Container>
|
|
105
|
+
)}
|
|
106
|
+
</AnimatePresence>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
);
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Elevation, styled } from '../../../styled';
|
|
2
|
+
import { AlertVariants } from '.';
|
|
3
|
+
import { motion } from 'framer-motion';
|
|
4
|
+
import { shade } from 'polished';
|
|
5
|
+
|
|
6
|
+
// Since this actually a motion.div we are passing props to that only should be consumed by styled compmonents
|
|
7
|
+
// and not being passed the the underlying react node, we can prefix the prop names with `$`to turn it into
|
|
8
|
+
// a transient prop.
|
|
9
|
+
export const Container = styled(motion.div)<{
|
|
10
|
+
$variant: AlertVariants;
|
|
11
|
+
$hasTitle: boolean;
|
|
12
|
+
$elevation: Elevation;
|
|
13
|
+
}>`
|
|
14
|
+
width: 100%;
|
|
15
|
+
padding: ${({ theme }) => `${theme.spacing['0_75']} ${theme.spacing[1]}`};
|
|
16
|
+
border-radius: ${({ theme }) => theme.borderRadius.large};
|
|
17
|
+
box-shadow: ${({ theme, $elevation }) => theme.elevation[$elevation]};
|
|
18
|
+
margin: ${({ theme }) => `${theme.spacing['1_5']} auto`};
|
|
19
|
+
h2 {
|
|
20
|
+
font-size: 1.825rem;
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
font-weight: 700;
|
|
24
|
+
justify-content: flex-start;
|
|
25
|
+
}
|
|
26
|
+
p {
|
|
27
|
+
margin-top: ${({ theme, $hasTitle }) => ($hasTitle ? theme.spacing['0_5'] : theme.spacing[0])};
|
|
28
|
+
margin-bottom: 0;
|
|
29
|
+
hyphens: auto;
|
|
30
|
+
}
|
|
31
|
+
p,
|
|
32
|
+
li {
|
|
33
|
+
font-size: 1.325rem;
|
|
34
|
+
}
|
|
35
|
+
ul {
|
|
36
|
+
margin-left: ${({ theme }) => theme.spacing['1_5']};
|
|
37
|
+
li {
|
|
38
|
+
list-style-type: disc;
|
|
39
|
+
margin-top: ${({ theme }) => theme.spacing['0_5']};
|
|
40
|
+
margin-bottom: ${({ theme }) => theme.spacing['0_5']};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/* set background color equal to provided type */
|
|
44
|
+
${({ $variant, theme }): string => {
|
|
45
|
+
return `
|
|
46
|
+
background-color: ${shade('0.5', theme.colors[$variant])};
|
|
47
|
+
border: 1px solid ${theme.colors[$variant]};
|
|
48
|
+
h2 {
|
|
49
|
+
color: white;
|
|
50
|
+
}
|
|
51
|
+
p, li {
|
|
52
|
+
color: white;
|
|
53
|
+
}
|
|
54
|
+
::marker {
|
|
55
|
+
color: white;
|
|
56
|
+
}
|
|
57
|
+
`;
|
|
58
|
+
}}
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
export const Grid = styled.div<{ hasTitle: boolean }>`
|
|
62
|
+
display: grid;
|
|
63
|
+
grid-template-columns: ${({ theme, hasTitle }) =>
|
|
64
|
+
!hasTitle ? `${theme.spacing[5]} 1fr fit-content(100px)` : `${theme.spacing[5]} 1fr`};}
|
|
65
|
+
align-items: center;
|
|
66
|
+
gap: ${({ theme, hasTitle }) => (hasTitle ? 0 : theme.spacing['0_5'])};
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
export const IconContainer = styled.div<{ variant: AlertVariants }>`
|
|
70
|
+
display: flex;
|
|
71
|
+
align-items: center;
|
|
72
|
+
justify-content: center;
|
|
73
|
+
margin-right: ${({ theme }) => theme.spacing['1']};
|
|
74
|
+
svg {
|
|
75
|
+
fill: ${({ variant, theme }): string => theme.colors[variant]};
|
|
76
|
+
}
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
export const ButtonContainer = styled.div<{
|
|
80
|
+
show: boolean;
|
|
81
|
+
variant: AlertVariants;
|
|
82
|
+
hasTitle: boolean;
|
|
83
|
+
}>`
|
|
84
|
+
display: ${({ show }): string => (show ? 'flex' : 'none')};
|
|
85
|
+
align-items: center;
|
|
86
|
+
margin-top: ${({ theme, hasTitle }): string => (hasTitle ? theme.spacing['1'] : theme.spacing[0])};
|
|
87
|
+
`;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { ErrorFallback } from '.';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Feedback/ErrorFallback',
|
|
7
|
+
component: ErrorFallback,
|
|
8
|
+
} as Meta;
|
|
9
|
+
|
|
10
|
+
export const Default: StoryFn = () => <ErrorFallback />;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { styled } from '../../../styled';
|
|
3
|
+
import { shade } from 'polished';
|
|
4
|
+
|
|
5
|
+
const Wrapper = styled.div`
|
|
6
|
+
display: grid;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
align-items: center;
|
|
9
|
+
height: 100%;
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
const Container = styled.div`
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
max-width: 600px;
|
|
16
|
+
width: 100%;
|
|
17
|
+
align-items: center;
|
|
18
|
+
border: 1px solid ${({ theme }) => theme.colors.error};
|
|
19
|
+
border-radius: ${({ theme }) => theme.borderRadius.large};
|
|
20
|
+
padding: ${({ theme }) => theme.spacing[2]};
|
|
21
|
+
background-color: ${({ theme }) => shade(0.5, theme.colors.error)};
|
|
22
|
+
text-align: center;
|
|
23
|
+
|
|
24
|
+
h1 {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
font-size: ${({ theme }) => theme.fontSize.mediumLarge};
|
|
29
|
+
margin-bottom: ${({ theme }) => theme.spacing['0_5']};
|
|
30
|
+
|
|
31
|
+
svg {
|
|
32
|
+
margin-right: ${({ theme }) => theme.spacing['0_75']};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
// This should be used as a fallback component for error boundaries.
|
|
38
|
+
export const ErrorFallback: FC = () => {
|
|
39
|
+
return (
|
|
40
|
+
<Wrapper>
|
|
41
|
+
<Container>
|
|
42
|
+
<h1>Oops, that's our bad!</h1>
|
|
43
|
+
<p>We are not exactly sure what happened, but something went wrong. </p>
|
|
44
|
+
<p>If you need immediate help, please let us know.</p>
|
|
45
|
+
</Container>
|
|
46
|
+
</Wrapper>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { ErrorPage, ErrorPageProps } from '.';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Views/PageNotFound',
|
|
7
|
+
component: ErrorPage,
|
|
8
|
+
} as Meta;
|
|
9
|
+
|
|
10
|
+
export const PageNotFound: StoryFn<ErrorPageProps> = () => {
|
|
11
|
+
return (
|
|
12
|
+
<ErrorPage
|
|
13
|
+
errorCode={404}
|
|
14
|
+
title="Page not found"
|
|
15
|
+
description="The page you are looking for does not exist."
|
|
16
|
+
homeRoute="/"
|
|
17
|
+
/>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const NotAuthorized: StoryFn<ErrorPageProps> = () => {
|
|
22
|
+
return (
|
|
23
|
+
<ErrorPage
|
|
24
|
+
errorCode={401}
|
|
25
|
+
title="Not authorized"
|
|
26
|
+
description="You are not authorized to view this page.
|
|
27
|
+
Contact your administrator to request access."
|
|
28
|
+
homeRoute="/"
|
|
29
|
+
/>
|
|
30
|
+
);
|
|
31
|
+
};
|