@rango-dev/ui 0.28.1 → 0.28.2-next.1
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/CHANGELOG.md +4 -0
- 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.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Alert/Alert.styles.d.ts +4 -4
- package/dist/widget/ui/src/components/Alert/Alert.types.d.ts +2 -0
- package/dist/widget/ui/src/components/Alert/Alert.types.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Button/Button.d.ts +6 -6
- package/dist/widget/ui/src/components/Button/Button.styles.d.ts +1 -1
- package/dist/widget/ui/src/components/Checkbox/Checkbox.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Divider/Divider.d.ts +1 -1
- package/dist/widget/ui/src/components/Divider/Divider.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Divider/Divider.styles.d.ts +2 -2
- package/dist/widget/ui/src/components/Icon/common.d.ts +2 -2
- package/dist/widget/ui/src/components/MessageBox/MessageBox.styles.d.ts +1 -1
- package/dist/widget/ui/src/components/Modal/Modal.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Modal/Modal.types.d.ts +6 -1
- package/dist/widget/ui/src/components/Modal/Modal.types.d.ts.map +1 -1
- package/dist/widget/ui/src/components/RadioGroup/RadioGroup.styles.d.ts +1 -1
- package/dist/widget/ui/src/components/StepDetails/StepDetails.styles.d.ts +4 -4
- package/dist/widget/ui/src/components/SvgIcon/SvgIcon.style.d.ts +1 -1
- package/dist/widget/ui/src/components/Toast/Toast.Provider.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.stories.d.ts +4 -3
- package/dist/widget/ui/src/components/Toast/Toast.stories.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Toast/Toast.styles.d.ts +4 -6
- package/dist/widget/ui/src/components/Toast/Toast.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Toast/Toast.types.d.ts +14 -14
- package/dist/widget/ui/src/components/Toast/Toast.types.d.ts.map +1 -1
- package/dist/widget/ui/src/components/TokenAmount/TokenAmount.styles.d.ts +1 -1
- package/dist/widget/ui/src/components/Typography/Typography.types.d.ts +1 -1
- package/dist/widget/ui/src/components/Typography/Typography.types.d.ts.map +1 -1
- package/dist/widget/ui/src/containers/ConnectWalletsModal/ConnectWalletsModal.d.ts.map +1 -1
- package/dist/widget/ui/src/containers/SwapInput/SwapInput.styles.d.ts +6 -6
- package/dist/widget/ui/src/containers/SwapInput/TokenSection.styles.d.ts +6 -6
- package/dist/widget/ui/src/icons/Autorenew.d.ts +5 -0
- package/dist/widget/ui/src/icons/Autorenew.d.ts.map +1 -0
- package/dist/widget/ui/src/icons/Exit.d.ts +5 -0
- package/dist/widget/ui/src/icons/Exit.d.ts.map +1 -0
- package/dist/widget/ui/src/icons/Swap.d.ts +5 -0
- package/dist/widget/ui/src/icons/Swap.d.ts.map +1 -0
- package/dist/widget/ui/src/icons/index.d.ts +3 -0
- package/dist/widget/ui/src/icons/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/components/Alert/Alert.tsx +2 -0
- package/src/components/Alert/Alert.types.ts +2 -0
- package/src/components/Checkbox/Checkbox.styles.ts +4 -0
- package/src/components/Divider/Divider.tsx +2 -1
- package/src/components/Modal/Modal.tsx +6 -5
- package/src/components/Modal/Modal.types.ts +6 -1
- package/src/components/Toast/Toast.Provider.tsx +82 -44
- package/src/components/Toast/Toast.stories.tsx +18 -21
- package/src/components/Toast/Toast.styles.ts +74 -38
- package/src/components/Toast/Toast.tsx +54 -27
- package/src/components/Toast/Toast.types.ts +19 -17
- package/src/components/Typography/Typography.types.tsx +1 -1
- package/src/containers/ConnectWalletsModal/ConnectWalletsModal.tsx +3 -1
- package/src/icons/Autorenew.tsx +20 -0
- package/src/icons/Exit.tsx +20 -0
- package/src/icons/Swap.tsx +20 -0
- package/src/icons/index.ts +3 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/icons/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,eAAe,CAAC;AAC3D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,QAAQ,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AO,CAAC;AAC3C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -18,6 +18,7 @@ export function Alert(props: PropsWithChildren<PropTypes>) {
|
|
|
18
18
|
action,
|
|
19
19
|
containerStyles,
|
|
20
20
|
variant = 'regular',
|
|
21
|
+
titleAlign,
|
|
21
22
|
} = props;
|
|
22
23
|
const isFooterString = typeof footer === 'string';
|
|
23
24
|
|
|
@@ -36,6 +37,7 @@ export function Alert(props: PropsWithChildren<PropTypes>) {
|
|
|
36
37
|
{title && (
|
|
37
38
|
<Typography
|
|
38
39
|
color={getColor(type, variant)}
|
|
40
|
+
align={titleAlign}
|
|
39
41
|
variant="body"
|
|
40
42
|
className="title_typography"
|
|
41
43
|
size={variant === 'regular' ? 'xsmall' : 'small'}>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { BaseAlign } from '../Typography/Typography.types';
|
|
1
2
|
import type { CSSProperties, ReactNode } from 'react';
|
|
2
3
|
|
|
3
4
|
export type Type = 'success' | 'warning' | 'error' | 'info' | 'loading';
|
|
@@ -9,4 +10,5 @@ export interface PropTypes {
|
|
|
9
10
|
action?: ReactNode;
|
|
10
11
|
variant?: 'alarm' | 'regular';
|
|
11
12
|
containerStyles?: CSSProperties;
|
|
13
|
+
titleAlign?: BaseAlign;
|
|
12
14
|
}
|
|
@@ -28,6 +28,10 @@ export const CheckboxRoot = styled(RadixCheckbox.Root, {
|
|
|
28
28
|
backgroundColor: '$$color',
|
|
29
29
|
borderColor: '$$color',
|
|
30
30
|
},
|
|
31
|
+
'&[data-disabled]': {
|
|
32
|
+
backgroundColor: '$neutral600',
|
|
33
|
+
borderColor: '$neutral700',
|
|
34
|
+
},
|
|
31
35
|
});
|
|
32
36
|
|
|
33
37
|
export const CheckboxIndicator = styled(RadixCheckbox.CheckboxIndicator, {
|
|
@@ -9,6 +9,7 @@ const DEFAULT_SIZE = 12;
|
|
|
9
9
|
export function Divider({
|
|
10
10
|
size = DEFAULT_SIZE,
|
|
11
11
|
direction = 'vertical',
|
|
12
|
+
...props
|
|
12
13
|
}: PropTypes) {
|
|
13
|
-
return <DividerContainer size={size} direction={direction} />;
|
|
14
|
+
return <DividerContainer size={size} direction={direction} {...props} />;
|
|
14
15
|
}
|
|
@@ -27,7 +27,7 @@ export function Modal(props: PropsWithChildren<PropTypes>) {
|
|
|
27
27
|
title,
|
|
28
28
|
open,
|
|
29
29
|
onClose,
|
|
30
|
-
|
|
30
|
+
styles,
|
|
31
31
|
anchor = 'bottom',
|
|
32
32
|
container = document.body,
|
|
33
33
|
prefix,
|
|
@@ -84,10 +84,11 @@ export function Modal(props: PropsWithChildren<PropTypes>) {
|
|
|
84
84
|
<BackDrop
|
|
85
85
|
active={active}
|
|
86
86
|
onClick={handleBackDropClick}
|
|
87
|
-
anchor={anchor}
|
|
87
|
+
anchor={anchor}
|
|
88
|
+
css={styles?.root}>
|
|
88
89
|
<ModalContainer
|
|
89
90
|
active={active}
|
|
90
|
-
css={
|
|
91
|
+
css={styles?.container}
|
|
91
92
|
anchor={anchor}>
|
|
92
93
|
{header ?? (
|
|
93
94
|
<ModalHeader noTitle={!title && dismissible && !prefix}>
|
|
@@ -107,9 +108,9 @@ export function Modal(props: PropsWithChildren<PropTypes>) {
|
|
|
107
108
|
</Flex>
|
|
108
109
|
</ModalHeader>
|
|
109
110
|
)}
|
|
110
|
-
<Content>{children}</Content>
|
|
111
|
+
<Content css={styles?.content}>{children}</Content>
|
|
111
112
|
|
|
112
|
-
<Footer>
|
|
113
|
+
<Footer css={styles?.footer}>
|
|
113
114
|
{footer && <div className="footer__content">{footer}</div>}
|
|
114
115
|
|
|
115
116
|
<div
|
|
@@ -15,7 +15,12 @@ export interface PropTypes {
|
|
|
15
15
|
prefix?: React.ReactNode;
|
|
16
16
|
suffix?: React.ReactNode;
|
|
17
17
|
container?: HTMLElement;
|
|
18
|
-
|
|
18
|
+
styles?: {
|
|
19
|
+
root?: Stitches.CSS<typeof config>;
|
|
20
|
+
container?: Stitches.CSS<typeof config>;
|
|
21
|
+
content?: Stitches.CSS<typeof config>;
|
|
22
|
+
footer?: Stitches.CSS<typeof config>;
|
|
23
|
+
};
|
|
19
24
|
footer?: React.ReactNode;
|
|
20
25
|
hasWatermark?: boolean;
|
|
21
26
|
hasCloseIcon?: boolean;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
ProviderContext,
|
|
3
3
|
ProviderPropTypes,
|
|
4
|
+
ToastPosition,
|
|
4
5
|
ToastProps,
|
|
5
6
|
ToastType,
|
|
6
7
|
} from './Toast.types';
|
|
@@ -15,61 +16,98 @@ import { ToastContainer } from './Toast.styles';
|
|
|
15
16
|
|
|
16
17
|
const ToastContext = createContext<ProviderContext | undefined>(undefined);
|
|
17
18
|
|
|
19
|
+
const renderToastContainer = (
|
|
20
|
+
toasts: ToastProps[],
|
|
21
|
+
position: ToastPosition
|
|
22
|
+
) => (
|
|
23
|
+
<>
|
|
24
|
+
{toasts.length > 0 && (
|
|
25
|
+
<ToastContainer style={toasts[0].containerStyle} position={position}>
|
|
26
|
+
{toasts.map((toast) => (
|
|
27
|
+
<Toast {...toast} key={toast.id} />
|
|
28
|
+
))}
|
|
29
|
+
</ToastContainer>
|
|
30
|
+
)}
|
|
31
|
+
</>
|
|
32
|
+
);
|
|
33
|
+
|
|
18
34
|
export const ToastProvider = (props: PropsWithChildren<ProviderPropTypes>) => {
|
|
19
35
|
const generateId = useMemo(() => idGenerator(), []);
|
|
20
36
|
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const [toasts, setToasts] = useState<ToastProps[]>([]);
|
|
37
|
+
const { children, container } = props;
|
|
38
|
+
const [leftTopToasts, setLeftTopToasts] = useState<ToastProps[]>([]);
|
|
39
|
+
const [leftBottomToasts, setLeftBottomToasts] = useState<ToastProps[]>([]);
|
|
40
|
+
const [rightTopToasts, setRightTopToasts] = useState<ToastProps[]>([]);
|
|
41
|
+
const [rightBottomToasts, setRightBottomToasts] = useState<ToastProps[]>([]);
|
|
42
|
+
const [centerTopToasts, setCenterTopToasts] = useState<ToastProps[]>([]);
|
|
43
|
+
const [centerBottomToasts, setCenterBottomToasts] = useState<ToastProps[]>(
|
|
44
|
+
[]
|
|
45
|
+
);
|
|
31
46
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
47
|
+
const getToastSetter = (position: ToastPosition) => {
|
|
48
|
+
switch (position) {
|
|
49
|
+
case 'right-top':
|
|
50
|
+
return setRightTopToasts;
|
|
51
|
+
case 'right-bottom':
|
|
52
|
+
return setRightBottomToasts;
|
|
53
|
+
case 'left-top':
|
|
54
|
+
return setLeftTopToasts;
|
|
55
|
+
case 'left-bottom':
|
|
56
|
+
return setLeftBottomToasts;
|
|
57
|
+
case 'center-top':
|
|
58
|
+
return setCenterTopToasts;
|
|
59
|
+
default:
|
|
60
|
+
return setCenterBottomToasts;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const handleAddToast = (content: ToastType) => {
|
|
65
|
+
const addToasts = () => getToastSetter(content.position);
|
|
66
|
+
|
|
67
|
+
addToasts()((toasts) => {
|
|
68
|
+
const isToastExistById = toasts.find((toast) => toast.id === content.id);
|
|
69
|
+
if (isToastExistById) {
|
|
70
|
+
console.warn(
|
|
71
|
+
'Trying to send a toast with an existing ID. Please update the toast ID or use it after the toast is hidden'
|
|
38
72
|
);
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
73
|
+
return toasts;
|
|
74
|
+
}
|
|
75
|
+
return [
|
|
76
|
+
...toasts,
|
|
77
|
+
{
|
|
78
|
+
...content,
|
|
79
|
+
id: content.id || generateId(),
|
|
80
|
+
},
|
|
81
|
+
];
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const handleRemoveToast = (id: number | string, position: ToastPosition) => {
|
|
86
|
+
const removeFromToasts = () => getToastSetter(position);
|
|
87
|
+
|
|
88
|
+
removeFromToasts()((toasts) => toasts.filter((t) => t.id !== id));
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
92
|
+
const toastApis = {
|
|
93
|
+
addToast: (content: ToastType) => handleAddToast(content),
|
|
94
|
+
removeToast: (id: number | string, position: ToastPosition) =>
|
|
95
|
+
handleRemoveToast(id, position),
|
|
58
96
|
};
|
|
59
97
|
|
|
60
98
|
return (
|
|
61
|
-
<ToastContext.Provider value={
|
|
99
|
+
<ToastContext.Provider value={toastApis}>
|
|
62
100
|
{children}
|
|
63
101
|
{container &&
|
|
64
102
|
createPortal(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
|
|
71
|
-
)
|
|
72
|
-
|
|
103
|
+
<>
|
|
104
|
+
{renderToastContainer(rightTopToasts, 'right-top')}
|
|
105
|
+
{renderToastContainer(leftTopToasts, 'left-top')}
|
|
106
|
+
{renderToastContainer(centerTopToasts, 'center-top')}
|
|
107
|
+
{renderToastContainer(rightBottomToasts, 'right-bottom')}
|
|
108
|
+
{renderToastContainer(leftBottomToasts, 'left-bottom')}
|
|
109
|
+
{renderToastContainer(centerBottomToasts, 'center-bottom')}
|
|
110
|
+
</>,
|
|
73
111
|
container
|
|
74
112
|
)}
|
|
75
113
|
</ToastContext.Provider>
|
|
@@ -16,7 +16,8 @@ export default {
|
|
|
16
16
|
type: 'success',
|
|
17
17
|
title: 'Please change your wallet network to Polygon',
|
|
18
18
|
autoHideDuration: 5_000,
|
|
19
|
-
|
|
19
|
+
position: 'right-top',
|
|
20
|
+
variant: 'standard',
|
|
20
21
|
},
|
|
21
22
|
argTypes: {
|
|
22
23
|
type: {
|
|
@@ -26,30 +27,26 @@ export default {
|
|
|
26
27
|
options: ['success', 'warning', 'error', 'info', 'loading'],
|
|
27
28
|
},
|
|
28
29
|
},
|
|
30
|
+
position: {
|
|
31
|
+
name: 'position',
|
|
32
|
+
control: {
|
|
33
|
+
type: 'select',
|
|
34
|
+
options: [
|
|
35
|
+
'right-top',
|
|
36
|
+
'left-top',
|
|
37
|
+
'center-top',
|
|
38
|
+
'right-bottom',
|
|
39
|
+
'left-bottom',
|
|
40
|
+
'center-bottom',
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
},
|
|
29
44
|
},
|
|
30
45
|
} as Meta<typeof Toast>;
|
|
31
46
|
|
|
32
|
-
export const
|
|
33
|
-
return (
|
|
34
|
-
<ToastProvider
|
|
35
|
-
container={document.body}
|
|
36
|
-
anchorOrigin={{
|
|
37
|
-
horizontal: props.horizontal,
|
|
38
|
-
vertical: 'top',
|
|
39
|
-
}}>
|
|
40
|
-
<ToastComponent {...props} />
|
|
41
|
-
</ToastProvider>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const BottomToasts = (props: ToastProps) => {
|
|
47
|
+
export const Main = (props: ToastProps) => {
|
|
46
48
|
return (
|
|
47
|
-
<ToastProvider
|
|
48
|
-
container={document.body}
|
|
49
|
-
anchorOrigin={{
|
|
50
|
-
horizontal: props.horizontal,
|
|
51
|
-
vertical: 'bottom',
|
|
52
|
-
}}>
|
|
49
|
+
<ToastProvider container={document.body}>
|
|
53
50
|
<ToastComponent {...props} />
|
|
54
51
|
</ToastProvider>
|
|
55
52
|
);
|
|
@@ -7,18 +7,7 @@ const toastOpacity = keyframes({
|
|
|
7
7
|
});
|
|
8
8
|
|
|
9
9
|
export const ToastContentContainer = styled('div', {
|
|
10
|
-
|
|
11
|
-
horizontal: {
|
|
12
|
-
right: {
|
|
13
|
-
right: 12,
|
|
14
|
-
animation: `${toastOpacity} .7s`,
|
|
15
|
-
},
|
|
16
|
-
left: {
|
|
17
|
-
left: 12,
|
|
18
|
-
animation: `${toastOpacity} .7s`,
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
},
|
|
10
|
+
animation: `${toastOpacity} .7s`,
|
|
22
11
|
});
|
|
23
12
|
|
|
24
13
|
export const ToastContainer = styled('div', {
|
|
@@ -28,20 +17,31 @@ export const ToastContainer = styled('div', {
|
|
|
28
17
|
gap: '$4',
|
|
29
18
|
flexDirection: 'column',
|
|
30
19
|
variants: {
|
|
31
|
-
|
|
32
|
-
right: {
|
|
20
|
+
position: {
|
|
21
|
+
'right-top': {
|
|
33
22
|
right: 12,
|
|
23
|
+
top: 2,
|
|
34
24
|
},
|
|
35
|
-
|
|
25
|
+
'right-bottom': {
|
|
26
|
+
right: 12,
|
|
27
|
+
bottom: 2,
|
|
28
|
+
},
|
|
29
|
+
'left-top': {
|
|
36
30
|
left: 12,
|
|
31
|
+
top: 2,
|
|
37
32
|
},
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
'left-bottom': {
|
|
34
|
+
left: 12,
|
|
35
|
+
bottom: 2,
|
|
36
|
+
},
|
|
37
|
+
'center-top': {
|
|
38
|
+
left: '50%',
|
|
39
|
+
transform: 'translateX(-50%)',
|
|
42
40
|
top: 2,
|
|
43
41
|
},
|
|
44
|
-
bottom: {
|
|
42
|
+
'center-bottom': {
|
|
43
|
+
left: '50%',
|
|
44
|
+
transform: 'translateX(-50%)',
|
|
45
45
|
bottom: 2,
|
|
46
46
|
},
|
|
47
47
|
},
|
|
@@ -53,36 +53,73 @@ export const AlertBox = styled('div', {
|
|
|
53
53
|
borderRadius: '$sm',
|
|
54
54
|
width: '292px',
|
|
55
55
|
minHeight: '52px',
|
|
56
|
-
backgroundColor: '$background',
|
|
57
|
-
borderRight: '1px solid',
|
|
58
|
-
[`.${darkTheme} &`]: {
|
|
59
|
-
backgroundColor: '#070917',
|
|
60
|
-
},
|
|
61
|
-
'&:hover': {
|
|
62
|
-
backgroundColor: '$info100',
|
|
63
|
-
[`.${darkTheme} &`]: {
|
|
64
|
-
backgroundColor: '#111733',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
56
|
variants: {
|
|
57
|
+
variant: {
|
|
58
|
+
custom: {
|
|
59
|
+
backgroundColor: '$background',
|
|
60
|
+
borderRight: '1px solid',
|
|
61
|
+
'&:hover': {
|
|
62
|
+
backgroundColor: '$info100',
|
|
63
|
+
[`.${darkTheme} &`]: {
|
|
64
|
+
backgroundColor: '$neutral300',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
standard: {
|
|
69
|
+
'& ._alert': {
|
|
70
|
+
padding: '$10',
|
|
71
|
+
width: '100%',
|
|
72
|
+
justifyContent: 'center',
|
|
73
|
+
alignItems: 'center',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
68
77
|
type: {
|
|
69
|
-
error: {
|
|
78
|
+
error: {},
|
|
79
|
+
success: {},
|
|
80
|
+
warning: {},
|
|
81
|
+
info: {},
|
|
82
|
+
loading: {},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
compoundVariants: [
|
|
86
|
+
{
|
|
87
|
+
variant: 'custom',
|
|
88
|
+
type: 'error',
|
|
89
|
+
|
|
90
|
+
css: {
|
|
70
91
|
borderRightColor: '$error500',
|
|
71
92
|
},
|
|
72
|
-
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
variant: 'custom',
|
|
96
|
+
type: 'success',
|
|
97
|
+
css: {
|
|
73
98
|
borderRightColor: '$success500',
|
|
74
99
|
},
|
|
75
|
-
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
variant: 'custom',
|
|
103
|
+
type: 'warning',
|
|
104
|
+
css: {
|
|
76
105
|
borderRightColor: '$warning500',
|
|
77
106
|
},
|
|
78
|
-
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
variant: 'custom',
|
|
110
|
+
type: 'info',
|
|
111
|
+
css: {
|
|
79
112
|
borderRightColor: '$info500',
|
|
80
113
|
},
|
|
81
|
-
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
variant: 'custom',
|
|
117
|
+
type: 'loading',
|
|
118
|
+
css: {
|
|
82
119
|
borderRightColor: '$info500',
|
|
83
120
|
},
|
|
84
121
|
},
|
|
85
|
-
|
|
122
|
+
],
|
|
86
123
|
});
|
|
87
124
|
|
|
88
125
|
export const AlertFlexContainer = styled('div', {
|
|
@@ -108,6 +145,5 @@ export const StyledTypography = styled(Typography, {
|
|
|
108
145
|
|
|
109
146
|
export const ToastStoryContainer = styled('div', {
|
|
110
147
|
display: 'flex',
|
|
111
|
-
justifyContent: 'center',
|
|
112
148
|
alignItems: 'center',
|
|
113
149
|
});
|
|
@@ -2,9 +2,12 @@ import type { ToastProps } from './Toast.types';
|
|
|
2
2
|
|
|
3
3
|
import React, { useEffect } from 'react';
|
|
4
4
|
|
|
5
|
+
import { CloseIcon } from '../../icons';
|
|
6
|
+
import { Alert } from '../Alert';
|
|
5
7
|
import { IconHighlight } from '../Alert/Alert.styles';
|
|
6
8
|
import AlertIcon from '../Alert/AlertIcon';
|
|
7
9
|
import { Divider } from '../Divider';
|
|
10
|
+
import { IconButton } from '../IconButton';
|
|
8
11
|
|
|
9
12
|
import { useToast } from './Toast.Provider';
|
|
10
13
|
import {
|
|
@@ -14,46 +17,70 @@ import {
|
|
|
14
17
|
ToastContentContainer,
|
|
15
18
|
} from './Toast.styles';
|
|
16
19
|
|
|
17
|
-
const DEFAULT_HIDE_DURATION = 3_000;
|
|
18
|
-
|
|
19
20
|
export const Toast = (props: ToastProps) => {
|
|
20
|
-
const {
|
|
21
|
+
const {
|
|
22
|
+
id,
|
|
23
|
+
autoHideDuration,
|
|
24
|
+
onClose,
|
|
25
|
+
type,
|
|
26
|
+
title,
|
|
27
|
+
position,
|
|
28
|
+
hasCloseIcon = true,
|
|
29
|
+
hideOnTap = true,
|
|
30
|
+
variant = 'standard',
|
|
31
|
+
} = props;
|
|
21
32
|
const { removeToast } = useToast();
|
|
22
33
|
useEffect(() => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
let cleanup;
|
|
35
|
+
|
|
36
|
+
if (autoHideDuration) {
|
|
37
|
+
const timer = setTimeout(() => {
|
|
38
|
+
handleClose();
|
|
39
|
+
}, autoHideDuration);
|
|
26
40
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
41
|
+
cleanup = () => clearTimeout(timer);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return cleanup;
|
|
30
45
|
}, [id]);
|
|
31
46
|
|
|
47
|
+
const handleClose = () => {
|
|
48
|
+
removeToast(id, position);
|
|
49
|
+
onClose?.();
|
|
50
|
+
};
|
|
51
|
+
|
|
32
52
|
return (
|
|
33
|
-
<ToastContentContainer
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
type={props.type}
|
|
40
|
-
style={props.style}>
|
|
53
|
+
<ToastContentContainer>
|
|
54
|
+
<AlertBox
|
|
55
|
+
onClick={hideOnTap ? handleClose : undefined}
|
|
56
|
+
variant={variant}
|
|
57
|
+
type={type}>
|
|
58
|
+
{variant === 'custom' ? (
|
|
41
59
|
<AlertFlexContainer>
|
|
42
|
-
<IconHighlight type={
|
|
43
|
-
<AlertIcon type={
|
|
60
|
+
<IconHighlight type={type} align="center">
|
|
61
|
+
<AlertIcon type={type} />
|
|
44
62
|
</IconHighlight>
|
|
45
63
|
<Divider direction="horizontal" size={10} />
|
|
46
|
-
<StyledTypography
|
|
47
|
-
variant="body"
|
|
48
|
-
size="small"
|
|
49
|
-
color={props.titleColor}
|
|
50
|
-
hasColor={!!props.titleColor}
|
|
51
|
-
align="left">
|
|
64
|
+
<StyledTypography variant="body" size="small" align="left">
|
|
52
65
|
{props.title}
|
|
53
66
|
</StyledTypography>
|
|
54
67
|
</AlertFlexContainer>
|
|
55
|
-
|
|
56
|
-
|
|
68
|
+
) : (
|
|
69
|
+
<Alert
|
|
70
|
+
title={title}
|
|
71
|
+
type={type}
|
|
72
|
+
variant="alarm"
|
|
73
|
+
titleAlign="left"
|
|
74
|
+
action={
|
|
75
|
+
hasCloseIcon ? (
|
|
76
|
+
<IconButton variant="ghost" size="xsmall" onClick={handleClose}>
|
|
77
|
+
<CloseIcon size={12} />
|
|
78
|
+
</IconButton>
|
|
79
|
+
) : undefined
|
|
80
|
+
}
|
|
81
|
+
/>
|
|
82
|
+
)}
|
|
83
|
+
</AlertBox>
|
|
57
84
|
</ToastContentContainer>
|
|
58
85
|
);
|
|
59
86
|
};
|
|
@@ -1,31 +1,33 @@
|
|
|
1
|
+
import type { ToastContainer } from './Toast.styles';
|
|
1
2
|
import type { Type } from '../Alert/Alert.types';
|
|
2
|
-
import type
|
|
3
|
+
import type * as Stitches from '@stitches/react';
|
|
4
|
+
import type { CSSProperties } from 'react';
|
|
3
5
|
|
|
6
|
+
type BaseProps = Stitches.VariantProps<typeof ToastContainer>;
|
|
7
|
+
export type ToastPosition = Exclude<BaseProps['position'], object>;
|
|
4
8
|
export interface ProviderPropTypes {
|
|
5
9
|
container: HTMLElement;
|
|
6
|
-
anchorOrigin?: {
|
|
7
|
-
horizontal: 'left' | 'right';
|
|
8
|
-
vertical: 'bottom' | 'top';
|
|
9
|
-
};
|
|
10
|
-
containerStyle?: CSSProperties;
|
|
11
10
|
}
|
|
12
11
|
|
|
13
|
-
export type ToastType = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
12
|
+
export type ToastType = {
|
|
13
|
+
autoHideDuration?: number;
|
|
14
|
+
id?: number | string;
|
|
15
|
+
containerStyle?: CSSProperties;
|
|
16
|
+
onClose?: () => void;
|
|
17
|
+
position: ToastPosition;
|
|
18
|
+
title: string;
|
|
19
|
+
type: Type;
|
|
20
|
+
style?: CSSProperties;
|
|
21
|
+
hasCloseIcon?: boolean;
|
|
22
|
+
hideOnTap?: boolean;
|
|
23
|
+
variant?: 'custom' | 'standard';
|
|
24
|
+
};
|
|
22
25
|
|
|
23
26
|
export type ToastProps = ToastType & {
|
|
24
27
|
id: number | string;
|
|
25
|
-
horizontal: 'left' | 'right';
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
export type ProviderContext = {
|
|
29
31
|
addToast: (content: ToastType) => void;
|
|
30
|
-
removeToast: (id: number | string) => void;
|
|
32
|
+
removeToast: (id: number | string, position: ToastPosition) => void;
|
|
31
33
|
};
|
|
@@ -4,7 +4,7 @@ import type * as Stitches from '@stitches/react';
|
|
|
4
4
|
type BaseProps = Stitches.VariantProps<typeof TypographyContainer>;
|
|
5
5
|
type BaseSizes = Exclude<BaseProps['size'], object>;
|
|
6
6
|
type BaseVariants = Exclude<BaseProps['variant'], object>;
|
|
7
|
-
type BaseAlign = Exclude<BaseProps['align'], object>;
|
|
7
|
+
export type BaseAlign = Exclude<BaseProps['align'], object>;
|
|
8
8
|
|
|
9
9
|
// eslint-disable-next-line @typescript-eslint/no-magic-numbers
|
|
10
10
|
type margin = 2 | 4 | 8 | 12;
|