@redsift/popovers 8.0.1 → 8.0.2

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.
Files changed (185) hide show
  1. package/{dist/index.js.map → index.js.map} +1 -1
  2. package/package.json +3 -2
  3. package/coverage/clover.xml +0 -738
  4. package/coverage/coverage-final.json +0 -53
  5. package/coverage/lcov-report/Tooltip.tsx.html +0 -235
  6. package/coverage/lcov-report/TooltipContent.tsx.html +0 -235
  7. package/coverage/lcov-report/TooltipTrigger.tsx.html +0 -241
  8. package/coverage/lcov-report/base.css +0 -224
  9. package/coverage/lcov-report/block-navigation.js +0 -87
  10. package/coverage/lcov-report/context.ts.html +0 -97
  11. package/coverage/lcov-report/dialog/Dialog.tsx.html +0 -271
  12. package/coverage/lcov-report/dialog/context.ts.html +0 -97
  13. package/coverage/lcov-report/dialog/index.html +0 -191
  14. package/coverage/lcov-report/dialog/index.ts.html +0 -100
  15. package/coverage/lcov-report/dialog/types.ts.html +0 -253
  16. package/coverage/lcov-report/dialog/useDialog.tsx.html +0 -346
  17. package/coverage/lcov-report/dialog/useDialogContext.tsx.html +0 -121
  18. package/coverage/lcov-report/dialog-content/DialogContent.tsx.html +0 -487
  19. package/coverage/lcov-report/dialog-content/index.html +0 -146
  20. package/coverage/lcov-report/dialog-content/index.ts.html +0 -91
  21. package/coverage/lcov-report/dialog-content/intl/index.html +0 -116
  22. package/coverage/lcov-report/dialog-content/intl/index.ts.html +0 -106
  23. package/coverage/lcov-report/dialog-content/styles.ts.html +0 -301
  24. package/coverage/lcov-report/dialog-content-actions/DialogContentActions.tsx.html +0 -205
  25. package/coverage/lcov-report/dialog-content-actions/index.html +0 -146
  26. package/coverage/lcov-report/dialog-content-actions/index.ts.html +0 -91
  27. package/coverage/lcov-report/dialog-content-actions/styles.ts.html +0 -139
  28. package/coverage/lcov-report/dialog-content-body/DialogContentBody.tsx.html +0 -232
  29. package/coverage/lcov-report/dialog-content-body/index.html +0 -146
  30. package/coverage/lcov-report/dialog-content-body/index.ts.html +0 -91
  31. package/coverage/lcov-report/dialog-content-body/styles.ts.html +0 -259
  32. package/coverage/lcov-report/dialog-content-header/DialogContentHeader.tsx.html +0 -328
  33. package/coverage/lcov-report/dialog-content-header/index.html +0 -146
  34. package/coverage/lcov-report/dialog-content-header/index.ts.html +0 -91
  35. package/coverage/lcov-report/dialog-content-header/styles.ts.html +0 -193
  36. package/coverage/lcov-report/dialog-trigger/DialogTrigger.tsx.html +0 -214
  37. package/coverage/lcov-report/dialog-trigger/index.html +0 -131
  38. package/coverage/lcov-report/dialog-trigger/index.ts.html +0 -91
  39. package/coverage/lcov-report/favicon.png +0 -0
  40. package/coverage/lcov-report/index.html +0 -341
  41. package/coverage/lcov-report/index.ts.html +0 -97
  42. package/coverage/lcov-report/popover/Popover.tsx.html +0 -244
  43. package/coverage/lcov-report/popover/context.ts.html +0 -97
  44. package/coverage/lcov-report/popover/index.html +0 -191
  45. package/coverage/lcov-report/popover/index.ts.html +0 -100
  46. package/coverage/lcov-report/popover/types.ts.html +0 -244
  47. package/coverage/lcov-report/popover/usePopover.tsx.html +0 -295
  48. package/coverage/lcov-report/popover/usePopoverContext.tsx.html +0 -121
  49. package/coverage/lcov-report/popover-content/PopoverContent.tsx.html +0 -268
  50. package/coverage/lcov-report/popover-content/index.html +0 -146
  51. package/coverage/lcov-report/popover-content/index.ts.html +0 -91
  52. package/coverage/lcov-report/popover-content/styles.ts.html +0 -166
  53. package/coverage/lcov-report/popover-trigger/PopoverTrigger.tsx.html +0 -214
  54. package/coverage/lcov-report/popover-trigger/index.html +0 -131
  55. package/coverage/lcov-report/popover-trigger/index.ts.html +0 -91
  56. package/coverage/lcov-report/prettify.css +0 -1
  57. package/coverage/lcov-report/prettify.js +0 -2
  58. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  59. package/coverage/lcov-report/sorter.js +0 -196
  60. package/coverage/lcov-report/styles.ts.html +0 -391
  61. package/coverage/lcov-report/toast/Toast.tsx.html +0 -451
  62. package/coverage/lcov-report/toast/index.html +0 -161
  63. package/coverage/lcov-report/toast/index.ts.html +0 -91
  64. package/coverage/lcov-report/toast/intl/index.html +0 -116
  65. package/coverage/lcov-report/toast/intl/index.ts.html +0 -106
  66. package/coverage/lcov-report/toast/styles.ts.html +0 -214
  67. package/coverage/lcov-report/toast/types.ts.html +0 -217
  68. package/coverage/lcov-report/toast-container/ToastContainer.tsx.html +0 -217
  69. package/coverage/lcov-report/toast-container/index.html +0 -161
  70. package/coverage/lcov-report/toast-container/index.ts.html +0 -94
  71. package/coverage/lcov-report/toast-container/styles.ts.html +0 -2323
  72. package/coverage/lcov-report/toast-container/useToast.tsx.html +0 -469
  73. package/coverage/lcov-report/toast-provider/ToastProvider.tsx.html +0 -256
  74. package/coverage/lcov-report/toast-provider/context.ts.html +0 -106
  75. package/coverage/lcov-report/toast-provider/index.html +0 -161
  76. package/coverage/lcov-report/toast-provider/index.ts.html +0 -97
  77. package/coverage/lcov-report/toast-provider/useToast.tsx.html +0 -109
  78. package/coverage/lcov-report/tooltip/Tooltip.tsx.html +0 -250
  79. package/coverage/lcov-report/tooltip/context.ts.html +0 -97
  80. package/coverage/lcov-report/tooltip/index.html +0 -191
  81. package/coverage/lcov-report/tooltip/index.ts.html +0 -100
  82. package/coverage/lcov-report/tooltip/types.ts.html +0 -250
  83. package/coverage/lcov-report/tooltip/useTooltip.tsx.html +0 -352
  84. package/coverage/lcov-report/tooltip/useTooltipContext.tsx.html +0 -121
  85. package/coverage/lcov-report/tooltip-content/TooltipContent.tsx.html +0 -313
  86. package/coverage/lcov-report/tooltip-content/index.html +0 -146
  87. package/coverage/lcov-report/tooltip-content/index.ts.html +0 -91
  88. package/coverage/lcov-report/tooltip-content/styles.ts.html +0 -337
  89. package/coverage/lcov-report/tooltip-trigger/TooltipTrigger.tsx.html +0 -211
  90. package/coverage/lcov-report/tooltip-trigger/index.html +0 -131
  91. package/coverage/lcov-report/tooltip-trigger/index.ts.html +0 -91
  92. package/coverage/lcov-report/types.ts.html +0 -226
  93. package/coverage/lcov-report/useTooltip.tsx.html +0 -277
  94. package/coverage/lcov-report/useTooltipContext.tsx.html +0 -121
  95. package/coverage/lcov-report/useTooltipOpen.tsx.html +0 -559
  96. package/coverage/lcov.info +0 -1330
  97. package/dist/package.json +0 -96
  98. package/index.ts +0 -1
  99. package/jest.config.js +0 -3
  100. package/rollup.config.js +0 -13
  101. package/src/components/dialog/Dialog.stories.tsx +0 -201
  102. package/src/components/dialog/Dialog.test.tsx +0 -116
  103. package/src/components/dialog/Dialog.tsx +0 -62
  104. package/src/components/dialog/context.ts +0 -4
  105. package/src/components/dialog/index.ts +0 -5
  106. package/src/components/dialog/types.ts +0 -56
  107. package/src/components/dialog/useDialog.tsx +0 -87
  108. package/src/components/dialog/useDialogContext.tsx +0 -12
  109. package/src/components/dialog-content/DialogContent.stories.tsx +0 -337
  110. package/src/components/dialog-content/DialogContent.tsx +0 -134
  111. package/src/components/dialog-content/index.ts +0 -2
  112. package/src/components/dialog-content/intl/en-US.json +0 -3
  113. package/src/components/dialog-content/intl/fr-FR.json +0 -3
  114. package/src/components/dialog-content/intl/index.ts +0 -7
  115. package/src/components/dialog-content/styles.ts +0 -72
  116. package/src/components/dialog-content/types.ts +0 -11
  117. package/src/components/dialog-content-actions/DialogContentActions.test.tsx +0 -68
  118. package/src/components/dialog-content-actions/DialogContentActions.tsx +0 -40
  119. package/src/components/dialog-content-actions/index.ts +0 -2
  120. package/src/components/dialog-content-actions/styles.ts +0 -18
  121. package/src/components/dialog-content-actions/types.ts +0 -11
  122. package/src/components/dialog-content-body/DialogContentBody.test.tsx +0 -63
  123. package/src/components/dialog-content-body/DialogContentBody.tsx +0 -49
  124. package/src/components/dialog-content-body/index.ts +0 -2
  125. package/src/components/dialog-content-body/styles.ts +0 -58
  126. package/src/components/dialog-content-body/types.ts +0 -14
  127. package/src/components/dialog-content-header/DialogContentHeader.test.tsx +0 -63
  128. package/src/components/dialog-content-header/DialogContentHeader.tsx +0 -81
  129. package/src/components/dialog-content-header/index.ts +0 -2
  130. package/src/components/dialog-content-header/styles.ts +0 -36
  131. package/src/components/dialog-content-header/types.ts +0 -23
  132. package/src/components/dialog-trigger/DialogTrigger.tsx +0 -43
  133. package/src/components/dialog-trigger/index.ts +0 -2
  134. package/src/components/dialog-trigger/types.ts +0 -9
  135. package/src/components/popover/Popover.stories.tsx +0 -158
  136. package/src/components/popover/Popover.test.tsx +0 -102
  137. package/src/components/popover/Popover.tsx +0 -53
  138. package/src/components/popover/context.ts +0 -4
  139. package/src/components/popover/index.ts +0 -5
  140. package/src/components/popover/types.ts +0 -53
  141. package/src/components/popover/usePopover.tsx +0 -70
  142. package/src/components/popover/usePopoverContext.tsx +0 -12
  143. package/src/components/popover-content/PopoverContent.tsx +0 -61
  144. package/src/components/popover-content/index.ts +0 -2
  145. package/src/components/popover-content/styles.ts +0 -27
  146. package/src/components/popover-content/types.ts +0 -11
  147. package/src/components/popover-trigger/PopoverTrigger.tsx +0 -43
  148. package/src/components/popover-trigger/index.ts +0 -2
  149. package/src/components/popover-trigger/types.ts +0 -9
  150. package/src/components/toast/Toast.stories.tsx +0 -75
  151. package/src/components/toast/Toast.test.tsx +0 -63
  152. package/src/components/toast/Toast.tsx +0 -122
  153. package/src/components/toast/index.ts +0 -2
  154. package/src/components/toast/intl/en-US.json +0 -3
  155. package/src/components/toast/intl/fr-FR.json +0 -3
  156. package/src/components/toast/intl/index.ts +0 -7
  157. package/src/components/toast/styles.ts +0 -43
  158. package/src/components/toast/types.ts +0 -44
  159. package/src/components/toast-container/ToastContainer.stories.tsx +0 -349
  160. package/src/components/toast-container/ToastContainer.tsx +0 -44
  161. package/src/components/toast-container/index.ts +0 -3
  162. package/src/components/toast-container/styles.ts +0 -746
  163. package/src/components/toast-container/types.ts +0 -110
  164. package/src/components/toast-container/useToast.test.tsx +0 -111
  165. package/src/components/toast-container/useToast.tsx +0 -128
  166. package/src/components/tooltip/Tooltip.stories.tsx +0 -200
  167. package/src/components/tooltip/Tooltip.test.tsx +0 -119
  168. package/src/components/tooltip/Tooltip.tsx +0 -55
  169. package/src/components/tooltip/context.ts +0 -4
  170. package/src/components/tooltip/index.ts +0 -5
  171. package/src/components/tooltip/types.ts +0 -55
  172. package/src/components/tooltip/useTooltip.tsx +0 -89
  173. package/src/components/tooltip/useTooltipContext.tsx +0 -12
  174. package/src/components/tooltip-content/TooltipContent.tsx +0 -76
  175. package/src/components/tooltip-content/index.ts +0 -2
  176. package/src/components/tooltip-content/styles.ts +0 -84
  177. package/src/components/tooltip-content/types.ts +0 -14
  178. package/src/components/tooltip-trigger/TooltipTrigger.tsx +0 -42
  179. package/src/components/tooltip-trigger/index.ts +0 -2
  180. package/src/components/tooltip-trigger/types.ts +0 -9
  181. package/src/index.ts +0 -14
  182. package/tsconfig.json +0 -3
  183. package/{dist/CONTRIBUTING.md → CONTRIBUTING.md} +0 -0
  184. package/{dist/index.d.ts → index.d.ts} +0 -0
  185. package/{dist/index.js → index.js} +2 -2
@@ -1,122 +0,0 @@
1
- import React, { forwardRef, RefObject } from 'react';
2
- import classNames from 'classnames';
3
-
4
- import { useLocalizedStringFormatter } from 'react-aria';
5
- import intlMessages from './intl';
6
-
7
- import {
8
- mdiAlert,
9
- mdiAlertCircle,
10
- mdiCheckCircle,
11
- mdiClose,
12
- mdiInformation,
13
- } from '@redsift/icons';
14
- import {
15
- ColorPalette,
16
- Comp,
17
- Icon,
18
- Heading,
19
- Flexbox,
20
- Spinner,
21
- isComponent,
22
- ButtonColor,
23
- IconButton,
24
- } from '@redsift/design-system';
25
- import { StyledToast } from './styles';
26
- import { ToastProps, ToastVariant } from './types';
27
-
28
- const COMPONENT_NAME = 'Toast';
29
- const CLASSNAME = 'redsift-toast';
30
- const DEFAULT_PROPS: Partial<ToastProps> = {
31
- variant: 'info',
32
- closeButton: true,
33
- };
34
-
35
- const getVariant = (variant: ToastVariant) => {
36
- switch (variant) {
37
- case ToastVariant.info:
38
- default:
39
- return <Icon icon={mdiInformation} color={ColorPalette.info} />;
40
- case ToastVariant.error:
41
- return <Icon icon={mdiAlertCircle} color={ColorPalette.error} />;
42
- case ToastVariant.success:
43
- return <Icon icon={mdiCheckCircle} color={ColorPalette.success} />;
44
- case ToastVariant.warning:
45
- return <Icon icon={mdiAlert} color={ColorPalette.warning} />;
46
- case ToastVariant.loading:
47
- return <Spinner size="small" />;
48
- }
49
- };
50
-
51
- /**
52
- * The Toast component.
53
- */
54
- export const Toast: Comp<
55
- ToastProps & { closeToast?: () => void },
56
- HTMLDivElement
57
- > = forwardRef((props, ref) => {
58
- const {
59
- children,
60
- className,
61
- closeToast,
62
- closeButton,
63
- title,
64
- variant,
65
- ...forwardedProps
66
- } = props;
67
-
68
- const stringFormatter = useLocalizedStringFormatter(intlMessages);
69
-
70
- const icon = getVariant(variant!);
71
-
72
- return (
73
- <StyledToast
74
- {...forwardedProps}
75
- className={classNames(Toast.className, className)}
76
- ref={ref as RefObject<HTMLDivElement>}
77
- $hasTitle={Boolean(title)}
78
- $variant={variant}
79
- >
80
- <Flexbox
81
- className={`${Toast.className}__header`}
82
- justifyContent="space-between"
83
- >
84
- <Flexbox justifyContent="space-between" flexDirection="column" gap="0">
85
- <Flexbox
86
- className={`${Toast.className}-header__title`}
87
- gap="14px"
88
- alignItems="flex-start"
89
- >
90
- {icon}
91
- {title ? <Heading as="h5">{title}</Heading> : null}
92
- </Flexbox>
93
-
94
- {children ? (
95
- <div className={`${Toast.className}__content`}>{children}</div>
96
- ) : null}
97
- </Flexbox>
98
-
99
- {closeButton === true ? (
100
- <IconButton
101
- aria-label={stringFormatter.format('close')}
102
- className={`${Toast.className}-header__icon-button`}
103
- icon={mdiClose}
104
- onClick={closeToast}
105
- />
106
- ) : isComponent('Button')(closeButton) ||
107
- isComponent('IconButton')(closeButton) ? (
108
- React.cloneElement(closeButton, {
109
- color: variant === 'loading' ? 'default' : (variant as ButtonColor),
110
- onClick: () => {
111
- closeButton.props.onClick?.();
112
- closeToast?.();
113
- },
114
- })
115
- ) : null}
116
- </Flexbox>
117
- </StyledToast>
118
- );
119
- });
120
- Toast.className = CLASSNAME;
121
- Toast.defaultProps = DEFAULT_PROPS;
122
- Toast.displayName = COMPONENT_NAME;
@@ -1,2 +0,0 @@
1
- export * from './types';
2
- export * from './Toast';
@@ -1,3 +0,0 @@
1
- {
2
- "close": "Close"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "close": "Fermer"
3
- }
@@ -1,7 +0,0 @@
1
- import enUS from './en-US.json';
2
- import frFR from './fr-FR.json';
3
-
4
- export default {
5
- 'en-US': enUS,
6
- 'fr-FR': frFR,
7
- };
@@ -1,43 +0,0 @@
1
- import styled, { css } from 'styled-components';
2
- import { baseStyling } from '@redsift/design-system';
3
- import { StyledToastProps } from './types';
4
-
5
- /**
6
- * Component style.
7
- */
8
- export const StyledToast = styled.div<StyledToastProps>`
9
- ${baseStyling}
10
-
11
- padding: 16px;
12
- box-shadow: 0px 2px 4px -1px rgb(0 0 0 / 20%), 0px 4px 5px rgb(0 0 0 / 14%),
13
- 0px 1px 10px rgb(0 0 0 / 12%);
14
-
15
- ${({ $hasTitle, $variant }) => css`
16
- background-color: ${$variant === 'loading'
17
- ? 'var(--redsift-color-neutral-white)'
18
- : `var(--redsift-color-${$variant}-hover)`};
19
-
20
- .redsift-toast__header {
21
- h5 {
22
- line-height: 26px;
23
- }
24
- }
25
-
26
- .redsift-toast-header__icon-button {
27
- padding: 0px;
28
- .redsift-icon {
29
- color: var(--redsift-color-neutral-black);
30
- }
31
-
32
- &:hover,
33
- &:focus-visible {
34
- background-color: var(--redsift-color-${$variant}-active);
35
- }
36
- }
37
-
38
- .redsift-toast__content {
39
- margin-top: ${$hasTitle ? '8px' : '-24px'};
40
- margin-left: 38px;
41
- }
42
- `}
43
- `;
@@ -1,44 +0,0 @@
1
- import { ComponentProps, ReactNode } from 'react';
2
- import { ValueOf, SizingProps, SpacingProps } from '@redsift/design-system';
3
-
4
- /**
5
- * Component variant.
6
- */
7
- export const ToastVariant = {
8
- success: 'success',
9
- error: 'error',
10
- warning: 'warning',
11
- info: 'info',
12
- loading: 'loading',
13
- } as const;
14
- export type ToastVariant = ValueOf<typeof ToastVariant>;
15
-
16
- export const ToastPlacement = {
17
- 'top-right': 'top-right',
18
- 'top-center': 'top-center',
19
- 'top-left': 'top-left',
20
- 'bottom-right': 'bottom-right',
21
- 'bottom-center': 'bottom-center',
22
- 'bottom-left': 'bottom-left',
23
- } as const;
24
- export type ToastPlacement = ValueOf<typeof ToastPlacement>;
25
-
26
- /**
27
- * Component props.
28
- */
29
- export interface ToastProps
30
- extends Omit<ComponentProps<'div'>, 'id' | 'style'>,
31
- SpacingProps,
32
- SizingProps {
33
- /** Whether the component has a close button or not. */
34
- closeButton?: boolean | ReactNode;
35
- /** Title. */
36
- title?: string;
37
- /** Variant */
38
- variant?: ToastVariant;
39
- }
40
-
41
- export type StyledToastProps = Omit<ToastProps, 'variant' | 'id'> & {
42
- $hasTitle: boolean;
43
- $variant: ToastProps['variant'];
44
- };
@@ -1,349 +0,0 @@
1
- import React from 'react';
2
-
3
- import { ToastContainer, useToast } from '.';
4
- import { Button, Flexbox } from '@redsift/design-system';
5
-
6
- export default {
7
- title: 'Popovers/Toast/ToastContainer',
8
- component: ToastContainer,
9
- };
10
-
11
- export const Simple = () => {
12
- const { notify } = useToast();
13
-
14
- return (
15
- <>
16
- <Flexbox>
17
- <Button
18
- onClick={() =>
19
- notify({
20
- content: 'This is a success',
21
- variant: 'success',
22
- })
23
- }
24
- >
25
- Success
26
- </Button>
27
- <Button
28
- onClick={() =>
29
- notify({
30
- title: 'This is a warning',
31
- content: 'Cupcake ipsum dolor sit amet.',
32
- variant: 'warning',
33
- })
34
- }
35
- >
36
- Warning
37
- </Button>
38
- <Button
39
- onClick={() =>
40
- notify({
41
- title: 'This is an error',
42
- content:
43
- 'Cupcake ipsum dolor sit amet. Cookie chocolate cake muffin chocolate bar powder cake chupa chups. Gummies chocolate cake cupcake chupa chups sesame snaps soufflé soufflé gingerbread blueie. Caramels chocolate bar soufflé sesame snaps tiramisu. Cookie muffin pie cake cupcake sweet.',
44
- variant: 'error',
45
- })
46
- }
47
- >
48
- Error
49
- </Button>
50
- <Button
51
- onClick={() =>
52
- notify({
53
- title: 'This is an info',
54
- content:
55
- 'Cupcake ipsum dolor sit amet. Cookie chocolate cake muffin chocolate bar powder cake chupa chups.',
56
- variant: 'info',
57
- })
58
- }
59
- >
60
- Info
61
- </Button>
62
- </Flexbox>
63
- <ToastContainer />
64
- </>
65
- );
66
- };
67
-
68
- export const AllVariants = () => {
69
- const { notify, success, warning, error, info, loading } = useToast();
70
-
71
- return (
72
- <>
73
- <Flexbox
74
- flexDirection="row"
75
- flexWrap="wrap"
76
- justifyContent="center"
77
- alignItems="flex-start"
78
- marginTop="96px"
79
- >
80
- <Button
81
- variant="secondary"
82
- onClick={() =>
83
- notify({
84
- content: 'Default',
85
- })
86
- }
87
- >
88
- Default
89
- </Button>
90
- <Button
91
- variant="secondary"
92
- onClick={() =>
93
- success({
94
- content: 'Success',
95
- })
96
- }
97
- >
98
- Success
99
- </Button>
100
- <Button
101
- variant="secondary"
102
- onClick={() =>
103
- warning({
104
- content: 'Warning',
105
- })
106
- }
107
- >
108
- Warning
109
- </Button>
110
- <Button
111
- variant="secondary"
112
- onClick={() =>
113
- error({
114
- content: 'Error',
115
- })
116
- }
117
- >
118
- Error
119
- </Button>
120
- <Button
121
- variant="secondary"
122
- onClick={() =>
123
- info({
124
- content: 'Info',
125
- })
126
- }
127
- >
128
- Info
129
- </Button>
130
- <Button
131
- variant="secondary"
132
- onClick={() =>
133
- loading({
134
- content: 'Loading',
135
- })
136
- }
137
- >
138
- Loading
139
- </Button>
140
- </Flexbox>
141
- <ToastContainer />
142
- </>
143
- );
144
- };
145
-
146
- export const AllPlacements = () => {
147
- const { notify } = useToast();
148
-
149
- return (
150
- <>
151
- <Flexbox
152
- flexDirection="row"
153
- flexWrap="wrap"
154
- justifyContent="center"
155
- alignItems="flex-start"
156
- marginTop="96px"
157
- >
158
- <Button
159
- variant="secondary"
160
- onClick={() =>
161
- notify({
162
- content: 'Top-left',
163
- placement: 'top-left',
164
- })
165
- }
166
- >
167
- Top-left
168
- </Button>
169
- <Button
170
- variant="secondary"
171
- onClick={() =>
172
- notify({
173
- content: 'Top-center',
174
- placement: 'top-center',
175
- })
176
- }
177
- >
178
- Top-center
179
- </Button>
180
- <Button
181
- variant="secondary"
182
- onClick={() =>
183
- notify({
184
- content: 'Top-right',
185
- placement: 'top-right',
186
- })
187
- }
188
- >
189
- Top-right
190
- </Button>
191
- <Button
192
- variant="secondary"
193
- onClick={() =>
194
- notify({
195
- content: 'Bottom-left',
196
- placement: 'bottom-left',
197
- })
198
- }
199
- >
200
- Bottom-left
201
- </Button>
202
- <Button
203
- variant="secondary"
204
- onClick={() =>
205
- notify({
206
- content: 'Bottom-center',
207
- placement: 'bottom-center',
208
- })
209
- }
210
- >
211
- Bottom-center
212
- </Button>
213
- <Button
214
- variant="secondary"
215
- onClick={() =>
216
- notify({
217
- content: 'Bottom-right',
218
- placement: 'bottom-right',
219
- })
220
- }
221
- >
222
- Bottom-right
223
- </Button>
224
- </Flexbox>
225
- <ToastContainer />
226
- </>
227
- );
228
- };
229
-
230
- export const Dismiss = () => {
231
- const toastId = React.useRef<number | string | null>(null);
232
- const { notify, dismiss } = useToast();
233
-
234
- return (
235
- <>
236
- <Flexbox>
237
- <Button
238
- onClick={() => {
239
- toastId.current = notify({
240
- content: 'Saved!',
241
- autoClose: false,
242
- closeButton: false,
243
- });
244
- }}
245
- >
246
- Notify
247
- </Button>
248
- <Button
249
- onClick={() => {
250
- if (toastId.current) {
251
- dismiss(toastId.current);
252
- }
253
- }}
254
- >
255
- Dismiss
256
- </Button>
257
- <Button
258
- onClick={() => {
259
- dismiss();
260
- }}
261
- >
262
- Dismiss all
263
- </Button>
264
- </Flexbox>
265
- <ToastContainer />
266
- </>
267
- );
268
- };
269
-
270
- export const Update = () => {
271
- const toastId = React.useRef<number | string | null>(null);
272
- const { notify, update } = useToast();
273
-
274
- return (
275
- <>
276
- <Flexbox>
277
- <Button
278
- onClick={() => {
279
- toastId.current = notify({
280
- content: 'Saving...',
281
- variant: 'loading',
282
- autoClose: false,
283
- closeButton: false,
284
- });
285
- }}
286
- >
287
- Notify
288
- </Button>
289
- <Button
290
- onClick={() => {
291
- if (toastId.current) {
292
- update(toastId.current, {
293
- content: 'Saved!',
294
- autoClose: 5000,
295
- });
296
- }
297
- }}
298
- >
299
- Update
300
- </Button>
301
- </Flexbox>
302
- <ToastContainer />
303
- </>
304
- );
305
- };
306
-
307
- export const WithPromise = () => {
308
- const { promise } = useToast();
309
-
310
- return (
311
- <>
312
- <Flexbox>
313
- <Button
314
- variant="secondary"
315
- color="success"
316
- onClick={() => {
317
- const resolveAfter3Sec = new Promise((resolve) =>
318
- setTimeout(resolve, 3000)
319
- );
320
- promise(resolveAfter3Sec, {
321
- pending: { content: 'Promise is pending' },
322
- success: { content: 'Promise resolved!' },
323
- error: { content: 'Promise rejected!' },
324
- });
325
- }}
326
- >
327
- Successful promise
328
- </Button>
329
- <Button
330
- variant="secondary"
331
- color="error"
332
- onClick={() => {
333
- const failAfter3Sec = new Promise((_, reject) =>
334
- setTimeout(reject, 3000)
335
- );
336
- promise(failAfter3Sec, {
337
- pending: { content: 'Promise is pending' },
338
- success: { content: 'Promise resolved!' },
339
- error: { content: 'Promise rejected!' },
340
- });
341
- }}
342
- >
343
- Failing promise
344
- </Button>
345
- </Flexbox>
346
- <ToastContainer />
347
- </>
348
- );
349
- };
@@ -1,44 +0,0 @@
1
- import React, { forwardRef, RefObject } from 'react';
2
- import { Slide } from 'react-toastify';
3
-
4
- import { Comp } from '@redsift/design-system';
5
- import { ReactToastify, StyledToastContainer } from './styles';
6
- import { ToastContainerProps } from './types';
7
-
8
- const COMPONENT_NAME = 'ToastContainer';
9
- const CLASSNAME = 'redsift-toast-container';
10
- const DEFAULT_PROPS: Partial<ToastContainerProps> = {
11
- autoClose: 5000,
12
- closeOnClick: false,
13
- draggable: true,
14
- pauseOnFocusLoss: true,
15
- pauseOnHover: true,
16
- placement: 'top-right',
17
- };
18
-
19
- /**
20
- * The ToastContainer component.
21
- */
22
- export const ToastContainer: Comp<ToastContainerProps, HTMLDivElement> =
23
- forwardRef((props, ref) => {
24
- const { placement, ...forwardedProps } = props;
25
-
26
- return (
27
- <ReactToastify>
28
- <StyledToastContainer
29
- {...forwardedProps}
30
- className={ToastContainer.className}
31
- closeButton={false}
32
- icon={false}
33
- newestOnTop={placement!.includes('bottom')}
34
- position={placement}
35
- ref={ref as RefObject<HTMLDivElement>}
36
- theme="colored"
37
- transition={Slide}
38
- />
39
- </ReactToastify>
40
- );
41
- });
42
- ToastContainer.className = CLASSNAME;
43
- ToastContainer.defaultProps = DEFAULT_PROPS;
44
- ToastContainer.displayName = COMPONENT_NAME;
@@ -1,3 +0,0 @@
1
- export * from './types';
2
- export * from './ToastContainer';
3
- export * from './useToast';