@conveyorhq/arrow-ds 2.0.0-beta.6 → 2.0.0-beta.7
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/package.json +28 -21
- package/public/components/Accordion/Accordion.d.ts +29 -17
- package/public/components/Accordion/Accordion.js +78 -56
- package/public/components/Accordion/context.d.ts +12 -0
- package/public/components/Accordion/context.js +30 -0
- package/public/components/Accordion/index.d.ts +1 -0
- package/public/components/Accordion/index.js +1 -0
- package/public/components/Accordion/types.d.ts +17 -0
- package/public/components/Accordion/types.js +2 -0
- package/public/components/Avatar/Avatar.d.ts +1 -1
- package/public/components/Avatar/AvatarGroup.d.ts +1 -1
- package/public/components/Avatar/AvatarGroup.js +11 -1
- package/public/components/Button/Button.d.ts +3 -2
- package/public/components/Button/Button.js +3 -0
- package/public/components/CloseButton/CloseButton.d.ts +1 -2
- package/public/components/ConveyorLogo/ConveyorLogo.js +1 -1
- package/public/components/Divider/Divider.d.ts +1 -9
- package/public/components/Divider/Divider.js +13 -24
- package/public/components/Drawer/Drawer.js +11 -9
- package/public/components/Flex/Flex.js +3 -4
- package/public/components/Grid/Grid.d.ts +2 -2
- package/public/components/Grid/Grid.js +9 -3
- package/public/components/Icon/Icon.d.ts +14 -0
- package/public/components/Icon/Icon.js +32 -2
- package/public/components/Icon/svg/ArrowToBottom.d.ts +2 -0
- package/public/components/Icon/svg/ArrowToBottom.js +14 -0
- package/public/components/Icon/svg/CommentAltCheck.d.ts +2 -0
- package/public/components/Icon/svg/CommentAltCheck.js +13 -0
- package/public/components/Icon/svg/index.d.ts +2 -0
- package/public/components/Icon/svg/index.js +2 -0
- package/public/components/Input/Input.d.ts +3 -2
- package/public/components/Input/Input.js +7 -6
- package/public/components/Loading/Loading.d.ts +3 -2
- package/public/components/Loading/Loading.js +4 -7
- package/public/components/Markdown/Markdown.d.ts +1 -1
- package/public/components/Markdown/Markdown.js +3 -3
- package/public/components/MarkdownEditor/MarkdownEditor.js +1 -2
- package/public/components/MarkdownEditor/MarkdownHelp.js +4 -7
- package/public/components/MenuRenderer/MenuRenderer.js +7 -4
- package/public/components/Modal/Modal.d.ts +6 -0
- package/public/components/Modal/Modal.js +29 -19
- package/public/components/Modal/context.d.ts +6 -0
- package/public/components/Modal/context.js +15 -0
- package/public/components/Modal/index.d.ts +1 -0
- package/public/components/Modal/index.js +1 -0
- package/public/components/OptionButton/OptionButton.d.ts +28 -1
- package/public/components/OptionButton/OptionButton.js +58 -11
- package/public/components/OptionButton/context.d.ts +11 -0
- package/public/components/OptionButton/context.js +16 -0
- package/public/components/Overlay/Overlay.js +2 -2
- package/public/components/Paragraph/Paragraph.js +3 -7
- package/public/components/Reference/Reference.d.ts +2 -2
- package/public/components/Select/Select.d.ts +1 -0
- package/public/components/Select/Select.js +12 -7
- package/public/components/Snackbar/Snackbar.d.ts +14 -22
- package/public/components/Snackbar/Snackbar.js +28 -85
- package/public/components/Snackbar/SnackbarProvider.d.ts +2 -0
- package/public/components/Snackbar/SnackbarProvider.js +21 -0
- package/public/components/Snackbar/constants.d.ts +2 -0
- package/public/components/Snackbar/constants.js +5 -0
- package/public/components/Snackbar/context.d.ts +4 -0
- package/public/components/Snackbar/context.js +17 -0
- package/public/components/Snackbar/helpers.d.ts +3 -0
- package/public/components/Snackbar/helpers.js +31 -0
- package/public/components/Snackbar/hooks.d.ts +2 -0
- package/public/components/Snackbar/hooks.js +47 -0
- package/public/components/Snackbar/index.d.ts +6 -0
- package/public/components/Snackbar/index.js +6 -0
- package/public/components/Snackbar/types.d.ts +43 -0
- package/public/components/Snackbar/types.js +2 -0
- package/public/components/SpeechBubble/SpeechBubble.d.ts +1 -0
- package/public/components/SpeechBubble/SpeechBubble.js +9 -2
- package/public/components/Table/Table.d.ts +5 -2
- package/public/components/Table/Table.js +11 -4
- package/public/components/Table/TableCell.d.ts +1 -0
- package/public/components/Table/TableCell.js +4 -2
- package/public/components/Table/TableHeaderCell.d.ts +2 -1
- package/public/components/Table/TableHeaderCell.js +24 -7
- package/public/components/Table/index.d.ts +3 -0
- package/public/components/Tag/Tag.d.ts +2 -2
- package/public/components/Toast/Toast.d.ts +3 -3
- package/public/components/Toast/Toast.js +6 -2
- package/public/css/styles.css +2550 -30950
- package/public/css/styles.min.css +1 -1
- package/public/css/styles.min.css.map +1 -1
- package/public/index.d.ts +0 -15
- package/public/index.js +0 -15
- package/public/storybook-components/ComponentHeading.js +3 -5
- package/public/storybook-components/ComponentStatus.d.ts +1 -0
- package/public/storybook-components/ComponentStatus.js +4 -0
- package/public/storybook-components/index.d.ts +1 -1
- package/public/storybook-components/index.js +1 -1
- package/public/style-dictionary/dist/tokens.css +377 -0
- package/public/style-dictionary/dist/tokens.d.ts +427 -0
- package/public/style-dictionary/dist/tokens.js +427 -0
- package/public/style-dictionary/dist/tokens.module.js +427 -0
- package/public/style-dictionary/src/border-radius.js +11 -0
- package/public/style-dictionary/src/border-width.js +10 -0
- package/public/style-dictionary/src/color.js +97 -0
- package/public/style-dictionary/src/font-size.js +15 -0
- package/public/style-dictionary/src/font-weight.js +7 -0
- package/public/style-dictionary/src/height.js +13 -0
- package/public/style-dictionary/src/leading.js +8 -0
- package/public/style-dictionary/src/screen-width.js +8 -0
- package/public/style-dictionary/src/shadow.js +19 -0
- package/public/style-dictionary/src/spacing.js +69 -0
- package/public/style-dictionary/src/tracking.js +7 -0
- package/public/style-dictionary/src/type.js +34 -0
- package/public/style-dictionary/src/width.js +32 -0
- package/public/style-dictionary/src/z-index.js +21 -0
- package/public/style-dictionary/tailwind.config.js +87 -0
- package/public/tokens/box-shadow.d.ts +1 -0
- package/public/tokens/box-shadow.js +1 -0
- package/public/tokens/font-family.js +1 -1
- package/public/tokens/height.d.ts +65 -43
- package/public/tokens/height.js +3 -44
- package/public/tokens/index.d.ts +526 -173
- package/public/tokens/index.js +1 -1
- package/public/tokens/margin.d.ts +129 -47
- package/public/tokens/margin.js +3 -47
- package/public/tokens/padding.d.ts +65 -24
- package/public/tokens/padding.js +2 -24
- package/public/tokens/sizing-scale.d.ts +133 -0
- package/public/tokens/sizing-scale.js +136 -0
- package/public/tokens/width.d.ts +197 -63
- package/public/tokens/width.js +6 -63
- package/public/types/index.d.ts +14 -2
- package/public/types/index.js +2 -4
- package/src/components/Accordion/Accordion.story.mdx +232 -22
- package/src/components/Accordion/Accordion.tsx +228 -117
- package/src/components/Accordion/context.ts +60 -0
- package/src/components/Accordion/index.css +0 -5
- package/src/components/Accordion/index.ts +1 -0
- package/src/components/Accordion/types.ts +55 -0
- package/src/components/Avatar/Avatar.story.mdx +60 -0
- package/src/components/Avatar/AvatarGroup.tsx +11 -9
- package/src/components/Avatar/index.css +8 -0
- package/src/components/Button/Button.story.mdx +116 -1
- package/src/components/Button/Button.tsx +10 -4
- package/src/components/Button/product.css +12 -0
- package/src/components/Card/Card.story.mdx +11 -36
- package/src/components/CloseButton/CloseButton.tsx +1 -1
- package/src/components/ConveyorLogo/ConveyorLogo.tsx +1 -0
- package/src/components/Divider/Divider.tsx +26 -40
- package/src/components/Divider/index.css +16 -0
- package/src/components/Drawer/Drawer.story.mdx +68 -70
- package/src/components/Drawer/Drawer.tsx +10 -9
- package/src/components/Drawer/index.css +26 -1
- package/src/components/Flex/Flex.story.mdx +130 -0
- package/src/components/Flex/Flex.tsx +7 -6
- package/src/components/Flex/index.css +3 -0
- package/src/components/Frame/Frame.story.mdx +7 -2
- package/src/components/Grid/Grid.story.mdx +205 -3
- package/src/components/Grid/Grid.tsx +44 -5
- package/src/components/Grid/index.css +3 -0
- package/src/components/Icon/Icon.tsx +60 -5
- package/src/components/Icon/svg/ArrowToBottom.tsx +17 -0
- package/src/components/Icon/svg/CommentAltCheck.tsx +13 -0
- package/src/components/Icon/svg/index.ts +2 -0
- package/src/components/Input/Input.story.mdx +199 -13
- package/src/components/Input/Input.tsx +39 -6
- package/src/components/Input/brand.css +7 -7
- package/src/components/Input/index.css +30 -0
- package/src/components/Input/product.css +12 -48
- package/src/components/Loading/Loading.story.mdx +16 -9
- package/src/components/Loading/Loading.tsx +17 -8
- package/src/components/Loading/index.css +1 -67
- package/src/components/Markdown/Markdown.story.mdx +67 -0
- package/src/components/Markdown/Markdown.tsx +3 -2
- package/src/components/MarkdownEditor/MarkdownEditor.tsx +2 -3
- package/src/components/MarkdownEditor/MarkdownHelp.tsx +7 -10
- package/src/components/MarkdownEditor/index.css +5 -1
- package/src/components/MenuRenderer/MenuRenderer.tsx +9 -7
- package/src/components/Modal/Modal.story.mdx +26 -0
- package/src/components/Modal/Modal.tsx +60 -42
- package/src/components/Modal/context.ts +20 -0
- package/src/components/Modal/index.ts +1 -0
- package/src/components/OptionButton/OptionButton.story.mdx +119 -20
- package/src/components/OptionButton/OptionButton.tsx +211 -23
- package/src/components/OptionButton/context.ts +22 -0
- package/src/components/OptionButton/index.css +1 -2
- package/src/components/Overlay/Overlay.tsx +2 -3
- package/src/components/Overlay/index.css +1 -0
- package/src/components/Paragraph/Paragraph.story.mdx +16 -2
- package/src/components/Paragraph/Paragraph.tsx +5 -13
- package/src/components/Paragraph/index.css +6 -0
- package/src/components/Popover/index.css +5 -6
- package/src/components/Reference/Reference.tsx +2 -2
- package/src/components/Select/Select.story.mdx +23 -10
- package/src/components/Select/Select.tsx +31 -6
- package/src/components/Snackbar/Snackbar.story.mdx +96 -9
- package/src/components/Snackbar/Snackbar.tsx +56 -145
- package/src/components/Snackbar/SnackbarProvider.tsx +31 -0
- package/src/components/Snackbar/constants.ts +2 -0
- package/src/components/Snackbar/context.ts +20 -0
- package/src/components/Snackbar/helpers.tsx +52 -0
- package/src/components/Snackbar/hooks.ts +57 -0
- package/src/components/Snackbar/index.ts +6 -0
- package/src/components/Snackbar/types.ts +180 -0
- package/src/components/SpeechBubble/SpeechBubble.story.mdx +76 -0
- package/src/components/SpeechBubble/SpeechBubble.tsx +22 -1
- package/src/components/SpeechBubble/index.css +7 -4
- package/src/components/Table/Table.story.mdx +243 -0
- package/src/components/Table/Table.tsx +36 -1
- package/src/components/Table/TableCell.tsx +24 -1
- package/src/components/Table/TableHeaderCell.tsx +64 -11
- package/src/components/Table/index.css +138 -10
- package/src/components/Table/index.ts +3 -0
- package/src/components/Tag/Tag.tsx +2 -2
- package/src/components/Toast/Toast.story.mdx +1 -1
- package/src/components/Toast/Toast.tsx +14 -10
- package/src/components/Toast/index.css +4 -2
- package/src/components/Toggle/index.css +2 -3
- package/src/css/base.css +6 -561
- package/src/css/components.css +4 -9
- package/src/css/fonts.css +13 -10
- package/src/css/styles.css +0 -1
- package/src/css/utilities/animations.css +13 -0
- package/src/docs/Typography.story.mdx +12 -9
- package/src/index.ts +0 -15
- package/src/storybook-components/ComponentHeading.tsx +4 -19
- package/src/storybook-components/ComponentStatus.tsx +4 -0
- package/src/storybook-components/index.tsx +1 -1
- package/src/tokens/box-shadow.ts +1 -0
- package/src/tokens/font-family.ts +1 -1
- package/src/tokens/height.ts +3 -44
- package/src/tokens/index.ts +2 -2
- package/src/tokens/margin.ts +4 -47
- package/src/tokens/padding.ts +3 -24
- package/src/tokens/sizing-scale.ts +134 -0
- package/src/tokens/width.ts +7 -63
- package/src/types/index.ts +34 -5
- package/public/components/Absolute/Absolute.d.ts +0 -2
- package/public/components/Absolute/Absolute.js +0 -14
- package/public/components/Absolute/index.d.ts +0 -1
- package/public/components/Absolute/index.js +0 -5
- package/public/components/Appbar/Appbar.d.ts +0 -40
- package/public/components/Appbar/Appbar.js +0 -29
- package/public/components/Appbar/AppbarLogo.d.ts +0 -2
- package/public/components/Appbar/AppbarLogo.js +0 -19
- package/public/components/Appbar/AppbarTabs.d.ts +0 -10
- package/public/components/Appbar/AppbarTabs.js +0 -42
- package/public/components/Appbar/AppbarUser.d.ts +0 -26
- package/public/components/Appbar/AppbarUser.js +0 -60
- package/public/components/Appbar/config.d.ts +0 -7
- package/public/components/Appbar/config.js +0 -13
- package/public/components/Appbar/index.d.ts +0 -1
- package/public/components/Appbar/index.js +0 -13
- package/public/components/ArrowButton/ArrowButton.d.ts +0 -9
- package/public/components/ArrowButton/ArrowButton.js +0 -22
- package/public/components/ArrowButton/index.d.ts +0 -1
- package/public/components/ArrowButton/index.js +0 -13
- package/public/components/ArrowLink/ArrowLink.d.ts +0 -9
- package/public/components/ArrowLink/ArrowLink.js +0 -21
- package/public/components/ArrowLink/index.d.ts +0 -1
- package/public/components/ArrowLink/index.js +0 -13
- package/public/components/Aside/Aside.d.ts +0 -14
- package/public/components/Aside/Aside.js +0 -28
- package/public/components/Aside/index.d.ts +0 -1
- package/public/components/Aside/index.js +0 -13
- package/public/components/Fixed/Fixed.d.ts +0 -2
- package/public/components/Fixed/Fixed.js +0 -14
- package/public/components/Fixed/Fixed.story.d.ts +0 -1
- package/public/components/Fixed/Fixed.story.js +0 -12
- package/public/components/Fixed/index.d.ts +0 -1
- package/public/components/Fixed/index.js +0 -5
- package/public/components/Flex/Flex.story.d.ts +0 -1
- package/public/components/Flex/Flex.story.js +0 -12
- package/public/components/IntegrationLogo/IntegrationLogo.d.ts +0 -10
- package/public/components/IntegrationLogo/IntegrationLogo.js +0 -33
- package/public/components/IntegrationLogo/IntegrationLogoSvg.d.ts +0 -9
- package/public/components/IntegrationLogo/IntegrationLogoSvg.js +0 -52
- package/public/components/IntegrationLogo/index.d.ts +0 -1
- package/public/components/IntegrationLogo/index.js +0 -13
- package/public/components/IntegrationLogo/svg/addigy.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/addigy.js +0 -17
- package/public/components/IntegrationLogo/svg/aws.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/aws.js +0 -22
- package/public/components/IntegrationLogo/svg/bamboohr.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/bamboohr.js +0 -18
- package/public/components/IntegrationLogo/svg/bitbucket.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/bitbucket.js +0 -18
- package/public/components/IntegrationLogo/svg/conveyor.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/conveyor.js +0 -20
- package/public/components/IntegrationLogo/svg/default.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/default.js +0 -13
- package/public/components/IntegrationLogo/svg/deploy.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/deploy.js +0 -17
- package/public/components/IntegrationLogo/svg/events-api.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/events-api.js +0 -26
- package/public/components/IntegrationLogo/svg/gcp.d.ts +0 -3
- package/public/components/IntegrationLogo/svg/gcp.js +0 -15
- package/public/components/IntegrationLogo/svg/github.d.ts +0 -3
- package/public/components/IntegrationLogo/svg/github.js +0 -12
- package/public/components/IntegrationLogo/svg/gitlab.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/gitlab.js +0 -19
- package/public/components/IntegrationLogo/svg/gsuite.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/gsuite.js +0 -15
- package/public/components/IntegrationLogo/svg/index.d.ts +0 -21
- package/public/components/IntegrationLogo/svg/index.js +0 -54
- package/public/components/IntegrationLogo/svg/jamf.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/jamf.js +0 -20
- package/public/components/IntegrationLogo/svg/jira.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/jira.js +0 -21
- package/public/components/IntegrationLogo/svg/jumpcloud.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/jumpcloud.js +0 -28
- package/public/components/IntegrationLogo/svg/okta.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/okta.js +0 -16
- package/public/components/IntegrationLogo/svg/onelogin.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/onelogin.js +0 -18
- package/public/components/IntegrationLogo/svg/salesforce.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/salesforce.js +0 -20
- package/public/components/IntegrationLogo/svg/slack.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/slack.js +0 -19
- package/public/components/IntegrationLogo/svg/wrapper.d.ts +0 -11
- package/public/components/IntegrationLogo/svg/wrapper.js +0 -13
- package/public/components/IntegrationLogo/svg/zoom.d.ts +0 -2
- package/public/components/IntegrationLogo/svg/zoom.js +0 -23
- package/public/components/Meta/Meta.d.ts +0 -6
- package/public/components/Meta/Meta.js +0 -21
- package/public/components/Meta/Meta.story.d.ts +0 -1
- package/public/components/Meta/Meta.story.js +0 -39
- package/public/components/Meta/index.d.ts +0 -1
- package/public/components/Meta/index.js +0 -5
- package/public/components/PropertyDiff/PropertyDiff.d.ts +0 -7
- package/public/components/PropertyDiff/PropertyDiff.js +0 -22
- package/public/components/PropertyDiff/index.d.ts +0 -1
- package/public/components/PropertyDiff/index.js +0 -13
- package/public/components/Relative/Relative.d.ts +0 -2
- package/public/components/Relative/Relative.js +0 -14
- package/public/components/Relative/Relative.story.d.ts +0 -1
- package/public/components/Relative/Relative.story.js +0 -12
- package/public/components/Relative/index.d.ts +0 -1
- package/public/components/Relative/index.js +0 -5
- package/public/components/SpeechBubble/SpeechBubble.story.d.ts +0 -1
- package/public/components/SpeechBubble/SpeechBubble.story.js +0 -19
- package/public/components/StatusLabel/StatusLabel.d.ts +0 -16
- package/public/components/StatusLabel/StatusLabel.js +0 -40
- package/public/components/StatusLabel/index.d.ts +0 -1
- package/public/components/StatusLabel/index.js +0 -13
- package/public/components/StatusPanel/StatusPanel.d.ts +0 -11
- package/public/components/StatusPanel/StatusPanel.js +0 -24
- package/public/components/StatusPanel/index.d.ts +0 -1
- package/public/components/StatusPanel/index.js +0 -13
- package/public/components/Sticky/Sticky.d.ts +0 -2
- package/public/components/Sticky/Sticky.js +0 -14
- package/public/components/Sticky/Sticky.story.d.ts +0 -1
- package/public/components/Sticky/Sticky.story.js +0 -12
- package/public/components/Sticky/index.d.ts +0 -1
- package/public/components/Sticky/index.js +0 -5
- package/public/components/TopBar/TopBar.d.ts +0 -14
- package/public/components/TopBar/TopBar.js +0 -24
- package/public/components/TopBar/TopBarBreadcrumbs.d.ts +0 -10
- package/public/components/TopBar/TopBarBreadcrumbs.js +0 -34
- package/public/components/TopBar/TopBarSubNav.d.ts +0 -2
- package/public/components/TopBar/TopBarSubNav.js +0 -16
- package/public/components/TopBar/TopBarSubNavItem.d.ts +0 -5
- package/public/components/TopBar/TopBarSubNavItem.js +0 -17
- package/public/components/TopBar/index.d.ts +0 -1
- package/public/components/TopBar/index.js +0 -13
- package/public/components/VendorLogo/VendorLogo.d.ts +0 -20
- package/public/components/VendorLogo/VendorLogo.js +0 -57
- package/public/components/VendorLogo/index.d.ts +0 -1
- package/public/components/VendorLogo/index.js +0 -13
- package/public/storybook-components/TailwindPropertyClasses.d.ts +0 -9
- package/public/storybook-components/TailwindPropertyClasses.js +0 -194
- package/public/tailwind.config.d.ts +0 -1
- package/public/tailwind.config.js +0 -4
- package/public/tokens/_tailwind-config.d.ts +0 -810
- package/public/tokens/_tailwind-config.js +0 -50
- package/src/components/Absolute/Absolute.story.mdx +0 -26
- package/src/components/Absolute/Absolute.tsx +0 -9
- package/src/components/Absolute/index.ts +0 -1
- package/src/components/Appbar/Appbar.story.mdx +0 -118
- package/src/components/Appbar/Appbar.tsx +0 -64
- package/src/components/Appbar/AppbarLogo.tsx +0 -29
- package/src/components/Appbar/AppbarTabs.tsx +0 -47
- package/src/components/Appbar/AppbarUser.tsx +0 -144
- package/src/components/Appbar/config.ts +0 -12
- package/src/components/Appbar/index.css +0 -203
- package/src/components/Appbar/index.ts +0 -1
- package/src/components/ArrowButton/ArrowButton.story.mdx +0 -110
- package/src/components/ArrowButton/ArrowButton.tsx +0 -54
- package/src/components/ArrowButton/index.css +0 -42
- package/src/components/ArrowButton/index.ts +0 -1
- package/src/components/ArrowLink/ArrowLink.story.mdx +0 -65
- package/src/components/ArrowLink/ArrowLink.tsx +0 -42
- package/src/components/ArrowLink/index.ts +0 -1
- package/src/components/Aside/Aside.story.mdx +0 -65
- package/src/components/Aside/Aside.tsx +0 -59
- package/src/components/Aside/index.css +0 -11
- package/src/components/Aside/index.ts +0 -1
- package/src/components/Fixed/Fixed.md +0 -16
- package/src/components/Fixed/Fixed.story.tsx +0 -12
- package/src/components/Fixed/Fixed.tsx +0 -9
- package/src/components/Fixed/index.ts +0 -1
- package/src/components/Flex/Flex.md +0 -14
- package/src/components/Flex/Flex.story.tsx +0 -12
- package/src/components/IntegrationLogo/IntegrationLogo.story.mdx +0 -159
- package/src/components/IntegrationLogo/IntegrationLogo.tsx +0 -54
- package/src/components/IntegrationLogo/IntegrationLogoSvg.tsx +0 -79
- package/src/components/IntegrationLogo/index.ts +0 -1
- package/src/components/IntegrationLogo/svg/addigy.tsx +0 -23
- package/src/components/IntegrationLogo/svg/aws.tsx +0 -52
- package/src/components/IntegrationLogo/svg/bamboohr.tsx +0 -34
- package/src/components/IntegrationLogo/svg/bitbucket.tsx +0 -37
- package/src/components/IntegrationLogo/svg/conveyor.tsx +0 -41
- package/src/components/IntegrationLogo/svg/default.tsx +0 -11
- package/src/components/IntegrationLogo/svg/deploy.tsx +0 -29
- package/src/components/IntegrationLogo/svg/events-api.tsx +0 -75
- package/src/components/IntegrationLogo/svg/gcp.tsx +0 -26
- package/src/components/IntegrationLogo/svg/github.tsx +0 -14
- package/src/components/IntegrationLogo/svg/gitlab.tsx +0 -40
- package/src/components/IntegrationLogo/svg/gsuite.tsx +0 -24
- package/src/components/IntegrationLogo/svg/index.ts +0 -21
- package/src/components/IntegrationLogo/svg/jamf.tsx +0 -36
- package/src/components/IntegrationLogo/svg/jira.tsx +0 -44
- package/src/components/IntegrationLogo/svg/jumpcloud.tsx +0 -86
- package/src/components/IntegrationLogo/svg/okta.tsx +0 -28
- package/src/components/IntegrationLogo/svg/onelogin.tsx +0 -34
- package/src/components/IntegrationLogo/svg/salesforce.tsx +0 -39
- package/src/components/IntegrationLogo/svg/slack.tsx +0 -40
- package/src/components/IntegrationLogo/svg/wrapper.tsx +0 -35
- package/src/components/IntegrationLogo/svg/zoom.tsx +0 -51
- package/src/components/Meta/Meta.md +0 -14
- package/src/components/Meta/Meta.story.tsx +0 -24
- package/src/components/Meta/Meta.tsx +0 -26
- package/src/components/Meta/index.ts +0 -1
- package/src/components/PropertyDiff/PropertDiff.story.mdx +0 -46
- package/src/components/PropertyDiff/PropertyDiff.tsx +0 -48
- package/src/components/PropertyDiff/index.css +0 -33
- package/src/components/PropertyDiff/index.ts +0 -1
- package/src/components/Relative/Relative.md +0 -16
- package/src/components/Relative/Relative.story.tsx +0 -12
- package/src/components/Relative/Relative.tsx +0 -9
- package/src/components/Relative/index.ts +0 -1
- package/src/components/SpeechBubble/SpeechBubble.md +0 -14
- package/src/components/SpeechBubble/SpeechBubble.story.tsx +0 -26
- package/src/components/StatusLabel/StatusLabel.story.mdx +0 -316
- package/src/components/StatusLabel/StatusLabel.tsx +0 -112
- package/src/components/StatusLabel/index.css +0 -23
- package/src/components/StatusLabel/index.ts +0 -1
- package/src/components/StatusPanel/StatusPanel.story.mdx +0 -109
- package/src/components/StatusPanel/StatusPanel.tsx +0 -51
- package/src/components/StatusPanel/index.css +0 -52
- package/src/components/StatusPanel/index.ts +0 -1
- package/src/components/Sticky/Sticky.md +0 -16
- package/src/components/Sticky/Sticky.story.tsx +0 -12
- package/src/components/Sticky/Sticky.tsx +0 -9
- package/src/components/Sticky/index.ts +0 -1
- package/src/components/TopBar/TopBar.story.mdx +0 -154
- package/src/components/TopBar/TopBar.tsx +0 -40
- package/src/components/TopBar/TopBarBreadcrumbs.tsx +0 -79
- package/src/components/TopBar/TopBarSubNav.tsx +0 -19
- package/src/components/TopBar/TopBarSubNavItem.tsx +0 -21
- package/src/components/TopBar/index.css +0 -102
- package/src/components/TopBar/index.ts +0 -1
- package/src/components/VendorLogo/VendorLogo.story.mdx +0 -209
- package/src/components/VendorLogo/VendorLogo.tsx +0 -110
- package/src/components/VendorLogo/index.css +0 -46
- package/src/components/VendorLogo/index.ts +0 -1
- package/src/docs/TailwindClasses.story.mdx +0 -15
- package/src/docs/brand-components/BrandButton.story.mdx +0 -103
- package/src/docs/brand-components/BrandCheckbox.story.mdx +0 -63
- package/src/docs/brand-components/BrandFormGroup.story.mdx +0 -76
- package/src/docs/brand-components/BrandInput.story.mdx +0 -41
- package/src/docs/brand-components/BrandRadio.story.mdx +0 -45
- package/src/docs/brand-components/BrandTextArea.story.mdx +0 -41
- package/src/storybook-components/TailwindPropertyClasses.tsx +0 -285
- package/src/tailwind.config.ts +0 -6
- package/src/tokens/_tailwind-config.ts +0 -69
|
@@ -10,7 +10,7 @@ import { ORIENTATION } from "../../types";
|
|
|
10
10
|
import { Button } from "../Button";
|
|
11
11
|
import { ICON_TYPE } from "../Icon";
|
|
12
12
|
import { Stack } from "../Stack";
|
|
13
|
-
import { Snackbar, useSnackbar, showSnackbar } from "./
|
|
13
|
+
import { Snackbar, useSnackbar, showSnackbar, useSnackbarContext } from "./";
|
|
14
14
|
|
|
15
15
|
<Meta title="Components/Feedback/Snackbar" component={Snackbar} />
|
|
16
16
|
|
|
@@ -27,13 +27,25 @@ The Snackbar component doesn’t get called directly. Instead use either
|
|
|
27
27
|
on-screen. You will need a way to dynamically set the `isVisible` prop in order
|
|
28
28
|
to show and hide the Snackbar on demand.
|
|
29
29
|
|
|
30
|
-
The Snackbar
|
|
31
|
-
configurable.
|
|
30
|
+
The Snackbar can appear at either the bottom-left or bottom-right of the screen.
|
|
32
31
|
|
|
33
32
|
```jsx
|
|
34
33
|
import { useSnackbar, showSnackbar } from "@conveyorhq/arrow-ds";
|
|
35
34
|
```
|
|
36
35
|
|
|
36
|
+
export const CustomSnackbar = ({ children }) => {
|
|
37
|
+
const { onClose } = useSnackbarContext();
|
|
38
|
+
return (
|
|
39
|
+
<div
|
|
40
|
+
className="rounded p-10 bg-gold-200 m-4 leading-normal"
|
|
41
|
+
onClick={onClose}
|
|
42
|
+
>
|
|
43
|
+
<p>{children}</p>
|
|
44
|
+
<p>Click anywhere to close</p>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
37
49
|
Here is a preview of how the Snackbar could look in its three different states.
|
|
38
50
|
Don’t copy these examples because a Snackbar should be implemented using the
|
|
39
51
|
`useSnackbar` hook, which is detailed below.
|
|
@@ -121,7 +133,7 @@ A duration can be used with an action if necessary.
|
|
|
121
133
|
},
|
|
122
134
|
});
|
|
123
135
|
};
|
|
124
|
-
return <Button onClick={onClick}>Show Snackbar</Button>;
|
|
136
|
+
return <Button onClick={onClick}>Show Snackbar with action</Button>;
|
|
125
137
|
}}
|
|
126
138
|
</Story>
|
|
127
139
|
</Preview>
|
|
@@ -142,12 +154,12 @@ hide the Snackbar with `useState` and `setTimeout`.
|
|
|
142
154
|
}, 3000);
|
|
143
155
|
};
|
|
144
156
|
useSnackbar({
|
|
145
|
-
message: "
|
|
157
|
+
message: "Snackbar triggered from a hook",
|
|
146
158
|
isVisible,
|
|
147
159
|
});
|
|
148
160
|
return (
|
|
149
161
|
<Button disabled={isVisible} onClick={onClick}>
|
|
150
|
-
|
|
162
|
+
Use Snackbar
|
|
151
163
|
</Button>
|
|
152
164
|
);
|
|
153
165
|
}}
|
|
@@ -201,10 +213,85 @@ happening is done.
|
|
|
201
213
|
</Story>
|
|
202
214
|
</Preview>
|
|
203
215
|
|
|
204
|
-
##
|
|
216
|
+
## Using a custom component
|
|
217
|
+
|
|
218
|
+
If you need Snackbar functionality, but would like to use a custom UI, you can
|
|
219
|
+
pass a `ReactNode` to the `component` prop. Note that you will need to handle
|
|
220
|
+
closing of the Snackbar on your own, but that’s made easy using the context
|
|
221
|
+
provider.
|
|
222
|
+
|
|
223
|
+
<Preview withSource={SourceState.OPEN}>
|
|
224
|
+
<Story name="showSnackbar function with a component">
|
|
225
|
+
{() => {
|
|
226
|
+
const CustomSnackbar = ({ children }) => {
|
|
227
|
+
const { onClose } = useSnackbarContext();
|
|
228
|
+
return (
|
|
229
|
+
<div
|
|
230
|
+
className="rounded p-10 bg-gold-200 m-4 leading-normal"
|
|
231
|
+
onClick={onClose}
|
|
232
|
+
>
|
|
233
|
+
<p>{children}</p>
|
|
234
|
+
<p>Click anywhere to close</p>
|
|
235
|
+
</div>
|
|
236
|
+
);
|
|
237
|
+
};
|
|
238
|
+
const onClick = () => {
|
|
239
|
+
showSnackbar({
|
|
240
|
+
component: (
|
|
241
|
+
<CustomSnackbar>
|
|
242
|
+
I am a custom snackbar without a duration
|
|
243
|
+
</CustomSnackbar>
|
|
244
|
+
),
|
|
245
|
+
position: "bottom-right",
|
|
246
|
+
});
|
|
247
|
+
};
|
|
248
|
+
return <Button onClick={onClick}>Show Custom Snackbar</Button>;
|
|
249
|
+
}}
|
|
250
|
+
</Story>
|
|
251
|
+
</Preview>
|
|
252
|
+
|
|
253
|
+
A custom component can also be used with the `useSnackbar` hook.
|
|
205
254
|
|
|
206
|
-
<
|
|
255
|
+
<Preview withSource={SourceState.OPEN}>
|
|
256
|
+
<Story name="useSnackbar hook with a component">
|
|
257
|
+
{() => {
|
|
258
|
+
const CustomSnackbar = ({ children }) => {
|
|
259
|
+
const { onClose } = useSnackbarContext();
|
|
260
|
+
return (
|
|
261
|
+
<div
|
|
262
|
+
className="rounded p-10 bg-gold-200 m-4 leading-normal"
|
|
263
|
+
onClick={onClose}
|
|
264
|
+
>
|
|
265
|
+
<p>{children}</p>
|
|
266
|
+
<p>Click anywhere to close</p>
|
|
267
|
+
</div>
|
|
268
|
+
);
|
|
269
|
+
};
|
|
270
|
+
const [isVisible, setVisible] = React.useState(false);
|
|
271
|
+
useSnackbar({
|
|
272
|
+
component: (
|
|
273
|
+
<CustomSnackbar>
|
|
274
|
+
I am a custom snackbar and will close in 3 seconds
|
|
275
|
+
</CustomSnackbar>
|
|
276
|
+
),
|
|
277
|
+
position: "bottom-right",
|
|
278
|
+
isVisible,
|
|
279
|
+
});
|
|
280
|
+
const onClick = () => {
|
|
281
|
+
setVisible(true);
|
|
282
|
+
setTimeout(() => {
|
|
283
|
+
setVisible(false);
|
|
284
|
+
}, 3000);
|
|
285
|
+
};
|
|
286
|
+
return (
|
|
287
|
+
<Button disabled={isVisible} onClick={onClick}>
|
|
288
|
+
Use Custom Snackbar
|
|
289
|
+
</Button>
|
|
290
|
+
);
|
|
291
|
+
}}
|
|
292
|
+
</Story>
|
|
293
|
+
</Preview>
|
|
207
294
|
|
|
208
|
-
##
|
|
295
|
+
## API
|
|
209
296
|
|
|
210
297
|
<Props of={showSnackbar} />
|
|
@@ -1,69 +1,46 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import toaster from "toasted-notes";
|
|
1
|
+
import React from "react";
|
|
3
2
|
import classNames from "classnames";
|
|
4
3
|
import { Action } from "../../types";
|
|
5
4
|
import { bemHOF } from "../../utilities/bem";
|
|
6
5
|
import { Box } from "../Box";
|
|
7
6
|
import { CloseButton } from "../CloseButton";
|
|
8
|
-
import { Icon,
|
|
7
|
+
import { Icon, ICON_TYPE } from "../Icon";
|
|
9
8
|
import { Link } from "../Link";
|
|
10
9
|
import { Text } from "../Text";
|
|
10
|
+
import { useSnackbarContext } from "./context";
|
|
11
|
+
import {
|
|
12
|
+
SnackbarProps,
|
|
13
|
+
SnackbarRootProps,
|
|
14
|
+
SnackbarIconProps,
|
|
15
|
+
SnackbarTextProps,
|
|
16
|
+
} from "./types";
|
|
17
|
+
import { SnackbarProvider } from "./SnackbarProvider";
|
|
11
18
|
|
|
12
19
|
const cn = bemHOF("Snackbar");
|
|
13
20
|
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
*/
|
|
24
|
-
action?: Action;
|
|
25
|
-
/**
|
|
26
|
-
* When a loading icon is detected, it will automatically spin.
|
|
27
|
-
*
|
|
28
|
-
* Sizing is handled automatically, too.
|
|
29
|
-
*/
|
|
30
|
-
icon?: ICON_TYPE;
|
|
31
|
-
/**
|
|
32
|
-
* The amount of time (in milliseconds) the snackbar appears on-screen. If
|
|
33
|
-
* undefined, then the Snackbar will stay on-screen indefinitely. An undefined
|
|
34
|
-
* duration would be used in cases when the Snackbar is used as a loading
|
|
35
|
-
* message (e.g., an in progress API call).
|
|
36
|
-
*/
|
|
37
|
-
duration?: number | null;
|
|
38
|
-
/**
|
|
39
|
-
* Prevent the close button from rendering. Useful in cases when the Snackbar
|
|
40
|
-
* is used as a loading message (e.g., an in progress API call).
|
|
41
|
-
*/
|
|
42
|
-
disableClose?: boolean;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
interface ShowSnackbarProps extends SharedProps {
|
|
46
|
-
/**
|
|
47
|
-
* Classname to apply to the Snackbar root element
|
|
48
|
-
*/
|
|
49
|
-
className?: string;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
interface SnackbarProps extends ShowSnackbarProps {
|
|
53
|
-
onClose: () => void;
|
|
54
|
-
id?: string;
|
|
55
|
-
}
|
|
21
|
+
export const SnackbarRoot = ({
|
|
22
|
+
children,
|
|
23
|
+
className,
|
|
24
|
+
...rest
|
|
25
|
+
}: SnackbarRootProps) => (
|
|
26
|
+
<Box className={classNames(cn(), className)} {...rest}>
|
|
27
|
+
{children}
|
|
28
|
+
</Box>
|
|
29
|
+
);
|
|
56
30
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
31
|
+
export const SnackbarIcon = ({ icon }: SnackbarIconProps) => (
|
|
32
|
+
<Icon
|
|
33
|
+
icon={icon}
|
|
34
|
+
spin={icon === ICON_TYPE.SPINNER || icon === ICON_TYPE.CIRCLE_NOTCH}
|
|
35
|
+
className={cn({ e: "icon" })}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
63
38
|
|
|
64
|
-
const
|
|
39
|
+
export const SnackbarText = ({ children }: SnackbarTextProps) => (
|
|
40
|
+
<Text>{children}</Text>
|
|
41
|
+
);
|
|
65
42
|
|
|
66
|
-
const SnackbarAction = ({ label, onClick, href, external }: Action) => {
|
|
43
|
+
export const SnackbarAction = ({ label, onClick, href, external }: Action) => {
|
|
67
44
|
const Component = typeof onClick === "function" ? "button" : "a";
|
|
68
45
|
const type = Component === "button" ? "button" : undefined;
|
|
69
46
|
|
|
@@ -81,27 +58,33 @@ const SnackbarAction = ({ label, onClick, href, external }: Action) => {
|
|
|
81
58
|
);
|
|
82
59
|
};
|
|
83
60
|
|
|
61
|
+
export const SnackbarCloseButton = () => {
|
|
62
|
+
const { onClose } = useSnackbarContext();
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<CloseButton
|
|
66
|
+
className={classNames(cn({ e: "dismiss" }))}
|
|
67
|
+
onClick={onClose}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
84
72
|
export const Snackbar = ({
|
|
85
73
|
message,
|
|
86
74
|
action,
|
|
87
75
|
icon,
|
|
88
|
-
id,
|
|
89
76
|
className,
|
|
90
|
-
onClose,
|
|
91
77
|
disableClose,
|
|
78
|
+
...rest
|
|
92
79
|
}: SnackbarProps) => {
|
|
93
|
-
const
|
|
94
|
-
const iconProps: IconProps | undefined = icon
|
|
95
|
-
? {
|
|
96
|
-
icon,
|
|
97
|
-
spin,
|
|
98
|
-
}
|
|
99
|
-
: undefined;
|
|
80
|
+
const { onClose } = useSnackbarContext();
|
|
100
81
|
|
|
101
82
|
return (
|
|
102
|
-
<
|
|
103
|
-
{
|
|
104
|
-
|
|
83
|
+
<SnackbarRoot className={className} {...rest}>
|
|
84
|
+
{icon && <SnackbarIcon icon={icon} />}
|
|
85
|
+
|
|
86
|
+
{message && <SnackbarText>{message}</SnackbarText>}
|
|
87
|
+
|
|
105
88
|
{action && action.label && (
|
|
106
89
|
<SnackbarAction
|
|
107
90
|
{...action}
|
|
@@ -113,86 +96,14 @@ export const Snackbar = ({
|
|
|
113
96
|
}}
|
|
114
97
|
/>
|
|
115
98
|
)}
|
|
116
|
-
{!disableClose && (
|
|
117
|
-
<CloseButton
|
|
118
|
-
className={classNames(cn({ e: "dismiss" }))}
|
|
119
|
-
onClick={onClose}
|
|
120
|
-
/>
|
|
121
|
-
)}
|
|
122
|
-
</Box>
|
|
123
|
-
);
|
|
124
|
-
};
|
|
125
99
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
action,
|
|
129
|
-
icon,
|
|
130
|
-
duration = null,
|
|
131
|
-
className,
|
|
132
|
-
disableClose,
|
|
133
|
-
}: ShowSnackbarProps) =>
|
|
134
|
-
toaster.notify(
|
|
135
|
-
({ onClose, id }: { onClose: () => void; id: number }) => {
|
|
136
|
-
return (
|
|
137
|
-
<Snackbar
|
|
138
|
-
{...{
|
|
139
|
-
message,
|
|
140
|
-
onClose,
|
|
141
|
-
action,
|
|
142
|
-
icon,
|
|
143
|
-
className,
|
|
144
|
-
disableClose,
|
|
145
|
-
id: `snackbar-component-${id}`,
|
|
146
|
-
}}
|
|
147
|
-
/>
|
|
148
|
-
);
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
position: POSITION,
|
|
152
|
-
duration,
|
|
153
|
-
},
|
|
100
|
+
{!disableClose && <SnackbarCloseButton />}
|
|
101
|
+
</SnackbarRoot>
|
|
154
102
|
);
|
|
155
|
-
|
|
156
|
-
export const useSnackbar = ({
|
|
157
|
-
message,
|
|
158
|
-
action,
|
|
159
|
-
isVisible,
|
|
160
|
-
icon,
|
|
161
|
-
duration,
|
|
162
|
-
disableClose,
|
|
163
|
-
}: SnackbarHookProps) => {
|
|
164
|
-
const [snackbar, setSnackbar] = useState<{ id: number; position: string }>({
|
|
165
|
-
id: 0,
|
|
166
|
-
position: POSITION,
|
|
167
|
-
});
|
|
168
|
-
const [wasViewed, setWasViewed] = useState<boolean>(false);
|
|
169
|
-
|
|
170
|
-
useEffect(() => {
|
|
171
|
-
if (isVisible && !wasViewed) {
|
|
172
|
-
setSnackbar(
|
|
173
|
-
showSnackbar({
|
|
174
|
-
message,
|
|
175
|
-
action,
|
|
176
|
-
icon,
|
|
177
|
-
duration,
|
|
178
|
-
disableClose,
|
|
179
|
-
}),
|
|
180
|
-
);
|
|
181
|
-
setWasViewed(true);
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (!isVisible && wasViewed) {
|
|
185
|
-
hideSnackbar(snackbar.id);
|
|
186
|
-
setWasViewed(false);
|
|
187
|
-
}
|
|
188
|
-
}, [
|
|
189
|
-
message,
|
|
190
|
-
action,
|
|
191
|
-
isVisible,
|
|
192
|
-
icon,
|
|
193
|
-
duration,
|
|
194
|
-
disableClose,
|
|
195
|
-
snackbar,
|
|
196
|
-
wasViewed,
|
|
197
|
-
]);
|
|
198
103
|
};
|
|
104
|
+
|
|
105
|
+
Snackbar.Provider = SnackbarProvider;
|
|
106
|
+
Snackbar.Root = SnackbarRoot;
|
|
107
|
+
Snackbar.Text = SnackbarText;
|
|
108
|
+
Snackbar.Action = SnackbarAction;
|
|
109
|
+
Snackbar.CloseButton = SnackbarCloseButton;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box } from "../Box";
|
|
3
|
+
import { SnackbarProviderProps } from "./types";
|
|
4
|
+
import { DEFAULT_SNACKBAR_ID } from "./constants";
|
|
5
|
+
import { SnackbarContext } from "./context";
|
|
6
|
+
|
|
7
|
+
export const SnackbarProvider = ({
|
|
8
|
+
component,
|
|
9
|
+
id = DEFAULT_SNACKBAR_ID,
|
|
10
|
+
onClose,
|
|
11
|
+
duration,
|
|
12
|
+
position,
|
|
13
|
+
...rest
|
|
14
|
+
}: SnackbarProviderProps) => {
|
|
15
|
+
const componentId = "snackbar-provider";
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<SnackbarContext.Provider
|
|
19
|
+
value={{
|
|
20
|
+
id,
|
|
21
|
+
onClose,
|
|
22
|
+
duration,
|
|
23
|
+
position,
|
|
24
|
+
}}
|
|
25
|
+
>
|
|
26
|
+
<Box id={`${componentId}-${id}`} data-component={componentId} {...rest}>
|
|
27
|
+
{component}
|
|
28
|
+
</Box>
|
|
29
|
+
</SnackbarContext.Provider>
|
|
30
|
+
);
|
|
31
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Context, createContext, useContext } from "react";
|
|
2
|
+
import { SnackbarContextProps } from "./types";
|
|
3
|
+
import { DEFAULT_SNACKBAR_ID } from "./constants";
|
|
4
|
+
|
|
5
|
+
const defaultContext: SnackbarContextProps = {
|
|
6
|
+
id: DEFAULT_SNACKBAR_ID,
|
|
7
|
+
onClose: () => {},
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export const SnackbarContext: Context<SnackbarContextProps> = createContext<SnackbarContextProps>(
|
|
11
|
+
defaultContext,
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
export function useSnackbarContext() {
|
|
15
|
+
const context = useContext<typeof defaultContext>(SnackbarContext) || {
|
|
16
|
+
...defaultContext,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return context;
|
|
20
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import toaster from "toasted-notes";
|
|
3
|
+
import { DEFAULT_SNACKBAR_POSITION } from "./constants";
|
|
4
|
+
import { Snackbar } from "./Snackbar";
|
|
5
|
+
import { SnackbarProvider } from "./SnackbarProvider";
|
|
6
|
+
import {
|
|
7
|
+
HideSnackbarProps,
|
|
8
|
+
SnackbarToasterProps,
|
|
9
|
+
ShowSnackbarProps,
|
|
10
|
+
} from "./types";
|
|
11
|
+
|
|
12
|
+
export const hideSnackbar = ({
|
|
13
|
+
id,
|
|
14
|
+
position = DEFAULT_SNACKBAR_POSITION,
|
|
15
|
+
}: HideSnackbarProps) => toaster.close(id, position);
|
|
16
|
+
|
|
17
|
+
export const showSnackbar = ({
|
|
18
|
+
component,
|
|
19
|
+
message,
|
|
20
|
+
duration = null,
|
|
21
|
+
position = DEFAULT_SNACKBAR_POSITION,
|
|
22
|
+
...rest
|
|
23
|
+
}: ShowSnackbarProps) => {
|
|
24
|
+
return toaster.notify(
|
|
25
|
+
({ onClose, id }: SnackbarToasterProps) => {
|
|
26
|
+
return (
|
|
27
|
+
<SnackbarProvider
|
|
28
|
+
{...{
|
|
29
|
+
id,
|
|
30
|
+
onClose,
|
|
31
|
+
duration,
|
|
32
|
+
position,
|
|
33
|
+
component: message ? (
|
|
34
|
+
<Snackbar
|
|
35
|
+
{...{
|
|
36
|
+
message,
|
|
37
|
+
...rest,
|
|
38
|
+
}}
|
|
39
|
+
/>
|
|
40
|
+
) : (
|
|
41
|
+
component
|
|
42
|
+
),
|
|
43
|
+
}}
|
|
44
|
+
/>
|
|
45
|
+
);
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
position,
|
|
49
|
+
duration,
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { DEFAULT_SNACKBAR_ID, DEFAULT_SNACKBAR_POSITION } from "./constants";
|
|
3
|
+
import { hideSnackbar, showSnackbar } from "./helpers";
|
|
4
|
+
import { SnackbarHookProps, SnackbarStateProps } from "./types";
|
|
5
|
+
|
|
6
|
+
export const useSnackbar = ({
|
|
7
|
+
component,
|
|
8
|
+
message,
|
|
9
|
+
position,
|
|
10
|
+
duration,
|
|
11
|
+
isVisible,
|
|
12
|
+
...rest
|
|
13
|
+
}: SnackbarHookProps) => {
|
|
14
|
+
const [snackbar, setSnackbar] = useState<SnackbarStateProps>({
|
|
15
|
+
id: DEFAULT_SNACKBAR_ID,
|
|
16
|
+
position: DEFAULT_SNACKBAR_POSITION,
|
|
17
|
+
});
|
|
18
|
+
const [wasViewed, setWasViewed] = useState<boolean>(false);
|
|
19
|
+
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
if (isVisible && !wasViewed) {
|
|
22
|
+
if (message) {
|
|
23
|
+
setSnackbar(
|
|
24
|
+
showSnackbar({
|
|
25
|
+
message,
|
|
26
|
+
position,
|
|
27
|
+
duration,
|
|
28
|
+
...rest,
|
|
29
|
+
}),
|
|
30
|
+
);
|
|
31
|
+
} else {
|
|
32
|
+
setSnackbar(
|
|
33
|
+
showSnackbar({
|
|
34
|
+
component,
|
|
35
|
+
position,
|
|
36
|
+
duration,
|
|
37
|
+
}),
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
setWasViewed(true);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (!isVisible && wasViewed) {
|
|
44
|
+
hideSnackbar({ id: snackbar.id, position });
|
|
45
|
+
setWasViewed(false);
|
|
46
|
+
}
|
|
47
|
+
}, [
|
|
48
|
+
component,
|
|
49
|
+
message,
|
|
50
|
+
position,
|
|
51
|
+
duration,
|
|
52
|
+
isVisible,
|
|
53
|
+
snackbar.id,
|
|
54
|
+
wasViewed,
|
|
55
|
+
rest,
|
|
56
|
+
]);
|
|
57
|
+
};
|