@rango-dev/ui 0.26.1-next.0 → 0.26.1-next.2

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 (54) hide show
  1. package/dist/index.js +6 -6
  2. package/dist/index.js.map +3 -3
  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/ja.d.ts.map +1 -1
  7. package/dist/widget/ui/src/components/Button/Button.d.ts +1 -0
  8. package/dist/widget/ui/src/components/Button/Button.d.ts.map +1 -1
  9. package/dist/widget/ui/src/components/Button/Button.types.d.ts +1 -0
  10. package/dist/widget/ui/src/components/Button/Button.types.d.ts.map +1 -1
  11. package/dist/widget/ui/src/components/PriceImpact/PriceImpact.d.ts.map +1 -1
  12. package/dist/widget/ui/src/components/PriceImpact/PriceImpact.types.d.ts +6 -0
  13. package/dist/widget/ui/src/components/PriceImpact/PriceImpact.types.d.ts.map +1 -1
  14. package/dist/widget/ui/src/components/StepDetails/StepDetails.d.ts.map +1 -1
  15. package/dist/widget/ui/src/components/StepDetails/StepDetails.types.d.ts +1 -0
  16. package/dist/widget/ui/src/components/StepDetails/StepDetails.types.d.ts.map +1 -1
  17. package/dist/widget/ui/src/components/SwapListItem/SwapListItem.d.ts.map +1 -1
  18. package/dist/widget/ui/src/components/SwapListItem/SwapListItem.types.d.ts +2 -1
  19. package/dist/widget/ui/src/components/SwapListItem/SwapListItem.types.d.ts.map +1 -1
  20. package/dist/widget/ui/src/components/SwapListItem/SwapToken.d.ts.map +1 -1
  21. package/dist/widget/ui/src/components/SwapListItem/SwapToken.types.d.ts +1 -0
  22. package/dist/widget/ui/src/components/SwapListItem/SwapToken.types.d.ts.map +1 -1
  23. package/dist/widget/ui/src/components/SwapListItem/mock.d.ts.map +1 -1
  24. package/dist/widget/ui/src/components/TokenAmount/TokenAmount.d.ts.map +1 -1
  25. package/dist/widget/ui/src/components/TokenAmount/TokenAmount.types.d.ts +1 -0
  26. package/dist/widget/ui/src/components/TokenAmount/TokenAmount.types.d.ts.map +1 -1
  27. package/dist/widget/ui/src/components/Tooltip/Tooltip.d.ts.map +1 -1
  28. package/dist/widget/ui/src/components/Tooltip/Tooltip.types.d.ts +2 -0
  29. package/dist/widget/ui/src/components/Tooltip/Tooltip.types.d.ts.map +1 -1
  30. package/dist/widget/ui/src/containers/SwapInput/SwapInput.d.ts.map +1 -1
  31. package/dist/widget/ui/src/containers/SwapInput/SwapInput.styles.d.ts +1 -0
  32. package/dist/widget/ui/src/containers/SwapInput/SwapInput.styles.d.ts.map +1 -1
  33. package/dist/widget/ui/src/containers/SwapInput/SwapInput.types.d.ts +3 -0
  34. package/dist/widget/ui/src/containers/SwapInput/SwapInput.types.d.ts.map +1 -1
  35. package/dist/widget/ui/src/containers/SwapInput/TokenSection.styles.d.ts +1 -0
  36. package/dist/widget/ui/src/containers/SwapInput/TokenSection.styles.d.ts.map +1 -1
  37. package/package.json +2 -2
  38. package/src/components/Button/Button.tsx +4 -1
  39. package/src/components/Button/Button.types.tsx +1 -0
  40. package/src/components/PriceImpact/PriceImpact.tsx +26 -8
  41. package/src/components/PriceImpact/PriceImpact.types.ts +7 -0
  42. package/src/components/StepDetails/StepDetails.tsx +31 -15
  43. package/src/components/StepDetails/StepDetails.types.ts +1 -0
  44. package/src/components/SwapListItem/SwapListItem.tsx +6 -1
  45. package/src/components/SwapListItem/SwapListItem.types.ts +2 -1
  46. package/src/components/SwapListItem/SwapToken.tsx +14 -8
  47. package/src/components/SwapListItem/SwapToken.types.ts +1 -0
  48. package/src/components/SwapListItem/mock.ts +1 -0
  49. package/src/components/TokenAmount/TokenAmount.tsx +36 -20
  50. package/src/components/TokenAmount/TokenAmount.types.ts +1 -0
  51. package/src/components/Tooltip/Tooltip.tsx +2 -1
  52. package/src/components/Tooltip/Tooltip.types.ts +2 -0
  53. package/src/containers/SwapInput/SwapInput.tsx +53 -22
  54. package/src/containers/SwapInput/SwapInput.types.ts +3 -0
@@ -4,6 +4,7 @@ import React from 'react';
4
4
 
5
5
  import { ChainToken } from '../ChainToken';
6
6
  import { PriceImpact } from '../PriceImpact/PriceImpact';
7
+ import { Tooltip } from '../Tooltip';
7
8
  import { Typography } from '../Typography';
8
9
 
9
10
  import {
@@ -27,37 +28,52 @@ export function TokenAmount(props: PropTypes) {
27
28
  {props.label}
28
29
  </Typography>
29
30
  )}
30
- <div title={`${props.price.value} ${props.token.displayName}`}>
31
- <Typography
32
- ml={4}
33
- size="medium"
34
- variant="title"
35
- style={{ fontWeight: 600 }}>
36
- {props.price.value}
37
- </Typography>
38
- <Typography
39
- ml={8}
40
- size="medium"
41
- variant="title"
42
- style={{ fontWeight: 400 }}>
43
- {props.token.displayName}
44
- </Typography>
31
+ <div>
32
+ <Tooltip
33
+ content={props.price.realValue}
34
+ open={!props.price.realValue ? false : undefined}
35
+ container={props.tooltipContainer}>
36
+ <Typography
37
+ ml={4}
38
+ size="medium"
39
+ variant="title"
40
+ style={{ fontWeight: 600 }}>
41
+ {props.price.value}
42
+ </Typography>
43
+ <Typography
44
+ ml={8}
45
+ size="medium"
46
+ variant="title"
47
+ style={{ fontWeight: 400 }}>
48
+ {props.token.displayName}
49
+ </Typography>
50
+ </Tooltip>
45
51
  </div>
46
52
  </div>
47
53
  </div>
48
54
  {props.price.usdValue && props.price.usdValue !== '0' && (
49
55
  <div className={usdValueStyles()}>
50
- {props.type === 'input' && (
51
- <Typography mr={4} size="small" variant="body" color="$neutral700">
52
- {`~$${props.price.usdValue}`}
53
- </Typography>
54
- )}
56
+ <Tooltip
57
+ content={props.price.realUsdValue}
58
+ container={props.tooltipContainer}>
59
+ {props.type === 'input' && (
60
+ <Typography
61
+ mr={4}
62
+ size="small"
63
+ variant="body"
64
+ color="$neutral700">
65
+ {`~$${props.price.usdValue}`}
66
+ </Typography>
67
+ )}
68
+ </Tooltip>
55
69
  {props.type === 'output' && (
56
70
  <PriceImpact
57
71
  size="small"
72
+ tooltipProps={{ container: props.tooltipContainer, side: 'top' }}
58
73
  outputUsdValue={props.price.usdValue}
59
74
  percentageChange={props.percentageChange}
60
75
  warningLevel={props.warningLevel}
76
+ realOutputUsdValue={props.price.realUsdValue}
61
77
  />
62
78
  )}
63
79
  </div>
@@ -6,6 +6,7 @@ type BaseProps = Pick<SwapInputProps, 'token' | 'price'> & {
6
6
  direction?: 'vertical' | 'horizontal';
7
7
  centerAlign?: boolean;
8
8
  label?: string;
9
+ tooltipContainer?: HTMLElement;
9
10
  };
10
11
 
11
12
  type InputAmountProps = { type: 'input' };
@@ -19,11 +19,12 @@ export function Tooltip(props: PropsWithChildren<PropTypes>) {
19
19
  container,
20
20
  open,
21
21
  side = 'top',
22
+ style,
22
23
  } = props;
23
24
  return (
24
25
  <RadixTooltip.Provider delayDuration={0}>
25
26
  <RadixTooltip.Root open={open}>
26
- <RadixTooltip.Trigger asChild>
27
+ <RadixTooltip.Trigger asChild style={style}>
27
28
  <TriggerContent>{children}</TriggerContent>
28
29
  </RadixTooltip.Trigger>
29
30
  <RadixTooltip.Portal container={container}>
@@ -1,4 +1,5 @@
1
1
  import type * as RadixTooltip from '@radix-ui/react-tooltip';
2
+ import type { CSSProperties } from '@stitches/react';
2
3
  import type { ComponentProps, ReactNode } from 'react';
3
4
 
4
5
  type RadixTooltipContentProps = ComponentProps<typeof RadixTooltip.Content>;
@@ -10,4 +11,5 @@ export interface PropTypes {
10
11
  sideOffset?: RadixTooltipContentProps['sideOffset'];
11
12
  container?: HTMLElement;
12
13
  open?: boolean;
14
+ style?: CSSProperties;
13
15
  }
@@ -3,7 +3,13 @@ import type { SwapInputProps } from './SwapInput.types';
3
3
  import { i18n } from '@lingui/core';
4
4
  import React from 'react';
5
5
 
6
- import { Divider, PriceImpact, Skeleton, Typography } from '../../components';
6
+ import {
7
+ Divider,
8
+ PriceImpact,
9
+ Skeleton,
10
+ Tooltip,
11
+ Typography,
12
+ } from '../../components';
7
13
 
8
14
  import {
9
15
  amountStyles,
@@ -77,36 +83,61 @@ export function SwapInput(props: SwapInputProps) {
77
83
  </>
78
84
  ) : (
79
85
  <>
80
- <InputAmount
81
- disabled={props.disabled || props.mode === 'To'}
82
- style={{ padding: 0 }}
83
- value={props.price.value}
84
- type={'onInputChange' in props ? 'number' : 'text'}
85
- size="large"
86
- placeholder="0"
87
- variant="ghost"
88
- min={0}
89
- {...('onInputChange' in props && {
90
- onChange: (event: React.ChangeEvent<HTMLInputElement>) =>
91
- props.onInputChange(event.target.value),
92
- })}
93
- />
86
+ <Tooltip
87
+ content={props.price.realValue}
88
+ container={props.tooltipContainer}
89
+ open={
90
+ !props.price.realValue || props.price.realValue === '0'
91
+ ? false
92
+ : undefined
93
+ }>
94
+ <InputAmount
95
+ disabled={props.disabled || props.mode === 'To'}
96
+ style={{ padding: 0 }}
97
+ value={props.price.value}
98
+ type={'onInputChange' in props ? 'number' : 'text'}
99
+ size="large"
100
+ placeholder="0"
101
+ variant="ghost"
102
+ min={0}
103
+ {...('onInputChange' in props && {
104
+ onChange: (event: React.ChangeEvent<HTMLInputElement>) =>
105
+ props.onInputChange(event.target.value),
106
+ })}
107
+ />
108
+ </Tooltip>
94
109
  {'percentageChange' in props ? (
95
110
  <PriceImpact
96
111
  size="large"
112
+ tooltipProps={{
113
+ container: props.tooltipContainer,
114
+ side: 'bottom',
115
+ }}
97
116
  outputUsdValue={props.price.usdValue}
117
+ realOutputUsdValue={props.price.realUsdValue}
98
118
  error={props.price.error}
99
119
  percentageChange={props.percentageChange}
100
120
  warningLevel={props.warningLevel}
101
121
  />
102
122
  ) : (
103
- <ValueTypography hasWarning={!!props.price.error}>
104
- <UsdPrice variant="body" size="medium">
105
- {props.price.usdValue
106
- ? `~$${props.price.usdValue}`
107
- : props.price.error}
108
- </UsdPrice>
109
- </ValueTypography>
123
+ <Tooltip
124
+ content={props.price.realUsdValue}
125
+ container={props.tooltipContainer}
126
+ open={
127
+ !props.price.realUsdValue ||
128
+ props.price.realUsdValue === '0'
129
+ ? false
130
+ : undefined
131
+ }
132
+ side="bottom">
133
+ <ValueTypography hasWarning={!!props.price.error}>
134
+ <UsdPrice variant="body" size="medium">
135
+ {props.price.usdValue
136
+ ? `~$${props.price.usdValue}`
137
+ : props.price.error}
138
+ </UsdPrice>
139
+ </ValueTypography>
140
+ </Tooltip>
110
141
  )}
111
142
  </>
112
143
  )}
@@ -12,6 +12,8 @@ export type BaseProps = {
12
12
  price: {
13
13
  value: string;
14
14
  usdValue?: string;
15
+ realValue?: string;
16
+ realUsdValue?: string;
15
17
  error?: string;
16
18
  };
17
19
  loading?: boolean;
@@ -20,6 +22,7 @@ export type BaseProps = {
20
22
  label: string;
21
23
  sharpBottomStyle?: boolean;
22
24
  onClickToken: () => void;
25
+ tooltipContainer?: HTMLElement;
23
26
  };
24
27
 
25
28
  type FromProps = {