@rango-dev/ui 0.15.1-next.16 → 0.15.1-next.18

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 (55) hide show
  1. package/dist/index.js +6 -6
  2. package/dist/index.js.map +4 -4
  3. package/dist/translations/en.d.ts.map +1 -1
  4. package/dist/translations/es.d.ts.map +1 -1
  5. package/dist/translations/fr.d.ts.map +1 -1
  6. package/dist/translations/jp.d.ts.map +1 -1
  7. package/dist/widget/ui/src/components/BlockchainsChip/BlockchainsChip.d.ts +5 -0
  8. package/dist/widget/ui/src/components/BlockchainsChip/BlockchainsChip.d.ts.map +1 -0
  9. package/dist/widget/ui/src/components/BlockchainsChip/BlockchainsChip.styles.d.ts +156 -0
  10. package/dist/widget/ui/src/components/BlockchainsChip/BlockchainsChip.styles.d.ts.map +1 -0
  11. package/dist/widget/ui/src/components/BlockchainsChip/BlockchainsChip.types.d.ts +6 -0
  12. package/dist/widget/ui/src/components/BlockchainsChip/BlockchainsChip.types.d.ts.map +1 -0
  13. package/dist/widget/ui/src/components/BlockchainsChip/index.d.ts +2 -0
  14. package/dist/widget/ui/src/components/BlockchainsChip/index.d.ts.map +1 -0
  15. package/dist/widget/ui/src/components/Button/Button.styles.d.ts.map +1 -1
  16. package/dist/widget/ui/src/components/Checkbox/Checkbox.types.d.ts +2 -1
  17. package/dist/widget/ui/src/components/Checkbox/Checkbox.types.d.ts.map +1 -1
  18. package/dist/widget/ui/src/components/RouteCost/RouteCost.d.ts.map +1 -1
  19. package/dist/widget/ui/src/components/SelectableCategoryList/SelectableCategoryList.d.ts +4 -0
  20. package/dist/widget/ui/src/components/SelectableCategoryList/SelectableCategoryList.d.ts.map +1 -0
  21. package/dist/widget/ui/src/components/SelectableCategoryList/SelectableCategoryList.helpers.d.ts +4 -0
  22. package/dist/widget/ui/src/components/SelectableCategoryList/SelectableCategoryList.helpers.d.ts.map +1 -0
  23. package/dist/widget/ui/src/components/SelectableCategoryList/SelectableCategoryList.styles.d.ts +460 -0
  24. package/dist/widget/ui/src/components/SelectableCategoryList/SelectableCategoryList.styles.d.ts.map +1 -0
  25. package/dist/widget/ui/src/components/SelectableCategoryList/SelectableCategoryList.types.d.ts +15 -0
  26. package/dist/widget/ui/src/components/SelectableCategoryList/SelectableCategoryList.types.d.ts.map +1 -0
  27. package/dist/widget/ui/src/components/SelectableCategoryList/index.d.ts +3 -0
  28. package/dist/widget/ui/src/components/SelectableCategoryList/index.d.ts.map +1 -0
  29. package/dist/widget/ui/src/components/StepDetails/StepDetails.d.ts.map +1 -1
  30. package/dist/widget/ui/src/components/Wallet/Wallet.helpers.d.ts.map +1 -1
  31. package/dist/widget/ui/src/components/index.d.ts +2 -0
  32. package/dist/widget/ui/src/components/index.d.ts.map +1 -1
  33. package/dist/widget/ui/src/containers/SwapInput/SwapInput.d.ts.map +1 -1
  34. package/dist/widget/ui/src/containers/SwapInput/SwapInput.stories.d.ts.map +1 -1
  35. package/dist/widget/ui/src/containers/SwapInput/SwapInput.types.d.ts +4 -6
  36. package/dist/widget/ui/src/containers/SwapInput/SwapInput.types.d.ts.map +1 -1
  37. package/package.json +1 -1
  38. package/src/components/BlockchainsChip/BlockchainsChip.styles.ts +42 -0
  39. package/src/components/BlockchainsChip/BlockchainsChip.tsx +15 -0
  40. package/src/components/BlockchainsChip/BlockchainsChip.types.ts +4 -0
  41. package/src/components/BlockchainsChip/index.ts +1 -0
  42. package/src/components/Button/Button.styles.tsx +1 -0
  43. package/src/components/Checkbox/Checkbox.types.ts +1 -1
  44. package/src/components/RouteCost/RouteCost.tsx +6 -1
  45. package/src/components/SelectableCategoryList/SelectableCategoryList.helpers.ts +35 -0
  46. package/src/components/SelectableCategoryList/SelectableCategoryList.styles.ts +21 -0
  47. package/src/components/SelectableCategoryList/SelectableCategoryList.tsx +76 -0
  48. package/src/components/SelectableCategoryList/SelectableCategoryList.types.ts +16 -0
  49. package/src/components/SelectableCategoryList/index.ts +2 -0
  50. package/src/components/StepDetails/StepDetails.tsx +11 -1
  51. package/src/components/Wallet/Wallet.helpers.ts +11 -9
  52. package/src/components/index.ts +2 -0
  53. package/src/containers/SwapInput/SwapInput.stories.tsx +1 -0
  54. package/src/containers/SwapInput/SwapInput.tsx +4 -3
  55. package/src/containers/SwapInput/SwapInput.types.ts +4 -7
@@ -1,5 +1,6 @@
1
1
  import type { PropTypes } from './RouteCost.types';
2
2
 
3
+ import { i18n } from '@lingui/core';
3
4
  import React from 'react';
4
5
 
5
6
  import { GasIcon, NumberIcon, TimeIcon } from '../../icons';
@@ -26,7 +27,11 @@ export function RouteCost(props: PropTypes) {
26
27
  <TimeIcon size={12} color="gray" />
27
28
  </div>
28
29
  <Typography ml={2} align="center" variant="body" size="small">
29
- {`${time} min`}
30
+ {i18n.t({
31
+ id: 'timeMin',
32
+ message: '{time} min',
33
+ values: { time },
34
+ })}
30
35
  </Typography>
31
36
  </div>
32
37
  <Separator />
@@ -0,0 +1,35 @@
1
+ import { type BlockchainMeta, TransactionType } from 'rango-sdk';
2
+
3
+ import { BlockchainCategories } from './SelectableCategoryList.types';
4
+
5
+ const filterByType = (blockchain: BlockchainMeta, type: string): boolean => {
6
+ switch (type) {
7
+ case BlockchainCategories.ALL:
8
+ return true;
9
+ case BlockchainCategories.UTXO:
10
+ return blockchain.type === TransactionType.TRANSFER;
11
+ case BlockchainCategories.OTHER:
12
+ return (
13
+ blockchain.type !== TransactionType.TRANSFER &&
14
+ blockchain.type !== TransactionType.COSMOS &&
15
+ blockchain.type !== TransactionType.EVM
16
+ );
17
+ default:
18
+ return blockchain.type === type;
19
+ }
20
+ };
21
+
22
+ const blockchainslogo = {
23
+ [BlockchainCategories.EVM]: ['ETH', 'BSC', 'POLYGON'],
24
+ [BlockchainCategories.COSMOS]: ['COSMOS', 'OSMOSIS', 'JUNO'],
25
+ [BlockchainCategories.UTXO]: ['BTC', 'LTC', 'BCH'],
26
+ [BlockchainCategories.OTHER]: ['STARKNET', 'TRON', 'SOLANA'],
27
+ };
28
+
29
+ export const generateBlockchainsLogo = (
30
+ list: BlockchainMeta[],
31
+ type: Exclude<BlockchainCategories, 'ALL'>
32
+ ) =>
33
+ list
34
+ .filter((item) => filterByType(item, type))
35
+ .filter((item) => blockchainslogo[type].includes(item.name));
@@ -0,0 +1,21 @@
1
+ import { styled } from '../../theme';
2
+
3
+ export const Container = styled('div', {
4
+ display: 'grid',
5
+ gap: '$10',
6
+ gridTemplateColumns: 'auto 1fr 1fr 1fr 1fr',
7
+ });
8
+
9
+ export const ImageContent = styled('div', {
10
+ display: 'flex',
11
+ position: 'relative',
12
+ alignItems: 'center',
13
+ justifyContent: 'center',
14
+ paddingTop: '$10',
15
+ });
16
+ export const FirstImage = styled('img', {
17
+ position: 'absolute',
18
+ top: -2,
19
+ width: 15,
20
+ height: 15,
21
+ });
@@ -0,0 +1,76 @@
1
+ /* eslint-disable @typescript-eslint/no-magic-numbers */
2
+ import type { PropTypes } from './SelectableCategoryList.types';
3
+
4
+ import { i18n } from '@lingui/core';
5
+ import React from 'react';
6
+
7
+ import { Divider, Image, Skeleton, Typography } from '..';
8
+ import { BlockchainsChip } from '../BlockchainsChip';
9
+
10
+ import { generateBlockchainsLogo } from './SelectableCategoryList.helpers';
11
+ import {
12
+ Container,
13
+ FirstImage,
14
+ ImageContent,
15
+ } from './SelectableCategoryList.styles';
16
+ import { BlockchainCategories } from './SelectableCategoryList.types';
17
+
18
+ export function SelectableCategoryList(props: PropTypes) {
19
+ const { setCategory, category, blockchains, isLoading } = props;
20
+ const categories = Object.keys(
21
+ BlockchainCategories
22
+ ) as BlockchainCategories[];
23
+ return (
24
+ <Container>
25
+ {isLoading &&
26
+ Array.from(Array(5), (_, index) => (
27
+ <Skeleton
28
+ key={index}
29
+ variant="rounded"
30
+ height={70}
31
+ width={index === 0 ? 45 : 65}
32
+ />
33
+ ))}
34
+ {!isLoading &&
35
+ categories.map((blockchainCategory) => (
36
+ <BlockchainsChip
37
+ selected={category === blockchainCategory}
38
+ key={blockchainCategory}
39
+ onClick={() => setCategory(blockchainCategory)}>
40
+ {blockchainCategory !== BlockchainCategories.ALL && (
41
+ <>
42
+ <ImageContent>
43
+ {generateBlockchainsLogo(blockchains, blockchainCategory).map(
44
+ (blockchain, index) =>
45
+ index === 0 ? (
46
+ <FirstImage
47
+ key={`image-${blockchain.name}-${blockchain.chainId}`}
48
+ src={blockchain.logo}
49
+ />
50
+ ) : (
51
+ <Image
52
+ key={`image-${blockchain.name}-${blockchain.chainId}`}
53
+ src={blockchain.logo}
54
+ size={15}
55
+ />
56
+ )
57
+ )}
58
+ </ImageContent>
59
+ <Divider size={12} />
60
+ </>
61
+ )}
62
+ <Typography
63
+ size="xsmall"
64
+ variant="body"
65
+ color={
66
+ blockchainCategory === BlockchainCategories.ALL
67
+ ? 'secondary500'
68
+ : undefined
69
+ }>
70
+ {i18n.t(BlockchainCategories[blockchainCategory])}
71
+ </Typography>
72
+ </BlockchainsChip>
73
+ ))}
74
+ </Container>
75
+ );
76
+ }
@@ -0,0 +1,16 @@
1
+ import type { BlockchainMeta } from 'rango-sdk';
2
+
3
+ export interface PropTypes {
4
+ setCategory: (type: string) => void;
5
+ category: string;
6
+ blockchains: BlockchainMeta[];
7
+ isLoading?: boolean;
8
+ }
9
+
10
+ export enum BlockchainCategories {
11
+ ALL = 'ALL',
12
+ EVM = 'EVM',
13
+ COSMOS = 'COSMOS',
14
+ UTXO = 'UTXO',
15
+ OTHER = 'OTHER',
16
+ }
@@ -0,0 +1,2 @@
1
+ export { SelectableCategoryList } from './SelectableCategoryList';
2
+ export { BlockchainCategories } from './SelectableCategoryList.types';
@@ -1,5 +1,6 @@
1
1
  import type { StepDetailsProps } from './StepDetails.types';
2
2
 
3
+ import { i18n } from '@lingui/core';
3
4
  import React, { forwardRef, memo, useEffect, useRef } from 'react';
4
5
 
5
6
  import { ChainToken } from '../../components/ChainToken/ChainToken';
@@ -49,7 +50,16 @@ const StepDetailsComponent = forwardRef<HTMLDivElement, StepDetailsProps>(
49
50
  className="swapper__description"
50
51
  ml={8}
51
52
  size="small"
52
- variant="body">{`Swap on ${step.from.chain.displayName} via ${step.swapper.displayName}`}</Typography>
53
+ variant="body">
54
+ {i18n.t({
55
+ id: 'swapperDescription',
56
+ message: 'Swap on {fromChain} via {swapper}',
57
+ values: {
58
+ fromChain: step.from.chain.displayName,
59
+ swapper: step.swapper.displayName,
60
+ },
61
+ })}
62
+ </Typography>
53
63
  </div>
54
64
  <div className="step-info">
55
65
  <DashedLine invisible={!hasSeparator || type === 'route-progress'} />
@@ -1,5 +1,7 @@
1
1
  import type { Info } from './Wallet.types';
2
2
 
3
+ import { i18n } from '@lingui/core';
4
+
3
5
  import { WalletState } from './Wallet.types';
4
6
 
5
7
  export function makeInfo(state: WalletState): Info {
@@ -7,28 +9,28 @@ export function makeInfo(state: WalletState): Info {
7
9
  case WalletState.CONNECTED:
8
10
  return {
9
11
  color: 'success500',
10
- description: 'Connected',
11
- tooltipText: 'Disconnect',
12
+ description: i18n.t('Connected'),
13
+ tooltipText: i18n.t('Disconnect'),
12
14
  };
13
15
  case WalletState.NOT_INSTALLED:
14
16
  return {
15
17
  color: 'info500',
16
- description: 'Install',
17
- tooltipText: 'Install',
18
+ description: i18n.t('Install'),
19
+ tooltipText: i18n.t('Install'),
18
20
  };
19
21
  case WalletState.CONNECTING:
20
22
  return {
21
23
  color: 'neutral800',
22
- description: 'Connecting...',
23
- tooltipText: 'Connecting',
24
+ description: i18n.t('Connecting...'),
25
+ tooltipText: i18n.t('Connecting'),
24
26
  };
25
27
  case WalletState.DISCONNECTED:
26
28
  return {
27
29
  color: 'neutral800',
28
- description: 'Disconnected',
29
- tooltipText: 'Connect',
30
+ description: i18n.t('Disconnected'),
31
+ tooltipText: i18n.t('Connect'),
30
32
  };
31
33
  default:
32
- throw new Error('you need to pass a correct state to Wallet.');
34
+ throw new Error(i18n.t('you need to pass a correct state to Wallet.'));
33
35
  }
34
36
  }
@@ -1,6 +1,7 @@
1
1
  export * from './I18nManager';
2
2
  export * from './Alert';
3
3
  export * from './BestRoute';
4
+ export * from './BlockchainsChip';
4
5
  export * from './BottomLogo';
5
6
  export * from './Button';
6
7
  export * from './IconButton';
@@ -21,6 +22,7 @@ export * from './RoutesOverview';
21
22
  export * from './SecondaryPage';
22
23
  export * from './SelectableWalletList';
23
24
  export * from './Wallet';
25
+ export * from './SelectableCategoryList';
24
26
  export * from './Spinner';
25
27
  export * from './StepDetail';
26
28
  export * from './SwapContainer';
@@ -32,6 +32,7 @@ export const SwapTo = (args: SwapInputProps) => (
32
32
  <SwapInput
33
33
  {...args}
34
34
  label="To"
35
+ mode="To"
35
36
  price={{ value: '2.5', usdValue: '610' }}
36
37
  percentageChange="6.4"
37
38
  warningLevel="high"
@@ -1,5 +1,6 @@
1
1
  import type { SwapInputProps } from './SwapInput.types';
2
2
 
3
+ import { i18n } from '@lingui/core';
3
4
  import React from 'react';
4
5
 
5
6
  import { Divider, PriceImpact, Skeleton, Typography } from '../../components';
@@ -22,14 +23,14 @@ export function SwapInput(props: SwapInputProps) {
22
23
  mr={4}
23
24
  variant="body"
24
25
  size="xsmall">
25
- Balance: {props.balance}
26
+ {i18n.t('Balance')}: {props.balance}
26
27
  </Typography>
27
28
  <MaxButton
28
29
  variant="default"
29
30
  size="xsmall"
30
31
  onClick={props.onSelectMaxBalance}>
31
32
  <Typography variant="body" size="xsmall" color="secondary500">
32
- Max
33
+ {i18n.t('Max')}
33
34
  </Typography>
34
35
  </MaxButton>
35
36
  </div>
@@ -61,7 +62,7 @@ export function SwapInput(props: SwapInputProps) {
61
62
  ) : (
62
63
  <>
63
64
  <InputAmount
64
- disabled={props.disabled || props.label === 'To'}
65
+ disabled={props.disabled || props.mode === 'To'}
65
66
  style={{ padding: 0 }}
66
67
  value={props.price.value}
67
68
  type={'onInputChange' in props ? 'number' : 'text'}
@@ -17,25 +17,22 @@ export type BaseProps = {
17
17
  loading?: boolean;
18
18
  error?: boolean;
19
19
  disabled?: boolean;
20
+ label: string;
20
21
  sharpBottomStyle?: boolean;
21
22
  onClickToken: () => void;
22
23
  };
23
24
 
24
25
  type FromProps = {
25
- label: 'From';
26
+ mode: 'From';
26
27
  balance?: string;
27
28
  onSelectMaxBalance: () => void;
28
29
  onInputChange: (inputAmount: string) => void;
29
30
  };
30
31
 
31
32
  type ToProps = {
32
- label: 'To';
33
+ mode: 'To';
33
34
  percentageChange: string | null;
34
35
  warningLevel: PriceImpactWarningLevel;
35
36
  };
36
37
 
37
- type Common = {
38
- label: string;
39
- };
40
-
41
- export type SwapInputProps = BaseProps & (FromProps | ToProps | Common);
38
+ export type SwapInputProps = BaseProps & (FromProps | ToProps);