@rango-dev/ui 0.28.2-next.1 → 0.28.2-next.11
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.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 +9 -5
- 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 +3 -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.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/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 +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.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/Popover/Popover.types.d.ts +4 -0
- package/dist/widget/ui/src/components/Popover/Popover.types.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.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.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 +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/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/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 +12 -1
- 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/icons/Tune.d.ts +5 -0
- package/dist/widget/ui/src/icons/Tune.d.ts.map +1 -0
- package/dist/widget/ui/src/icons/index.d.ts +1 -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 +6 -6
- package/src/components/Alert/Alert.types.ts +3 -2
- 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 +19 -7
- package/src/components/Popover/Popover.tsx +5 -3
- package/src/components/Popover/Popover.types.ts +4 -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/TextField/TextField.styles.ts +1 -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/Typography/NotSelectableTypography.ts +7 -0
- package/src/components/Typography/index.ts +1 -0
- package/src/components/index.ts +1 -0
- package/src/icons/Tune.tsx +51 -0
- package/src/icons/index.ts +1 -0
- package/src/theme.ts +4 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { Type } from './Alert.types';
|
|
1
|
+
import type { PropTypes, Type } from './Alert.types';
|
|
2
2
|
|
|
3
|
-
export const getColor = (type: Type, variant: '
|
|
3
|
+
export const getColor = (type: Type, variant: PropTypes['variant']) => {
|
|
4
4
|
if (variant === 'regular') {
|
|
5
5
|
return undefined;
|
|
6
6
|
}
|
|
@@ -15,3 +15,14 @@ export const getColor = (type: Type, variant: 'alarm' | 'regular') => {
|
|
|
15
15
|
return undefined;
|
|
16
16
|
}
|
|
17
17
|
};
|
|
18
|
+
|
|
19
|
+
export const mapVariantToSize = (variant: PropTypes['variant']) => {
|
|
20
|
+
switch (variant) {
|
|
21
|
+
case 'alarm':
|
|
22
|
+
return 'small';
|
|
23
|
+
case 'regular':
|
|
24
|
+
return 'xsmall';
|
|
25
|
+
default:
|
|
26
|
+
return 'xsmall';
|
|
27
|
+
}
|
|
28
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { darkTheme, styled } from '../../theme';
|
|
2
2
|
|
|
3
3
|
export const Container = styled('div', {
|
|
4
4
|
display: 'flex',
|
|
@@ -34,7 +34,6 @@ export const Container = styled('div', {
|
|
|
34
34
|
},
|
|
35
35
|
alarm: {
|
|
36
36
|
padding: '$5 $10',
|
|
37
|
-
alignItems: 'center',
|
|
38
37
|
'.title_typography': {
|
|
39
38
|
fontWeight: '$medium',
|
|
40
39
|
},
|
|
@@ -106,6 +105,12 @@ export const Main = styled('div', {
|
|
|
106
105
|
},
|
|
107
106
|
});
|
|
108
107
|
|
|
108
|
+
export const TitleContainer = styled('div', {
|
|
109
|
+
display: 'flex',
|
|
110
|
+
alignItems: 'center',
|
|
111
|
+
flex: '1 0 0',
|
|
112
|
+
});
|
|
113
|
+
|
|
109
114
|
export const IconHighlight = styled('div', {
|
|
110
115
|
borderRadius: '$lg',
|
|
111
116
|
width: '$20',
|
|
@@ -160,9 +165,3 @@ export const IconHighlight = styled('div', {
|
|
|
160
165
|
},
|
|
161
166
|
},
|
|
162
167
|
});
|
|
163
|
-
|
|
164
|
-
export const titleStyles = css({
|
|
165
|
-
display: 'flex',
|
|
166
|
-
alignItems: 'center',
|
|
167
|
-
flex: '1 0 0',
|
|
168
|
-
});
|
|
@@ -6,8 +6,8 @@ import React from 'react';
|
|
|
6
6
|
import { Divider } from '../Divider';
|
|
7
7
|
import { Typography } from '../Typography';
|
|
8
8
|
|
|
9
|
-
import { getColor } from './Alert.helpers';
|
|
10
|
-
import { Container, IconHighlight, Main,
|
|
9
|
+
import { getColor, mapVariantToSize } from './Alert.helpers';
|
|
10
|
+
import { Container, IconHighlight, Main, TitleContainer } from './Alert.styles';
|
|
11
11
|
import AlertIcon from './AlertIcon';
|
|
12
12
|
|
|
13
13
|
export function Alert(props: PropsWithChildren<PropTypes>) {
|
|
@@ -25,11 +25,11 @@ export function Alert(props: PropsWithChildren<PropTypes>) {
|
|
|
25
25
|
return (
|
|
26
26
|
<Container
|
|
27
27
|
className="_alert"
|
|
28
|
-
|
|
28
|
+
css={containerStyles}
|
|
29
29
|
type={type}
|
|
30
30
|
variant={variant}>
|
|
31
31
|
<Main variant={variant}>
|
|
32
|
-
<
|
|
32
|
+
<TitleContainer>
|
|
33
33
|
<IconHighlight type={type}>
|
|
34
34
|
<AlertIcon type={type} />
|
|
35
35
|
</IconHighlight>
|
|
@@ -40,11 +40,11 @@ export function Alert(props: PropsWithChildren<PropTypes>) {
|
|
|
40
40
|
align={titleAlign}
|
|
41
41
|
variant="body"
|
|
42
42
|
className="title_typography"
|
|
43
|
-
size={variant
|
|
43
|
+
size={mapVariantToSize(variant)}>
|
|
44
44
|
{title}
|
|
45
45
|
</Typography>
|
|
46
46
|
)}
|
|
47
|
-
</
|
|
47
|
+
</TitleContainer>
|
|
48
48
|
{action ? <div>{action}</div> : null}
|
|
49
49
|
</Main>
|
|
50
50
|
{footer ? (
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { BaseAlign } from '../Typography/Typography.types';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { CSS } from 'src/theme';
|
|
3
4
|
|
|
4
5
|
export type Type = 'success' | 'warning' | 'error' | 'info' | 'loading';
|
|
5
6
|
|
|
@@ -9,6 +10,6 @@ export interface PropTypes {
|
|
|
9
10
|
footer?: ReactNode;
|
|
10
11
|
action?: ReactNode;
|
|
11
12
|
variant?: 'alarm' | 'regular';
|
|
12
|
-
containerStyles?:
|
|
13
|
+
containerStyles?: CSS;
|
|
13
14
|
titleAlign?: BaseAlign;
|
|
14
15
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { FlagPropTypes } from './Flags.types';
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
|
|
5
|
+
import { DEFAULT_SIZE } from './Flags.constants';
|
|
6
|
+
|
|
7
|
+
export default function Portuguese(props: FlagPropTypes) {
|
|
8
|
+
const { size = DEFAULT_SIZE } = props;
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<svg
|
|
12
|
+
width={size}
|
|
13
|
+
height={size}
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
viewBox="0 0 512 512">
|
|
16
|
+
<mask id="a">
|
|
17
|
+
<circle cx="256" cy="256" r="256" fill="#fff" />
|
|
18
|
+
</mask>
|
|
19
|
+
<g mask="url(#a)">
|
|
20
|
+
<path fill="#6da544" d="M0 512h167l37.9-260.3L167 0H0z" />
|
|
21
|
+
<path fill="#d80027" d="M512 0H167v512h345z" />
|
|
22
|
+
<circle cx="167" cy="256" r="89" fill="#ffda44" />
|
|
23
|
+
<path
|
|
24
|
+
fill="#d80027"
|
|
25
|
+
d="M116.9 211.5V267a50 50 0 1 0 100.1 0v-55.6H117z"
|
|
26
|
+
/>
|
|
27
|
+
<path
|
|
28
|
+
fill="#eee"
|
|
29
|
+
d="M167 283.8c-9.2 0-16.7-7.5-16.7-16.7V245h33.4v22c0 9.2-7.5 16.7-16.7 16.7z"
|
|
30
|
+
/>
|
|
31
|
+
</g>
|
|
32
|
+
</svg>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import English from './English';
|
|
2
2
|
import French from './French';
|
|
3
3
|
import Japanese from './Japanese';
|
|
4
|
+
import Portuguese from './Portuguese';
|
|
4
5
|
import Spanish from './Spanish';
|
|
5
6
|
|
|
6
7
|
export type { FlagPropTypes } from './Flags.types';
|
|
7
8
|
|
|
8
|
-
export { English, Spanish, Japanese, French };
|
|
9
|
+
export { English, Spanish, Japanese, French, Portuguese };
|
|
@@ -15,12 +15,14 @@ import { messages as enMessages } from '../../../../../translations/en';
|
|
|
15
15
|
import { messages as esMessages } from '../../../../../translations/es';
|
|
16
16
|
import { messages as frMessages } from '../../../../../translations/fr';
|
|
17
17
|
import { messages as jaMessages } from '../../../../../translations/ja';
|
|
18
|
+
import { messages as ptMessages } from '../../../../../translations/pt';
|
|
18
19
|
|
|
19
20
|
const messages = {
|
|
20
21
|
en: enMessages,
|
|
21
22
|
es: esMessages,
|
|
22
23
|
ja: jaMessages,
|
|
23
24
|
fr: frMessages,
|
|
25
|
+
pt: ptMessages,
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
i18n.load(messages);
|
|
@@ -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 () => {
|
|
@@ -13,12 +13,12 @@ export const PopoverContentComponent = (
|
|
|
13
13
|
props: PropsWithChildren<ContentType>,
|
|
14
14
|
forwardedRef: Ref
|
|
15
15
|
) => {
|
|
16
|
-
const { container, children, ...rest } = props;
|
|
16
|
+
const { container, children, styles, ...rest } = props;
|
|
17
17
|
return (
|
|
18
18
|
<RadixPopover.Portal container={container}>
|
|
19
19
|
<PopoverContainer {...rest} ref={forwardedRef}>
|
|
20
20
|
{children}
|
|
21
|
-
<PopoverArrow />
|
|
21
|
+
<PopoverArrow css={styles?.arrowStyles} />
|
|
22
22
|
</PopoverContainer>
|
|
23
23
|
</RadixPopover.Portal>
|
|
24
24
|
);
|
|
@@ -38,6 +38,7 @@ export function Popover(props: PropsWithChildren<PropTypes>) {
|
|
|
38
38
|
collisionBoundary = [],
|
|
39
39
|
collisionPadding = 0,
|
|
40
40
|
container = document.body,
|
|
41
|
+
...rest
|
|
41
42
|
} = props;
|
|
42
43
|
return (
|
|
43
44
|
<RadixPopover.Root>
|
|
@@ -49,7 +50,8 @@ export function Popover(props: PropsWithChildren<PropTypes>) {
|
|
|
49
50
|
collisionPadding={collisionPadding}
|
|
50
51
|
side={side}
|
|
51
52
|
sideOffset={sideOffset}
|
|
52
|
-
container={container}
|
|
53
|
+
container={container}
|
|
54
|
+
{...rest}>
|
|
53
55
|
{content}
|
|
54
56
|
</PopoverContent>
|
|
55
57
|
</RadixPopover.Root>
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { CSS } from '../../theme';
|
|
1
2
|
import type { ReactNode } from 'react';
|
|
2
3
|
|
|
3
4
|
export type Ref =
|
|
@@ -16,6 +17,9 @@ export interface ContentType {
|
|
|
16
17
|
collisionBoundary?: Element | null | Array<Element | null>;
|
|
17
18
|
collisionPadding?: number | Partial<Record<Side, number>>;
|
|
18
19
|
container?: HTMLElement;
|
|
20
|
+
styles?: {
|
|
21
|
+
arrowStyles?: CSS;
|
|
22
|
+
};
|
|
19
23
|
}
|
|
20
24
|
|
|
21
25
|
export type PropTypes = ContentType & {
|
|
@@ -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
|
+
});
|
|
@@ -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
|