@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,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,14 @@
|
|
|
1
|
+
import { NotificationBanner } from '.';
|
|
2
|
+
import { render } from 'test-utils';
|
|
3
|
+
|
|
4
|
+
it('Should render <NotificationBanner/>', () => {
|
|
5
|
+
// we need to create the portal
|
|
6
|
+
const notificationBannerPortal = document.createElement('div');
|
|
7
|
+
notificationBannerPortal.setAttribute('id', 'notification-banner');
|
|
8
|
+
document.body.appendChild(notificationBannerPortal);
|
|
9
|
+
|
|
10
|
+
const { container } = render(
|
|
11
|
+
<NotificationBanner description="Notification banner description" title="Notification banner title" />
|
|
12
|
+
);
|
|
13
|
+
expect(container).toMatchSnapshot();
|
|
14
|
+
});
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { FC, useState } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import { Elevation, 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
|
+
|
|
8
|
+
const Container = styled(motion.div)<{ $elevation: Elevation }>`
|
|
9
|
+
position: sticky;
|
|
10
|
+
background-color: ${({ theme }): string => theme.colors.primaryShade};
|
|
11
|
+
border: 1px solid ${({ theme }) => theme.colors.primary};
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: space-between;
|
|
15
|
+
padding: ${({ theme }) => `${theme.spacing['0_75']} ${theme.spacing[1]}`};
|
|
16
|
+
will-change: height;
|
|
17
|
+
overflow: hidden;
|
|
18
|
+
box-shadow: ${({ theme, $elevation }) => theme.elevation[$elevation]};
|
|
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
|
+
elevation?: Elevation;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* What is <NotificationBanner?
|
|
51
|
+
------------------------------
|
|
52
|
+
It is a sticky component that shows above the headerbar to show a notification and
|
|
53
|
+
can be hidden by clicking the X in the upper right corner.
|
|
54
|
+
IMPORTANT: the component requires a separate div mounted outside of root called with id notification-banner.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
export const NotificationBanner: FC<NotificationBannerProps> = ({ title, description, elevation = 4 }) => {
|
|
58
|
+
const [visible, setVisible] = useState<boolean>(true);
|
|
59
|
+
|
|
60
|
+
return createPortal(
|
|
61
|
+
<AnimatePresence>
|
|
62
|
+
{visible && (
|
|
63
|
+
<Container $elevation={elevation} initial={{ y: -40 }} animate={{ y: 0 }} exit={{ opacity: '0' }}>
|
|
64
|
+
<div>
|
|
65
|
+
<h3>{title}</h3>
|
|
66
|
+
<p>{description}</p>
|
|
67
|
+
</div>
|
|
68
|
+
<Tooltip>
|
|
69
|
+
<Tooltip.Trigger asChild>
|
|
70
|
+
<CloseIcon onClick={() => setVisible(false)} size={18} />
|
|
71
|
+
</Tooltip.Trigger>
|
|
72
|
+
<Tooltip.Content>Close</Tooltip.Content>
|
|
73
|
+
</Tooltip>
|
|
74
|
+
</Container>
|
|
75
|
+
)}
|
|
76
|
+
</AnimatePresence>,
|
|
77
|
+
document.querySelector('#notification-banner') as Element
|
|
78
|
+
);
|
|
79
|
+
};
|
|
@@ -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,43 @@
|
|
|
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>>(({ style, ...props }, propRef) => {
|
|
14
|
+
const theme = useTheme();
|
|
15
|
+
const { context: floatingContext, arrowRef, ...context } = usePopoverContext();
|
|
16
|
+
const ref = useMergeRefs([context.refs.setFloating, propRef]);
|
|
17
|
+
|
|
18
|
+
if (!floatingContext.open) return null;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<FloatingPortal>
|
|
22
|
+
<FloatingFocusManager context={floatingContext} modal={context.modal}>
|
|
23
|
+
<Container
|
|
24
|
+
ref={ref}
|
|
25
|
+
style={{ ...context.floatingStyles, ...style }}
|
|
26
|
+
aria-labelledby={context.labelId}
|
|
27
|
+
aria-describedby={context.descriptionId}
|
|
28
|
+
{...context.getFloatingProps(props)}
|
|
29
|
+
>
|
|
30
|
+
{props.children}
|
|
31
|
+
<FloatingArrow
|
|
32
|
+
ref={arrowRef}
|
|
33
|
+
context={floatingContext}
|
|
34
|
+
fill={theme.colors.background}
|
|
35
|
+
stroke={theme.colors.backgroundAccent}
|
|
36
|
+
style={{ transform: 'translateY(-1px)' }}
|
|
37
|
+
strokeWidth={1}
|
|
38
|
+
/>
|
|
39
|
+
</Container>
|
|
40
|
+
</FloatingFocusManager>
|
|
41
|
+
</FloatingPortal>
|
|
42
|
+
);
|
|
43
|
+
});
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { forwardRef, cloneElement, isValidElement, HTMLProps, PropsWithChildren } from 'react';
|
|
2
|
+
import { usePopoverContext } from './PopoverContext';
|
|
3
|
+
import { useMergeRefs } from '@floating-ui/react';
|
|
4
|
+
|
|
5
|
+
export type PopoverTriggerProps = HTMLProps<HTMLElement> &
|
|
6
|
+
PropsWithChildren<{
|
|
7
|
+
asChild?: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
|
|
10
|
+
export const PopoverTrigger = forwardRef<HTMLElement, PopoverTriggerProps>(
|
|
11
|
+
({ children, asChild = false, ...props }, propRef) => {
|
|
12
|
+
const context = usePopoverContext();
|
|
13
|
+
const childrenRef = (children as any).ref;
|
|
14
|
+
const ref = useMergeRefs([context.refs.setReference, propRef, childrenRef]);
|
|
15
|
+
|
|
16
|
+
// `asChild` allows the user to pass any element as the anchor
|
|
17
|
+
if (asChild && isValidElement(children)) {
|
|
18
|
+
return cloneElement(
|
|
19
|
+
children,
|
|
20
|
+
context.getReferenceProps({
|
|
21
|
+
ref,
|
|
22
|
+
...props,
|
|
23
|
+
...children.props,
|
|
24
|
+
'data-state': context.open ? 'open' : 'closed',
|
|
25
|
+
onFocus: props.onFocus,
|
|
26
|
+
onBlur: props.onBlur,
|
|
27
|
+
})
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<button
|
|
33
|
+
ref={ref}
|
|
34
|
+
type="button"
|
|
35
|
+
// The user can style the trigger based on the state
|
|
36
|
+
data-state={context.open ? 'open' : 'closed'}
|
|
37
|
+
{...context.getReferenceProps(props)}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</button>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PropsWithChildren, FC } from 'react';
|
|
2
|
+
import { PopoverOptions, usePopover } from './usePopover';
|
|
3
|
+
import { PopoverContext } from './PopoverContext';
|
|
4
|
+
import { PopoverTrigger } from './PopoverTrigger';
|
|
5
|
+
import { PopoverContent } from './PopoverContent';
|
|
6
|
+
|
|
7
|
+
interface SubComponents {
|
|
8
|
+
Trigger: typeof PopoverTrigger;
|
|
9
|
+
Content: typeof PopoverContent;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type PopoverProps = PropsWithChildren<PopoverOptions>;
|
|
13
|
+
|
|
14
|
+
export const Popover: FC<PopoverProps> & SubComponents = ({ children, modal = false, ...restOptions }) => {
|
|
15
|
+
// This can accept any props as options, e.g. `placement`,
|
|
16
|
+
// or other positioning options.
|
|
17
|
+
const popover = usePopover({ modal, ...restOptions });
|
|
18
|
+
return <PopoverContext.Provider value={popover}>{children}</PopoverContext.Provider>;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
Popover.Trigger = PopoverTrigger;
|
|
22
|
+
Popover.Content = PopoverContent;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { useState, useMemo, useRef } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
useFloating,
|
|
4
|
+
autoUpdate,
|
|
5
|
+
offset,
|
|
6
|
+
flip,
|
|
7
|
+
shift,
|
|
8
|
+
useClick,
|
|
9
|
+
useDismiss,
|
|
10
|
+
useRole,
|
|
11
|
+
useInteractions,
|
|
12
|
+
Placement,
|
|
13
|
+
arrow,
|
|
14
|
+
} from '@floating-ui/react';
|
|
15
|
+
|
|
16
|
+
export interface PopoverOptions {
|
|
17
|
+
initialOpen?: boolean;
|
|
18
|
+
placement?: Placement;
|
|
19
|
+
/// If focus is modal, focus is trapped inside the floating element and outside content cannot be accessed.
|
|
20
|
+
/// When set, the floating element should have a dedicated close button.
|
|
21
|
+
modal?: boolean;
|
|
22
|
+
open?: boolean;
|
|
23
|
+
onOpenChange?: (open: boolean) => void;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function usePopover({
|
|
27
|
+
initialOpen = false,
|
|
28
|
+
placement = 'bottom',
|
|
29
|
+
modal,
|
|
30
|
+
open: controlledOpen,
|
|
31
|
+
onOpenChange: setControlledOpen,
|
|
32
|
+
}: PopoverOptions = {}) {
|
|
33
|
+
const [uncontrolledOpen, setUncontrolledOpen] = useState(initialOpen);
|
|
34
|
+
const [labelId, setLabelId] = useState<string | undefined>();
|
|
35
|
+
const [descriptionId, setDescriptionId] = useState<string | undefined>();
|
|
36
|
+
|
|
37
|
+
const open = controlledOpen ?? uncontrolledOpen;
|
|
38
|
+
const setOpen = setControlledOpen ?? setUncontrolledOpen;
|
|
39
|
+
|
|
40
|
+
const arrowRef = useRef(null);
|
|
41
|
+
const ARROW_HEIGHT = 7;
|
|
42
|
+
const GAP = 7;
|
|
43
|
+
|
|
44
|
+
const { context, ...data } = useFloating({
|
|
45
|
+
placement,
|
|
46
|
+
open,
|
|
47
|
+
onOpenChange: setOpen,
|
|
48
|
+
whileElementsMounted: autoUpdate,
|
|
49
|
+
middleware: [
|
|
50
|
+
offset(ARROW_HEIGHT + GAP),
|
|
51
|
+
flip({
|
|
52
|
+
crossAxis: placement.includes('-'),
|
|
53
|
+
fallbackAxisSideDirection: 'end',
|
|
54
|
+
padding: 5,
|
|
55
|
+
}),
|
|
56
|
+
shift({ padding: 5 }),
|
|
57
|
+
arrow({
|
|
58
|
+
element: arrowRef,
|
|
59
|
+
}),
|
|
60
|
+
],
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const interactions = useInteractions([
|
|
64
|
+
useClick(context, {
|
|
65
|
+
enabled: controlledOpen == null,
|
|
66
|
+
}),
|
|
67
|
+
useDismiss(context),
|
|
68
|
+
useRole(context),
|
|
69
|
+
]);
|
|
70
|
+
|
|
71
|
+
return useMemo(
|
|
72
|
+
() => ({
|
|
73
|
+
open,
|
|
74
|
+
setOpen,
|
|
75
|
+
...interactions,
|
|
76
|
+
context,
|
|
77
|
+
...data,
|
|
78
|
+
modal,
|
|
79
|
+
labelId,
|
|
80
|
+
descriptionId,
|
|
81
|
+
setLabelId,
|
|
82
|
+
setDescriptionId,
|
|
83
|
+
arrowRef,
|
|
84
|
+
}),
|
|
85
|
+
[open, setOpen, interactions, data, modal, labelId, descriptionId]
|
|
86
|
+
);
|
|
87
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { ProgressBar, ProgressBarProps } from '.';
|
|
4
|
+
import { styled } from '../../../styled';
|
|
5
|
+
|
|
6
|
+
const ButtonContainer = styled.div`
|
|
7
|
+
display: flex;
|
|
8
|
+
button {
|
|
9
|
+
&:first-child {
|
|
10
|
+
margin: 0 1rem;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
export default {
|
|
16
|
+
title: 'Feedback/ProgressBar',
|
|
17
|
+
component: ProgressBar,
|
|
18
|
+
args: {
|
|
19
|
+
mode: 'indeterminate',
|
|
20
|
+
showValue: false,
|
|
21
|
+
},
|
|
22
|
+
} as Meta<ProgressBarProps>;
|
|
23
|
+
|
|
24
|
+
export const Default: StoryFn<ProgressBarProps> = (args) => <ProgressBar {...args} />;
|
|
25
|
+
|
|
26
|
+
export const Determinate: StoryFn<ProgressBarProps> = () => {
|
|
27
|
+
const [value, setValue] = useState<number>(0);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
<ProgressBar mode="determinate" showValue value={value} />
|
|
32
|
+
<ButtonContainer>
|
|
33
|
+
<button onClick={() => setValue(value + 5)}>+5</button>
|
|
34
|
+
<button onClick={() => setValue(value + 10)}>+10</button>
|
|
35
|
+
</ButtonContainer>
|
|
36
|
+
</>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { styled, Color } from '../../../styled';
|
|
3
|
+
import { darken } from 'polished';
|
|
4
|
+
import { keyframes } from 'styled-components';
|
|
5
|
+
|
|
6
|
+
const indeterminateAnimation = keyframes`
|
|
7
|
+
0% {
|
|
8
|
+
transform: translateX(0) scaleX(0);
|
|
9
|
+
}
|
|
10
|
+
40% {
|
|
11
|
+
transform: translateX(0) scaleX(0.4);
|
|
12
|
+
}
|
|
13
|
+
100% {
|
|
14
|
+
transform: translateX(100%) scaleX(0.5);
|
|
15
|
+
}
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
const IndeterminateProgress = styled.div<{ color: Color }>`
|
|
19
|
+
width: 100%;
|
|
20
|
+
position: relative;
|
|
21
|
+
background-color: ${({ theme }) => theme.colors.background};
|
|
22
|
+
height: 1rem;
|
|
23
|
+
border-radius: ${({ theme }) => theme.borderRadius.medium};
|
|
24
|
+
overflow: hidden;
|
|
25
|
+
will-change: translateX, scaleX;
|
|
26
|
+
|
|
27
|
+
&::after {
|
|
28
|
+
position: absolute;
|
|
29
|
+
content: '';
|
|
30
|
+
width: 100%;
|
|
31
|
+
height: 100%;
|
|
32
|
+
background-color: ${({ theme, color }) => theme.colors[color]};
|
|
33
|
+
animation: ${indeterminateAnimation} 5s infinite linear;
|
|
34
|
+
transform-origin: 0% 50%;
|
|
35
|
+
border-radius: ${({ theme }) => theme.borderRadius.large};
|
|
36
|
+
background-color: ${({ theme, color }) => theme.colors[color]};
|
|
37
|
+
}
|
|
38
|
+
`;
|
|
39
|
+
|
|
40
|
+
const Container = styled.div`
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: row;
|
|
43
|
+
align-items: center;
|
|
44
|
+
justify-content: flex-start;
|
|
45
|
+
width: 100%;
|
|
46
|
+
padding: ${({ theme }) => theme.spacing[1]};
|
|
47
|
+
`;
|
|
48
|
+
const Progress = styled.div<{ color: Color; progress: number }>`
|
|
49
|
+
width: calc(100% - 50px);
|
|
50
|
+
position: relative;
|
|
51
|
+
background-color: ${({ theme }) => theme.colors.background};
|
|
52
|
+
height: ${({ theme }) => theme.spacing[1]};
|
|
53
|
+
border-radius: ${({ theme }) => theme.borderRadius.large};
|
|
54
|
+
overflow: hidden;
|
|
55
|
+
|
|
56
|
+
&::after {
|
|
57
|
+
position: absolute;
|
|
58
|
+
content: '';
|
|
59
|
+
width: ${({ progress }) => progress}%;
|
|
60
|
+
top: 50%;
|
|
61
|
+
transform: translateY(-50%);
|
|
62
|
+
left: 0;
|
|
63
|
+
height: ${({ theme }) => theme.spacing[1]};
|
|
64
|
+
max-width: 100%;
|
|
65
|
+
transition: 0.2s width ease-out;
|
|
66
|
+
background-color: ${({ theme, color }) => darken(0.2, theme.colors[color])};
|
|
67
|
+
background-image: ${({ theme, color }): string =>
|
|
68
|
+
`url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 40 40' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%23${theme.colors[
|
|
69
|
+
color
|
|
70
|
+
].slice(
|
|
71
|
+
1,
|
|
72
|
+
theme.colors[color].length
|
|
73
|
+
)}' fill-opacity='1' fill-rule='evenodd'%3E%3Cpath d='M0 40L40 0H20L0 20M40 40V20L20 40'/%3E%3C/g%3E%3C/svg%3E")`};
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
76
|
+
|
|
77
|
+
const Label = styled.div`
|
|
78
|
+
margin-left: ${({ theme }) => theme.spacing[1]};
|
|
79
|
+
`;
|
|
80
|
+
|
|
81
|
+
export interface ProgressBarProps {
|
|
82
|
+
mode: 'determinate' | 'indeterminate';
|
|
83
|
+
value?: number;
|
|
84
|
+
color?: Color;
|
|
85
|
+
showValue?: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export const ProgressBar: FC<ProgressBarProps> = ({ mode, value = 0, color = 'primary', showValue = false }) => {
|
|
89
|
+
if (mode === 'determinate') {
|
|
90
|
+
return (
|
|
91
|
+
<Container>
|
|
92
|
+
<Progress color={color} progress={value} />
|
|
93
|
+
{showValue && <Label>{Math.min(value, 100)}%</Label>}
|
|
94
|
+
</Container>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<Container>
|
|
100
|
+
<IndeterminateProgress color={color} />
|
|
101
|
+
</Container>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { QuestionTooltip } from '.';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'Feedback/QuestionTooltip',
|
|
7
|
+
component: QuestionTooltip,
|
|
8
|
+
args: {
|
|
9
|
+
placement: 'bottom',
|
|
10
|
+
label: 'this is the tooltip content',
|
|
11
|
+
},
|
|
12
|
+
} as Meta;
|
|
13
|
+
|
|
14
|
+
export const Default: StoryFn = () => {
|
|
15
|
+
return (
|
|
16
|
+
<div>
|
|
17
|
+
<QuestionTooltip>this is the tooltip content</QuestionTooltip>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { Tooltip } from '../Tooltip';
|
|
3
|
+
import { AiOutlineQuestion as QuestionIcon } from 'react-icons/ai';
|
|
4
|
+
import { styled } from '../../../styled';
|
|
5
|
+
import { TooltipProps } from '../Tooltip';
|
|
6
|
+
|
|
7
|
+
const TriggerContainer = styled.div`
|
|
8
|
+
background-color: ${({ theme }) => theme.colors.backgroundAlt};
|
|
9
|
+
border: 1px solid ${({ theme }) => theme.colors.backgroundAccent};
|
|
10
|
+
border-radius: ${({ theme }) => theme.borderRadius.medium};
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
margin-left: ${({ theme }) => theme.spacing['0_5']};
|
|
15
|
+
margin-right: ${({ theme }) => theme.spacing['0_5']};
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
const ContentContainer = styled.div`
|
|
19
|
+
max-width: 450px;
|
|
20
|
+
hyphens: auto;
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
export const QuestionTooltip: FC<TooltipProps> = ({ children }) => {
|
|
24
|
+
return (
|
|
25
|
+
<Tooltip>
|
|
26
|
+
<Tooltip.Trigger asChild>
|
|
27
|
+
<TriggerContainer>
|
|
28
|
+
<QuestionIcon size="18" />
|
|
29
|
+
</TriggerContainer>
|
|
30
|
+
</Tooltip.Trigger>
|
|
31
|
+
<Tooltip.Content>
|
|
32
|
+
<ContentContainer>{children}</ContentContainer>
|
|
33
|
+
</Tooltip.Content>
|
|
34
|
+
</Tooltip>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Meta, StoryFn } from '@storybook/react';
|
|
3
|
+
import { styled } from '../../../styled';
|
|
4
|
+
import { Skeleton, SkeletonProps } from '.';
|
|
5
|
+
|
|
6
|
+
const Wrapper = styled.div`
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
gap: ${({ theme }) => theme.spacing['1']};
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
title: 'Feedback/Skeleton',
|
|
14
|
+
component: Skeleton,
|
|
15
|
+
} as Meta<SkeletonProps>;
|
|
16
|
+
|
|
17
|
+
export const Default: StoryFn<SkeletonProps> = (args) => <Skeleton {...args} />;
|
|
18
|
+
|
|
19
|
+
export const Example = () => (
|
|
20
|
+
<Wrapper>
|
|
21
|
+
<Skeleton variant="text" />
|
|
22
|
+
<Skeleton height="40px" variant="circular" width="40px" />
|
|
23
|
+
<Skeleton height="180px" variant="rectangular" width="210px" />
|
|
24
|
+
</Wrapper>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
export const Example2 = () => (
|
|
28
|
+
<Wrapper>
|
|
29
|
+
<Skeleton variant="text" />
|
|
30
|
+
<Skeleton variant="text" />
|
|
31
|
+
<Skeleton variant="text" />
|
|
32
|
+
</Wrapper>
|
|
33
|
+
);
|