@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,35 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Should render <Skeleton/> 1`] = `
|
|
4
|
+
.c0 {
|
|
5
|
+
width: 210px;
|
|
6
|
+
height: 20px;
|
|
7
|
+
margin: 10px 0;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
position: relative;
|
|
10
|
+
background-color: #f5f5f5;
|
|
11
|
+
border-radius: 1rem;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.c0::before {
|
|
15
|
+
content: '';
|
|
16
|
+
width: 100%;
|
|
17
|
+
position: absolute;
|
|
18
|
+
top: 0;
|
|
19
|
+
right: 0;
|
|
20
|
+
bottom: 0;
|
|
21
|
+
left: 0;
|
|
22
|
+
-webkit-transform: translateX(-100%);
|
|
23
|
+
-ms-transform: translateX(-100%);
|
|
24
|
+
transform: translateX(-100%);
|
|
25
|
+
background-image: linear-gradient( 90deg, #ffffffd3 0, #ffffff4d 20%, #ffffff66 60%, #ffffffd3 );
|
|
26
|
+
-webkit-animation: cTtZmo 2.5s infinite ease-in-out;
|
|
27
|
+
animation: cTtZmo 2.5s infinite ease-in-out;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
<div>
|
|
31
|
+
<div
|
|
32
|
+
class="c0"
|
|
33
|
+
/>
|
|
34
|
+
</div>
|
|
35
|
+
`;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { styled } from '../../../styled';
|
|
3
|
+
import { keyframes } from 'styled-components';
|
|
4
|
+
|
|
5
|
+
export interface SkeletonProps {
|
|
6
|
+
width?: string;
|
|
7
|
+
height?: string;
|
|
8
|
+
variant: Variants;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type Variants = 'text' | 'circular' | 'rectangular';
|
|
12
|
+
|
|
13
|
+
const skeletonLoading = keyframes`
|
|
14
|
+
0% { transform: translateX(-100%); }
|
|
15
|
+
40%, 100% { transform: translateX(100%); }
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
const StyledDiv = styled.div<{
|
|
19
|
+
variant: Variants;
|
|
20
|
+
s_height: string;
|
|
21
|
+
s_width: string;
|
|
22
|
+
}>`
|
|
23
|
+
width: ${({ s_width }) => s_width};
|
|
24
|
+
height: ${({ s_height }) => s_height};
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
position: relative;
|
|
27
|
+
|
|
28
|
+
background-color: ${({ theme }): string => theme.colors.placeholder};
|
|
29
|
+
&::before {
|
|
30
|
+
content: '';
|
|
31
|
+
width: 100%;
|
|
32
|
+
position: absolute;
|
|
33
|
+
top: 0;
|
|
34
|
+
right: 0;
|
|
35
|
+
bottom: 0;
|
|
36
|
+
left: 0;
|
|
37
|
+
transform: translateX(-100%);
|
|
38
|
+
background-image: linear-gradient(
|
|
39
|
+
90deg,
|
|
40
|
+
${({ theme }): string => theme.colors.placeholderHighlight}d3 0,
|
|
41
|
+
${({ theme }): string => theme.colors.placeholderHighlight}4d 20%,
|
|
42
|
+
${({ theme }): string => theme.colors.placeholderHighlight}66 60%,
|
|
43
|
+
${({ theme }): string => theme.colors.placeholderHighlight}d3
|
|
44
|
+
);
|
|
45
|
+
animation: ${skeletonLoading} 2.5s infinite ease-in-out;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
border-radius: ${({ variant }) => {
|
|
49
|
+
switch (variant) {
|
|
50
|
+
case 'rectangular':
|
|
51
|
+
return '1rem';
|
|
52
|
+
case 'text':
|
|
53
|
+
return '3px';
|
|
54
|
+
case 'circular':
|
|
55
|
+
return '50%';
|
|
56
|
+
}
|
|
57
|
+
}};
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
export const Skeleton: FC<SkeletonProps> = ({ width = '210px', height = '20px', variant }) => {
|
|
61
|
+
return <StyledDiv s_height={height} s_width={width} variant={variant} />;
|
|
62
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { Tooltip, TooltipProps } from '.';
|
|
4
|
+
import { Button, IconButton } from '../../actions';
|
|
5
|
+
import { AiOutlineWoman as Icon } from 'react-icons/ai';
|
|
6
|
+
|
|
7
|
+
interface ExtraTooltipStoryProps {
|
|
8
|
+
label: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'Feedback/Tooltip',
|
|
13
|
+
component: Tooltip,
|
|
14
|
+
args: {
|
|
15
|
+
placement: 'bottom',
|
|
16
|
+
label: 'this is the tooltip content',
|
|
17
|
+
},
|
|
18
|
+
} as Meta<TooltipProps & ExtraTooltipStoryProps>;
|
|
19
|
+
|
|
20
|
+
export const Default: StoryFn<TooltipProps & ExtraTooltipStoryProps> = (args) => (
|
|
21
|
+
<>
|
|
22
|
+
By default the tooltip is rendered in a div tag. This is because the tooltip component needs a ref to the trigger
|
|
23
|
+
element. If you want to render the tooltip in a different element, you can use the asChild prop.
|
|
24
|
+
<Tooltip placement={args.placement}>
|
|
25
|
+
<Tooltip.Trigger asChild>trigger</Tooltip.Trigger>
|
|
26
|
+
<Tooltip.Content>{args.label}</Tooltip.Content>
|
|
27
|
+
</Tooltip>
|
|
28
|
+
</>
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
export const UnControlled: StoryFn<TooltipProps & ExtraTooltipStoryProps> = (args) => (
|
|
32
|
+
<Tooltip placement={args.placement}>
|
|
33
|
+
<Tooltip.Trigger asChild>
|
|
34
|
+
<span>trigger</span>
|
|
35
|
+
</Tooltip.Trigger>
|
|
36
|
+
<Tooltip.Content>{args.label}</Tooltip.Content>
|
|
37
|
+
</Tooltip>
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
export const UnControlledCustomChild: StoryFn<TooltipProps & ExtraTooltipStoryProps> = (args) => (
|
|
41
|
+
<>
|
|
42
|
+
By default the component is rendered in a div tag. because the component is expected to have a ref. So if the
|
|
43
|
+
component you want to render as the trigger does not have a ref, you can NOT set the asChild prop. By setting the
|
|
44
|
+
asChild prop, the component will be rendered as the trigger component.
|
|
45
|
+
<Tooltip>
|
|
46
|
+
<Tooltip.Trigger asChild>
|
|
47
|
+
<IconButton icon={<Icon />} ariaLabel="aria label here" />
|
|
48
|
+
</Tooltip.Trigger>
|
|
49
|
+
<Tooltip.Content>{args.label}</Tooltip.Content>
|
|
50
|
+
</Tooltip>
|
|
51
|
+
</>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
export const Controlled: StoryFn<TooltipProps & ExtraTooltipStoryProps> = () => {
|
|
55
|
+
const [open, setOpen] = useState<boolean>(false);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<>
|
|
59
|
+
A controlled open means that the child component is responsible for opening and closing the tooltip. Which is e.g.
|
|
60
|
+
useful when you want to open the tooltip on click instead of hover. or when you want to open a tooltip on a
|
|
61
|
+
different component than the trigger.
|
|
62
|
+
<Tooltip open={open} onOpenChange={setOpen}>
|
|
63
|
+
<Tooltip.Trigger asChild>I am the trigger</Tooltip.Trigger>
|
|
64
|
+
<Tooltip.Content>controlled tooltip</Tooltip.Content>
|
|
65
|
+
</Tooltip>
|
|
66
|
+
<Button onClick={() => setOpen(true)} text="open tooltip on, I am the trigger" />
|
|
67
|
+
</>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { forwardRef, HTMLProps } from 'react';
|
|
2
|
+
import { useMergeRefs, FloatingPortal, FloatingArrow } from '@floating-ui/react';
|
|
3
|
+
import { useTooltipContext } from './TooltipContext';
|
|
4
|
+
import { Elevation, styled } from '../../../styled';
|
|
5
|
+
import { useTheme } from '../../../hooks';
|
|
6
|
+
|
|
7
|
+
const Container = styled.div<{ elevation: Elevation }>`
|
|
8
|
+
background: ${({ theme }) => theme.colors.background};
|
|
9
|
+
color: ${({ theme }) => theme.colors.text};
|
|
10
|
+
box-shadow: ${({ theme, elevation }) => theme.elevation[elevation]};
|
|
11
|
+
pointer-events: none;
|
|
12
|
+
border-radius: ${({ theme }) => theme.borderRadius.medium};
|
|
13
|
+
border: 1px solid ${({ theme }) => theme.colors.backgroundAlt};
|
|
14
|
+
padding: ${({ theme }) => `${theme.spacing['0_5']} ${theme.spacing['0_75']}`};
|
|
15
|
+
font-size: 1.4rem;
|
|
16
|
+
width: max-content;
|
|
17
|
+
z-index: ${({ theme }) => theme.zIndex.tooltip};
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
export const TooltipContent = forwardRef<HTMLDivElement, HTMLProps<HTMLDivElement>>(({ style, ...props }, propRef) => {
|
|
21
|
+
const theme = useTheme();
|
|
22
|
+
const { floatingStyles, open, arrowRef, context, getFloatingProps } = useTooltipContext();
|
|
23
|
+
const ref = useMergeRefs([context.refs.setFloating, propRef]);
|
|
24
|
+
|
|
25
|
+
if (!open) return null;
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<FloatingPortal>
|
|
29
|
+
<Container
|
|
30
|
+
elevation={1}
|
|
31
|
+
ref={ref}
|
|
32
|
+
style={{
|
|
33
|
+
...floatingStyles,
|
|
34
|
+
...style,
|
|
35
|
+
border: `1px solid ${theme.colors.backgroundAccent}`,
|
|
36
|
+
}}
|
|
37
|
+
{...getFloatingProps(props)}
|
|
38
|
+
>
|
|
39
|
+
{props.children}
|
|
40
|
+
<FloatingArrow
|
|
41
|
+
ref={arrowRef}
|
|
42
|
+
context={context}
|
|
43
|
+
fill={theme.colors.background}
|
|
44
|
+
stroke={theme.colors.backgroundAccent}
|
|
45
|
+
strokeWidth={1}
|
|
46
|
+
/>
|
|
47
|
+
</Container>
|
|
48
|
+
</FloatingPortal>
|
|
49
|
+
);
|
|
50
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
import { useTooltip } from './useTooltip';
|
|
3
|
+
|
|
4
|
+
type ContextType = ReturnType<typeof useTooltip> | null;
|
|
5
|
+
export const TooltipContext = createContext<ContextType>(null);
|
|
6
|
+
|
|
7
|
+
export const useTooltipContext = () => {
|
|
8
|
+
const context = useContext(TooltipContext);
|
|
9
|
+
if (context == null) {
|
|
10
|
+
throw new Error('Tooltip components must be wrapped in <Tooltip />');
|
|
11
|
+
}
|
|
12
|
+
return context;
|
|
13
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { HTMLProps, forwardRef, isValidElement, cloneElement } from 'react';
|
|
2
|
+
import { useTooltipContext } from './TooltipContext';
|
|
3
|
+
import { useMergeRefs } from '@floating-ui/react';
|
|
4
|
+
import { styled } from '../../../styled';
|
|
5
|
+
|
|
6
|
+
const Container = styled.div<{ isOpen: boolean }>`
|
|
7
|
+
width: fit-content;
|
|
8
|
+
`;
|
|
9
|
+
|
|
10
|
+
interface TooltipTriggerProps {
|
|
11
|
+
asChild?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const TooltipTrigger = forwardRef<HTMLElement, HTMLProps<HTMLElement> & TooltipTriggerProps>(
|
|
15
|
+
({ children, asChild = false, ...props }, propRef) => {
|
|
16
|
+
const context = useTooltipContext();
|
|
17
|
+
const childrenRef = (children as any).ref;
|
|
18
|
+
const ref = useMergeRefs([context.refs.setReference, propRef, childrenRef]);
|
|
19
|
+
|
|
20
|
+
// `asChild` allows the user to pass any element as the anchor
|
|
21
|
+
if (asChild && isValidElement(children)) {
|
|
22
|
+
return cloneElement(
|
|
23
|
+
children,
|
|
24
|
+
context.getReferenceProps({
|
|
25
|
+
...props,
|
|
26
|
+
...children.props,
|
|
27
|
+
ref,
|
|
28
|
+
'data-state': context.open ? 'open' : 'closed',
|
|
29
|
+
})
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Container ref={ref} isOpen={context.open} {...context.getReferenceProps(props)}>
|
|
35
|
+
{children}
|
|
36
|
+
</Container>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { TooltipOptions, useTooltip } from './useTooltip';
|
|
3
|
+
import { TooltipContext } from './TooltipContext';
|
|
4
|
+
import { TooltipTrigger } from './TooltipTrigger';
|
|
5
|
+
import { TooltipContent } from './TooltipContent';
|
|
6
|
+
|
|
7
|
+
/*
|
|
8
|
+
* tooltip is the wrapper component that provides the context
|
|
9
|
+
* trigger is the component that triggers the tooltip to open (the thing you hover over)
|
|
10
|
+
* content is the component that is rendered inside the tooltip
|
|
11
|
+
*/
|
|
12
|
+
interface SubComponentTypes {
|
|
13
|
+
Trigger: typeof TooltipTrigger;
|
|
14
|
+
Content: typeof TooltipContent;
|
|
15
|
+
}
|
|
16
|
+
export type TooltipProps = PropsWithChildren<TooltipOptions>;
|
|
17
|
+
|
|
18
|
+
export const Tooltip: FC<TooltipProps> & SubComponentTypes = ({ children, ...options }) => {
|
|
19
|
+
// This can accept any props as options, e.g. `placement`,
|
|
20
|
+
// or other positioning options.
|
|
21
|
+
const tooltip = useTooltip(options);
|
|
22
|
+
return <TooltipContext.Provider value={tooltip}>{children}</TooltipContext.Provider>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
Tooltip.Trigger = TooltipTrigger;
|
|
26
|
+
Tooltip.Content = TooltipContent;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { useState, useMemo, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
useFloating,
|
|
5
|
+
autoUpdate,
|
|
6
|
+
offset,
|
|
7
|
+
flip,
|
|
8
|
+
shift,
|
|
9
|
+
useHover,
|
|
10
|
+
useFocus,
|
|
11
|
+
useDismiss,
|
|
12
|
+
useRole,
|
|
13
|
+
useInteractions,
|
|
14
|
+
Placement,
|
|
15
|
+
arrow,
|
|
16
|
+
} from '@floating-ui/react';
|
|
17
|
+
|
|
18
|
+
export interface TooltipOptions {
|
|
19
|
+
initialOpen?: boolean;
|
|
20
|
+
placement?: Placement;
|
|
21
|
+
open?: boolean;
|
|
22
|
+
onOpenChange?: (open: boolean) => void;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function useTooltip({
|
|
26
|
+
initialOpen = false,
|
|
27
|
+
placement = 'top',
|
|
28
|
+
open: controlledOpen,
|
|
29
|
+
onOpenChange: setControlledOpen,
|
|
30
|
+
}: TooltipOptions = {}) {
|
|
31
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(initialOpen);
|
|
32
|
+
|
|
33
|
+
const open = controlledOpen ?? uncontrolledOpen;
|
|
34
|
+
const setOpen = setControlledOpen ?? setUncontrolledOpen;
|
|
35
|
+
|
|
36
|
+
const arrowRef = useRef(null);
|
|
37
|
+
|
|
38
|
+
const ARROW_HEIGHT = 7;
|
|
39
|
+
const GAP = 2;
|
|
40
|
+
|
|
41
|
+
const data = useFloating({
|
|
42
|
+
placement,
|
|
43
|
+
open,
|
|
44
|
+
onOpenChange: setOpen,
|
|
45
|
+
whileElementsMounted: autoUpdate,
|
|
46
|
+
middleware: [
|
|
47
|
+
offset(ARROW_HEIGHT + GAP),
|
|
48
|
+
flip({
|
|
49
|
+
crossAxis: placement.includes('-'),
|
|
50
|
+
fallbackAxisSideDirection: 'start',
|
|
51
|
+
padding: 5,
|
|
52
|
+
}),
|
|
53
|
+
shift({ padding: 5 }),
|
|
54
|
+
arrow({
|
|
55
|
+
element: arrowRef,
|
|
56
|
+
}),
|
|
57
|
+
],
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
const context = data.context;
|
|
61
|
+
|
|
62
|
+
const interactions = useInteractions([
|
|
63
|
+
useHover(context, { move: false, enabled: controlledOpen == null }),
|
|
64
|
+
useFocus(context, { enabled: controlledOpen == null }),
|
|
65
|
+
useDismiss(context),
|
|
66
|
+
useRole(context, { role: 'tooltip' }),
|
|
67
|
+
]);
|
|
68
|
+
|
|
69
|
+
return useMemo(
|
|
70
|
+
() => ({
|
|
71
|
+
open,
|
|
72
|
+
setOpen,
|
|
73
|
+
arrowRef,
|
|
74
|
+
...interactions,
|
|
75
|
+
...data,
|
|
76
|
+
}),
|
|
77
|
+
[open, setOpen, interactions, data]
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export { Alert } from './Alert';
|
|
2
|
+
export type { AlertProps } from './Alert';
|
|
3
|
+
|
|
4
|
+
export { Skeleton } from './Skeleton';
|
|
5
|
+
export type { SkeletonProps } from './Skeleton';
|
|
6
|
+
|
|
7
|
+
export { Loading, Spinner } from './Loaders';
|
|
8
|
+
export type { SpinnerProps } from './Loaders/Spinner';
|
|
9
|
+
export type { LoadingProps } from './Loaders/Loading';
|
|
10
|
+
|
|
11
|
+
export { NetworkDetector } from './NetworkDetector';
|
|
12
|
+
|
|
13
|
+
export { NotificationBanner } from './NotificationBanner';
|
|
14
|
+
export type { NotificationBannerProps } from './NotificationBanner';
|
|
15
|
+
|
|
16
|
+
export { ErrorFallback } from './ErrorFallback';
|
|
17
|
+
|
|
18
|
+
export { ProgressBar } from './ProgressBar';
|
|
19
|
+
export type { ProgressBarProps } from './ProgressBar';
|
|
20
|
+
|
|
21
|
+
export { Tooltip } from './Tooltip';
|
|
22
|
+
export type { TooltipProps } from './Tooltip';
|
|
23
|
+
|
|
24
|
+
export { QuestionTooltip } from './QuestionTooltip';
|
|
25
|
+
|
|
26
|
+
export { Popover } from './Popover';
|
|
27
|
+
export type { PopoverProps } from './Popover';
|
|
28
|
+
|
|
29
|
+
export { ErrorPage } from './ErrorPage';
|
|
30
|
+
export type { ErrorPageProps } from './ErrorPage';
|
|
31
|
+
|
|
32
|
+
export { FormError } from './FormError';
|
|
33
|
+
export type { FormErrorProps } from './FormError';
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { FC, forwardRef, useState, useMemo } from 'react';
|
|
2
|
+
import { CustomContentProps, useSnackbar } from 'notistack';
|
|
3
|
+
import {
|
|
4
|
+
Container,
|
|
5
|
+
ButtonContainer,
|
|
6
|
+
CookieTypeContainer,
|
|
7
|
+
NecessaryCookieContainer,
|
|
8
|
+
Wrapper,
|
|
9
|
+
ActionContainer,
|
|
10
|
+
} from './style';
|
|
11
|
+
import { Button, Switch } from '../../..';
|
|
12
|
+
import { Control, SubmitHandler, useForm, useWatch } from 'react-hook-form';
|
|
13
|
+
import { AiOutlineDown as Arrow } from 'react-icons/ai';
|
|
14
|
+
import { FaCookieBite as CookieBite } from 'react-icons/fa';
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
import { zodResolver } from '@hookform/resolvers/zod';
|
|
17
|
+
|
|
18
|
+
type FormInputs = {
|
|
19
|
+
functional: boolean;
|
|
20
|
+
analytical: boolean;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const CookieConsentSnack = forwardRef<HTMLDivElement, CustomContentProps>(({ id }, ref) => {
|
|
24
|
+
const { closeSnackbar } = useSnackbar();
|
|
25
|
+
const [showDetails, setShowDetails] = useState<boolean>(false);
|
|
26
|
+
|
|
27
|
+
const validationSchema = useMemo(
|
|
28
|
+
() =>
|
|
29
|
+
z.object({
|
|
30
|
+
functional: z.boolean(),
|
|
31
|
+
analytical: z.boolean(),
|
|
32
|
+
}),
|
|
33
|
+
[]
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
const onSubmit: SubmitHandler<FormInputs> = async () => {
|
|
37
|
+
// TODO: send data to backend
|
|
38
|
+
//const response = await fetch('', { method: 'POST', body: JSON.stringify({ analytical, functional }) });
|
|
39
|
+
closeSnackbar(id);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
const { control, handleSubmit } = useForm<FormInputs>({
|
|
43
|
+
mode: 'onSubmit',
|
|
44
|
+
resolver: zodResolver(validationSchema),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
const functionalValue = useWatch({ control, name: 'functional' });
|
|
48
|
+
const analyticalValue = useWatch({ control, name: 'analytical' });
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<Wrapper ref={ref}>
|
|
52
|
+
<h2>
|
|
53
|
+
Cookies <CookieBite size={24} />
|
|
54
|
+
</h2>
|
|
55
|
+
<p>
|
|
56
|
+
I know, I know, its annoying. But we need to get through this! We only use cookies to guarantee you the best
|
|
57
|
+
experience on our website.
|
|
58
|
+
</p>
|
|
59
|
+
|
|
60
|
+
<ActionContainer
|
|
61
|
+
active={showDetails}
|
|
62
|
+
onClick={() => {
|
|
63
|
+
setShowDetails(!showDetails);
|
|
64
|
+
}}
|
|
65
|
+
>
|
|
66
|
+
customize <Arrow size={18} />
|
|
67
|
+
</ActionContainer>
|
|
68
|
+
<NecessaryCookieContainer>
|
|
69
|
+
<p>Strictly necessary cookies</p>
|
|
70
|
+
<p>Always on</p>
|
|
71
|
+
</NecessaryCookieContainer>
|
|
72
|
+
<Container isVisible={showDetails}>
|
|
73
|
+
<form id="cookie-consent" onSubmit={handleSubmit(onSubmit)}>
|
|
74
|
+
<CookieType
|
|
75
|
+
control={control}
|
|
76
|
+
description="We will remember the basics such as language."
|
|
77
|
+
cookieType="functional"
|
|
78
|
+
value={functionalValue}
|
|
79
|
+
/>
|
|
80
|
+
<CookieType
|
|
81
|
+
control={control}
|
|
82
|
+
description="We will know where we should improve your experience."
|
|
83
|
+
cookieType="analytical"
|
|
84
|
+
value={analyticalValue}
|
|
85
|
+
/>
|
|
86
|
+
</form>
|
|
87
|
+
</Container>
|
|
88
|
+
<div>
|
|
89
|
+
{' '}
|
|
90
|
+
Read the{' '}
|
|
91
|
+
<strong>
|
|
92
|
+
<a className="underline" href="https://takaro.io/cookie-policy" rel="noopener noreferrer" target="_blank">
|
|
93
|
+
cookie policy.
|
|
94
|
+
</a>
|
|
95
|
+
</strong>
|
|
96
|
+
</div>
|
|
97
|
+
<ButtonContainer>
|
|
98
|
+
<Button text="Decline" />
|
|
99
|
+
<Button text="Accept" type="submit" />
|
|
100
|
+
</ButtonContainer>
|
|
101
|
+
</Wrapper>
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
interface CookieTypeProps {
|
|
106
|
+
cookieType: string;
|
|
107
|
+
description: string;
|
|
108
|
+
control: Control<FormInputs>;
|
|
109
|
+
value: boolean;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const CookieType: FC<CookieTypeProps> = ({ cookieType, description, control, value }) => {
|
|
113
|
+
return (
|
|
114
|
+
<CookieTypeContainer active={value}>
|
|
115
|
+
<div>
|
|
116
|
+
<h4>{cookieType} cookies</h4>
|
|
117
|
+
<p>{description}</p>
|
|
118
|
+
</div>
|
|
119
|
+
<Switch control={control} name={cookieType} />
|
|
120
|
+
</CookieTypeContainer>
|
|
121
|
+
);
|
|
122
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { styled } from '../../../../styled';
|
|
2
|
+
import { lighten } from 'polished';
|
|
3
|
+
|
|
4
|
+
export const Wrapper = styled.div`
|
|
5
|
+
border: 0.1rem solid ${({ theme }) => theme.colors.primary};
|
|
6
|
+
padding: ${({ theme }) => theme.spacing['1_5']};
|
|
7
|
+
max-width: 450px;
|
|
8
|
+
border-radius: ${({ theme }) => theme.borderRadius.large};
|
|
9
|
+
box-shadow: ${({ theme }) => theme.elevation[4]};
|
|
10
|
+
|
|
11
|
+
& > p {
|
|
12
|
+
margin-top: ${({ theme }) => theme.spacing[1]};
|
|
13
|
+
margin-bottom: ${({ theme }) => theme.spacing[1]};
|
|
14
|
+
font-size: 110%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
a {
|
|
18
|
+
text-decoration: underline;
|
|
19
|
+
color: ${({ theme }) => theme.colors.primary};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
strong {
|
|
23
|
+
font-weight: 600;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
h2 {
|
|
27
|
+
display: flex;
|
|
28
|
+
justify-content: space-between;
|
|
29
|
+
align-items: center;
|
|
30
|
+
|
|
31
|
+
svg {
|
|
32
|
+
fill: ${({ theme }) => theme.colors.secondary};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
export const Container = styled.div<{ isVisible: boolean }>`
|
|
38
|
+
overflow: ${({ isVisible }): string => (isVisible ? 'visible' : 'hidden')};
|
|
39
|
+
height: ${({ isVisible }) => (isVisible ? 'auto' : '0')};
|
|
40
|
+
/* todo fix height change animation */
|
|
41
|
+
transition: height 0.2s ease-in-out;
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
export const ButtonContainer = styled.div`
|
|
45
|
+
display: flex;
|
|
46
|
+
flex-direction: row;
|
|
47
|
+
align-items: center;
|
|
48
|
+
margin-top: ${({ theme }) => theme.spacing[2]};
|
|
49
|
+
|
|
50
|
+
button:last-child {
|
|
51
|
+
margin-left: ${({ theme }) => theme.spacing[1]};
|
|
52
|
+
}
|
|
53
|
+
`;
|
|
54
|
+
|
|
55
|
+
export const ActionContainer = styled.div<{ active: boolean }>`
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
margin-bottom: ${({ theme }) => theme.spacing[1]};
|
|
60
|
+
font-weight: 600;
|
|
61
|
+
|
|
62
|
+
svg {
|
|
63
|
+
margin-left: ${({ theme }) => theme.spacing['0_5']};
|
|
64
|
+
${({ active }): string => (active ? 'transform: rotate(180deg)' : '')};
|
|
65
|
+
transition: transform 0.2s ease-in-out;
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
68
|
+
|
|
69
|
+
export const CookieTypeContainer = styled.div<{ active: boolean }>`
|
|
70
|
+
border: 0.1rem solid ${({ theme }) => theme.colors.primary};
|
|
71
|
+
margin: ${({ theme }) => `${theme.spacing[1]} 0`};
|
|
72
|
+
padding: ${({ theme }) => `${theme.spacing[1]} ${theme.spacing[2]} ${theme.spacing[1]} ${theme.spacing[1]}`};
|
|
73
|
+
border-radius: ${({ theme }) => theme.borderRadius.large};
|
|
74
|
+
display: flex;
|
|
75
|
+
flex-direction: row;
|
|
76
|
+
align-items: center;
|
|
77
|
+
justify-content: space-between;
|
|
78
|
+
will-change: background-color;
|
|
79
|
+
|
|
80
|
+
h4 {
|
|
81
|
+
font-weight: 600;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
div:first-child {
|
|
85
|
+
margin-left: ${({ theme }) => theme.spacing[1]};
|
|
86
|
+
}
|
|
87
|
+
`;
|
|
88
|
+
export const NecessaryCookieContainer = styled.div`
|
|
89
|
+
display: flex;
|
|
90
|
+
align-items: center;
|
|
91
|
+
justify-content: space-between;
|
|
92
|
+
border-radius: ${({ theme }) => theme.borderRadius.large};
|
|
93
|
+
padding: ${({ theme }) => `${theme.spacing['1_5']} ${theme.spacing[2]}`};
|
|
94
|
+
margin-bottom: ${({ theme }) => theme.spacing[1]};
|
|
95
|
+
background-color: ${({ theme }) => lighten(0, theme.colors.primary)};
|
|
96
|
+
|
|
97
|
+
p {
|
|
98
|
+
color: white;
|
|
99
|
+
}
|
|
100
|
+
`;
|