@rango-dev/ui 0.26.1-next.9 → 0.27.1-next.0

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.
Files changed (77) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/index.js +6 -6
  3. package/dist/index.js.map +4 -4
  4. package/dist/translations/en.d.ts.map +1 -1
  5. package/dist/translations/es.d.ts.map +1 -1
  6. package/dist/translations/fr.d.ts.map +1 -1
  7. package/dist/translations/ja.d.ts.map +1 -1
  8. package/dist/widget/ui/src/components/Alert/Alert.styles.d.ts +1 -0
  9. package/dist/widget/ui/src/components/Alert/Alert.styles.d.ts.map +1 -1
  10. package/dist/widget/ui/src/components/Divider/Divider.styles.d.ts +1 -1
  11. package/dist/widget/ui/src/components/Divider/Divider.styles.d.ts.map +1 -1
  12. package/dist/widget/ui/src/components/Header/Header.constants.d.ts +2 -0
  13. package/dist/widget/ui/src/components/Header/Header.constants.d.ts.map +1 -0
  14. package/dist/widget/ui/src/components/Header/Header.d.ts.map +1 -1
  15. package/dist/widget/ui/src/components/Header/Header.styles.d.ts +1 -0
  16. package/dist/widget/ui/src/components/Header/Header.styles.d.ts.map +1 -1
  17. package/dist/widget/ui/src/components/Header/index.d.ts +1 -0
  18. package/dist/widget/ui/src/components/Header/index.d.ts.map +1 -1
  19. package/dist/widget/ui/src/components/QuoteCost/QuoteCost.d.ts.map +1 -1
  20. package/dist/widget/ui/src/components/QuoteCost/QuoteCost.styles.d.ts.map +1 -1
  21. package/dist/widget/ui/src/components/QuoteCost/QuoteCost.types.d.ts +4 -0
  22. package/dist/widget/ui/src/components/QuoteCost/QuoteCost.types.d.ts.map +1 -1
  23. package/dist/widget/ui/src/components/SwapContainer/SwapContainer.d.ts +0 -1
  24. package/dist/widget/ui/src/components/SwapContainer/SwapContainer.d.ts.map +1 -1
  25. package/dist/widget/ui/src/components/Toast/Toast.Provider.d.ts +6 -0
  26. package/dist/widget/ui/src/components/Toast/Toast.Provider.d.ts.map +1 -0
  27. package/dist/widget/ui/src/components/Toast/Toast.d.ts +4 -0
  28. package/dist/widget/ui/src/components/Toast/Toast.d.ts.map +1 -0
  29. package/dist/widget/ui/src/components/Toast/Toast.helpers.d.ts +2 -0
  30. package/dist/widget/ui/src/components/Toast/Toast.helpers.d.ts.map +1 -0
  31. package/dist/widget/ui/src/components/Toast/Toast.stories.d.ts +7 -0
  32. package/dist/widget/ui/src/components/Toast/Toast.stories.d.ts.map +1 -0
  33. package/dist/widget/ui/src/components/Toast/Toast.styles.d.ts +977 -0
  34. package/dist/widget/ui/src/components/Toast/Toast.styles.d.ts.map +1 -0
  35. package/dist/widget/ui/src/components/Toast/Toast.types.d.ts +31 -0
  36. package/dist/widget/ui/src/components/Toast/Toast.types.d.ts.map +1 -0
  37. package/dist/widget/ui/src/components/Toast/index.d.ts +3 -0
  38. package/dist/widget/ui/src/components/Toast/index.d.ts.map +1 -0
  39. package/dist/widget/ui/src/components/Typography/Typography.styles.d.ts +4 -4
  40. package/dist/widget/ui/src/components/Wallet/ClickableWallet.d.ts.map +1 -1
  41. package/dist/widget/ui/src/components/Wallet/SelectableWallet.d.ts.map +1 -1
  42. package/dist/widget/ui/src/components/Wallet/Wallet.styles.d.ts.map +1 -1
  43. package/dist/widget/ui/src/components/Wallet/Wallet.types.d.ts +2 -0
  44. package/dist/widget/ui/src/components/Wallet/Wallet.types.d.ts.map +1 -1
  45. package/dist/widget/ui/src/components/index.d.ts +1 -0
  46. package/dist/widget/ui/src/components/index.d.ts.map +1 -1
  47. package/dist/widget/ui/src/icons/Add.d.ts +5 -0
  48. package/dist/widget/ui/src/icons/Add.d.ts.map +1 -0
  49. package/dist/widget/ui/src/icons/index.d.ts +1 -0
  50. package/dist/widget/ui/src/icons/index.d.ts.map +1 -1
  51. package/package.json +2 -2
  52. package/src/components/Alert/Alert.styles.ts +5 -0
  53. package/src/components/Divider/Divider.styles.ts +15 -0
  54. package/src/components/Divider/Divider.tsx +2 -2
  55. package/src/components/Header/Header.constants.ts +1 -0
  56. package/src/components/Header/Header.styles.ts +46 -2
  57. package/src/components/Header/Header.tsx +5 -1
  58. package/src/components/Header/index.ts +1 -0
  59. package/src/components/Modal/Modal.tsx +1 -1
  60. package/src/components/QuoteCost/QuoteCost.styles.ts +28 -1
  61. package/src/components/QuoteCost/QuoteCost.tsx +28 -8
  62. package/src/components/QuoteCost/QuoteCost.types.ts +4 -0
  63. package/src/components/SwapContainer/SwapContainer.tsx +2 -14
  64. package/src/components/Toast/Toast.Provider.tsx +87 -0
  65. package/src/components/Toast/Toast.helpers.ts +7 -0
  66. package/src/components/Toast/Toast.stories.tsx +71 -0
  67. package/src/components/Toast/Toast.styles.ts +113 -0
  68. package/src/components/Toast/Toast.tsx +59 -0
  69. package/src/components/Toast/Toast.types.ts +31 -0
  70. package/src/components/Toast/index.ts +2 -0
  71. package/src/components/Wallet/ClickableWallet.tsx +10 -5
  72. package/src/components/Wallet/SelectableWallet.tsx +11 -2
  73. package/src/components/Wallet/Wallet.styles.ts +4 -0
  74. package/src/components/Wallet/Wallet.types.ts +2 -0
  75. package/src/components/index.ts +1 -0
  76. package/src/icons/Add.tsx +25 -0
  77. package/src/icons/index.ts +1 -0
@@ -0,0 +1,113 @@
1
+ import { darkTheme, keyframes, lightTheme, styled } from '../../theme';
2
+ import { Typography } from '../Typography';
3
+
4
+ const toastOpacity = keyframes({
5
+ from: { opacity: 0 },
6
+ to: { opacity: 1 },
7
+ });
8
+
9
+ export const ToastContentContainer = styled('div', {
10
+ variants: {
11
+ horizontal: {
12
+ right: {
13
+ right: 12,
14
+ animation: `${toastOpacity} .7s`,
15
+ },
16
+ left: {
17
+ left: 12,
18
+ animation: `${toastOpacity} .7s`,
19
+ },
20
+ },
21
+ },
22
+ });
23
+
24
+ export const ToastContainer = styled('div', {
25
+ position: 'absolute',
26
+ zIndex: 9999,
27
+ display: 'flex',
28
+ gap: '$4',
29
+ flexDirection: 'column',
30
+ variants: {
31
+ horizontal: {
32
+ right: {
33
+ right: 12,
34
+ },
35
+ left: {
36
+ left: 12,
37
+ },
38
+ },
39
+
40
+ vertical: {
41
+ top: {
42
+ top: 2,
43
+ },
44
+ bottom: {
45
+ bottom: 2,
46
+ },
47
+ },
48
+ },
49
+ });
50
+
51
+ export const AlertBox = styled('div', {
52
+ display: 'flex',
53
+ borderRadius: '$sm',
54
+ width: '292px',
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
+ variants: {
68
+ type: {
69
+ error: {
70
+ borderRightColor: '$error500',
71
+ },
72
+ success: {
73
+ borderRightColor: '$success500',
74
+ },
75
+ warning: {
76
+ borderRightColor: '$warning500',
77
+ },
78
+ info: {
79
+ borderRightColor: '$info500',
80
+ },
81
+ loading: {
82
+ borderRightColor: '$info500',
83
+ },
84
+ },
85
+ },
86
+ });
87
+
88
+ export const AlertFlexContainer = styled('div', {
89
+ display: 'flex',
90
+ padding: '$10',
91
+ alignItems: 'center',
92
+ });
93
+
94
+ export const StyledTypography = styled(Typography, {
95
+ variants: {
96
+ hasColor: {
97
+ false: {
98
+ [`.${lightTheme} &`]: {
99
+ color: '$neutral700',
100
+ },
101
+ [`.${darkTheme} &`]: {
102
+ color: '$neutral900',
103
+ },
104
+ },
105
+ },
106
+ },
107
+ });
108
+
109
+ export const ToastStoryContainer = styled('div', {
110
+ display: 'flex',
111
+ justifyContent: 'center',
112
+ alignItems: 'center',
113
+ });
@@ -0,0 +1,59 @@
1
+ import type { ToastProps } from './Toast.types';
2
+
3
+ import React, { useEffect } from 'react';
4
+
5
+ import { IconHighlight } from '../Alert/Alert.styles';
6
+ import AlertIcon from '../Alert/AlertIcon';
7
+ import { Divider } from '../Divider';
8
+
9
+ import { useToast } from './Toast.Provider';
10
+ import {
11
+ AlertBox,
12
+ AlertFlexContainer,
13
+ StyledTypography,
14
+ ToastContentContainer,
15
+ } from './Toast.styles';
16
+
17
+ const DEFAULT_HIDE_DURATION = 3_000;
18
+
19
+ export const Toast = (props: ToastProps) => {
20
+ const { id, horizontal, autoHideDuration = DEFAULT_HIDE_DURATION } = props;
21
+ const { removeToast } = useToast();
22
+ useEffect(() => {
23
+ const timer = setTimeout(() => {
24
+ removeToast(id);
25
+ }, autoHideDuration);
26
+
27
+ return () => {
28
+ clearTimeout(timer);
29
+ };
30
+ }, [id]);
31
+
32
+ return (
33
+ <ToastContentContainer horizontal={horizontal}>
34
+ {'component' in props ? (
35
+ props.component
36
+ ) : (
37
+ <AlertBox
38
+ onClick={() => removeToast(id)}
39
+ type={props.type}
40
+ style={props.style}>
41
+ <AlertFlexContainer>
42
+ <IconHighlight type={props.type} align="center">
43
+ <AlertIcon type={props.type} />
44
+ </IconHighlight>
45
+ <Divider direction="horizontal" size={10} />
46
+ <StyledTypography
47
+ variant="body"
48
+ size="small"
49
+ color={props.titleColor}
50
+ hasColor={!!props.titleColor}
51
+ align="left">
52
+ {props.title}
53
+ </StyledTypography>
54
+ </AlertFlexContainer>
55
+ </AlertBox>
56
+ )}
57
+ </ToastContentContainer>
58
+ );
59
+ };
@@ -0,0 +1,31 @@
1
+ import type { Type } from '../Alert/Alert.types';
2
+ import type { CSSProperties } from '@stitches/react';
3
+
4
+ export interface ProviderPropTypes {
5
+ container: HTMLElement;
6
+ anchorOrigin?: {
7
+ horizontal: 'left' | 'right';
8
+ vertical: 'bottom' | 'top';
9
+ };
10
+ containerStyle?: CSSProperties;
11
+ }
12
+
13
+ export type ToastType = { autoHideDuration?: number; id?: number | string } & (
14
+ | {
15
+ title: string;
16
+ type: Type;
17
+ titleColor?: string;
18
+ style?: CSSProperties;
19
+ }
20
+ | { component: React.ReactNode }
21
+ );
22
+
23
+ export type ToastProps = ToastType & {
24
+ id: number | string;
25
+ horizontal: 'left' | 'right';
26
+ };
27
+
28
+ export type ProviderContext = {
29
+ addToast: (content: ToastType) => void;
30
+ removeToast: (id: number | string) => void;
31
+ };
@@ -0,0 +1,2 @@
1
+ export { Toast } from './Toast';
2
+ export { ToastProvider, useToast } from './Toast.Provider';
@@ -1,7 +1,7 @@
1
1
  import type { WalletPropTypes } from './Wallet.types';
2
2
 
3
3
  import { detectInstallLink } from '@rango-dev/wallets-shared';
4
- import React from 'react';
4
+ import React, { Fragment } from 'react';
5
5
 
6
6
  import { Image } from '../common';
7
7
  import { Divider } from '../Divider';
@@ -20,7 +20,7 @@ import {
20
20
  import { WalletState } from './Wallet.types';
21
21
 
22
22
  function Wallet(props: WalletPropTypes) {
23
- const { title, type, image, onClick, isLoading } = props;
23
+ const { title, type, image, onClick, isLoading, disabled = false } = props;
24
24
  const info = makeInfo(props.state);
25
25
 
26
26
  if (isLoading) {
@@ -35,10 +35,15 @@ function Wallet(props: WalletPropTypes) {
35
35
  );
36
36
  }
37
37
 
38
+ const WrapperComponent = disabled ? Fragment : Tooltip;
39
+
38
40
  return (
39
- <Tooltip container={props.container} content={info.tooltipText} side="top">
41
+ <WrapperComponent
42
+ container={props.container}
43
+ content={info.tooltipText}
44
+ side="top">
40
45
  <WalletButton
41
- disabled={props.state == WalletState.CONNECTING}
46
+ disabled={props.state == WalletState.CONNECTING || disabled}
42
47
  onClick={() => {
43
48
  if (props.state === WalletState.NOT_INSTALLED) {
44
49
  window.open(detectInstallLink(props.link), '_blank');
@@ -64,7 +69,7 @@ function Wallet(props: WalletPropTypes) {
64
69
  </Typography>
65
70
  </Text>
66
71
  </WalletButton>
67
- </Tooltip>
72
+ </WrapperComponent>
68
73
  );
69
74
  }
70
75
 
@@ -14,12 +14,21 @@ import {
14
14
  import { type SelectablePropTypes, WalletState } from './Wallet.types';
15
15
 
16
16
  export function SelectableWallet(props: SelectablePropTypes) {
17
- const { title, type, image, onClick, selected, description, state } = props;
17
+ const {
18
+ title,
19
+ type,
20
+ image,
21
+ onClick,
22
+ selected,
23
+ description,
24
+ state,
25
+ disabled = false,
26
+ } = props;
18
27
  const info = makeInfo(props.state);
19
28
  return (
20
29
  <WalletButton
21
30
  selected={selected}
22
- disabled={props.state == WalletState.CONNECTING}
31
+ disabled={props.state == WalletState.CONNECTING || disabled}
23
32
  onClick={() => {
24
33
  if (props.state === WalletState.NOT_INSTALLED) {
25
34
  window.open(detectInstallLink(props.link), '_blank');
@@ -48,6 +48,10 @@ export const WalletButton = styled('button', {
48
48
  backgroundColor: '$$color',
49
49
  outline: 0,
50
50
  },
51
+ '&:disabled': {
52
+ filter: 'grayscale(1)',
53
+ pointerEvents: 'none',
54
+ },
51
55
  variants: {
52
56
  selected: {
53
57
  true: {
@@ -39,8 +39,10 @@ export interface WalletPropTypes {
39
39
  description?: string;
40
40
  isLoading?: boolean;
41
41
  container?: HTMLElement;
42
+ disabled?: boolean;
42
43
  }
43
44
 
44
45
  export type SelectablePropTypes = WalletPropTypes & {
45
46
  selected: boolean;
47
+ disabled?: boolean;
46
48
  };
@@ -29,6 +29,7 @@ export * from './SwapListItem';
29
29
  export * from './SwapDetailsPlaceholder';
30
30
  export * from './Switch';
31
31
  export * from './TextField';
32
+ export * from './Toast';
32
33
  export * from './TokenList';
33
34
  export * from './TokenPreview';
34
35
  export * from './Tooltip';
@@ -0,0 +1,25 @@
1
+ import type { SvgIconPropsWithChildren } from '../components/SvgIcon';
2
+
3
+ import React, { createElement } from 'react';
4
+
5
+ import { SvgIcon } from '../components/SvgIcon';
6
+
7
+ function SvgAdd(props: SvgIconPropsWithChildren) {
8
+ return createElement(
9
+ SvgIcon,
10
+ props,
11
+ <svg viewBox="0 0 24 25" xmlns="http://www.w3.org/2000/svg">
12
+ <path
13
+ fillRule="evenodd"
14
+ d="M18.8611 13.6389H4.63889C4.15296 13.6389 3.75 13.2359 3.75 12.75C3.75 12.2641 4.15296 11.8611 4.63889 11.8611H18.8611C19.347 11.8611 19.75 12.2641 19.75 12.75C19.75 13.2359 19.347 13.6389 18.8611 13.6389Z"
15
+ fill="currentColor"
16
+ />
17
+ <path
18
+ fillRule="evenodd"
19
+ d="M11.75 20.75C11.2641 20.75 10.8611 20.347 10.8611 19.8611V5.63889C10.8611 5.15296 11.2641 4.75 11.75 4.75C12.2359 4.75 12.6389 5.15296 12.6389 5.63889V19.8611C12.6389 20.347 12.2359 20.75 11.75 20.75Z"
20
+ fill="currentColor"
21
+ />
22
+ </svg>
23
+ );
24
+ }
25
+ export default SvgAdd;
@@ -1,3 +1,4 @@
1
+ export { default as AddIcon } from './Add';
1
2
  export { default as AutoThemeIcon } from './AutoTheme';
2
3
  export { default as BorderRadiusIcon } from './BorderRadius';
3
4
  export { default as ChevronDownIcon } from './ChevronDown';