@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,135 @@
|
|
|
1
|
+
@import '../../readyclasses.module.scss';
|
|
2
|
+
|
|
3
|
+
.snackbar {
|
|
4
|
+
padding: 1rem 1.25rem;
|
|
5
|
+
border-radius: var(--snackbar-border-radius);
|
|
6
|
+
display: flex;
|
|
7
|
+
width: 100%;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
|
|
10
|
+
&.info {
|
|
11
|
+
background-color: var(--snackbar-info-background-color);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
&.success {
|
|
15
|
+
background-color: var(--snackbar-success-background-color);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&.error {
|
|
19
|
+
background-color: var(--snackbar-error-background-color);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
& + & {
|
|
23
|
+
margin-top: 0.5rem;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.container {
|
|
27
|
+
flex: 1;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.headline {
|
|
31
|
+
display: flex;
|
|
32
|
+
color: var(--snackbar-text-color);
|
|
33
|
+
|
|
34
|
+
.close-btn {
|
|
35
|
+
color: var(--snackbar-text-color);
|
|
36
|
+
|
|
37
|
+
&:hover,
|
|
38
|
+
&:focus {
|
|
39
|
+
border-color: var(--snackbar-text-color);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&:active {
|
|
43
|
+
border-color: transparent;
|
|
44
|
+
|
|
45
|
+
&:after {
|
|
46
|
+
top: 0;
|
|
47
|
+
height: 100%;
|
|
48
|
+
background-color: var(--snackbar-text-color);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.icon {
|
|
55
|
+
color: var(--snackbar-text-color);
|
|
56
|
+
margin-top: 0.5rem;
|
|
57
|
+
font-size: 1.25rem;
|
|
58
|
+
line-height: 1.5rem;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.title {
|
|
62
|
+
color: var(--snackbar-text-color);
|
|
63
|
+
flex: 1;
|
|
64
|
+
margin: calc(0.5rem - 0.125rem) 1.25rem 0 0.75rem;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.content {
|
|
68
|
+
margin: 0.25rem 0.75rem 0 0.75rem;
|
|
69
|
+
color: var(--snackbar-text-color);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.actions {
|
|
73
|
+
margin: 0.5rem 0.75rem 0 0.75rem;
|
|
74
|
+
text-align: right;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.action-button {
|
|
78
|
+
border-width: var(--button-border-width);
|
|
79
|
+
border-style: var(--button-border-style);
|
|
80
|
+
border-radius: var(--button-border-radius);
|
|
81
|
+
font-size: var(--button-font-size);
|
|
82
|
+
line-height: var(--button-font-size);
|
|
83
|
+
font-weight: 700;
|
|
84
|
+
margin: 0;
|
|
85
|
+
padding: 0.625rem 1.25rem;
|
|
86
|
+
cursor: pointer;
|
|
87
|
+
transition: color, background-color, border-color 0.2s ease-in-out;
|
|
88
|
+
font-family: var(--font-family);
|
|
89
|
+
color: var(--snackbar-text-color);
|
|
90
|
+
background-color: transparent;
|
|
91
|
+
border-color: transparent;
|
|
92
|
+
|
|
93
|
+
&:disabled {
|
|
94
|
+
color: var(--greyed-out);
|
|
95
|
+
cursor: not-allowed;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@include focusOutline(var(--snackbar-text-color));
|
|
99
|
+
|
|
100
|
+
&:not(:disabled):hover,
|
|
101
|
+
&:not(:disabled):focus {
|
|
102
|
+
border-color: var(--snackbar-text-color);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
&:active {
|
|
106
|
+
position: relative;
|
|
107
|
+
border-color: transparent;
|
|
108
|
+
border: 0;
|
|
109
|
+
padding: calc(0.625rem + var(--button-border-width))
|
|
110
|
+
calc(1.25rem + var(--button-border-width));
|
|
111
|
+
|
|
112
|
+
&:after {
|
|
113
|
+
content: '';
|
|
114
|
+
position: absolute;
|
|
115
|
+
top: 0;
|
|
116
|
+
left: 0;
|
|
117
|
+
width: 100%;
|
|
118
|
+
height: 100%;
|
|
119
|
+
background-color: var(--snackbar-text-color);
|
|
120
|
+
border-radius: var(--button-border-radius);
|
|
121
|
+
filter: opacity(0.1);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
& + .action-button {
|
|
126
|
+
margin-left: 1rem;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@media only screen and (min-width: 37.5rem) {
|
|
132
|
+
.snackbar {
|
|
133
|
+
width: 37.5rem;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { render, getByRole, waitFor } from '@testing-library/react';
|
|
3
|
+
import { SnackbarItem, Props } from './SnackbarItem';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
|
|
6
|
+
const initParams: Props = {
|
|
7
|
+
id: 'id',
|
|
8
|
+
title: 'title',
|
|
9
|
+
duration: 1,
|
|
10
|
+
variant: 'success',
|
|
11
|
+
closeButtonTitle: 'close',
|
|
12
|
+
onClose: jest.fn(),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
describe('SnackbarItem', () => {
|
|
16
|
+
it('renders without crashing', () => {
|
|
17
|
+
const { container } = render(<SnackbarItem {...initParams} />);
|
|
18
|
+
|
|
19
|
+
expect(container).toHaveTextContent(initParams.title);
|
|
20
|
+
const contentDiv = container.querySelector('.content');
|
|
21
|
+
expect(contentDiv).toBeNull();
|
|
22
|
+
const actionsDiv = container.querySelector('.actions');
|
|
23
|
+
expect(actionsDiv).toBeNull();
|
|
24
|
+
expect(getByRole(container, 'button')).toBeDefined();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('clicking close button call callback function', () => {
|
|
28
|
+
const { container } = render(<SnackbarItem {...initParams} duration={10000000} />);
|
|
29
|
+
|
|
30
|
+
expect(initParams.onClose).not.toBeCalled();
|
|
31
|
+
userEvent.click(getByRole(container, 'button'));
|
|
32
|
+
waitFor(() => {
|
|
33
|
+
expect(initParams.onClose).toBeCalledTimes(1);
|
|
34
|
+
expect(initParams.onClose).toHaveBeenCalledWith(initParams.id);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('call close callback after provided duration', () => {
|
|
39
|
+
render(<SnackbarItem {...initParams} />);
|
|
40
|
+
|
|
41
|
+
expect(initParams.onClose).not.toBeCalled();
|
|
42
|
+
waitFor(() => {
|
|
43
|
+
expect(initParams.onClose).toBeCalledTimes(1);
|
|
44
|
+
expect(initParams.onClose).toHaveBeenCalledWith(initParams.id);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { IconButton } from '../../Button/IconButton';
|
|
3
|
+
import { Icon, Icons } from '../../Icon/Icon';
|
|
4
|
+
import { Variant, Actions } from '../interfaces';
|
|
5
|
+
import classes from './SnackbarItem.module.scss';
|
|
6
|
+
import readyclasses from '../../readyclasses.module.scss';
|
|
7
|
+
import { useAnimation } from '../../hooks/useAnimation';
|
|
8
|
+
import { Typography } from '../../Typography/Typography';
|
|
9
|
+
|
|
10
|
+
const textColor = 'var(--snackbar-text-color)';
|
|
11
|
+
|
|
12
|
+
export interface Props {
|
|
13
|
+
id: string;
|
|
14
|
+
title: string;
|
|
15
|
+
duration: number;
|
|
16
|
+
variant: Variant;
|
|
17
|
+
onClose: (key: string) => void;
|
|
18
|
+
closeButtonTitle: string;
|
|
19
|
+
content?: string;
|
|
20
|
+
actions?: Actions;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const SnackbarItem = ({
|
|
24
|
+
id,
|
|
25
|
+
title,
|
|
26
|
+
duration,
|
|
27
|
+
variant,
|
|
28
|
+
content,
|
|
29
|
+
actions = [],
|
|
30
|
+
onClose,
|
|
31
|
+
closeButtonTitle,
|
|
32
|
+
}: Props) => {
|
|
33
|
+
const timerHandler = useRef<ReturnType<typeof setTimeout>>();
|
|
34
|
+
const onAnimationEnd = () => onClose(id);
|
|
35
|
+
const { ref, animationStarted, startAnimation } = useAnimation<HTMLDivElement>(onAnimationEnd);
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
timerHandler.current = setTimeout(() => startAnimation(), duration);
|
|
39
|
+
return () => {
|
|
40
|
+
timerHandler.current && clearTimeout(timerHandler.current);
|
|
41
|
+
};
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
const onMouseEnter = () => {
|
|
45
|
+
timerHandler.current && clearTimeout(timerHandler.current);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const onMouseLeave = () => {
|
|
49
|
+
timerHandler.current = setTimeout(() => startAnimation(), duration);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const getVariantIcon = () => {
|
|
53
|
+
if (variant === 'error') {
|
|
54
|
+
return Icons.TimesCircleAlt;
|
|
55
|
+
}
|
|
56
|
+
return variant === 'success' ? Icons.CheckmarkCircleBreakout : Icons.InfoCircle;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
const actionButtons = actions.map((actionProp, index) => (
|
|
60
|
+
<button
|
|
61
|
+
key={index}
|
|
62
|
+
{...actionProp}
|
|
63
|
+
onClick={(e) => {
|
|
64
|
+
onClose(id);
|
|
65
|
+
actionProp.onClick && actionProp.onClick(e);
|
|
66
|
+
}}
|
|
67
|
+
children={actionProp.label}
|
|
68
|
+
className={classes['action-button']}
|
|
69
|
+
></button>
|
|
70
|
+
));
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<div
|
|
74
|
+
ref={ref}
|
|
75
|
+
className={`${classes['snackbar']} ${classes[variant]} ${
|
|
76
|
+
animationStarted ? readyclasses['slide-out'] : readyclasses['slide-in']
|
|
77
|
+
}`}
|
|
78
|
+
onMouseEnter={onMouseEnter}
|
|
79
|
+
onMouseLeave={onMouseLeave}
|
|
80
|
+
>
|
|
81
|
+
<Icon icon={getVariantIcon()} className={classes['icon']} />
|
|
82
|
+
<div className={classes['container']}>
|
|
83
|
+
<div className={classes['headline']}>
|
|
84
|
+
<Typography className={classes['title']} variant="h4" tag="span">
|
|
85
|
+
{title}
|
|
86
|
+
</Typography>
|
|
87
|
+
<IconButton
|
|
88
|
+
onClick={() => startAnimation()}
|
|
89
|
+
className={classes['close-btn']}
|
|
90
|
+
title={closeButtonTitle}
|
|
91
|
+
>
|
|
92
|
+
<Icon icon={Icons.Times} color={textColor} />
|
|
93
|
+
</IconButton>
|
|
94
|
+
</div>
|
|
95
|
+
{/* @TODO: change it to Typography*/}
|
|
96
|
+
{!!content && (
|
|
97
|
+
<Typography className={classes['content']} variant="body">
|
|
98
|
+
{content}
|
|
99
|
+
</Typography>
|
|
100
|
+
)}
|
|
101
|
+
{actionButtons.length > 0 && <div className={classes['actions']}>{actionButtons}</div>}
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
);
|
|
105
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
render,
|
|
4
|
+
getByTestId,
|
|
5
|
+
getAllByText,
|
|
6
|
+
waitFor,
|
|
7
|
+
getAllByRole,
|
|
8
|
+
getByText,
|
|
9
|
+
findByText,
|
|
10
|
+
findAllByText,
|
|
11
|
+
queryByText,
|
|
12
|
+
} from '@testing-library/react';
|
|
13
|
+
import { SnackbarProvider, Props } from './SnackbarProvider';
|
|
14
|
+
import { useSnackbar } from '../useSnackbar';
|
|
15
|
+
import userEvent from '@testing-library/user-event';
|
|
16
|
+
|
|
17
|
+
const successProps = {
|
|
18
|
+
title: 'success title',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const errorProps = {
|
|
22
|
+
title: 'error title',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const infoProps = {
|
|
26
|
+
title: 'info title',
|
|
27
|
+
content: 'test content',
|
|
28
|
+
options: {
|
|
29
|
+
actions: [
|
|
30
|
+
{ label: 'Contact support', onClick: jest.fn() },
|
|
31
|
+
{ label: 'Contact Onewelcome', onClick: jest.fn() },
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const renderSnackbarProvider = (props?: Partial<Props>) => {
|
|
37
|
+
const AppComponent = () => {
|
|
38
|
+
const { enqueueSuccessSnackbar, enqueueErrorSnackbar, enqueueSnackbar } = useSnackbar();
|
|
39
|
+
const [index, setIndex] = useState(0);
|
|
40
|
+
return (
|
|
41
|
+
<div>
|
|
42
|
+
content
|
|
43
|
+
<button
|
|
44
|
+
data-testid="show-success"
|
|
45
|
+
onClick={() => {
|
|
46
|
+
enqueueSuccessSnackbar(successProps.title + index);
|
|
47
|
+
setIndex(index + 1);
|
|
48
|
+
}}
|
|
49
|
+
>
|
|
50
|
+
Success
|
|
51
|
+
</button>
|
|
52
|
+
<button
|
|
53
|
+
data-testid="show-error"
|
|
54
|
+
onClick={() => {
|
|
55
|
+
enqueueErrorSnackbar(errorProps.title + index);
|
|
56
|
+
setIndex(index + 1);
|
|
57
|
+
}}
|
|
58
|
+
>
|
|
59
|
+
Error
|
|
60
|
+
</button>
|
|
61
|
+
<button
|
|
62
|
+
data-testid="show-info"
|
|
63
|
+
onClick={() => {
|
|
64
|
+
enqueueSnackbar(infoProps.title + index, infoProps.content, infoProps.options);
|
|
65
|
+
setIndex(index + 1);
|
|
66
|
+
}}
|
|
67
|
+
>
|
|
68
|
+
Info
|
|
69
|
+
</button>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const queries = render(
|
|
75
|
+
<SnackbarProvider {...props} closeButtonTitle="close">
|
|
76
|
+
<AppComponent />
|
|
77
|
+
</SnackbarProvider>
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
const showSuccessSnackbarBtn = getByTestId(queries.container, 'show-success');
|
|
81
|
+
const showErrorSnackbarBtn = getByTestId(queries.container, 'show-error');
|
|
82
|
+
const showInfoSnackbarBtn = getByTestId(queries.container, 'show-info');
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
...queries,
|
|
86
|
+
showSuccessSnackbarBtn,
|
|
87
|
+
showErrorSnackbarBtn,
|
|
88
|
+
showInfoSnackbarBtn,
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
describe('SnackbarProvider', () => {
|
|
93
|
+
it('renders without crashing', () => {
|
|
94
|
+
const { container } = renderSnackbarProvider();
|
|
95
|
+
|
|
96
|
+
expect(container).toHaveTextContent('content');
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('should stack 3 snackbars at one time', () => {
|
|
100
|
+
const { showSuccessSnackbarBtn } = renderSnackbarProvider();
|
|
101
|
+
|
|
102
|
+
userEvent.click(showSuccessSnackbarBtn);
|
|
103
|
+
userEvent.click(showSuccessSnackbarBtn);
|
|
104
|
+
userEvent.click(showSuccessSnackbarBtn);
|
|
105
|
+
userEvent.click(showSuccessSnackbarBtn);
|
|
106
|
+
|
|
107
|
+
expect(getAllByText(document.body, new RegExp(successProps.title))).toHaveLength(3);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should render 3 variants of snackbars', () => {
|
|
111
|
+
const { showSuccessSnackbarBtn, showErrorSnackbarBtn, showInfoSnackbarBtn } =
|
|
112
|
+
renderSnackbarProvider();
|
|
113
|
+
|
|
114
|
+
userEvent.click(showSuccessSnackbarBtn);
|
|
115
|
+
userEvent.click(showErrorSnackbarBtn);
|
|
116
|
+
userEvent.click(showInfoSnackbarBtn);
|
|
117
|
+
|
|
118
|
+
expect(getByText(document.body, new RegExp(successProps.title))).toBeDefined();
|
|
119
|
+
expect(getByText(document.body, new RegExp(errorProps.title))).toBeDefined();
|
|
120
|
+
expect(getByText(document.body, new RegExp(infoProps.title))).toBeDefined();
|
|
121
|
+
expect(getByText(document.body, infoProps.content)).toBeDefined();
|
|
122
|
+
const infoSnackbarActions = getAllByRole(document.body, 'button', { name: /Contact/i });
|
|
123
|
+
expect(infoSnackbarActions).toHaveLength(2);
|
|
124
|
+
|
|
125
|
+
userEvent.click(infoSnackbarActions[0]);
|
|
126
|
+
userEvent.click(infoSnackbarActions[1]);
|
|
127
|
+
|
|
128
|
+
expect(infoProps.options.actions[0].onClick).toBeCalledTimes(1);
|
|
129
|
+
waitFor(() => expect(infoProps.options.actions[1].onClick).toBeCalledTimes(1));
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('should stack 3 snackbars at one time and then after 3 disapear show the fourth one', () => {
|
|
133
|
+
const { showSuccessSnackbarBtn } = renderSnackbarProvider({
|
|
134
|
+
autoHideDuration: { long: 1, short: 1 },
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
userEvent.click(showSuccessSnackbarBtn);
|
|
138
|
+
userEvent.click(showSuccessSnackbarBtn);
|
|
139
|
+
userEvent.click(showSuccessSnackbarBtn);
|
|
140
|
+
userEvent.click(showSuccessSnackbarBtn);
|
|
141
|
+
|
|
142
|
+
expect(getAllByText(document.body, new RegExp(successProps.title))).toHaveLength(3);
|
|
143
|
+
|
|
144
|
+
/** Looking for fourth one to be shown */
|
|
145
|
+
waitFor(() => expect(getAllByText(document.body, successProps.title + '3')).toHaveLength(1));
|
|
146
|
+
|
|
147
|
+
/** There shouldn't be any other snackbars */
|
|
148
|
+
waitFor(() =>
|
|
149
|
+
expect(getAllByText(document.body, new RegExp(successProps.title))).not.toBeDefined()
|
|
150
|
+
);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it('should close snackbar after clicking X button', async () => {
|
|
154
|
+
const { showSuccessSnackbarBtn } = renderSnackbarProvider({
|
|
155
|
+
autoHideDuration: { long: 1_000_000, short: 1_000_000 },
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
userEvent.click(showSuccessSnackbarBtn);
|
|
159
|
+
userEvent.click(showSuccessSnackbarBtn);
|
|
160
|
+
userEvent.click(showSuccessSnackbarBtn);
|
|
161
|
+
userEvent.click(showSuccessSnackbarBtn);
|
|
162
|
+
|
|
163
|
+
const closeButtons = getAllByRole(document.body, 'button', { name: 'close' });
|
|
164
|
+
|
|
165
|
+
expect(closeButtons).toHaveLength(3);
|
|
166
|
+
expect(getAllByText(document.body, new RegExp(successProps.title))).toHaveLength(3);
|
|
167
|
+
|
|
168
|
+
userEvent.click(closeButtons[0]);
|
|
169
|
+
expect(
|
|
170
|
+
await findAllByText(document.body, new RegExp(successProps.title + '[12]+'))
|
|
171
|
+
).toHaveLength(2);
|
|
172
|
+
|
|
173
|
+
userEvent.click(closeButtons[1]);
|
|
174
|
+
expect(await findByText(document.body, successProps.title + '2')).toBeDefined();
|
|
175
|
+
|
|
176
|
+
userEvent.click(closeButtons[2]);
|
|
177
|
+
waitFor(() => expect(queryByText(document.body, new RegExp(successProps.title))).toBeNull());
|
|
178
|
+
});
|
|
179
|
+
});
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import React, { ReactNode, useState } from 'react';
|
|
2
|
+
import { createPortal } from 'react-dom';
|
|
3
|
+
import { SnackbarContextProvider } from './SnackbarStateProvider';
|
|
4
|
+
import { Actions, SnackbarOptionsProps, Variant } from '../interfaces';
|
|
5
|
+
import { Placement, SnackbarContainer } from '../SnackbarContainer/SnackbarContainer';
|
|
6
|
+
import { generateID } from '../../util/helper';
|
|
7
|
+
import { SnackbarItem } from '../SnackbarItem/SnackbarItem';
|
|
8
|
+
|
|
9
|
+
/** Short msg is when only title is provided. Long one when content or/and actions are provided (or type is error). */
|
|
10
|
+
interface Duration {
|
|
11
|
+
long: number;
|
|
12
|
+
short: number;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface Props {
|
|
16
|
+
closeButtonTitle: string;
|
|
17
|
+
children?: ReactNode | ReactNode[];
|
|
18
|
+
placement?: Placement;
|
|
19
|
+
stackSize?: number;
|
|
20
|
+
domRoot?: HTMLElement;
|
|
21
|
+
autoHideDuration?: Duration;
|
|
22
|
+
className?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
interface Item {
|
|
26
|
+
id: string;
|
|
27
|
+
title: string;
|
|
28
|
+
duration: number;
|
|
29
|
+
variant: Variant;
|
|
30
|
+
content?: string;
|
|
31
|
+
actions?: Actions;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const SnackbarProvider = (
|
|
35
|
+
{
|
|
36
|
+
closeButtonTitle,
|
|
37
|
+
placement = { vertical: 'bottom', horizontal: 'center' },
|
|
38
|
+
autoHideDuration = { long: 8000, short: 4000 },
|
|
39
|
+
stackSize = 3,
|
|
40
|
+
domRoot = document.body,
|
|
41
|
+
children,
|
|
42
|
+
className,
|
|
43
|
+
}: Props = { closeButtonTitle: '' }
|
|
44
|
+
) => {
|
|
45
|
+
const [snackbars, setSnackbars] = useState<Item[]>([]);
|
|
46
|
+
|
|
47
|
+
const addSnackbar = (item: Item) => {
|
|
48
|
+
setSnackbars((items) => [...items, item]);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const getDuration = (variant: Variant, actions?: Actions, content?: string) => {
|
|
52
|
+
const hasError = variant === 'error';
|
|
53
|
+
const hasContentOrActions = content || actions;
|
|
54
|
+
if (hasError || hasContentOrActions) {
|
|
55
|
+
return autoHideDuration.long;
|
|
56
|
+
}
|
|
57
|
+
return autoHideDuration.short;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const enqueueSnackbar = (
|
|
61
|
+
title: string,
|
|
62
|
+
content?: string,
|
|
63
|
+
options: SnackbarOptionsProps = {}
|
|
64
|
+
): void => {
|
|
65
|
+
const {
|
|
66
|
+
variant = 'info',
|
|
67
|
+
actions,
|
|
68
|
+
duration = getDuration(variant, actions, content),
|
|
69
|
+
} = options;
|
|
70
|
+
const item: Item = {
|
|
71
|
+
title,
|
|
72
|
+
content,
|
|
73
|
+
variant,
|
|
74
|
+
actions,
|
|
75
|
+
duration,
|
|
76
|
+
id: generateID(15, title),
|
|
77
|
+
};
|
|
78
|
+
addSnackbar(item);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const enqueueSuccessSnackbar = (
|
|
82
|
+
title: string,
|
|
83
|
+
content?: string,
|
|
84
|
+
options?: SnackbarOptionsProps
|
|
85
|
+
): void => {
|
|
86
|
+
enqueueSnackbar(title, content, { ...options, variant: 'success' });
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const enqueueErrorSnackbar = (
|
|
90
|
+
title: string,
|
|
91
|
+
content?: string,
|
|
92
|
+
options?: SnackbarOptionsProps
|
|
93
|
+
): void => {
|
|
94
|
+
enqueueSnackbar(title, content, { ...options, variant: 'error' });
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const onItemClosed = (id: string) => {
|
|
98
|
+
setSnackbars((items) => [...items].filter((item) => item.id !== id));
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const snackbarList = snackbars.map((item, index) =>
|
|
102
|
+
index < stackSize ? (
|
|
103
|
+
<SnackbarItem
|
|
104
|
+
{...item}
|
|
105
|
+
key={item.id}
|
|
106
|
+
onClose={onItemClosed}
|
|
107
|
+
closeButtonTitle={closeButtonTitle}
|
|
108
|
+
/>
|
|
109
|
+
) : null
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
const snackbarPortal = createPortal(
|
|
113
|
+
<SnackbarContainer placement={placement} className={className}>
|
|
114
|
+
{snackbarList}
|
|
115
|
+
</SnackbarContainer>,
|
|
116
|
+
domRoot
|
|
117
|
+
);
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<SnackbarContextProvider
|
|
121
|
+
initialState={{ enqueueSnackbar, enqueueSuccessSnackbar, enqueueErrorSnackbar }}
|
|
122
|
+
>
|
|
123
|
+
{children}
|
|
124
|
+
{snackbarPortal}
|
|
125
|
+
</SnackbarContextProvider>
|
|
126
|
+
);
|
|
127
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { createContext } from 'react';
|
|
2
|
+
import { SnackbarOptionsProps } from '../interfaces';
|
|
3
|
+
|
|
4
|
+
interface SnackbarContextProps {
|
|
5
|
+
enqueueSnackbar: (title: string, content?: string, options?: SnackbarOptionsProps) => void;
|
|
6
|
+
enqueueSuccessSnackbar: (title: string, content?: string, options?: SnackbarOptionsProps) => void;
|
|
7
|
+
enqueueErrorSnackbar: (title: string, content?: string, options?: SnackbarOptionsProps) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const SnackbarContext = createContext<SnackbarContextProps>({
|
|
11
|
+
enqueueSnackbar: () => null,
|
|
12
|
+
enqueueSuccessSnackbar: () => null,
|
|
13
|
+
enqueueErrorSnackbar: () => null,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
interface Props {
|
|
17
|
+
initialState: SnackbarContextProps;
|
|
18
|
+
children?: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const SnackbarContextProvider = ({ children, initialState }: Props) => {
|
|
22
|
+
return <SnackbarContext.Provider value={initialState}>{children}</SnackbarContext.Provider>;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export { SnackbarContextProvider, SnackbarContext, SnackbarContextProps };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
export type Variant = 'info' | 'success' | 'error';
|
|
4
|
+
|
|
5
|
+
export type Actions = (ButtonHTMLAttributes<HTMLButtonElement> & { label: string })[];
|
|
6
|
+
|
|
7
|
+
export interface SnackbarOptionsProps {
|
|
8
|
+
actions?: Actions;
|
|
9
|
+
variant?: Variant;
|
|
10
|
+
duration?: number;
|
|
11
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
@import '../readyclasses.module.scss';
|
|
2
|
+
|
|
3
|
+
.tile {
|
|
4
|
+
border: 1px solid #e9e9eb;
|
|
5
|
+
border-radius: 8px;
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
padding: 0 0 2rem;
|
|
8
|
+
background-color: #fff;
|
|
9
|
+
transition: box-shadow 0.2s ease-in-out;
|
|
10
|
+
|
|
11
|
+
&:hover {
|
|
12
|
+
box-shadow: 0 3px 6px rgba(0, 0, 0, 0.29);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
header {
|
|
16
|
+
display: flex;
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
align-items: center;
|
|
19
|
+
|
|
20
|
+
.icon {
|
|
21
|
+
padding: 0 1rem;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
figure {
|
|
26
|
+
margin: 0 0 1rem;
|
|
27
|
+
height: 3rem;
|
|
28
|
+
|
|
29
|
+
img {
|
|
30
|
+
vertical-align: top;
|
|
31
|
+
height: 3rem;
|
|
32
|
+
width: auto;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.placeholder {
|
|
37
|
+
font-size: 3rem;
|
|
38
|
+
margin: 0 0 1rem;
|
|
39
|
+
color: var(--greyed-out);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.content {
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-direction: column;
|
|
45
|
+
align-items: center;
|
|
46
|
+
justify-content: center;
|
|
47
|
+
cursor: default;
|
|
48
|
+
padding: 0 1rem;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&.loading {
|
|
52
|
+
header {
|
|
53
|
+
display: none;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.image {
|
|
57
|
+
margin-top: 2.5rem;
|
|
58
|
+
@include skeletonLoading();
|
|
59
|
+
border-radius: 0.5rem;
|
|
60
|
+
width: 3rem;
|
|
61
|
+
height: 3rem;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.title {
|
|
65
|
+
@include skeletonLoading();
|
|
66
|
+
color: transparent;
|
|
67
|
+
display: inline-block;
|
|
68
|
+
width: 70%;
|
|
69
|
+
border-radius: 0.5rem;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|