@onewelcome/react-lib-components 0.1.0-alpha
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/LICENSE +21 -0
- package/README.md +71 -0
- package/dist/BaseModal/BaseModal.d.ts +16 -0
- package/dist/BaseModal/BaseModalActions/BaseModalActions.d.ts +5 -0
- package/dist/BaseModal/BaseModalContent/BaseModalContent.d.ts +8 -0
- package/dist/BaseModal/BaseModalContext.d.ts +2 -0
- package/dist/BaseModal/BaseModalHeader/BaseModalHeader.d.ts +8 -0
- package/dist/Breadcrumbs/Breadcrumbs.d.ts +9 -0
- package/dist/Button/BaseButton.d.ts +8 -0
- package/dist/Button/Button.d.ts +10 -0
- package/dist/Button/IconButton.d.ts +10 -0
- package/dist/ContextMenu/ContextMenu.d.ts +18 -0
- package/dist/ContextMenu/ContextMenuItem.d.ts +6 -0
- package/dist/Dialog/Dialog.d.ts +18 -0
- package/dist/Dialog/DialogActions/DialogActions.d.ts +6 -0
- package/dist/Dialog/DialogTitle/DialogTitle.d.ts +6 -0
- package/dist/Form/Checkbox/Checkbox.d.ts +13 -0
- package/dist/Form/Fieldset/Fieldset.d.ts +13 -0
- package/dist/Form/Form.d.ts +5 -0
- package/dist/Form/FormControl/FormControl.d.ts +8 -0
- package/dist/Form/FormGroup/FormGroup.d.ts +18 -0
- package/dist/Form/FormHelperText/FormHelperText.d.ts +7 -0
- package/dist/Form/FormSelectorWrapper/FormSelectorWrapper.d.ts +18 -0
- package/dist/Form/Input/Input.d.ts +12 -0
- package/dist/Form/Label/Label.d.ts +6 -0
- package/dist/Form/Radio/Radio.d.ts +11 -0
- package/dist/Form/Select/Option.d.ts +12 -0
- package/dist/Form/Select/Select.d.ts +15 -0
- package/dist/Form/Textarea/Textarea.d.ts +7 -0
- package/dist/Form/Toggle/Toggle.d.ts +6 -0
- package/dist/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.d.ts +8 -0
- package/dist/Form/Wrapper/InputWrapper/InputWrapper.d.ts +17 -0
- package/dist/Form/Wrapper/RadioWrapper/RadioWrapper.d.ts +10 -0
- package/dist/Form/Wrapper/SelectWrapper/SelectWrapper.d.ts +12 -0
- package/dist/Form/Wrapper/TextareaWrapper/TextareaWrapper.d.ts +14 -0
- package/dist/Form/Wrapper/Wrapper/Wrapper.d.ts +28 -0
- package/dist/Form/form.interfaces.d.ts +12 -0
- package/dist/Icon/Icon.d.ts +75 -0
- package/dist/Link/Link.d.ts +15 -0
- package/dist/Modal/Modal.d.ts +1 -0
- package/dist/Modal/ModalActions/ModalActions.d.ts +1 -0
- package/dist/Modal/ModalContent/ModalContent.d.ts +1 -0
- package/dist/Modal/ModalHeader/ModalHeader.d.ts +1 -0
- package/dist/Popover/Popover.d.ts +11 -0
- package/dist/Snackbar/SnackbarContainer/SnackbarContainer.d.ts +12 -0
- package/dist/Snackbar/SnackbarItem/SnackbarItem.d.ts +13 -0
- package/dist/Snackbar/SnackbarProvider/SnackbarProvider.d.ts +18 -0
- package/dist/Snackbar/SnackbarProvider/SnackbarStateProvider.d.ts +14 -0
- package/dist/Snackbar/interfaces.d.ts +10 -0
- package/dist/Snackbar/useSnackbar.d.ts +1 -0
- package/dist/Tiles/Tile.d.ts +16 -0
- package/dist/Tiles/Tiles.d.ts +6 -0
- package/dist/Tooltip/Tooltip.d.ts +11 -0
- package/dist/Typography/Typography.d.ts +12 -0
- package/dist/Wizard/BaseWizardSteps/BaseWizardSteps.d.ts +13 -0
- package/dist/Wizard/Wizard.d.ts +12 -0
- package/dist/Wizard/WizardActions/WizardActions.d.ts +12 -0
- package/dist/Wizard/WizardStateProvider.d.ts +12 -0
- package/dist/Wizard/WizardSteps/WizardSteps.d.ts +5 -0
- package/dist/Wizard/wizardStateReducer.d.ts +26 -0
- package/dist/_BaseStyling_/BaseStyling.d.ts +47 -0
- package/dist/hooks/useAnimation.d.ts +6 -0
- package/dist/hooks/useBodyClick.d.ts +1 -0
- package/dist/hooks/useFormSelector.d.ts +13 -0
- package/dist/hooks/usePosition.d.ts +36 -0
- package/dist/hooks/useScroll.d.ts +2 -0
- package/dist/hooks/useSpacing.d.ts +18 -0
- package/dist/hooks/useWrapper.d.ts +11 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +8 -0
- package/dist/interfaces.d.ts +13 -0
- package/dist/react-lib-components.cjs.development.js +3282 -0
- package/dist/react-lib-components.cjs.development.js.map +1 -0
- package/dist/react-lib-components.cjs.production.min.js +2 -0
- package/dist/react-lib-components.cjs.production.min.js.map +1 -0
- package/dist/react-lib-components.esm.js +3235 -0
- package/dist/react-lib-components.esm.js.map +1 -0
- package/dist/util/helper.d.ts +1 -0
- package/package.json +88 -0
- package/src/BaseModal/BaseModal.module.scss +58 -0
- package/src/BaseModal/BaseModal.test.tsx +59 -0
- package/src/BaseModal/BaseModal.tsx +113 -0
- package/src/BaseModal/BaseModalActions/BaseModalActions.module.scss +9 -0
- package/src/BaseModal/BaseModalActions/BaseModalActions.test.tsx +17 -0
- package/src/BaseModal/BaseModalActions/BaseModalActions.tsx +14 -0
- package/src/BaseModal/BaseModalContent/BaseModalContent.module.scss +6 -0
- package/src/BaseModal/BaseModalContent/BaseModalContent.test.tsx +29 -0
- package/src/BaseModal/BaseModalContent/BaseModalContent.tsx +35 -0
- package/src/BaseModal/BaseModalContext.ts +2 -0
- package/src/BaseModal/BaseModalHeader/BaseModalHeader.module.scss +17 -0
- package/src/BaseModal/BaseModalHeader/BaseModalHeader.test.tsx +30 -0
- package/src/BaseModal/BaseModalHeader/BaseModalHeader.tsx +28 -0
- package/src/Breadcrumbs/Breadcrumbs.module.scss +14 -0
- package/src/Breadcrumbs/Breadcrumbs.test.tsx +42 -0
- package/src/Breadcrumbs/Breadcrumbs.tsx +48 -0
- package/src/Button/BaseButton.module.scss +20 -0
- package/src/Button/BaseButton.test.tsx +59 -0
- package/src/Button/BaseButton.tsx +31 -0
- package/src/Button/Button.module.scss +336 -0
- package/src/Button/Button.test.tsx +76 -0
- package/src/Button/Button.tsx +44 -0
- package/src/Button/IconButton.module.scss +161 -0
- package/src/Button/IconButton.test.tsx +47 -0
- package/src/Button/IconButton.tsx +29 -0
- package/src/ContextMenu/ContextMenu.module.scss +20 -0
- package/src/ContextMenu/ContextMenu.test.tsx +93 -0
- package/src/ContextMenu/ContextMenu.tsx +91 -0
- package/src/ContextMenu/ContextMenuItem.module.scss +31 -0
- package/src/ContextMenu/ContextMenuItem.tsx +15 -0
- package/src/Dialog/Dialog.module.scss +16 -0
- package/src/Dialog/Dialog.test.tsx +79 -0
- package/src/Dialog/Dialog.tsx +96 -0
- package/src/Dialog/DialogActions/DialogActions.module.scss +11 -0
- package/src/Dialog/DialogActions/DialogActions.test.tsx +25 -0
- package/src/Dialog/DialogActions/DialogActions.tsx +21 -0
- package/src/Dialog/DialogTitle/DialogTitle.module.scss +7 -0
- package/src/Dialog/DialogTitle/DialogTitle.test.tsx +18 -0
- package/src/Dialog/DialogTitle/DialogTitle.tsx +18 -0
- package/src/Form/Checkbox/Checkbox.module.scss +65 -0
- package/src/Form/Checkbox/Checkbox.test.tsx +119 -0
- package/src/Form/Checkbox/Checkbox.tsx +145 -0
- package/src/Form/Fieldset/Fieldset.module.scss +19 -0
- package/src/Form/Fieldset/Fieldset.test.tsx +85 -0
- package/src/Form/Fieldset/Fieldset.tsx +55 -0
- package/src/Form/Form.module.scss +3 -0
- package/src/Form/Form.test.tsx +47 -0
- package/src/Form/Form.tsx +14 -0
- package/src/Form/FormControl/FormControl.module.scss +67 -0
- package/src/Form/FormControl/FormControl.test.tsx +56 -0
- package/src/Form/FormControl/FormControl.tsx +47 -0
- package/src/Form/FormGroup/FormGroup.module.scss +29 -0
- package/src/Form/FormGroup/FormGroup.test.tsx +61 -0
- package/src/Form/FormGroup/FormGroup.tsx +78 -0
- package/src/Form/FormHelperText/FormHelperText.module.scss +8 -0
- package/src/Form/FormHelperText/FormHelperText.test.tsx +42 -0
- package/src/Form/FormHelperText/FormHelperText.tsx +22 -0
- package/src/Form/FormSelectorWrapper/FormSelectorWrapper.module.scss +33 -0
- package/src/Form/FormSelectorWrapper/FormSelectorWrapper.tsx +65 -0
- package/src/Form/Input/Input.module.scss +65 -0
- package/src/Form/Input/Input.test.tsx +135 -0
- package/src/Form/Input/Input.tsx +72 -0
- package/src/Form/Label/Label.module.scss +5 -0
- package/src/Form/Label/Label.test.tsx +26 -0
- package/src/Form/Label/Label.tsx +19 -0
- package/src/Form/Radio/Radio.module.scss +100 -0
- package/src/Form/Radio/Radio.test.tsx +88 -0
- package/src/Form/Radio/Radio.tsx +98 -0
- package/src/Form/Select/Option.test.tsx +15 -0
- package/src/Form/Select/Option.tsx +57 -0
- package/src/Form/Select/Select.module.scss +189 -0
- package/src/Form/Select/Select.test.tsx +96 -0
- package/src/Form/Select/Select.tsx +217 -0
- package/src/Form/Textarea/Textarea.module.scss +53 -0
- package/src/Form/Textarea/Textarea.test.tsx +76 -0
- package/src/Form/Textarea/Textarea.tsx +33 -0
- package/src/Form/Toggle/Toggle.module.scss +58 -0
- package/src/Form/Toggle/Toggle.test.tsx +29 -0
- package/src/Form/Toggle/Toggle.tsx +20 -0
- package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.module.scss +12 -0
- package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.test.tsx +99 -0
- package/src/Form/Wrapper/CheckboxWrapper/CheckboxWrapper.tsx +62 -0
- package/src/Form/Wrapper/InputWrapper/InputWrapper.module.scss +24 -0
- package/src/Form/Wrapper/InputWrapper/InputWrapper.test.tsx +93 -0
- package/src/Form/Wrapper/InputWrapper/InputWrapper.tsx +92 -0
- package/src/Form/Wrapper/RadioWrapper/RadioWrapper.module.scss +12 -0
- package/src/Form/Wrapper/RadioWrapper/RadioWrapper.test.tsx +101 -0
- package/src/Form/Wrapper/RadioWrapper/RadioWrapper.tsx +74 -0
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.module.scss +14 -0
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.test.tsx +101 -0
- package/src/Form/Wrapper/SelectWrapper/SelectWrapper.tsx +59 -0
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.module.scss +65 -0
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.test.tsx +125 -0
- package/src/Form/Wrapper/TextareaWrapper/TextareaWrapper.tsx +105 -0
- package/src/Form/Wrapper/Wrapper/Wrapper.module.scss +35 -0
- package/src/Form/Wrapper/Wrapper/Wrapper.test.tsx +17 -0
- package/src/Form/Wrapper/Wrapper/Wrapper.tsx +101 -0
- package/src/Form/form.interfaces.ts +14 -0
- package/src/Icon/Icon.module.scss +278 -0
- package/src/Icon/Icon.test.tsx +39 -0
- package/src/Icon/Icon.tsx +94 -0
- package/src/Link/Link.module.scss +46 -0
- package/src/Link/Link.test.tsx +122 -0
- package/src/Link/Link.tsx +80 -0
- package/src/Link/types.d.ts +9 -0
- package/src/Modal/Modal.test.tsx +16 -0
- package/src/Modal/Modal.tsx +1 -0
- package/src/Modal/ModalActions/ModalActions.tsx +4 -0
- package/src/Modal/ModalContent/ModalContent.tsx +4 -0
- package/src/Modal/ModalHeader/ModalHeader.tsx +4 -0
- package/src/Popover/Popover.module.scss +18 -0
- package/src/Popover/Popover.test.tsx +84 -0
- package/src/Popover/Popover.tsx +46 -0
- package/src/Snackbar/SnackbarContainer/SnackbarContainer.module.scss +35 -0
- package/src/Snackbar/SnackbarContainer/SnackbarContainer.test.tsx +37 -0
- package/src/Snackbar/SnackbarContainer/SnackbarContainer.tsx +28 -0
- package/src/Snackbar/SnackbarItem/SnackbarItem.module.scss +135 -0
- package/src/Snackbar/SnackbarItem/SnackbarItem.test.tsx +47 -0
- package/src/Snackbar/SnackbarItem/SnackbarItem.tsx +105 -0
- package/src/Snackbar/SnackbarProvider/SnackbarProvider.test.tsx +179 -0
- package/src/Snackbar/SnackbarProvider/SnackbarProvider.tsx +127 -0
- package/src/Snackbar/SnackbarProvider/SnackbarStateProvider.tsx +25 -0
- package/src/Snackbar/interfaces.ts +11 -0
- package/src/Snackbar/useSnackbar.ts +4 -0
- package/src/Tiles/Tile.module.scss +72 -0
- package/src/Tiles/Tile.test.tsx +129 -0
- package/src/Tiles/Tile.tsx +48 -0
- package/src/Tiles/Tiles.module.scss +11 -0
- package/src/Tiles/Tiles.test.tsx +118 -0
- package/src/Tiles/Tiles.tsx +48 -0
- package/src/Tooltip/Tooltip.module.scss +42 -0
- package/src/Tooltip/Tooltip.test.tsx +72 -0
- package/src/Tooltip/Tooltip.tsx +130 -0
- package/src/Typography/Typography.module.scss +46 -0
- package/src/Typography/Typography.test.tsx +114 -0
- package/src/Typography/Typography.tsx +84 -0
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.module.scss +192 -0
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.test.tsx +75 -0
- package/src/Wizard/BaseWizardSteps/BaseWizardSteps.tsx +86 -0
- package/src/Wizard/Wizard.test.tsx +198 -0
- package/src/Wizard/Wizard.tsx +49 -0
- package/src/Wizard/WizardActions/WizardActions.test.tsx +168 -0
- package/src/Wizard/WizardActions/WizardActions.tsx +100 -0
- package/src/Wizard/WizardStateProvider.tsx +26 -0
- package/src/Wizard/WizardSteps/WizardSteps.test.tsx +110 -0
- package/src/Wizard/WizardSteps/WizardSteps.tsx +30 -0
- package/src/Wizard/wizardStateReducer.ts +51 -0
- package/src/_BaseStyling_/BaseStyling.test.tsx +39 -0
- package/src/_BaseStyling_/BaseStyling.tsx +115 -0
- package/src/hooks/useAnimation.test.tsx +45 -0
- package/src/hooks/useAnimation.ts +20 -0
- package/src/hooks/useBodyClick.test.tsx +39 -0
- package/src/hooks/useBodyClick.ts +20 -0
- package/src/hooks/useFormSelector.test.ts +40 -0
- package/src/hooks/useFormSelector.ts +47 -0
- package/src/hooks/usePosition.test.tsx +494 -0
- package/src/hooks/usePosition.ts +347 -0
- package/src/hooks/useScroll.test.tsx +20 -0
- package/src/hooks/useScroll.ts +16 -0
- package/src/hooks/useSpacing.test.ts +70 -0
- package/src/hooks/useSpacing.ts +42 -0
- package/src/hooks/useWrapper.test.ts +49 -0
- package/src/hooks/useWrapper.ts +35 -0
- package/src/index.ts +52 -0
- package/src/interfaces.ts +15 -0
- package/src/readyclasses.module.scss +77 -0
- package/src/types.d.ts +4 -0
- package/src/util/helper.test.tsx +15 -0
- package/src/util/helper.tsx +80 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Icon, Props, Icons } from './Icon';
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
|
+
|
|
5
|
+
const initParams: Props = {
|
|
6
|
+
icon: Icons.Calendar,
|
|
7
|
+
color: 'rgb(26, 153, 60)',
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const createIcon = (params = initParams) => {
|
|
11
|
+
const queries = render(
|
|
12
|
+
<Icon {...params} data-testid="icon-component" color={params.color} icon={params.icon} />
|
|
13
|
+
);
|
|
14
|
+
const icon = queries.getByTestId('icon-component');
|
|
15
|
+
|
|
16
|
+
return {
|
|
17
|
+
...queries,
|
|
18
|
+
icon,
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe('Icon', () => {
|
|
23
|
+
it('renders without crashing', () => {
|
|
24
|
+
const { icon } = createIcon();
|
|
25
|
+
|
|
26
|
+
expect(icon).toBeDefined();
|
|
27
|
+
expect(icon).toHaveClass('icon-calendar');
|
|
28
|
+
expect(icon.tagName.toLowerCase()).toBe('span');
|
|
29
|
+
expect(icon.getAttribute('style')).toBe('color: rgb(26, 153, 60);');
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should render icon with within div tag', () => {
|
|
33
|
+
const tag = 'div';
|
|
34
|
+
const { icon } = createIcon({ ...initParams, tag });
|
|
35
|
+
|
|
36
|
+
expect(icon).toBeDefined();
|
|
37
|
+
expect(icon.tagName.toLowerCase()).toBe(tag);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classes from './Icon.module.scss';
|
|
3
|
+
import { HTMLAttributes } from '../interfaces';
|
|
4
|
+
|
|
5
|
+
export enum Icons {
|
|
6
|
+
Bell = 'bell',
|
|
7
|
+
BellAlt = 'bell-alt',
|
|
8
|
+
Bookmark = 'bookmark',
|
|
9
|
+
BookmarkAlt = 'bookmark-alt',
|
|
10
|
+
Build = 'build',
|
|
11
|
+
Calendar = 'calendar',
|
|
12
|
+
Change = 'change',
|
|
13
|
+
Checkmark = 'checkmark',
|
|
14
|
+
CheckmarkCircle = 'checkmark-circle',
|
|
15
|
+
CheckmarkCircleAlt = 'checkmark-circle-alt',
|
|
16
|
+
CheckmarkCircleBreakout = 'checkmark-circle-breakout',
|
|
17
|
+
CheckmarkSquare = 'checkmark-square',
|
|
18
|
+
ChevronUp = 'chevron-up',
|
|
19
|
+
ChevronDown = 'chevron-down',
|
|
20
|
+
ChevronLeft = 'chevron-left',
|
|
21
|
+
ChevronRight = 'chevron-right',
|
|
22
|
+
Circle = 'circle',
|
|
23
|
+
Clock = 'clock',
|
|
24
|
+
Copy = 'copy',
|
|
25
|
+
Edit = 'edit',
|
|
26
|
+
Ellipsis = 'ellipsis',
|
|
27
|
+
EllipsisAlt = 'ellipsis-alt',
|
|
28
|
+
Equal = 'equal',
|
|
29
|
+
Eye = 'eye',
|
|
30
|
+
Filter = 'filter',
|
|
31
|
+
FilterAlt = 'filter-alt',
|
|
32
|
+
FilterAltArrow = 'filter-alt-arrow',
|
|
33
|
+
FilterAltTimes = 'filter-alt-times',
|
|
34
|
+
Forbidden = 'forbidden',
|
|
35
|
+
Fullscreen = 'fullscreen',
|
|
36
|
+
FullscreenExit = 'fullscreen-exit',
|
|
37
|
+
Gearwheel = 'gearwheel',
|
|
38
|
+
Grid = 'grid',
|
|
39
|
+
Hamburger = 'hamburger',
|
|
40
|
+
Heart = 'heart',
|
|
41
|
+
Image = 'image',
|
|
42
|
+
InfoBell = 'info-bell',
|
|
43
|
+
InfoCircle = 'info-circle',
|
|
44
|
+
Link = 'link',
|
|
45
|
+
MinusSquare = 'minus-square',
|
|
46
|
+
NavigationFirst = 'navigation-first',
|
|
47
|
+
NavigationLast = 'navigation-last',
|
|
48
|
+
Plus = 'plus',
|
|
49
|
+
Radio = 'radio',
|
|
50
|
+
Refresh = 'refresh',
|
|
51
|
+
Search = 'search',
|
|
52
|
+
Share = 'share',
|
|
53
|
+
Square = 'square',
|
|
54
|
+
Star = 'star',
|
|
55
|
+
StarAlt = 'star-alt',
|
|
56
|
+
Times = 'times',
|
|
57
|
+
TimesCircle = 'times-circle',
|
|
58
|
+
TimesCircleAlt = 'times-circle-alt',
|
|
59
|
+
TimesThin = 'times-thin',
|
|
60
|
+
Trash = 'trash',
|
|
61
|
+
TriangleDown = 'triangle-down',
|
|
62
|
+
TriangleDownCircle = 'triangle-down-circle',
|
|
63
|
+
TriangleLeft = 'triangle-left',
|
|
64
|
+
TriangleRight = 'triangle-right',
|
|
65
|
+
TriangleUp = 'triangle-up',
|
|
66
|
+
Undo = 'undo',
|
|
67
|
+
Warning = 'warning',
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
type Tag = 'span' | 'div' | 'i';
|
|
71
|
+
|
|
72
|
+
export interface Props extends Omit<HTMLAttributes<HTMLOrSVGElement>, 'size'> {
|
|
73
|
+
icon: Icons;
|
|
74
|
+
color?: string;
|
|
75
|
+
size?: string;
|
|
76
|
+
tag?: Tag;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const Icon = React.forwardRef(
|
|
80
|
+
({ icon, color, className, style, size, tag = 'span', ...rest }: Props, ref) => {
|
|
81
|
+
const Component = tag;
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<Component
|
|
85
|
+
{...rest}
|
|
86
|
+
ref={ref as React.LegacyRef<HTMLDivElement>}
|
|
87
|
+
style={{ color: color, ...style, fontSize: size }}
|
|
88
|
+
data-icon
|
|
89
|
+
aria-hidden="true"
|
|
90
|
+
className={`${classes['icon']} ${classes['icon-' + icon]} ${className ? className : ''}`}
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.link {
|
|
2
|
+
font-family: var(--font-family);
|
|
3
|
+
font-size: var(--font-size);
|
|
4
|
+
font-style: normal;
|
|
5
|
+
font-variant: normal;
|
|
6
|
+
line-height: 1.5;
|
|
7
|
+
font-weight: normal;
|
|
8
|
+
text-transform: none;
|
|
9
|
+
letter-spacing: 0;
|
|
10
|
+
|
|
11
|
+
&.disabled {
|
|
12
|
+
cursor: not-allowed;
|
|
13
|
+
color: var(--greyed-out);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&:focus,
|
|
17
|
+
&:hover,
|
|
18
|
+
&:active {
|
|
19
|
+
text-decoration-thickness: 0.125rem;
|
|
20
|
+
outline: 0;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.primary {
|
|
24
|
+
color: var(--color-primary);
|
|
25
|
+
|
|
26
|
+
&:focus-visible {
|
|
27
|
+
outline: 0.5px dashed var(--color-primary);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&.secondary {
|
|
32
|
+
color: var(--color-secondary);
|
|
33
|
+
|
|
34
|
+
&:focus-visible {
|
|
35
|
+
outline: 0.5px dashed var(--color-primary);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
&.tertiary {
|
|
40
|
+
color: var(--color-tertiary);
|
|
41
|
+
|
|
42
|
+
&:focus-visible {
|
|
43
|
+
outline: 0.5px dashed var(--color-primary);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Link, Props } from './Link';
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
|
+
import { BrowserRouter, Link as RouterLink } from 'react-router-dom';
|
|
5
|
+
|
|
6
|
+
const defaultParams: Props = {
|
|
7
|
+
type: 'external',
|
|
8
|
+
to: 'https://www.google.com',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const createLink = (params?: (defaultParams: Props) => Props) => {
|
|
12
|
+
let parameters: Props = defaultParams;
|
|
13
|
+
if (params) {
|
|
14
|
+
parameters = params(defaultParams);
|
|
15
|
+
}
|
|
16
|
+
const queries = render(
|
|
17
|
+
<Link {...parameters} data-testid="link">
|
|
18
|
+
link content
|
|
19
|
+
</Link>
|
|
20
|
+
);
|
|
21
|
+
const link = queries.getByTestId('link');
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
...queries,
|
|
25
|
+
link,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
describe('Link should render', () => {
|
|
30
|
+
it('renders without crashing', () => {
|
|
31
|
+
const { link } = createLink();
|
|
32
|
+
|
|
33
|
+
expect(link).toBeTruthy();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('is an external link with the right attributes', () => {
|
|
37
|
+
const { link } = createLink();
|
|
38
|
+
|
|
39
|
+
expect(link).toHaveAttribute('aria-disabled', 'false');
|
|
40
|
+
expect(link).toHaveAttribute('rel', 'noopener noreferer');
|
|
41
|
+
expect(link).toHaveAttribute('target', '_blank');
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('is an internal link with the right attributes', () => {
|
|
45
|
+
const { link } = createLink((defaultParams) => ({
|
|
46
|
+
...defaultParams,
|
|
47
|
+
type: 'internal',
|
|
48
|
+
to: '/home',
|
|
49
|
+
}));
|
|
50
|
+
|
|
51
|
+
expect(link).toHaveAttribute('aria-disabled', 'false');
|
|
52
|
+
expect(link).not.toHaveAttribute('rel', 'noopener noreferer');
|
|
53
|
+
expect(link).not.toHaveAttribute('target', '_blank');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('is a download link with the right attributes', () => {
|
|
57
|
+
const { link } = createLink((defaultParams) => ({
|
|
58
|
+
...defaultParams,
|
|
59
|
+
type: 'download',
|
|
60
|
+
to: '/test.png',
|
|
61
|
+
}));
|
|
62
|
+
|
|
63
|
+
expect(link).toHaveAttribute('aria-disabled', 'false');
|
|
64
|
+
expect(link).not.toHaveAttribute('rel', 'noopener noreferer');
|
|
65
|
+
expect(link).not.toHaveAttribute('target', '_blank');
|
|
66
|
+
expect(link).toHaveAttribute('download');
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('should set the correct target', () => {
|
|
70
|
+
const { link } = createLink((defaultParams) => ({ ...defaultParams, target: '_parent' }));
|
|
71
|
+
|
|
72
|
+
expect(link).toHaveAttribute('target', '_parent');
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('should accept this React Router Link prop and render as such', () => {
|
|
76
|
+
const queries = render(
|
|
77
|
+
<BrowserRouter>
|
|
78
|
+
<Link to="/contact" component={RouterLink} children="Routerlink" />
|
|
79
|
+
</BrowserRouter>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
const routerLink = queries.getByText('Routerlink');
|
|
83
|
+
|
|
84
|
+
expect(routerLink).toBeTruthy();
|
|
85
|
+
expect(routerLink).toHaveClass('link');
|
|
86
|
+
expect(routerLink).toHaveAttribute('href', '/contact');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('should be disabled', () => {
|
|
90
|
+
const { link } = createLink((defaultParams) => ({ ...defaultParams, disabled: true }));
|
|
91
|
+
|
|
92
|
+
expect(link).not.toHaveAttribute('href');
|
|
93
|
+
expect(link).toHaveClass('disabled');
|
|
94
|
+
expect(link).toHaveStyle({ color: 'var(--greyed-out)' });
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it('should have a className added', () => {
|
|
98
|
+
const { link } = createLink((defaultParams) => ({ ...defaultParams, className: 'classname' }));
|
|
99
|
+
|
|
100
|
+
expect(link).toHaveClass('classname');
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
describe('colors', () => {
|
|
105
|
+
it('should be color primary', () => {
|
|
106
|
+
const { link } = createLink((defaultParams) => ({ ...defaultParams, color: 'primary' }));
|
|
107
|
+
|
|
108
|
+
expect(link).toHaveStyle({ color: 'var(--color-primary)' });
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it('should be color secondary', () => {
|
|
112
|
+
const { link } = createLink((defaultParams) => ({ ...defaultParams, color: 'secondary' }));
|
|
113
|
+
|
|
114
|
+
expect(link).toHaveStyle({ color: 'var(--color-secondary)' });
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('should be color tertiary', () => {
|
|
118
|
+
const { link } = createLink((defaultParams) => ({ ...defaultParams, color: 'tertiary' }));
|
|
119
|
+
|
|
120
|
+
expect(link).toHaveStyle({ color: 'var(--color-tertiary)' });
|
|
121
|
+
});
|
|
122
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React, { ForwardRefExoticComponent, Ref, RefAttributes } from 'react';
|
|
2
|
+
import { HTMLProps } from '../interfaces';
|
|
3
|
+
import classes from './Link.module.scss';
|
|
4
|
+
import { LinkProps } from './types';
|
|
5
|
+
|
|
6
|
+
type AnchorType = 'external' | 'internal' | 'download';
|
|
7
|
+
|
|
8
|
+
export interface Props extends HTMLProps<HTMLAnchorElement> {
|
|
9
|
+
children?: string;
|
|
10
|
+
color?: 'primary' | 'secondary' | 'tertiary';
|
|
11
|
+
type?: AnchorType;
|
|
12
|
+
to: string;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
component?: ForwardRefExoticComponent<LinkProps & RefAttributes<HTMLAnchorElement>>;
|
|
15
|
+
ref?: Ref<HTMLAnchorElement>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const Link = React.forwardRef(
|
|
19
|
+
(
|
|
20
|
+
{
|
|
21
|
+
children,
|
|
22
|
+
className,
|
|
23
|
+
disabled = false,
|
|
24
|
+
to,
|
|
25
|
+
color = 'primary',
|
|
26
|
+
type = 'internal',
|
|
27
|
+
component,
|
|
28
|
+
...rest
|
|
29
|
+
}: Props,
|
|
30
|
+
ref: Ref<HTMLAnchorElement>
|
|
31
|
+
) => {
|
|
32
|
+
const determineTarget = () => {
|
|
33
|
+
if (rest.target) {
|
|
34
|
+
return rest.target;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (type === 'external') {
|
|
38
|
+
return '_blank';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return '';
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const classNames = [classes['link'], classes[color]];
|
|
45
|
+
disabled && classNames.push(classes['disabled']);
|
|
46
|
+
className && classNames.push(className);
|
|
47
|
+
|
|
48
|
+
if (component) {
|
|
49
|
+
return React.createElement(component, {
|
|
50
|
+
...rest,
|
|
51
|
+
ref: ref,
|
|
52
|
+
to: to,
|
|
53
|
+
className: classNames.join(' '),
|
|
54
|
+
'aria-disabled': disabled,
|
|
55
|
+
style: {
|
|
56
|
+
...rest.style,
|
|
57
|
+
},
|
|
58
|
+
children: children,
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
<a
|
|
64
|
+
{...rest}
|
|
65
|
+
ref={ref}
|
|
66
|
+
download={type === 'download'}
|
|
67
|
+
rel={type === 'external' ? 'noopener noreferer' : undefined}
|
|
68
|
+
href={!disabled ? to : undefined}
|
|
69
|
+
className={classNames.join(' ')}
|
|
70
|
+
aria-disabled={disabled}
|
|
71
|
+
target={determineTarget()}
|
|
72
|
+
style={{
|
|
73
|
+
...rest.style,
|
|
74
|
+
}}
|
|
75
|
+
>
|
|
76
|
+
{children}
|
|
77
|
+
</a>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as H from 'history';
|
|
2
|
+
|
|
3
|
+
export interface LinkProps<S = H.LocationState>
|
|
4
|
+
extends React.AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
5
|
+
component?: React.ComponentType<any> | undefined;
|
|
6
|
+
to: H.LocationDescriptor<S> | ((location: H.Location<S>) => H.LocationDescriptor<S>);
|
|
7
|
+
replace?: boolean | undefined;
|
|
8
|
+
innerRef?: React.Ref<HTMLAnchorElement> | undefined;
|
|
9
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import * as ReactDOM from 'react-dom';
|
|
3
|
+
import { Modal } from './Modal';
|
|
4
|
+
|
|
5
|
+
describe('Modal', () => {
|
|
6
|
+
it('renders without crashing', () => {
|
|
7
|
+
const div = document.createElement('div');
|
|
8
|
+
ReactDOM.render(
|
|
9
|
+
<Modal id="modal" open={true} onClose={() => {}}>
|
|
10
|
+
test
|
|
11
|
+
</Modal>,
|
|
12
|
+
div
|
|
13
|
+
);
|
|
14
|
+
ReactDOM.unmountComponentAtNode(div);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BaseModal as Modal, Props } from '../BaseModal/BaseModal';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.popover {
|
|
2
|
+
position: fixed;
|
|
3
|
+
pointer-events: none;
|
|
4
|
+
background-color: #fff;
|
|
5
|
+
border-radius: 8px;
|
|
6
|
+
box-shadow: 0px 30px 50px rgba(0, 0, 0, 0.29);
|
|
7
|
+
opacity: 0;
|
|
8
|
+
transform: scale(0.5);
|
|
9
|
+
transition-property: transform, opacity;
|
|
10
|
+
transition-duration: 0.2s;
|
|
11
|
+
transition-timing-function: ease-in-out;
|
|
12
|
+
|
|
13
|
+
&.show {
|
|
14
|
+
transform: scale(1);
|
|
15
|
+
pointer-events: auto;
|
|
16
|
+
opacity: 1;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { Popover, Props } from './Popover';
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
|
+
import { usePosition } from '../hooks/usePosition';
|
|
5
|
+
|
|
6
|
+
const createPopover = (params?: (defaultParams: Props) => Props) => {
|
|
7
|
+
const Component = () => {
|
|
8
|
+
const relativeElement = useRef<HTMLButtonElement>(null);
|
|
9
|
+
const elementToBePositioned = useRef<HTMLDivElement>(null);
|
|
10
|
+
|
|
11
|
+
const defaultParams: Props = {
|
|
12
|
+
children: (
|
|
13
|
+
<ul>
|
|
14
|
+
<li>Test</li>
|
|
15
|
+
<li>Test</li>
|
|
16
|
+
<li>Test</li>
|
|
17
|
+
</ul>
|
|
18
|
+
),
|
|
19
|
+
show: false,
|
|
20
|
+
placement: { vertical: 'top', horizontal: 'left' },
|
|
21
|
+
};
|
|
22
|
+
let parameters: Props = defaultParams;
|
|
23
|
+
|
|
24
|
+
if (params) {
|
|
25
|
+
parameters = params(defaultParams);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const { top, left, bottom, right, calculatePosition } = usePosition({
|
|
29
|
+
elementToBePositioned: elementToBePositioned,
|
|
30
|
+
relativeElement: relativeElement,
|
|
31
|
+
...parameters,
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<>
|
|
36
|
+
<button data-testid="button" onClick={calculatePosition} ref={relativeElement}>
|
|
37
|
+
Test
|
|
38
|
+
</button>
|
|
39
|
+
<Popover
|
|
40
|
+
{...defaultParams}
|
|
41
|
+
data-testid="popover"
|
|
42
|
+
style={{ top: top, left: left, bottom: bottom, right: right }}
|
|
43
|
+
ref={elementToBePositioned}
|
|
44
|
+
>
|
|
45
|
+
Test
|
|
46
|
+
</Popover>
|
|
47
|
+
</>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const queries = render(<Component />);
|
|
52
|
+
const button = queries.getByTestId('button');
|
|
53
|
+
const popover = queries.getByTestId('popover');
|
|
54
|
+
|
|
55
|
+
/** Let the hacking begin */
|
|
56
|
+
Object.defineProperty(button, 'offsetHeight', { configurable: true, value: 500 });
|
|
57
|
+
Object.defineProperty(button, 'offsetWidth', { configurable: true, value: 500 });
|
|
58
|
+
|
|
59
|
+
Object.defineProperty(window, 'innerHeight', {
|
|
60
|
+
configurable: true,
|
|
61
|
+
value: 1000,
|
|
62
|
+
});
|
|
63
|
+
Object.defineProperty(window, 'innerWidth', {
|
|
64
|
+
configurable: true,
|
|
65
|
+
value: 1000,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
Object.defineProperty(popover, 'offsetHeight', { configurable: true, value: 100 });
|
|
69
|
+
Object.defineProperty(popover, 'offsetWidth', { configurable: true, value: 100 });
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
...queries,
|
|
73
|
+
popover,
|
|
74
|
+
button,
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
describe('Popover should render', () => {
|
|
79
|
+
it('renders without crashing and has default left and top attributes', () => {
|
|
80
|
+
const { popover } = createPopover();
|
|
81
|
+
|
|
82
|
+
expect(popover).toBeTruthy();
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { forwardRef, HTMLProps, ReactNode, RefObject, useEffect, useRef } from 'react';
|
|
2
|
+
import { usePosition, Offset, Placement } from '../hooks/usePosition';
|
|
3
|
+
import classes from './Popover.module.scss';
|
|
4
|
+
|
|
5
|
+
export interface Props extends HTMLProps<HTMLDivElement> {
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
show?: boolean;
|
|
8
|
+
anchorEl?: RefObject<HTMLOrSVGElement>;
|
|
9
|
+
placement?: Placement;
|
|
10
|
+
offset?: Offset;
|
|
11
|
+
transformOrigin?: Placement;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const Popover = forwardRef<HTMLDivElement, Props>(
|
|
15
|
+
({ children, className, show, placement, offset, transformOrigin, anchorEl, ...rest }, ref) => {
|
|
16
|
+
const elToBePositioned = useRef<HTMLDivElement>(null);
|
|
17
|
+
|
|
18
|
+
if (show === undefined) {
|
|
19
|
+
throw new Error('Please make sure to define the "show" property on your Popover component');
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const { top, left, right, bottom, calculatePosition } = usePosition({
|
|
23
|
+
elementToBePositioned: elToBePositioned,
|
|
24
|
+
relativeElement: anchorEl,
|
|
25
|
+
offset: offset,
|
|
26
|
+
placement: placement,
|
|
27
|
+
transformOrigin: transformOrigin,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
calculatePosition();
|
|
32
|
+
}, [show]);
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div ref={ref} {...rest}>
|
|
36
|
+
<div
|
|
37
|
+
ref={elToBePositioned}
|
|
38
|
+
className={`${classes.popover} ${className ?? ''} ${show ? classes.show : ''}`}
|
|
39
|
+
style={{ top: top, left: left, right: right, bottom: bottom }}
|
|
40
|
+
>
|
|
41
|
+
{children}
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
.snackbars {
|
|
2
|
+
position: fixed;
|
|
3
|
+
z-index: 20;
|
|
4
|
+
width: 100%;
|
|
5
|
+
|
|
6
|
+
&.bottom {
|
|
7
|
+
bottom: 3.5rem;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
&.top {
|
|
11
|
+
top: 3.5rem;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&.start {
|
|
15
|
+
left: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&.center {
|
|
19
|
+
left: 0;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.end {
|
|
23
|
+
right: 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@media only screen and (min-width: 37.5rem) {
|
|
28
|
+
.snackbars {
|
|
29
|
+
width: initial;
|
|
30
|
+
|
|
31
|
+
&.center {
|
|
32
|
+
left: calc(50% - 18.75rem);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SnackbarContainer, Props } from './SnackbarContainer';
|
|
3
|
+
import { render } from '@testing-library/react';
|
|
4
|
+
|
|
5
|
+
const defaultParams: Props = {
|
|
6
|
+
placement: { vertical: 'top', horizontal: 'center' },
|
|
7
|
+
children: <span>children</span>,
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const createSnackbarContainer = (params?: (defaultParams: Props) => Props) => {
|
|
11
|
+
let parameters: Props = defaultParams;
|
|
12
|
+
if (params) {
|
|
13
|
+
parameters = params(defaultParams);
|
|
14
|
+
}
|
|
15
|
+
const queries = render(<SnackbarContainer {...parameters} data-testid="snackbarcontainer" />);
|
|
16
|
+
const snackbarcontainer = queries.getByTestId('snackbarcontainer');
|
|
17
|
+
return { ...queries, snackbarcontainer };
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
describe('SnackbarContainer should render', () => {
|
|
21
|
+
it('renders without crashing', () => {
|
|
22
|
+
const { snackbarcontainer, getByText } = createSnackbarContainer();
|
|
23
|
+
expect(snackbarcontainer).toHaveClass('top');
|
|
24
|
+
expect(snackbarcontainer).toHaveClass('center');
|
|
25
|
+
expect(snackbarcontainer).toHaveStyle({ zIndex: '' });
|
|
26
|
+
expect(getByText('children')).toBeDefined();
|
|
27
|
+
expect(snackbarcontainer).toBeDefined();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('renders with zIndex', () => {
|
|
31
|
+
const { snackbarcontainer } = createSnackbarContainer((defaultParams) => ({
|
|
32
|
+
...defaultParams,
|
|
33
|
+
zIndex: 1,
|
|
34
|
+
}));
|
|
35
|
+
expect(snackbarcontainer).toHaveStyle({ zIndex: '1' });
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import classes from './SnackbarContainer.module.scss';
|
|
3
|
+
|
|
4
|
+
export interface Placement {
|
|
5
|
+
vertical: 'top' | 'bottom';
|
|
6
|
+
horizontal: 'start' | 'center' | 'end';
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Props {
|
|
10
|
+
placement: Placement;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
zIndex?: number;
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export const SnackbarContainer = ({ placement, children, zIndex, className, ...rest }: Props) => {
|
|
17
|
+
return (
|
|
18
|
+
<div
|
|
19
|
+
{...rest}
|
|
20
|
+
style={{ zIndex }}
|
|
21
|
+
className={`${classes['snackbars']} ${classes[placement.horizontal]} ${
|
|
22
|
+
classes[placement.vertical]
|
|
23
|
+
} ${className ?? ''}`}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
};
|