@rango-dev/ui 0.28.2-next.0 → 0.28.2-next.10
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/translations/pt.d.ts +2 -0
- package/dist/translations/pt.d.ts.map +1 -0
- package/dist/widget/ui/src/components/Alert/Alert.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Alert/Alert.helpers.d.ts +3 -2
- package/dist/widget/ui/src/components/Alert/Alert.helpers.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Alert/Alert.styles.d.ts +12 -8
- package/dist/widget/ui/src/components/Alert/Alert.styles.d.ts.map +1 -1
- package/dist/widget/ui/src/components/Alert/Alert.types.d.ts +5 -2
- package/dist/widget/ui/src/components/Alert/Alert.types.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.d.ts +6 -6
- package/dist/widget/ui/src/components/Button/Button.styles.d.ts +4 -1
- 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.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 +3 -2
- 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/Flags/Portuguese.d.ts +4 -0
- package/dist/widget/ui/src/components/Flags/Portuguese.d.ts.map +1 -0
- package/dist/widget/ui/src/components/Flags/index.d.ts +2 -1
- package/dist/widget/ui/src/components/Flags/index.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/I18nManager/I18nManager.d.ts +1 -0
- package/dist/widget/ui/src/components/I18nManager/I18nManager.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 +4 -2
- 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 +4 -1
- 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/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/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 +5 -1
- 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 +10 -4
- 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 +2 -1
- 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.d.ts +1 -1
- package/dist/widget/ui/src/components/TextField/TextField.stories.d.ts +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.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.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.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 +174 -4
- 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 +4 -1
- 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 +164 -0
- package/dist/widget/ui/src/components/Typography/NotSelectableTypography.d.ts.map +1 -0
- 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/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/components/Typography/index.d.ts +1 -0
- package/dist/widget/ui/src/components/Typography/index.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/ConnectWalletsModal/ConnectWalletsModal.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 +18 -7
- 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 +11 -6
- 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/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/dist/widget/ui/src/theme.d.ts +25 -13
- package/dist/widget/ui/src/theme.d.ts.map +1 -1
- package/package.json +5 -4
- package/readme.md +3 -1
- package/src/components/Alert/Alert.helpers.ts +13 -2
- package/src/components/Alert/Alert.styles.ts +7 -8
- package/src/components/Alert/Alert.tsx +8 -6
- package/src/components/Alert/Alert.types.ts +5 -2
- package/src/components/Divider/Divider.tsx +2 -1
- package/src/components/Flags/Portuguese.tsx +34 -0
- package/src/components/Flags/index.ts +2 -1
- package/src/components/I18nManager/I18nManager.tsx +2 -0
- package/src/components/Modal/Modal.tsx +25 -12
- package/src/components/Modal/Modal.types.ts +6 -1
- 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/TextField/TextField.styles.ts +1 -0
- package/src/components/Toast/Toast.Provider.tsx +82 -44
- package/src/components/Toast/Toast.helpers.ts +5 -0
- package/src/components/Toast/Toast.stories.tsx +18 -21
- package/src/components/Toast/Toast.styles.ts +278 -38
- package/src/components/Toast/Toast.tsx +84 -32
- package/src/components/Toast/Toast.types.ts +19 -17
- package/src/components/Typography/NotSelectableTypography.ts +7 -0
- package/src/components/Typography/Typography.types.tsx +1 -1
- package/src/components/Typography/index.ts +1 -0
- package/src/components/index.ts +1 -0
- 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
- package/src/theme.ts +4 -1
|
@@ -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,
|
|
@@ -46,6 +46,8 @@ export function Modal(props: PropsWithChildren<PropTypes>) {
|
|
|
46
46
|
const timeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
47
47
|
|
|
48
48
|
const handleBackDropClick = (event: React.MouseEvent<HTMLDivElement>) => {
|
|
49
|
+
event.stopPropagation();
|
|
50
|
+
|
|
49
51
|
if (event.target === event.currentTarget && dismissible) {
|
|
50
52
|
onClose();
|
|
51
53
|
}
|
|
@@ -58,15 +60,25 @@ export function Modal(props: PropsWithChildren<PropTypes>) {
|
|
|
58
60
|
if (open) {
|
|
59
61
|
setIsMount(true);
|
|
60
62
|
container.style.overflow = 'hidden';
|
|
61
|
-
timeoutRef.current = setTimeout(
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
timeoutRef.current = setTimeout(
|
|
64
|
+
() => {
|
|
65
|
+
setActive(true);
|
|
66
|
+
},
|
|
67
|
+
typeof transitionDuration?.enter !== 'undefined'
|
|
68
|
+
? transitionDuration?.enter
|
|
69
|
+
: OPEN_DELAY
|
|
70
|
+
);
|
|
64
71
|
} else {
|
|
65
72
|
setActive(false);
|
|
66
|
-
timeoutRef.current = setTimeout(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
73
|
+
timeoutRef.current = setTimeout(
|
|
74
|
+
() => {
|
|
75
|
+
setIsMount(false);
|
|
76
|
+
container.style.removeProperty('overflow');
|
|
77
|
+
},
|
|
78
|
+
typeof transitionDuration?.exit !== 'undefined'
|
|
79
|
+
? transitionDuration?.exit
|
|
80
|
+
: CLOSED_DELAY
|
|
81
|
+
);
|
|
70
82
|
}
|
|
71
83
|
}
|
|
72
84
|
return () => {
|
|
@@ -84,10 +96,11 @@ export function Modal(props: PropsWithChildren<PropTypes>) {
|
|
|
84
96
|
<BackDrop
|
|
85
97
|
active={active}
|
|
86
98
|
onClick={handleBackDropClick}
|
|
87
|
-
anchor={anchor}
|
|
99
|
+
anchor={anchor}
|
|
100
|
+
css={styles?.root}>
|
|
88
101
|
<ModalContainer
|
|
89
102
|
active={active}
|
|
90
|
-
css={
|
|
103
|
+
css={styles?.container}
|
|
91
104
|
anchor={anchor}>
|
|
92
105
|
{header ?? (
|
|
93
106
|
<ModalHeader noTitle={!title && dismissible && !prefix}>
|
|
@@ -107,9 +120,9 @@ export function Modal(props: PropsWithChildren<PropTypes>) {
|
|
|
107
120
|
</Flex>
|
|
108
121
|
</ModalHeader>
|
|
109
122
|
)}
|
|
110
|
-
<Content>{children}</Content>
|
|
123
|
+
<Content css={styles?.content}>{children}</Content>
|
|
111
124
|
|
|
112
|
-
<Footer>
|
|
125
|
+
<Footer css={styles?.footer}>
|
|
113
126
|
{footer && <div className="footer__content">{footer}</div>}
|
|
114
127
|
|
|
115
128
|
<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;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { PropTypes } from './Select.types';
|
|
2
|
+
|
|
3
|
+
import * as Select from '@radix-ui/react-select';
|
|
4
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
5
|
+
|
|
6
|
+
import { ChevronDownIcon, ChevronUpIcon } from '../../icons';
|
|
7
|
+
import { Typography } from '../Typography';
|
|
8
|
+
|
|
9
|
+
import { SelectContent, SelectItem, SelectTrigger } from './select.styles';
|
|
10
|
+
|
|
11
|
+
export function SelectComponent(props: PropTypes) {
|
|
12
|
+
const [open, setOpen] = useState(false);
|
|
13
|
+
const selectRef = useRef<HTMLDivElement>(null);
|
|
14
|
+
const { options, value, container, handleItemClick } = props;
|
|
15
|
+
const handleToggle = () => {
|
|
16
|
+
setOpen((prev) => !prev);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const handleClickOutside = (e: MouseEvent) => {
|
|
20
|
+
if (selectRef.current && !selectRef.current.contains(e.target as Node)) {
|
|
21
|
+
setOpen(false);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
document.addEventListener('click', handleClickOutside);
|
|
27
|
+
return () => {
|
|
28
|
+
document.removeEventListener('click', handleClickOutside);
|
|
29
|
+
};
|
|
30
|
+
}, []);
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<div ref={selectRef}>
|
|
34
|
+
<Select.Root value={value.value} open={open}>
|
|
35
|
+
<SelectTrigger
|
|
36
|
+
onKeyDown={(event) => event.key === 'Enter' && handleToggle()}
|
|
37
|
+
onClick={handleToggle}
|
|
38
|
+
open={open}
|
|
39
|
+
aria-label={value.label}>
|
|
40
|
+
<Select.Value>
|
|
41
|
+
<Typography variant="body" size="small">
|
|
42
|
+
{value.label}
|
|
43
|
+
</Typography>
|
|
44
|
+
</Select.Value>
|
|
45
|
+
|
|
46
|
+
<Select.Icon className="SelectIcon">
|
|
47
|
+
<ChevronDownIcon size={12} />
|
|
48
|
+
</Select.Icon>
|
|
49
|
+
</SelectTrigger>
|
|
50
|
+
<Select.Portal container={container}>
|
|
51
|
+
<SelectContent>
|
|
52
|
+
<Select.ScrollUpButton className="SelectScrollButton">
|
|
53
|
+
<ChevronUpIcon />
|
|
54
|
+
</Select.ScrollUpButton>
|
|
55
|
+
<Select.Viewport className="SelectViewport">
|
|
56
|
+
<Select.Group>
|
|
57
|
+
{options.map(
|
|
58
|
+
(option) =>
|
|
59
|
+
option.value !== value?.value && (
|
|
60
|
+
<SelectItem
|
|
61
|
+
onClick={() => {
|
|
62
|
+
handleItemClick && handleItemClick(option);
|
|
63
|
+
handleToggle();
|
|
64
|
+
}}
|
|
65
|
+
key={option.value}
|
|
66
|
+
value={option.value}>
|
|
67
|
+
<Select.ItemText>
|
|
68
|
+
<Typography variant="body" size="small">
|
|
69
|
+
{option.label}
|
|
70
|
+
</Typography>
|
|
71
|
+
</Select.ItemText>
|
|
72
|
+
</SelectItem>
|
|
73
|
+
)
|
|
74
|
+
)}
|
|
75
|
+
</Select.Group>
|
|
76
|
+
</Select.Viewport>
|
|
77
|
+
<Select.ScrollDownButton className="SelectScrollButton">
|
|
78
|
+
<ChevronDownIcon />
|
|
79
|
+
</Select.ScrollDownButton>
|
|
80
|
+
</SelectContent>
|
|
81
|
+
</Select.Portal>
|
|
82
|
+
</Select.Root>
|
|
83
|
+
</div>
|
|
84
|
+
);
|
|
85
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { SelectComponent as Select } from './Select';
|
|
@@ -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
|
+
});
|
|
@@ -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>
|
|
@@ -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
|
|
@@ -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
|
);
|