@rango-dev/ui 0.28.2-next.5 → 0.28.2-next.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +6 -6
- package/dist/index.js.map +4 -4
- package/dist/translations/en.d.ts.map +1 -1
- package/dist/translations/es.d.ts.map +1 -1
- package/dist/translations/fr.d.ts.map +1 -1
- package/dist/translations/ja.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Alert/Alert.styles.d.ts +4 -0
- package/dist/widget/ui/src/components/Alert/Alert.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/BlockchainsChip/BlockchainsChip.styles.d.ts +1 -0
- package/dist/widget/ui/src/components/BlockchainsChip/BlockchainsChip.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/BottomLogo/BottomLogo.styles.d.ts +2 -0
- package/dist/widget/ui/src/components/BottomLogo/BottomLogo.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Button/Button.styles.d.ts +3 -0
- package/dist/widget/ui/src/components/Button/Button.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/ChainToken/ChainToken.styles.d.ts +2 -0
- package/dist/widget/ui/src/components/ChainToken/ChainToken.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Checkbox/Checkbox.styles.d.ts +4 -0
- package/dist/widget/ui/src/components/Checkbox/Checkbox.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Chip/Chip.styles.d.ts +1 -0
- package/dist/widget/ui/src/components/Chip/Chip.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Collapsible/Collapsible.styles.d.ts +1 -0
- package/dist/widget/ui/src/components/Collapsible/Collapsible.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Divider/Divider.styles.d.ts +1 -0
- package/dist/widget/ui/src/components/Divider/Divider.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Drawer/Drawer.styles.d.ts +5 -0
- package/dist/widget/ui/src/components/Drawer/Drawer.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Header/Header.styles.d.ts +2 -0
- package/dist/widget/ui/src/components/Header/Header.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Icon/CloseIcon.d.ts +1 -0
- package/dist/widget/ui/src/components/Icon/CloseIcon.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Icon/common.d.ts +2 -0
- package/dist/widget/ui/src/components/Icon/common.d.ts.map +1 -1
- package/dist/widget/ui/src/components/List/List.styles.d.ts +1 -0
- package/dist/widget/ui/src/components/List/List.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/ListItem/ListItem.styles.d.ts +1 -0
- package/dist/widget/ui/src/components/ListItem/ListItem.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/ListItemButton/ListItemButton.styles.d.ts +1 -0
- package/dist/widget/ui/src/components/ListItemButton/ListItemButton.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/MessageBox/CollapsibleMessageBox.styles.d.ts +1 -0
- package/dist/widget/ui/src/components/MessageBox/CollapsibleMessageBox.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/MessageBox/MessageBox.styles.d.ts +3 -0
- package/dist/widget/ui/src/components/MessageBox/MessageBox.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Modal/Modal.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Modal/Modal.styles.d.ts +6 -0
- package/dist/widget/ui/src/components/Modal/Modal.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/NotFound/NotFound.styles.d.ts +1 -0
- package/dist/widget/ui/src/components/NotFound/NotFound.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Popover/Popover.styles.d.ts +2 -0
- package/dist/widget/ui/src/components/Popover/Popover.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/PriceImpact/PriceImpact.styles.d.ts +2 -0
- package/dist/widget/ui/src/components/PriceImpact/PriceImpact.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/QuoteCost/QuoteCost.styles.d.ts +4 -0
- package/dist/widget/ui/src/components/QuoteCost/QuoteCost.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/QuoteCost/QuoteCost.types.d.ts +2 -1
- package/dist/widget/ui/src/components/QuoteCost/QuoteCost.types.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Radio/Radio.styles.d.ts +2 -0
- package/dist/widget/ui/src/components/Radio/Radio.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/RadioGroup/RadioGroup.styles.d.ts +4 -0
- package/dist/widget/ui/src/components/RadioGroup/RadioGroup.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/RefreshProgressButton/RefreshProgressButton.styles.d.ts +2 -0
- package/dist/widget/ui/src/components/RefreshProgressButton/RefreshProgressButton.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/RoutesOverview/RoutesOverview.d.ts +1 -0
- package/dist/widget/ui/src/components/RoutesOverview/RoutesOverview.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Select/Select.d.ts +4 -0
- package/dist/widget/ui/src/components/Select/Select.d.ts.map +1 -0
- package/dist/widget/ui/src/components/Select/Select.types.d.ts +12 -0
- package/dist/widget/ui/src/components/Select/Select.types.d.ts.map +1 -0
- package/dist/widget/ui/src/components/Select/index.d.ts +2 -0
- package/dist/widget/ui/src/components/Select/index.d.ts.map +1 -0
- package/dist/widget/ui/src/components/Select/select.styles.d.ts +492 -0
- package/dist/widget/ui/src/components/Select/select.styles.d.ts.map +1 -0
- package/dist/widget/ui/src/components/SelectableCategoryList/SelectableCategoryList.styles.d.ts +3 -0
- package/dist/widget/ui/src/components/SelectableCategoryList/SelectableCategoryList.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Skeleton/Skeleton.styles.d.ts +1 -0
- package/dist/widget/ui/src/components/Skeleton/Skeleton.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/StepDetails/StepDetails.styles.d.ts +6 -0
- package/dist/widget/ui/src/components/StepDetails/StepDetails.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/SvgIcon/SvgIcon.style.d.ts +1 -0
- package/dist/widget/ui/src/components/SvgIcon/SvgIcon.style.d.ts.map +1 -1
- package/dist/widget/ui/src/components/SwapDetailsPlaceholder/SwapDetailsPlaceholder.d.ts +1 -0
- package/dist/widget/ui/src/components/SwapDetailsPlaceholder/SwapDetailsPlaceholder.d.ts.map +1 -1
- package/dist/widget/ui/src/components/SwapListItem/SwapListItem.styles.d.ts +6 -0
- package/dist/widget/ui/src/components/SwapListItem/SwapListItem.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/SwapListItem/SwapToken.styles.d.ts +9 -0
- package/dist/widget/ui/src/components/SwapListItem/SwapToken.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Switch/Switch.styles.d.ts +2 -0
- package/dist/widget/ui/src/components/Switch/Switch.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/TextField/TextField.styles.d.ts +3 -0
- package/dist/widget/ui/src/components/TextField/TextField.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Toast/Toast.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Toast/Toast.helpers.d.ts +4 -0
- package/dist/widget/ui/src/components/Toast/Toast.helpers.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Toast/Toast.styles.d.ts +173 -1
- package/dist/widget/ui/src/components/Toast/Toast.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/TokenAmount/TokenAmount.styles.d.ts +3 -0
- package/dist/widget/ui/src/components/TokenAmount/TokenAmount.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Tooltip/Tooltip.styles.d.ts +3 -0
- package/dist/widget/ui/src/components/Tooltip/Tooltip.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Typography/NotSelectableTypography.d.ts +1 -0
- package/dist/widget/ui/src/components/Typography/NotSelectableTypography.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Typography/Typography.styles.d.ts +1 -0
- package/dist/widget/ui/src/components/Typography/Typography.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Wallet/Wallet.styles.d.ts +5 -0
- package/dist/widget/ui/src/components/Wallet/Wallet.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/common/FilledCircle.d.ts +1 -0
- package/dist/widget/ui/src/components/common/FilledCircle.d.ts.map +1 -1
- package/dist/widget/ui/src/components/common/Image.d.ts +1 -0
- package/dist/widget/ui/src/components/common/Image.d.ts.map +1 -1
- package/dist/widget/ui/src/components/common/styles.d.ts +1 -0
- package/dist/widget/ui/src/components/common/styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/index.d.ts +1 -0
- package/dist/widget/ui/src/components/index.d.ts.map +1 -1
- package/dist/widget/ui/src/containers/SwapHistory/SwapHistory.d.ts +10 -0
- package/dist/widget/ui/src/containers/SwapHistory/SwapHistory.d.ts.map +1 -1
- package/dist/widget/ui/src/containers/SwapInput/SwapInput.styles.d.ts +11 -0
- package/dist/widget/ui/src/containers/SwapInput/SwapInput.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/containers/SwapInput/TokenSection.styles.d.ts +5 -0
- package/dist/widget/ui/src/containers/SwapInput/TokenSection.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/containers/TokenSelector/TokenSelector.d.ts +1 -0
- package/dist/widget/ui/src/containers/TokenSelector/TokenSelector.d.ts.map +1 -1
- package/dist/widget/ui/src/theme.d.ts +10 -0
- package/dist/widget/ui/src/theme.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/components/Alert/Alert.styles.ts +0 -1
- package/src/components/Modal/Modal.tsx +2 -0
- package/src/components/QuoteCost/QuoteCost.styles.ts +0 -1
- package/src/components/QuoteCost/QuoteCost.types.ts +1 -1
- package/src/components/Select/Select.tsx +85 -0
- package/src/components/Select/Select.types.ts +10 -0
- package/src/components/Select/index.ts +1 -0
- package/src/components/Select/select.styles.ts +100 -0
- package/src/components/Toast/Toast.helpers.ts +5 -0
- package/src/components/Toast/Toast.styles.ts +209 -5
- package/src/components/Toast/Toast.tsx +59 -34
- package/src/components/index.ts +1 -0
- package/src/theme.ts +1 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import * as Select from '@radix-ui/react-select';
|
|
2
|
+
|
|
3
|
+
import { darkTheme, styled } from '../../theme';
|
|
4
|
+
|
|
5
|
+
export const EXPANDABLE_QUOTE_TRANSITION_DURATION = 300;
|
|
6
|
+
|
|
7
|
+
export const SelectTrigger = styled(Select.Trigger, {
|
|
8
|
+
display: 'flex',
|
|
9
|
+
justifyContent: 'space-between',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
cursor: 'pointer',
|
|
12
|
+
backgroundColor: '$secondary',
|
|
13
|
+
padding: '$5 $10',
|
|
14
|
+
border: 0,
|
|
15
|
+
whiteSpace: 'nowrap',
|
|
16
|
+
|
|
17
|
+
'& svg': {
|
|
18
|
+
transition: `all ${EXPANDABLE_QUOTE_TRANSITION_DURATION}ms ease`,
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
variants: {
|
|
22
|
+
open: {
|
|
23
|
+
true: {
|
|
24
|
+
borderTopLeftRadius: '$sm',
|
|
25
|
+
borderTopRightRadius: '$sm',
|
|
26
|
+
'& ._typography, & svg': {
|
|
27
|
+
color: '$secondary',
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
'& svg': {
|
|
31
|
+
transform: 'rotate(180deg)',
|
|
32
|
+
},
|
|
33
|
+
backgroundColor: '$neutral100',
|
|
34
|
+
[`.${darkTheme} &`]: {
|
|
35
|
+
backgroundColor: '$neutral300',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
false: {
|
|
39
|
+
borderRadius: '$md',
|
|
40
|
+
'& ._typography, & svg': {
|
|
41
|
+
color: '$background',
|
|
42
|
+
[`.${darkTheme} &`]: {
|
|
43
|
+
color: '$foreground',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
'& svg': {
|
|
47
|
+
transform: 'rotate(0)',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
width: '100%',
|
|
53
|
+
'& ._typography': {
|
|
54
|
+
whiteSpace: 'nowrap',
|
|
55
|
+
overflow: 'hidden',
|
|
56
|
+
textOverflow: 'ellipsis',
|
|
57
|
+
width: '52px',
|
|
58
|
+
'@xs': {
|
|
59
|
+
width: 'auto',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
export const SelectContent = styled(Select.Content, {
|
|
65
|
+
padding: '$5 $10',
|
|
66
|
+
width: '100%',
|
|
67
|
+
position: 'absolute',
|
|
68
|
+
top: '38px',
|
|
69
|
+
maxHeight: '146px',
|
|
70
|
+
overflowY: 'auto',
|
|
71
|
+
borderBottomLeftRadius: '$sm',
|
|
72
|
+
borderBottomRightRadius: '$sm',
|
|
73
|
+
boxShadow: '-5px 5px 10px 0px rgba(86, 86, 86, 0.10)',
|
|
74
|
+
backgroundColor: '$neutral100',
|
|
75
|
+
[`.${darkTheme} &`]: {
|
|
76
|
+
backgroundColor: '$neutral300',
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
export const SelectItem = styled(Select.Item, {
|
|
81
|
+
padding: '$10 0',
|
|
82
|
+
borderTop: '1px solid',
|
|
83
|
+
borderColor: '$neutral300',
|
|
84
|
+
[`.${darkTheme} &`]: {
|
|
85
|
+
borderColor: '$neutral400',
|
|
86
|
+
},
|
|
87
|
+
listStyleType: 'none',
|
|
88
|
+
cursor: 'pointer',
|
|
89
|
+
'&:hover': {
|
|
90
|
+
'& ._typography': {
|
|
91
|
+
color: '$colors$secondary',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
'&:focus': {
|
|
95
|
+
outline: 'none',
|
|
96
|
+
'& ._typography': {
|
|
97
|
+
color: '$colors$secondary',
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
});
|
|
@@ -5,3 +5,8 @@ export function idGenerator() {
|
|
|
5
5
|
return id;
|
|
6
6
|
};
|
|
7
7
|
}
|
|
8
|
+
|
|
9
|
+
export const TOAST_UNMOUNT_DELAY = 500; // the delay before the toast is unmounted
|
|
10
|
+
export const TOAST_TRANSITION_DURATION = 300; // the duration of the toast transition
|
|
11
|
+
export const HOVER_TRANSITION_DURATION = 200; // the duration of the toast transition hover
|
|
12
|
+
export const TOAST_HIDE_DELAY = 200; // the delay before the toast is invisible to shift remained toast smoothly
|
|
@@ -1,16 +1,217 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { css, darkTheme, lightTheme, styled } from '../../theme';
|
|
2
2
|
import { Typography } from '../Typography';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import {
|
|
5
|
+
HOVER_TRANSITION_DURATION,
|
|
6
|
+
TOAST_TRANSITION_DURATION,
|
|
7
|
+
} from './Toast.helpers';
|
|
8
|
+
|
|
9
|
+
export const toastContentStyles = css({
|
|
10
|
+
transition: `transform ${HOVER_TRANSITION_DURATION}ms ease-in-out`,
|
|
11
|
+
'&:hover': {
|
|
12
|
+
transform: 'scale(0.99)',
|
|
13
|
+
},
|
|
7
14
|
});
|
|
8
15
|
|
|
9
16
|
export const ToastContentContainer = styled('div', {
|
|
10
|
-
|
|
17
|
+
transition: `transform ${TOAST_TRANSITION_DURATION}ms cubic-bezier(0, 0, 0.75, 1.25)`,
|
|
18
|
+
cursor: 'pointer',
|
|
19
|
+
variants: {
|
|
20
|
+
isActive: {
|
|
21
|
+
true: {},
|
|
22
|
+
},
|
|
23
|
+
isVisible: {
|
|
24
|
+
true: {},
|
|
25
|
+
},
|
|
26
|
+
position: {
|
|
27
|
+
'right-top': {},
|
|
28
|
+
'right-bottom': {},
|
|
29
|
+
'left-top': {},
|
|
30
|
+
'left-bottom': {},
|
|
31
|
+
'center-top': {},
|
|
32
|
+
'center-bottom': {},
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
compoundVariants: [
|
|
36
|
+
{
|
|
37
|
+
position: 'right-top',
|
|
38
|
+
isActive: true,
|
|
39
|
+
isVisible: true,
|
|
40
|
+
css: {
|
|
41
|
+
transform: 'translateX(0)',
|
|
42
|
+
maxHeight: '200px',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
position: 'right-top',
|
|
47
|
+
isActive: false,
|
|
48
|
+
isVisible: true,
|
|
49
|
+
css: {
|
|
50
|
+
maxHeight: '200px',
|
|
51
|
+
transform: 'translateX(100%)',
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
position: 'right-top',
|
|
56
|
+
isActive: false,
|
|
57
|
+
isVisible: false,
|
|
58
|
+
css: {
|
|
59
|
+
maxHeight: '0px',
|
|
60
|
+
transform: 'translateX(100%)',
|
|
61
|
+
transition: `max-height ${TOAST_TRANSITION_DURATION}ms ease-in-out`,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
position: 'right-bottom',
|
|
66
|
+
isActive: true,
|
|
67
|
+
isVisible: true,
|
|
68
|
+
css: {
|
|
69
|
+
transform: 'translateX(0)',
|
|
70
|
+
maxHeight: '200px',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
position: 'right-bottom',
|
|
75
|
+
isActive: false,
|
|
76
|
+
isVisible: true,
|
|
77
|
+
css: {
|
|
78
|
+
transform: 'translateX(100%)',
|
|
79
|
+
maxHeight: '200px',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
position: 'right-bottom',
|
|
84
|
+
isActive: false,
|
|
85
|
+
isVisible: false,
|
|
86
|
+
css: {
|
|
87
|
+
transform: 'translateX(100%)',
|
|
88
|
+
maxHeight: '0px',
|
|
89
|
+
transition: `max-height ${TOAST_TRANSITION_DURATION}ms ease-in-out`,
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
position: 'left-top',
|
|
94
|
+
isActive: true,
|
|
95
|
+
isVisible: true,
|
|
96
|
+
css: {
|
|
97
|
+
transform: 'translateX(0)',
|
|
98
|
+
maxHeight: '200px',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
position: 'left-top',
|
|
103
|
+
isActive: false,
|
|
104
|
+
isVisible: true,
|
|
105
|
+
css: {
|
|
106
|
+
transform: 'translateX(-100%)',
|
|
107
|
+
maxHeight: '200px',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
position: 'left-top',
|
|
112
|
+
isActive: false,
|
|
113
|
+
isVisible: false,
|
|
114
|
+
css: {
|
|
115
|
+
transform: 'translateX(-100%)',
|
|
116
|
+
maxHeight: '0px',
|
|
117
|
+
transition: `max-height ${TOAST_TRANSITION_DURATION}ms ease-in-out`,
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
position: 'left-bottom',
|
|
122
|
+
isActive: true,
|
|
123
|
+
isVisible: true,
|
|
124
|
+
css: {
|
|
125
|
+
transform: 'translateX(0)',
|
|
126
|
+
maxHeight: '200px',
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
position: 'left-bottom',
|
|
131
|
+
isActive: false,
|
|
132
|
+
isVisible: true,
|
|
133
|
+
css: {
|
|
134
|
+
transform: 'translateX(-100%)',
|
|
135
|
+
maxHeight: '200px',
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
position: 'left-bottom',
|
|
140
|
+
isActive: false,
|
|
141
|
+
isVisible: false,
|
|
142
|
+
css: {
|
|
143
|
+
transform: 'translateX(-100%)',
|
|
144
|
+
maxHeight: '0px',
|
|
145
|
+
transition: `max-height ${TOAST_TRANSITION_DURATION}ms ease-in-out`,
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
position: 'center-top',
|
|
150
|
+
isActive: true,
|
|
151
|
+
isVisible: true,
|
|
152
|
+
css: {
|
|
153
|
+
maxHeight: '200px',
|
|
154
|
+
transform: 'translateY(0)',
|
|
155
|
+
opacity: 1,
|
|
156
|
+
},
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
position: 'center-top',
|
|
160
|
+
isActive: false,
|
|
161
|
+
isVisible: true,
|
|
162
|
+
css: {
|
|
163
|
+
maxHeight: '200px',
|
|
164
|
+
transform: 'translateY(-1000%)',
|
|
165
|
+
opacity: 0,
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
position: 'center-top',
|
|
170
|
+
isActive: false,
|
|
171
|
+
isVisible: false,
|
|
172
|
+
css: {
|
|
173
|
+
maxHeight: '0px',
|
|
174
|
+
opacity: 0,
|
|
175
|
+
transform: 'translateY(-1000%)',
|
|
176
|
+
transition: `max-height ${TOAST_TRANSITION_DURATION}ms ease-in-out`,
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
position: 'center-bottom',
|
|
181
|
+
isActive: true,
|
|
182
|
+
isVisible: true,
|
|
183
|
+
css: {
|
|
184
|
+
transform: 'translateY(0)',
|
|
185
|
+
maxHeight: '200px',
|
|
186
|
+
opacity: 1,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
position: 'center-bottom',
|
|
191
|
+
isActive: false,
|
|
192
|
+
isVisible: true,
|
|
193
|
+
css: {
|
|
194
|
+
transform: 'translateY(1000%)',
|
|
195
|
+
maxHeight: '200px',
|
|
196
|
+
opacity: 0,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
position: 'center-bottom',
|
|
201
|
+
isActive: false,
|
|
202
|
+
isVisible: false,
|
|
203
|
+
css: {
|
|
204
|
+
transform: 'translateY(1000%)',
|
|
205
|
+
maxHeight: '0px',
|
|
206
|
+
opacity: 0,
|
|
207
|
+
transition: `max-height ${TOAST_TRANSITION_DURATION}ms ease-in-out`,
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
],
|
|
11
211
|
});
|
|
12
212
|
|
|
13
213
|
export const ToastContainer = styled('div', {
|
|
214
|
+
overflow: 'hidden',
|
|
14
215
|
position: 'absolute',
|
|
15
216
|
zIndex: 9999,
|
|
16
217
|
display: 'flex',
|
|
@@ -25,6 +226,7 @@ export const ToastContainer = styled('div', {
|
|
|
25
226
|
'right-bottom': {
|
|
26
227
|
right: 12,
|
|
27
228
|
bottom: 2,
|
|
229
|
+
flexDirection: 'column-reverse',
|
|
28
230
|
},
|
|
29
231
|
'left-top': {
|
|
30
232
|
left: 12,
|
|
@@ -33,6 +235,7 @@ export const ToastContainer = styled('div', {
|
|
|
33
235
|
'left-bottom': {
|
|
34
236
|
left: 12,
|
|
35
237
|
bottom: 2,
|
|
238
|
+
flexDirection: 'column-reverse',
|
|
36
239
|
},
|
|
37
240
|
'center-top': {
|
|
38
241
|
left: '50%',
|
|
@@ -43,6 +246,7 @@ export const ToastContainer = styled('div', {
|
|
|
43
246
|
left: '50%',
|
|
44
247
|
transform: 'translateX(-50%)',
|
|
45
248
|
bottom: 2,
|
|
249
|
+
flexDirection: 'column-reverse',
|
|
46
250
|
},
|
|
47
251
|
},
|
|
48
252
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ToastProps } from './Toast.types';
|
|
2
2
|
|
|
3
|
-
import React, { useEffect } from 'react';
|
|
3
|
+
import React, { useEffect, useState } from 'react';
|
|
4
4
|
|
|
5
5
|
import { CloseIcon } from '../../icons';
|
|
6
6
|
import { Alert } from '../Alert';
|
|
@@ -9,12 +9,14 @@ import AlertIcon from '../Alert/AlertIcon';
|
|
|
9
9
|
import { Divider } from '../Divider';
|
|
10
10
|
import { IconButton } from '../IconButton';
|
|
11
11
|
|
|
12
|
+
import { TOAST_HIDE_DELAY, TOAST_UNMOUNT_DELAY } from './Toast.helpers';
|
|
12
13
|
import { useToast } from './Toast.Provider';
|
|
13
14
|
import {
|
|
14
15
|
AlertBox,
|
|
15
16
|
AlertFlexContainer,
|
|
16
17
|
StyledTypography,
|
|
17
18
|
ToastContentContainer,
|
|
19
|
+
toastContentStyles,
|
|
18
20
|
} from './Toast.styles';
|
|
19
21
|
|
|
20
22
|
export const Toast = (props: ToastProps) => {
|
|
@@ -29,6 +31,8 @@ export const Toast = (props: ToastProps) => {
|
|
|
29
31
|
hideOnTap = true,
|
|
30
32
|
variant = 'standard',
|
|
31
33
|
} = props;
|
|
34
|
+
const [isActive, setIsActive] = useState(false);
|
|
35
|
+
const [isVisible, setIsVisible] = useState(false);
|
|
32
36
|
const { removeToast } = useToast();
|
|
33
37
|
useEffect(() => {
|
|
34
38
|
let cleanup;
|
|
@@ -45,42 +49,63 @@ export const Toast = (props: ToastProps) => {
|
|
|
45
49
|
}, [id]);
|
|
46
50
|
|
|
47
51
|
const handleClose = () => {
|
|
48
|
-
|
|
49
|
-
|
|
52
|
+
setIsActive(false);
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
setIsVisible(false);
|
|
55
|
+
}, TOAST_HIDE_DELAY);
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
removeToast(id, position);
|
|
58
|
+
onClose?.();
|
|
59
|
+
}, TOAST_UNMOUNT_DELAY);
|
|
50
60
|
};
|
|
51
61
|
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
setIsVisible(true);
|
|
64
|
+
setTimeout(() => {
|
|
65
|
+
setIsActive(true);
|
|
66
|
+
}, 0);
|
|
67
|
+
}, []);
|
|
68
|
+
|
|
52
69
|
return (
|
|
53
|
-
<ToastContentContainer
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
70
|
+
<ToastContentContainer
|
|
71
|
+
isActive={isActive}
|
|
72
|
+
position={position}
|
|
73
|
+
isVisible={isVisible}>
|
|
74
|
+
<div className={toastContentStyles()}>
|
|
75
|
+
<AlertBox
|
|
76
|
+
onClick={hideOnTap ? handleClose : undefined}
|
|
77
|
+
variant={variant}
|
|
78
|
+
type={type}>
|
|
79
|
+
{variant === 'custom' ? (
|
|
80
|
+
<AlertFlexContainer>
|
|
81
|
+
<IconHighlight type={type} align="center">
|
|
82
|
+
<AlertIcon type={type} />
|
|
83
|
+
</IconHighlight>
|
|
84
|
+
<Divider direction="horizontal" size={10} />
|
|
85
|
+
<StyledTypography variant="body" size="small" align="left">
|
|
86
|
+
{props.title}
|
|
87
|
+
</StyledTypography>
|
|
88
|
+
</AlertFlexContainer>
|
|
89
|
+
) : (
|
|
90
|
+
<Alert
|
|
91
|
+
title={title}
|
|
92
|
+
type={type}
|
|
93
|
+
variant="alarm"
|
|
94
|
+
titleAlign="left"
|
|
95
|
+
action={
|
|
96
|
+
hasCloseIcon ? (
|
|
97
|
+
<IconButton
|
|
98
|
+
variant="ghost"
|
|
99
|
+
size="xsmall"
|
|
100
|
+
onClick={handleClose}>
|
|
101
|
+
<CloseIcon size={12} />
|
|
102
|
+
</IconButton>
|
|
103
|
+
) : undefined
|
|
104
|
+
}
|
|
105
|
+
/>
|
|
106
|
+
)}
|
|
107
|
+
</AlertBox>
|
|
108
|
+
</div>
|
|
84
109
|
</ToastContentContainer>
|
|
85
110
|
);
|
|
86
111
|
};
|
package/src/components/index.ts
CHANGED