@takaro/lib-components 0.0.0-next.0da151e
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 +15 -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 +149 -0
- package/src/components/actions/Button/Button.test.tsx +8 -0
- package/src/components/actions/Button/Button.test.tsx.snap +89 -0
- package/src/components/actions/Button/__snapshots__/Button.test.tsx.snap +18 -0
- package/src/components/actions/Button/index.tsx +89 -0
- package/src/components/actions/Button/style.ts +142 -0
- package/src/components/actions/ContextMenu/ContextMenu.stories.tsx +41 -0
- package/src/components/actions/ContextMenu/Group.tsx +34 -0
- package/src/components/actions/ContextMenu/MenuItem.tsx +69 -0
- package/src/components/actions/ContextMenu/index.tsx +216 -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 +70 -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 +87 -0
- package/src/components/actions/Dropdown/index.tsx +22 -0
- package/src/components/actions/Dropdown/useDropdown.tsx +89 -0
- package/src/components/actions/DropdownButton/DropdownButton.stories.tsx +88 -0
- package/src/components/actions/DropdownButton/index.tsx +128 -0
- package/src/components/actions/IconButton/IconButton.stories.tsx +54 -0
- package/src/components/actions/IconButton/IconButton.test.tsx +8 -0
- package/src/components/actions/IconButton/IconButton.test.tsx.snap +46 -0
- package/src/components/actions/IconButton/__snapshots__/IconButton.test.tsx.snap +18 -0
- package/src/components/actions/IconButton/getIconSize.ts +16 -0
- package/src/components/actions/IconButton/index.tsx +28 -0
- package/src/components/actions/IconButton/style.ts +51 -0
- package/src/components/actions/ToggleButton/ToggleButton.stories.tsx +85 -0
- package/src/components/actions/ToggleButton/ToggleButton.tsx +48 -0
- package/src/components/actions/ToggleButton/ToggleButtonGroup.tsx +107 -0
- package/src/components/actions/ToggleButton/index.tsx +2 -0
- package/src/components/actions/ToggleButton/style.ts +75 -0
- package/src/components/actions/index.ts +16 -0
- package/src/components/charts/AreaChart/AreaChart.stories.tsx +103 -0
- package/src/components/charts/AreaChart/index.tsx +428 -0
- package/src/components/charts/BarChart/BarChart.stories.tsx +55 -0
- package/src/components/charts/BarChart/index.tsx +420 -0
- package/src/components/charts/BrushHandle.tsx +21 -0
- package/src/components/charts/EmptyChart.tsx +45 -0
- package/src/components/charts/GeoMercator/GeoMercator.stories.tsx +77 -0
- package/src/components/charts/GeoMercator/index.tsx +228 -0
- package/src/components/charts/GeoMercator/iso3166-alpha2-to-alpha3.ts +250 -0
- package/src/components/charts/GeoMercator/world.d.ts +1 -0
- package/src/components/charts/GeoMercator/world.json +99818 -0
- package/src/components/charts/Heatmap/Heatmap.stories.tsx +189 -0
- package/src/components/charts/Heatmap/index.tsx +461 -0
- package/src/components/charts/LineChart/LineChart.stories.tsx +111 -0
- package/src/components/charts/LineChart/index.tsx +353 -0
- package/src/components/charts/PieChart/PieChart.stories.tsx +151 -0
- package/src/components/charts/PieChart/index.tsx +457 -0
- package/src/components/charts/PointHighlight.tsx +49 -0
- package/src/components/charts/RadarChart/RadarChart.stories.tsx +47 -0
- package/src/components/charts/RadarChart/generators.ts +30 -0
- package/src/components/charts/RadarChart/index.tsx +224 -0
- package/src/components/charts/RadialBarChart/RadialBarChart.stories.tsx +59 -0
- package/src/components/charts/RadialBarChart/index.tsx +231 -0
- package/src/components/charts/RadialLineChart/RadialLineChart.stories.tsx +43 -0
- package/src/components/charts/RadialLineChart/index.tsx +231 -0
- package/src/components/charts/ZoomControls.tsx +49 -0
- package/src/components/charts/index.tsx +26 -0
- package/src/components/charts/useGradients.tsx +37 -0
- package/src/components/charts/util.ts +78 -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 +136 -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 +8 -0
- package/src/components/data/Chip/Chip.test.tsx.snap +50 -0
- package/src/components/data/Chip/__snapshots__/Chip.test.tsx.snap +38 -0
- package/src/components/data/Chip/index.tsx +67 -0
- package/src/components/data/Chip/style.ts +49 -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/constants.ts +6 -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 +107 -0
- package/src/components/data/CountryList/index.tsx +146 -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 +155 -0
- package/src/components/data/Drawer/DrawerBody.tsx +22 -0
- package/src/components/data/Drawer/DrawerContent.tsx +169 -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 +50 -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 +66 -0
- package/src/components/data/InfiniteScroll/InfiniteScroll.stories.tsx +33 -0
- package/src/components/data/InfiniteScroll/index.tsx +54 -0
- package/src/components/data/Stats/Sparkline.tsx +48 -0
- package/src/components/data/Stats/Stat.tsx +192 -0
- package/src/components/data/Stats/Stats.stories.tsx +196 -0
- package/src/components/data/Stats/context.tsx +18 -0
- package/src/components/data/Stats/index.tsx +62 -0
- package/src/components/data/Table/Table.stories.tsx +146 -0
- package/src/components/data/Table/index.tsx +492 -0
- package/src/components/data/Table/react-table.d.ts +14 -0
- package/src/components/data/Table/style.ts +97 -0
- package/src/components/data/Table/subcomponents/ColumnHeader/ColumnSettings.tsx +164 -0
- package/src/components/data/Table/subcomponents/ColumnHeader/index.tsx +207 -0
- package/src/components/data/Table/subcomponents/ColumnHeader/style.ts +90 -0
- package/src/components/data/Table/subcomponents/ColumnVisibility/index.tsx +70 -0
- package/src/components/data/Table/subcomponents/Filter/field.tsx +127 -0
- package/src/components/data/Table/subcomponents/Filter/index.tsx +228 -0
- package/src/components/data/Table/subcomponents/Filter/style.ts +26 -0
- package/src/components/data/Table/subcomponents/Filter/types.ts +10 -0
- package/src/components/data/Table/subcomponents/Pagination/PagePicker.tsx +109 -0
- package/src/components/data/Table/subcomponents/Pagination/PageSizeSelect.tsx +37 -0
- package/src/components/data/Table/subcomponents/Pagination/style.ts +49 -0
- package/src/components/data/index.ts +28 -0
- package/src/components/dialogs/Dialog/Dialog.stories.tsx +77 -0
- package/src/components/dialogs/Dialog/DialogBody.tsx +64 -0
- package/src/components/dialogs/Dialog/DialogContent.tsx +44 -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 +75 -0
- package/src/components/feedback/Alert/Alert.test.tsx +8 -0
- package/src/components/feedback/Alert/Alert.test.tsx.snap +146 -0
- package/src/components/feedback/Alert/__snapshots__/Alert.test.tsx.snap +44 -0
- package/src/components/feedback/Alert/index.tsx +120 -0
- package/src/components/feedback/Alert/style.ts +97 -0
- package/src/components/feedback/Badge/Badge.stories.tsx +23 -0
- package/src/components/feedback/Badge/index.tsx +47 -0
- package/src/components/feedback/ErrorFallback/ErrorFallback.stories.tsx +10 -0
- package/src/components/feedback/ErrorFallback/index.tsx +49 -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/IconTooltip/IconTooltip.stories.tsx +22 -0
- package/src/components/feedback/IconTooltip/index.tsx +51 -0
- package/src/components/feedback/Loaders/Loaders.stories.tsx +28 -0
- package/src/components/feedback/Loaders/Loading.test.tsx +8 -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 +8 -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/__snapshots__/Loading.test.tsx.snap +141 -0
- package/src/components/feedback/Loaders/__snapshots__/Spinner.test.tsx.snap +10 -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 +8 -0
- package/src/components/feedback/NetworkDetector/NetworkDetector.test.tsx.snap +3 -0
- package/src/components/feedback/NetworkDetector/__snapshots__/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 +15 -0
- package/src/components/feedback/NotificationBanner/NotificationBanner.test.tsx.snap +3 -0
- package/src/components/feedback/NotificationBanner/__snapshots__/NotificationBanner.test.tsx.snap +3 -0
- package/src/components/feedback/NotificationBanner/index.tsx +78 -0
- package/src/components/feedback/Popover/Popover.stories.tsx +33 -0
- package/src/components/feedback/Popover/PopoverContent.tsx +46 -0
- package/src/components/feedback/Popover/PopoverContext.tsx +21 -0
- package/src/components/feedback/Popover/PopoverTrigger.tsx +45 -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 +137 -0
- package/src/components/feedback/Skeleton/Skeleton.stories.tsx +33 -0
- package/src/components/feedback/Skeleton/Skeleton.test.tsx +8 -0
- package/src/components/feedback/Skeleton/Skeleton.test.tsx.snap +35 -0
- package/src/components/feedback/Skeleton/__snapshots__/Skeleton.test.tsx.snap +9 -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 +51 -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 +82 -0
- package/src/components/feedback/index.ts +37 -0
- package/src/components/feedback/snacks/CookieConsent/index.tsx +125 -0
- package/src/components/feedback/snacks/CookieConsent/style.ts +99 -0
- package/src/components/feedback/snacks/Default/default.stories.tsx +73 -0
- package/src/components/feedback/snacks/Default/index.tsx +78 -0
- package/src/components/feedback/snacks/Default/style.ts +58 -0
- package/src/components/feedback/snacks/Drawer/Drawer.stories.tsx +46 -0
- package/src/components/feedback/snacks/Drawer/index.tsx +85 -0
- package/src/components/feedback/snacks/NetworkDetector/index.tsx +73 -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 +123 -0
- package/src/components/inputs/CheckBox/Generic.tsx +42 -0
- package/src/components/inputs/CheckBox/index.tsx +4 -0
- package/src/components/inputs/CheckBox/style.ts +56 -0
- package/src/components/inputs/CodeField/CodeField.stories.tsx +86 -0
- package/src/components/inputs/CodeField/index.tsx +174 -0
- package/src/components/inputs/CodeField/style.ts +50 -0
- package/src/components/inputs/Date/DatePicker/Controlled.tsx +103 -0
- package/src/components/inputs/Date/DatePicker/DatePicker.stories.tsx +267 -0
- package/src/components/inputs/Date/DatePicker/Generic.tsx +283 -0
- package/src/components/inputs/Date/DatePicker/formats.tsx +32 -0
- package/src/components/inputs/Date/DatePicker/style.ts +41 -0
- package/src/components/inputs/Date/DateRangePicker/Context.tsx +123 -0
- package/src/components/inputs/Date/DateRangePicker/Controlled.tsx +74 -0
- package/src/components/inputs/Date/DateRangePicker/DateRangePicker.stories.tsx +37 -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/Generic.tsx +167 -0
- package/src/components/inputs/Date/DateRangePicker/QuickSelect/index.tsx +254 -0
- package/src/components/inputs/Date/DateRangePicker/QuickSelect/style.ts +40 -0
- package/src/components/inputs/Date/DateRangePicker/style.ts +65 -0
- package/src/components/inputs/Date/subcomponents/Calendar/index.tsx +150 -0
- package/src/components/inputs/Date/subcomponents/Calendar/style.ts +61 -0
- package/src/components/inputs/Date/subcomponents/RelativePicker/index.tsx +170 -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 +34 -0
- package/src/components/inputs/Date/types.ts +14 -0
- package/src/components/inputs/DurationField/Controlled.tsx +69 -0
- package/src/components/inputs/DurationField/Duration.stories.tsx +57 -0
- package/src/components/inputs/DurationField/Generic.tsx +197 -0
- package/src/components/inputs/DurationField/__tests__/Generic.test.tsx +12 -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 +210 -0
- package/src/components/inputs/FileField/Generic.tsx +133 -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 +59 -0
- package/src/components/inputs/RadioGroup/Controlled.tsx +45 -0
- package/src/components/inputs/RadioGroup/Generic.tsx +34 -0
- package/src/components/inputs/RadioGroup/RadioGroup.stories.tsx +118 -0
- package/src/components/inputs/RadioGroup/RadioItem.tsx +130 -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/Switch/Controlled.tsx +57 -0
- package/src/components/inputs/Switch/Generic.tsx +40 -0
- package/src/components/inputs/Switch/Switch.stories.tsx +89 -0
- package/src/components/inputs/Switch/index.ts +5 -0
- package/src/components/inputs/Switch/style.ts +62 -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 +58 -0
- package/src/components/inputs/TextAreaField/TextAreaField.stories.tsx +99 -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 +138 -0
- package/src/components/inputs/TextField/TextField.stories.tsx +217 -0
- package/src/components/inputs/TextField/index.ts +5 -0
- package/src/components/inputs/TextField/style.ts +103 -0
- package/src/components/inputs/TextField/util.ts +24 -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 +72 -0
- package/src/components/inputs/layout/Description.tsx +33 -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 +50 -0
- package/src/components/inputs/layout/index.ts +8 -0
- package/src/components/inputs/layout/setAriaDescribedBy.ts +3 -0
- package/src/components/inputs/selects/SelectField/Controlled.tsx +127 -0
- package/src/components/inputs/selects/SelectField/Generic/FilterInput.tsx +48 -0
- package/src/components/inputs/selects/SelectField/Generic/index.tsx +299 -0
- package/src/components/inputs/selects/SelectField/SelectField.stories.tsx +252 -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 +110 -0
- package/src/components/inputs/selects/SelectQueryField/Generic/index.tsx +401 -0
- package/src/components/inputs/selects/SelectQueryField/SelectQueryField.stories.tsx +280 -0
- package/src/components/inputs/selects/SelectQueryField/index.tsx +5 -0
- package/src/components/inputs/selects/SelectQueryField/style.ts +13 -0
- package/src/components/inputs/selects/SubComponents/Option.tsx +114 -0
- package/src/components/inputs/selects/SubComponents/OptionGroup.tsx +18 -0
- package/src/components/inputs/selects/SubComponents/index.ts +10 -0
- package/src/components/inputs/selects/SubComponents/style.ts +51 -0
- package/src/components/inputs/selects/data.ts +123 -0
- package/src/components/inputs/selects/index.tsx +49 -0
- package/src/components/inputs/selects/sharedStyle.ts +76 -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 +29 -0
- package/src/components/navigation/HorizontalNav/index.tsx +13 -0
- package/src/components/navigation/HorizontalNav/style.ts +93 -0
- package/src/components/navigation/IconNav/IconNav.stories.tsx +46 -0
- package/src/components/navigation/IconNav/index.tsx +50 -0
- package/src/components/navigation/Steppers/SlimStepper/Stepper.stories.tsx +90 -0
- package/src/components/navigation/Steppers/SlimStepper/index.tsx +104 -0
- package/src/components/navigation/Steppers/SlimStepper/style.ts +85 -0
- package/src/components/navigation/Steppers/Stepper/Stepper.stories.tsx +88 -0
- package/src/components/navigation/Steppers/Stepper/index.tsx +114 -0
- package/src/components/navigation/Steppers/Stepper/style.ts +106 -0
- package/src/components/navigation/Steppers/context.tsx +2 -0
- package/src/components/navigation/Steppers/provider.tsx +18 -0
- package/src/components/navigation/Steppers/reducer.ts +51 -0
- package/src/components/navigation/Steppers/stepStates.ts +5 -0
- package/src/components/navigation/Steppers/useStepper.ts +34 -0
- package/src/components/navigation/Tabs/Content.tsx +39 -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 +66 -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 +17 -0
- package/src/components/other/ActionMenu/ActionMenu.stories.tsx +81 -0
- package/src/components/other/ActionMenu/index.tsx +62 -0
- package/src/components/other/ActionMenu/style.ts +47 -0
- package/src/components/other/ClipBoard/ClipBoard.stories.tsx +14 -0
- package/src/components/other/ClipBoard/ClipBoard.test.tsx +8 -0
- package/src/components/other/ClipBoard/ClipBoard.test.tsx.snap +70 -0
- package/src/components/other/ClipBoard/__snapshots__/ClipBoard.test.tsx.snap +36 -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 +110 -0
- package/src/components/other/Collapsible/Collapsible.stories.tsx +19 -0
- package/src/components/other/Collapsible/CollapsibleContent.tsx +29 -0
- package/src/components/other/Collapsible/CollapsibleContext.tsx +17 -0
- package/src/components/other/Collapsible/CollapsibleTrigger.tsx +83 -0
- package/src/components/other/Collapsible/index.tsx +21 -0
- package/src/components/other/Company/index.tsx +44 -0
- package/src/components/other/Company/style.ts +58 -0
- package/src/components/other/Empty/Empty.stories.tsx +28 -0
- package/src/components/other/Empty/Empty.test.tsx +10 -0
- package/src/components/other/Empty/Empty.test.tsx.snap +85 -0
- package/src/components/other/Empty/__snapshots__/Empty.test.tsx.snap +21 -0
- package/src/components/other/Empty/index.tsx +85 -0
- package/src/components/other/PermissionsGuard/PermissionsGuard.stories.tsx +55 -0
- package/src/components/other/PermissionsGuard/hasPermissionsHelper.ts +18 -0
- package/src/components/other/PermissionsGuard/index.tsx +27 -0
- package/src/components/other/Plan/Plan.stories.tsx +21 -0
- package/src/components/other/Plan/index.tsx +92 -0
- package/src/components/other/Plan/style.ts +61 -0
- package/src/components/other/Usage/Usage.stories.tsx +21 -0
- package/src/components/other/Usage/Usage.tsx +35 -0
- package/src/components/other/Usage/UsageCard.stories.tsx +31 -0
- package/src/components/other/Usage/UsageCard.tsx +88 -0
- package/src/components/other/index.ts +27 -0
- package/src/components/visual/Card/Card.stories.tsx +22 -0
- package/src/components/visual/Card/CardBody.tsx +11 -0
- package/src/components/visual/Card/CardTitle.tsx +29 -0
- package/src/components/visual/Card/index.tsx +58 -0
- package/src/components/visual/Divider/Divider.stories.tsx +19 -0
- package/src/components/visual/Divider/Divider.test.tsx +8 -0
- package/src/components/visual/Divider/Divider.test.tsx.snap +35 -0
- package/src/components/visual/Divider/__snapshots__/Divider.test.tsx.snap +13 -0
- package/src/components/visual/Divider/index.tsx +88 -0
- package/src/components/visual/Flag/index.tsx +61 -0
- package/src/components/visual/index.ts +8 -0
- package/src/errors/base.ts +14 -0
- package/src/errors/errors.ts +126 -0
- package/src/errors/index.ts +14 -0
- package/src/helpers/camelCaseToSpaces.ts +5 -0
- package/src/helpers/formatNumber.ts +6 -0
- package/src/helpers/getInitials.ts +16 -0
- package/src/helpers/getSnackbarProvider.tsx +57 -0
- package/src/helpers/getTransition.ts +9 -0
- package/src/helpers/index.ts +6 -0
- package/src/helpers/makeData.ts +34 -0
- package/src/helpers/regexprs.ts +9 -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 +12 -0
- package/src/hooks/useLocalStorage.tsx +35 -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 +61 -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.mdx +35 -0
- package/src/stories/Introduction.mdx +17 -0
- package/src/stories/Spacing.mdx +25 -0
- package/src/styled/GlobalStyle.ts +209 -0
- package/src/styled/Snackbar.tsx +41 -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/index.ts +10 -0
- package/src/styled/spacing.ts +38 -0
- package/src/styled/theme.tsx +110 -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 +34 -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 +14 -0
- package/vite.config.mts +17 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { useTheme } from '../../../hooks';
|
|
3
|
+
|
|
4
|
+
export interface LoadingProps {
|
|
5
|
+
fill?: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const Loading: FC<LoadingProps> = ({ fill = undefined }) => {
|
|
9
|
+
const theme = useTheme();
|
|
10
|
+
if (!fill) {
|
|
11
|
+
fill = theme.colors.primary;
|
|
12
|
+
}
|
|
13
|
+
return (
|
|
14
|
+
<svg fill={fill} height="105" viewBox="0 0 105 105" width="105" xmlns="http://www.w3.org/2000/svg">
|
|
15
|
+
<circle cx="12.5" cy="12.5" r="12.5">
|
|
16
|
+
<animate
|
|
17
|
+
attributeName="fill-opacity"
|
|
18
|
+
begin="0s"
|
|
19
|
+
calcMode="linear"
|
|
20
|
+
dur="1s"
|
|
21
|
+
repeatCount="indefinite"
|
|
22
|
+
values="1;.2;1"
|
|
23
|
+
/>
|
|
24
|
+
</circle>
|
|
25
|
+
<circle cx="12.5" cy="52.5" fillOpacity=".5" r="12.5">
|
|
26
|
+
<animate
|
|
27
|
+
attributeName="fill-opacity"
|
|
28
|
+
begin="100ms"
|
|
29
|
+
calcMode="linear"
|
|
30
|
+
dur="1s"
|
|
31
|
+
repeatCount="indefinite"
|
|
32
|
+
values="1;.2;1"
|
|
33
|
+
/>
|
|
34
|
+
</circle>
|
|
35
|
+
<circle cx="52.5" cy="12.5" r="12.5">
|
|
36
|
+
<animate
|
|
37
|
+
attributeName="fill-opacity"
|
|
38
|
+
begin="300ms"
|
|
39
|
+
calcMode="linear"
|
|
40
|
+
dur="1s"
|
|
41
|
+
repeatCount="indefinite"
|
|
42
|
+
values="1;.2;1"
|
|
43
|
+
/>
|
|
44
|
+
</circle>
|
|
45
|
+
<circle cx="52.5" cy="52.5" r="12.5">
|
|
46
|
+
<animate
|
|
47
|
+
attributeName="fill-opacity"
|
|
48
|
+
begin="600ms"
|
|
49
|
+
calcMode="linear"
|
|
50
|
+
dur="1s"
|
|
51
|
+
repeatCount="indefinite"
|
|
52
|
+
values="1;.2;1"
|
|
53
|
+
/>
|
|
54
|
+
</circle>
|
|
55
|
+
<circle cx="92.5" cy="12.5" r="12.5">
|
|
56
|
+
<animate
|
|
57
|
+
attributeName="fill-opacity"
|
|
58
|
+
begin="800ms"
|
|
59
|
+
calcMode="linear"
|
|
60
|
+
dur="1s"
|
|
61
|
+
repeatCount="indefinite"
|
|
62
|
+
values="1;.2;1"
|
|
63
|
+
/>
|
|
64
|
+
</circle>
|
|
65
|
+
<circle cx="92.5" cy="52.5" r="12.5">
|
|
66
|
+
<animate
|
|
67
|
+
attributeName="fill-opacity"
|
|
68
|
+
begin="400ms"
|
|
69
|
+
calcMode="linear"
|
|
70
|
+
dur="1s"
|
|
71
|
+
repeatCount="indefinite"
|
|
72
|
+
values="1;.2;1"
|
|
73
|
+
/>
|
|
74
|
+
</circle>
|
|
75
|
+
<circle cx="12.5" cy="92.5" r="12.5">
|
|
76
|
+
<animate
|
|
77
|
+
attributeName="fill-opacity"
|
|
78
|
+
begin="700ms"
|
|
79
|
+
calcMode="linear"
|
|
80
|
+
dur="1s"
|
|
81
|
+
repeatCount="indefinite"
|
|
82
|
+
values="1;.2;1"
|
|
83
|
+
/>
|
|
84
|
+
</circle>
|
|
85
|
+
<circle cx="52.5" cy="92.5" r="12.5">
|
|
86
|
+
<animate
|
|
87
|
+
attributeName="fill-opacity"
|
|
88
|
+
begin="500ms"
|
|
89
|
+
calcMode="linear"
|
|
90
|
+
dur="1s"
|
|
91
|
+
repeatCount="indefinite"
|
|
92
|
+
values="1;.2;1"
|
|
93
|
+
/>
|
|
94
|
+
</circle>
|
|
95
|
+
<circle cx="92.5" cy="92.5" r="12.5">
|
|
96
|
+
<animate
|
|
97
|
+
attributeName="fill-opacity"
|
|
98
|
+
begin="200ms"
|
|
99
|
+
calcMode="linear"
|
|
100
|
+
dur="1s"
|
|
101
|
+
repeatCount="indefinite"
|
|
102
|
+
values="1;.2;1"
|
|
103
|
+
/>
|
|
104
|
+
</circle>
|
|
105
|
+
</svg>
|
|
106
|
+
);
|
|
107
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Should render <Spinner/> 1`] = `
|
|
4
|
+
.c0 {
|
|
5
|
+
width: 15px;
|
|
6
|
+
height: 15px;
|
|
7
|
+
background-color: #ffffff;
|
|
8
|
+
width: 6px;
|
|
9
|
+
height: 6px;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
<div>
|
|
13
|
+
<div
|
|
14
|
+
class="c0"
|
|
15
|
+
color="white"
|
|
16
|
+
/>
|
|
17
|
+
</div>
|
|
18
|
+
`;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// credits: https://codesandbox.io/s/framer-motion-keyframes-ekks8?fontsize=14&module=/src/Example.tsx&file=/src/Example.tsx:136-445
|
|
2
|
+
|
|
3
|
+
import { FC } from 'react';
|
|
4
|
+
import { styled } from '../../../styled';
|
|
5
|
+
import { Color, Size, AlertVariants } from '../../../styled/types';
|
|
6
|
+
import { motion } from 'framer-motion';
|
|
7
|
+
import { shade } from 'polished';
|
|
8
|
+
|
|
9
|
+
const Container = styled(motion.div)<{
|
|
10
|
+
$color: Color | AlertVariants | 'white' | 'background';
|
|
11
|
+
$size: Size;
|
|
12
|
+
}>`
|
|
13
|
+
width: 15px;
|
|
14
|
+
height: 15px;
|
|
15
|
+
background-color: ${({ theme, $color }) => shade(0.5, theme.colors[$color])};
|
|
16
|
+
border: 1px solid ${({ theme, $color }) => theme.colors[$color]};
|
|
17
|
+
|
|
18
|
+
${({ $size }) => {
|
|
19
|
+
switch ($size) {
|
|
20
|
+
case 'tiny':
|
|
21
|
+
return `
|
|
22
|
+
width: 4px;
|
|
23
|
+
height: 4px;
|
|
24
|
+
`;
|
|
25
|
+
case 'small':
|
|
26
|
+
return `
|
|
27
|
+
width: 6px;
|
|
28
|
+
height: 6px;
|
|
29
|
+
`;
|
|
30
|
+
case 'medium':
|
|
31
|
+
return `
|
|
32
|
+
width: 8px;
|
|
33
|
+
height: 8px;
|
|
34
|
+
`;
|
|
35
|
+
case 'large':
|
|
36
|
+
return `
|
|
37
|
+
width: 13px;
|
|
38
|
+
height: 13px;
|
|
39
|
+
`;
|
|
40
|
+
case 'huge':
|
|
41
|
+
return `
|
|
42
|
+
width: 20px;
|
|
43
|
+
height: 20px;
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
}}
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
export interface SpinnerProps {
|
|
50
|
+
size: Size;
|
|
51
|
+
color?: Color | AlertVariants | 'white' | 'background';
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const Spinner: FC<SpinnerProps> = ({ size, color = 'primary' }) => {
|
|
55
|
+
return (
|
|
56
|
+
<Container
|
|
57
|
+
animate={{
|
|
58
|
+
scale: [1, 2, 2, 1, 1],
|
|
59
|
+
rotate: [0, 0, 270, 270, 0],
|
|
60
|
+
borderRadius: ['20%', '20%', '50%', '50%', '20%'],
|
|
61
|
+
}}
|
|
62
|
+
$color={color}
|
|
63
|
+
$size={size}
|
|
64
|
+
transition={{
|
|
65
|
+
duration: 1.5,
|
|
66
|
+
ease: 'easeInOut',
|
|
67
|
+
times: [0, 0.2, 0.5, 0.8, 1],
|
|
68
|
+
repeat: Infinity,
|
|
69
|
+
repeatType: 'loop',
|
|
70
|
+
repeatDelay: 0,
|
|
71
|
+
}}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
|
+
|
|
3
|
+
exports[`Should render <Loading/> 1`] = `
|
|
4
|
+
<div>
|
|
5
|
+
<svg
|
|
6
|
+
fill="#664de5"
|
|
7
|
+
height="105"
|
|
8
|
+
viewBox="0 0 105 105"
|
|
9
|
+
width="105"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
>
|
|
12
|
+
<circle
|
|
13
|
+
cx="12.5"
|
|
14
|
+
cy="12.5"
|
|
15
|
+
r="12.5"
|
|
16
|
+
>
|
|
17
|
+
<animate
|
|
18
|
+
attributeName="fill-opacity"
|
|
19
|
+
begin="0s"
|
|
20
|
+
calcMode="linear"
|
|
21
|
+
dur="1s"
|
|
22
|
+
repeatCount="indefinite"
|
|
23
|
+
values="1;.2;1"
|
|
24
|
+
/>
|
|
25
|
+
</circle>
|
|
26
|
+
<circle
|
|
27
|
+
cx="12.5"
|
|
28
|
+
cy="52.5"
|
|
29
|
+
fill-opacity=".5"
|
|
30
|
+
r="12.5"
|
|
31
|
+
>
|
|
32
|
+
<animate
|
|
33
|
+
attributeName="fill-opacity"
|
|
34
|
+
begin="100ms"
|
|
35
|
+
calcMode="linear"
|
|
36
|
+
dur="1s"
|
|
37
|
+
repeatCount="indefinite"
|
|
38
|
+
values="1;.2;1"
|
|
39
|
+
/>
|
|
40
|
+
</circle>
|
|
41
|
+
<circle
|
|
42
|
+
cx="52.5"
|
|
43
|
+
cy="12.5"
|
|
44
|
+
r="12.5"
|
|
45
|
+
>
|
|
46
|
+
<animate
|
|
47
|
+
attributeName="fill-opacity"
|
|
48
|
+
begin="300ms"
|
|
49
|
+
calcMode="linear"
|
|
50
|
+
dur="1s"
|
|
51
|
+
repeatCount="indefinite"
|
|
52
|
+
values="1;.2;1"
|
|
53
|
+
/>
|
|
54
|
+
</circle>
|
|
55
|
+
<circle
|
|
56
|
+
cx="52.5"
|
|
57
|
+
cy="52.5"
|
|
58
|
+
r="12.5"
|
|
59
|
+
>
|
|
60
|
+
<animate
|
|
61
|
+
attributeName="fill-opacity"
|
|
62
|
+
begin="600ms"
|
|
63
|
+
calcMode="linear"
|
|
64
|
+
dur="1s"
|
|
65
|
+
repeatCount="indefinite"
|
|
66
|
+
values="1;.2;1"
|
|
67
|
+
/>
|
|
68
|
+
</circle>
|
|
69
|
+
<circle
|
|
70
|
+
cx="92.5"
|
|
71
|
+
cy="12.5"
|
|
72
|
+
r="12.5"
|
|
73
|
+
>
|
|
74
|
+
<animate
|
|
75
|
+
attributeName="fill-opacity"
|
|
76
|
+
begin="800ms"
|
|
77
|
+
calcMode="linear"
|
|
78
|
+
dur="1s"
|
|
79
|
+
repeatCount="indefinite"
|
|
80
|
+
values="1;.2;1"
|
|
81
|
+
/>
|
|
82
|
+
</circle>
|
|
83
|
+
<circle
|
|
84
|
+
cx="92.5"
|
|
85
|
+
cy="52.5"
|
|
86
|
+
r="12.5"
|
|
87
|
+
>
|
|
88
|
+
<animate
|
|
89
|
+
attributeName="fill-opacity"
|
|
90
|
+
begin="400ms"
|
|
91
|
+
calcMode="linear"
|
|
92
|
+
dur="1s"
|
|
93
|
+
repeatCount="indefinite"
|
|
94
|
+
values="1;.2;1"
|
|
95
|
+
/>
|
|
96
|
+
</circle>
|
|
97
|
+
<circle
|
|
98
|
+
cx="12.5"
|
|
99
|
+
cy="92.5"
|
|
100
|
+
r="12.5"
|
|
101
|
+
>
|
|
102
|
+
<animate
|
|
103
|
+
attributeName="fill-opacity"
|
|
104
|
+
begin="700ms"
|
|
105
|
+
calcMode="linear"
|
|
106
|
+
dur="1s"
|
|
107
|
+
repeatCount="indefinite"
|
|
108
|
+
values="1;.2;1"
|
|
109
|
+
/>
|
|
110
|
+
</circle>
|
|
111
|
+
<circle
|
|
112
|
+
cx="52.5"
|
|
113
|
+
cy="92.5"
|
|
114
|
+
r="12.5"
|
|
115
|
+
>
|
|
116
|
+
<animate
|
|
117
|
+
attributeName="fill-opacity"
|
|
118
|
+
begin="500ms"
|
|
119
|
+
calcMode="linear"
|
|
120
|
+
dur="1s"
|
|
121
|
+
repeatCount="indefinite"
|
|
122
|
+
values="1;.2;1"
|
|
123
|
+
/>
|
|
124
|
+
</circle>
|
|
125
|
+
<circle
|
|
126
|
+
cx="92.5"
|
|
127
|
+
cy="92.5"
|
|
128
|
+
r="12.5"
|
|
129
|
+
>
|
|
130
|
+
<animate
|
|
131
|
+
attributeName="fill-opacity"
|
|
132
|
+
begin="200ms"
|
|
133
|
+
calcMode="linear"
|
|
134
|
+
dur="1s"
|
|
135
|
+
repeatCount="indefinite"
|
|
136
|
+
values="1;.2;1"
|
|
137
|
+
/>
|
|
138
|
+
</circle>
|
|
139
|
+
</svg>
|
|
140
|
+
</div>
|
|
141
|
+
`;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { styled } from '../../../styled';
|
|
4
|
+
import { NetworkDetector } from '.';
|
|
5
|
+
|
|
6
|
+
const Wrapper = styled.div`
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 100vh;
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
title: 'Feedback/NetworkDetector',
|
|
13
|
+
component: NetworkDetector,
|
|
14
|
+
} as Meta;
|
|
15
|
+
|
|
16
|
+
export const Default: StoryFn = () => (
|
|
17
|
+
<Wrapper>
|
|
18
|
+
<p>You can simulate an offline state in the browsers network tab.</p>
|
|
19
|
+
<NetworkDetector />
|
|
20
|
+
</Wrapper>
|
|
21
|
+
);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { NetworkDetector } from '.';
|
|
2
|
+
import { render } from '../../../test/testUtils';
|
|
3
|
+
import { it, expect } from 'vitest';
|
|
4
|
+
|
|
5
|
+
it('Should render <NetworkDetector/>', () => {
|
|
6
|
+
const { container } = render(<NetworkDetector />);
|
|
7
|
+
expect(container).toMatchSnapshot();
|
|
8
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { FC, useEffect } from 'react';
|
|
2
|
+
import { useSnackbar } from 'notistack';
|
|
3
|
+
|
|
4
|
+
export const NetworkDetector: FC = () => {
|
|
5
|
+
const { enqueueSnackbar } = useSnackbar();
|
|
6
|
+
// const [current, setCurrent] = useState();
|
|
7
|
+
|
|
8
|
+
function hasNetwork(online: boolean) {
|
|
9
|
+
if (online) {
|
|
10
|
+
enqueueSnackbar('Your network is back online!', {
|
|
11
|
+
variant: 'networkDetectorOnline',
|
|
12
|
+
anchorOrigin: { horizontal: 'right', vertical: 'bottom' },
|
|
13
|
+
});
|
|
14
|
+
} else {
|
|
15
|
+
// offline
|
|
16
|
+
// TODO: make this persistent, with custom button and custom child
|
|
17
|
+
enqueueSnackbar('You are currently offline.', {
|
|
18
|
+
variant: 'networkDetectorOffline',
|
|
19
|
+
anchorOrigin: { horizontal: 'right', vertical: 'bottom' },
|
|
20
|
+
persist: true,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
window.addEventListener('offline', () => hasNetwork(false));
|
|
27
|
+
window.addEventListener('online', () => hasNetwork(true));
|
|
28
|
+
|
|
29
|
+
// clean up
|
|
30
|
+
return () => {
|
|
31
|
+
window.removeEventListener('online', () => {
|
|
32
|
+
/* */
|
|
33
|
+
});
|
|
34
|
+
window.removeEventListener('offline', () => {
|
|
35
|
+
/* */
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
}, []);
|
|
39
|
+
|
|
40
|
+
return null;
|
|
41
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
2
|
+
import { NotificationBanner, NotificationBannerProps } from '.';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Feedback/NotificationBanner',
|
|
6
|
+
component: NotificationBanner,
|
|
7
|
+
args: {
|
|
8
|
+
title: 'This is the notification banner title',
|
|
9
|
+
description: 'This is the notification banner description',
|
|
10
|
+
},
|
|
11
|
+
} as Meta<NotificationBannerProps>;
|
|
12
|
+
|
|
13
|
+
export const Default: StoryFn<NotificationBannerProps> = (args) => <NotificationBanner {...args} />;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NotificationBanner } from '.';
|
|
2
|
+
import { it, expect } from 'vitest';
|
|
3
|
+
import { render } from '../../../test/testUtils';
|
|
4
|
+
|
|
5
|
+
it('Should render <NotificationBanner/>', () => {
|
|
6
|
+
// we need to create the portal
|
|
7
|
+
const notificationBannerPortal = document.createElement('div');
|
|
8
|
+
notificationBannerPortal.setAttribute('id', 'notification-banner');
|
|
9
|
+
document.body.appendChild(notificationBannerPortal);
|
|
10
|
+
|
|
11
|
+
const { container } = render(
|
|
12
|
+
<NotificationBanner description="Notification banner description" title="Notification banner title" />,
|
|
13
|
+
);
|
|
14
|
+
expect(container).toMatchSnapshot();
|
|
15
|
+
});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { FC, useState } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import { styled } from '../../../styled';
|
|
4
|
+
import { AnimatePresence, motion } from 'framer-motion';
|
|
5
|
+
import { Tooltip } from '../Tooltip';
|
|
6
|
+
import { AiOutlineClose as CloseIcon } from 'react-icons/ai';
|
|
7
|
+
import { shade } from 'polished';
|
|
8
|
+
|
|
9
|
+
const Container = styled(motion.div)`
|
|
10
|
+
position: sticky;
|
|
11
|
+
background-color: ${({ theme }): string => shade(0.5, theme.colors.primary)};
|
|
12
|
+
border: 1px solid ${({ theme }) => theme.colors.primary};
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-content: space-between;
|
|
16
|
+
padding: ${({ theme }) => `${theme.spacing['0_75']} ${theme.spacing[1]}`};
|
|
17
|
+
will-change: height;
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
z-index: ${({ theme }) => theme.zIndex.notificationBanner};
|
|
20
|
+
|
|
21
|
+
div {
|
|
22
|
+
display: flex;
|
|
23
|
+
flex-direction: column;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
h3 {
|
|
27
|
+
font-size: 1.5rem;
|
|
28
|
+
}
|
|
29
|
+
p {
|
|
30
|
+
font-size: 1.1rem;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
h3,
|
|
34
|
+
p {
|
|
35
|
+
color: white;
|
|
36
|
+
font-weight: 500;
|
|
37
|
+
}
|
|
38
|
+
svg {
|
|
39
|
+
fill: white;
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
export interface NotificationBannerProps {
|
|
45
|
+
title: string;
|
|
46
|
+
description: string;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* What is <NotificationBanner?
|
|
50
|
+
------------------------------
|
|
51
|
+
It is a sticky component that shows above the headerbar to show a notification and
|
|
52
|
+
can be hidden by clicking the X in the upper right corner.
|
|
53
|
+
IMPORTANT: the component requires a separate div mounted outside of root called with id notification-banner.
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
export const NotificationBanner: FC<NotificationBannerProps> = ({ title, description }) => {
|
|
57
|
+
const [visible, setVisible] = useState<boolean>(true);
|
|
58
|
+
|
|
59
|
+
return createPortal(
|
|
60
|
+
<AnimatePresence>
|
|
61
|
+
{visible && (
|
|
62
|
+
<Container initial={{ y: -40 }} animate={{ y: 0 }} exit={{ opacity: '0' }}>
|
|
63
|
+
<div>
|
|
64
|
+
<h3>{title}</h3>
|
|
65
|
+
<p>{description}</p>
|
|
66
|
+
</div>
|
|
67
|
+
<Tooltip>
|
|
68
|
+
<Tooltip.Trigger asChild>
|
|
69
|
+
<CloseIcon onClick={() => setVisible(false)} size={18} />
|
|
70
|
+
</Tooltip.Trigger>
|
|
71
|
+
<Tooltip.Content>Close</Tooltip.Content>
|
|
72
|
+
</Tooltip>
|
|
73
|
+
</Container>
|
|
74
|
+
)}
|
|
75
|
+
</AnimatePresence>,
|
|
76
|
+
document.querySelector('#notification-banner') as Element,
|
|
77
|
+
);
|
|
78
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { Popover, PopoverProps } from '.';
|
|
4
|
+
import { IconButton } from '../../actions';
|
|
5
|
+
import { AiFillBug as BugIcon } from 'react-icons/ai';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Feedback/Popover',
|
|
9
|
+
component: Popover,
|
|
10
|
+
args: {
|
|
11
|
+
placement: 'bottom',
|
|
12
|
+
},
|
|
13
|
+
} as Meta<PopoverProps>;
|
|
14
|
+
|
|
15
|
+
export const UnControlled: StoryFn<PopoverProps> = () => (
|
|
16
|
+
<Popover>
|
|
17
|
+
<Popover.Trigger>Click this to open it in the popover</Popover.Trigger>
|
|
18
|
+
<Popover.Content>this is the content of the popover</Popover.Content>
|
|
19
|
+
</Popover>
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
export const CustomTrigger: StoryFn<PopoverProps> = () => (
|
|
23
|
+
<>
|
|
24
|
+
By default trigger is rendered as a button, but you can pass any component as a trigger by setting the asChild prop
|
|
25
|
+
on the Popover.Trigger component.
|
|
26
|
+
<Popover>
|
|
27
|
+
<Popover.Trigger asChild>
|
|
28
|
+
<IconButton icon={<BugIcon />} ariaLabel="click me" />
|
|
29
|
+
</Popover.Trigger>
|
|
30
|
+
<Popover.Content>this is the content of the popover</Popover.Content>
|
|
31
|
+
</Popover>
|
|
32
|
+
</>
|
|
33
|
+
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { forwardRef, HTMLProps } from 'react';
|
|
2
|
+
import { useMergeRefs, FloatingPortal, FloatingFocusManager, FloatingArrow } from '@floating-ui/react';
|
|
3
|
+
import { usePopoverContext } from './PopoverContext';
|
|
4
|
+
import { styled } from '../../../styled';
|
|
5
|
+
import { useTheme } from '../../../hooks';
|
|
6
|
+
|
|
7
|
+
const Container = styled.div`
|
|
8
|
+
background-color: ${({ theme }) => theme.colors.background};
|
|
9
|
+
border: 0.1rem solid ${({ theme }) => theme.colors.backgroundAccent};
|
|
10
|
+
border-radius: ${({ theme }) => theme.borderRadius.medium};
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
export const PopoverContent = forwardRef<HTMLDivElement, HTMLProps<HTMLDivElement>>(function PopoverContent(
|
|
14
|
+
{ style, ...props },
|
|
15
|
+
propRef,
|
|
16
|
+
) {
|
|
17
|
+
const theme = useTheme();
|
|
18
|
+
const { context: floatingContext, arrowRef, ...context } = usePopoverContext();
|
|
19
|
+
const ref = useMergeRefs([context.refs.setFloating, propRef]);
|
|
20
|
+
|
|
21
|
+
if (!floatingContext.open) return null;
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<FloatingPortal>
|
|
25
|
+
<FloatingFocusManager context={floatingContext} modal={context.modal}>
|
|
26
|
+
<Container
|
|
27
|
+
ref={ref}
|
|
28
|
+
style={{ ...context.floatingStyles, ...style }}
|
|
29
|
+
aria-labelledby={context.labelId}
|
|
30
|
+
aria-describedby={context.descriptionId}
|
|
31
|
+
{...context.getFloatingProps(props)}
|
|
32
|
+
>
|
|
33
|
+
{props.children}
|
|
34
|
+
<FloatingArrow
|
|
35
|
+
ref={arrowRef}
|
|
36
|
+
context={floatingContext}
|
|
37
|
+
fill={theme.colors.background}
|
|
38
|
+
stroke={theme.colors.backgroundAccent}
|
|
39
|
+
style={{ transform: 'translateY(-1px)' }}
|
|
40
|
+
strokeWidth={1}
|
|
41
|
+
/>
|
|
42
|
+
</Container>
|
|
43
|
+
</FloatingFocusManager>
|
|
44
|
+
</FloatingPortal>
|
|
45
|
+
);
|
|
46
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useContext, createContext } from 'react';
|
|
2
|
+
import { usePopover } from './usePopover';
|
|
3
|
+
|
|
4
|
+
type ContextType =
|
|
5
|
+
| (ReturnType<typeof usePopover> & {
|
|
6
|
+
setLabelId: React.Dispatch<React.SetStateAction<string | undefined>>;
|
|
7
|
+
setDescriptionId: React.Dispatch<React.SetStateAction<string | undefined>>;
|
|
8
|
+
})
|
|
9
|
+
| null;
|
|
10
|
+
|
|
11
|
+
export const PopoverContext = createContext<ContextType>(null);
|
|
12
|
+
|
|
13
|
+
export const usePopoverContext = () => {
|
|
14
|
+
const context = useContext(PopoverContext);
|
|
15
|
+
|
|
16
|
+
if (context == null) {
|
|
17
|
+
throw new Error('Popover components must be wrapped in <Popover />');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return context;
|
|
21
|
+
};
|