@rango-dev/widget-embedded 0.20.1-next.2 → 0.20.1-next.21

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 (227) hide show
  1. package/dist/components/BlockchainList/BlockchainList.styles.d.ts +169 -1
  2. package/dist/components/BlockchainList/BlockchainList.styles.d.ts.map +1 -1
  3. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts +4 -0
  4. package/dist/components/BlockchainsSection/BlockchainsSection.styles.d.ts.map +1 -1
  5. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts +514 -1088
  6. package/dist/components/ConfirmWalletsModal/ConfirmWallets.styles.d.ts.map +1 -1
  7. package/dist/components/ConfirmWalletsModal/ConfirmWalletsModal.d.ts.map +1 -1
  8. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts +12 -0
  9. package/dist/components/ConfirmWalletsModal/WalletList.styles.d.ts.map +1 -1
  10. package/dist/components/CustomCollapsible/CustomCollapsible.d.ts +5 -0
  11. package/dist/components/CustomCollapsible/CustomCollapsible.d.ts.map +1 -0
  12. package/dist/components/CustomCollapsible/CustomCollapsible.styles.d.ts +654 -0
  13. package/dist/components/CustomCollapsible/CustomCollapsible.styles.d.ts.map +1 -0
  14. package/dist/components/CustomCollapsible/CustomCollapsible.types.d.ts +10 -0
  15. package/dist/components/CustomCollapsible/CustomCollapsible.types.d.ts.map +1 -0
  16. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts +179 -0
  17. package/dist/components/HeaderButtons/HeaderButtons.styles.d.ts.map +1 -1
  18. package/dist/components/HeaderButtons/HeaderButtons.types.d.ts +0 -2
  19. package/dist/components/HeaderButtons/HeaderButtons.types.d.ts.map +1 -1
  20. package/dist/components/HeaderButtons/HomeButtons.d.ts.map +1 -1
  21. package/dist/components/HeaderButtons/RefreshButton.d.ts +6 -0
  22. package/dist/components/HeaderButtons/RefreshButton.d.ts.map +1 -0
  23. package/dist/components/Layout/Layout.d.ts +2 -3
  24. package/dist/components/Layout/Layout.d.ts.map +1 -1
  25. package/dist/components/Layout/Layout.helpers.d.ts +2 -0
  26. package/dist/components/Layout/Layout.helpers.d.ts.map +1 -0
  27. package/dist/components/Layout/Layout.styles.d.ts +14 -4
  28. package/dist/components/Layout/Layout.styles.d.ts.map +1 -1
  29. package/dist/components/Layout/Layout.types.d.ts +6 -3
  30. package/dist/components/Layout/Layout.types.d.ts.map +1 -1
  31. package/dist/components/Layout/PageContainer.d.ts +166 -0
  32. package/dist/components/Layout/PageContainer.d.ts.map +1 -0
  33. package/dist/components/Layout/ScrollableArea.d.ts +164 -0
  34. package/dist/components/Layout/ScrollableArea.d.ts.map +1 -0
  35. package/dist/components/Layout/index.d.ts +2 -0
  36. package/dist/components/Layout/index.d.ts.map +1 -1
  37. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts +4 -0
  38. package/dist/components/LoadingLiquiditySourceList/LoadingLiquiditySourceList.styles.d.ts.map +1 -1
  39. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts +56 -0
  40. package/dist/components/LoadingSwapDetails/LoadingSwapDetails.styles.d.ts.map +1 -1
  41. package/dist/components/NoResult/NoResult.styles.d.ts +12 -0
  42. package/dist/components/NoResult/NoResult.styles.d.ts.map +1 -1
  43. package/dist/components/NotificationContent/NotificationContent.d.ts.map +1 -1
  44. package/dist/components/NotificationContent/NotificationContent.styles.d.ts +16 -0
  45. package/dist/components/NotificationContent/NotificationContent.styles.d.ts.map +1 -1
  46. package/dist/components/Quote/Quote.d.ts.map +1 -1
  47. package/dist/components/Quote/Quote.styles.d.ts +386 -2
  48. package/dist/components/Quote/Quote.styles.d.ts.map +1 -1
  49. package/dist/components/Quote/Quote.types.d.ts +19 -0
  50. package/dist/components/Quote/Quote.types.d.ts.map +1 -1
  51. package/dist/components/Quote/QuoteCostDetails.d.ts +4 -0
  52. package/dist/components/Quote/QuoteCostDetails.d.ts.map +1 -0
  53. package/dist/components/Quote/QuoteCostDetails.styles.d.ts +806 -0
  54. package/dist/components/Quote/QuoteCostDetails.styles.d.ts.map +1 -0
  55. package/dist/components/Quote/QuoteSummary.d.ts.map +1 -1
  56. package/dist/components/Quote/QuoteSummary.styles.d.ts +8 -0
  57. package/dist/components/Quote/QuoteSummary.styles.d.ts.map +1 -1
  58. package/dist/components/Quote/QuoteTrigger .d.ts +4 -0
  59. package/dist/components/Quote/QuoteTrigger .d.ts.map +1 -0
  60. package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts +16 -0
  61. package/dist/components/QuoteSkeleton/QuoteSkeleton.styles.d.ts.map +1 -1
  62. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts +40 -0
  63. package/dist/components/QuoteSkeleton/QuoteSummarySkeleton.styles.d.ts.map +1 -1
  64. package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts +20 -0
  65. package/dist/components/QuoteSkeleton/StepSkeleton.styles.d.ts.map +1 -1
  66. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts +16 -0
  67. package/dist/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.d.ts.map +1 -1
  68. package/dist/components/SearchInput/SearchInput.styles.d.ts +4 -0
  69. package/dist/components/SearchInput/SearchInput.styles.d.ts.map +1 -1
  70. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts +11 -156
  71. package/dist/components/SettingsContainer/SettingsContainer.style.d.ts.map +1 -1
  72. package/dist/components/SettingsContainer/index.d.ts +1 -1
  73. package/dist/components/SettingsContainer/index.d.ts.map +1 -1
  74. package/dist/components/Slippage/Slippage.styles.d.ts +20 -0
  75. package/dist/components/Slippage/Slippage.styles.d.ts.map +1 -1
  76. package/dist/components/SwapDetails/SwapDetails.Placeholder.d.ts.map +1 -1
  77. package/dist/components/SwapDetails/SwapDetails.d.ts.map +1 -1
  78. package/dist/components/SwapDetails/SwapDetails.helpers.d.ts +1 -1
  79. package/dist/components/SwapDetails/SwapDetails.helpers.d.ts.map +1 -1
  80. package/dist/components/SwapDetails/SwapDetails.styles.d.ts +523 -1
  81. package/dist/components/SwapDetails/SwapDetails.styles.d.ts.map +1 -1
  82. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.d.ts.map +1 -1
  83. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts +4 -0
  84. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.styles.d.ts.map +1 -1
  85. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts +2 -1
  86. package/dist/components/SwapDetailsAlerts/SwapDetailsAlerts.types.d.ts.map +1 -1
  87. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts +4 -0
  88. package/dist/components/SwapDetailsModal/SwapDetailsModal.styles.d.ts.map +1 -1
  89. package/dist/components/SwapsGroup/SwapsGroup.d.ts.map +1 -1
  90. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts +20 -0
  91. package/dist/components/SwapsGroup/SwapsGroup.styles.d.ts.map +1 -1
  92. package/dist/components/TokenList/TokenList.styles.d.ts +68 -0
  93. package/dist/components/TokenList/TokenList.styles.d.ts.map +1 -1
  94. package/dist/components/WalletModal/WalletModalContent.styles.d.ts +16 -0
  95. package/dist/components/WalletModal/WalletModalContent.styles.d.ts.map +1 -1
  96. package/dist/components/WidgetEvents.d.ts.map +1 -1
  97. package/dist/constants/index.d.ts +1 -0
  98. package/dist/constants/index.d.ts.map +1 -1
  99. package/dist/constants/quote.d.ts +12 -0
  100. package/dist/constants/quote.d.ts.map +1 -0
  101. package/dist/containers/App/App.d.ts.map +1 -1
  102. package/dist/containers/App/App.styles.d.ts +4 -0
  103. package/dist/containers/App/App.styles.d.ts.map +1 -1
  104. package/dist/containers/QuoteInfo/QuoteInfo.d.ts +1 -1
  105. package/dist/containers/QuoteInfo/QuoteInfo.d.ts.map +1 -1
  106. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts +10 -314
  107. package/dist/containers/QuoteInfo/QuoteInfo.styles.d.ts.map +1 -1
  108. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts +0 -7
  109. package/dist/containers/QuoteInfo/QuoteInfo.types.d.ts.map +1 -1
  110. package/dist/containers/Wallets/Wallets.d.ts.map +1 -1
  111. package/dist/containers/WidgetInfo/WidgetInfo.d.ts.map +1 -1
  112. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts +5 -0
  113. package/dist/containers/WidgetInfo/WidgetInfo.types.d.ts.map +1 -1
  114. package/dist/containers/WidgetProvider/WidgetProvider.d.ts.map +1 -1
  115. package/dist/hooks/useLanguage.d.ts +2 -1
  116. package/dist/hooks/useLanguage.d.ts.map +1 -1
  117. package/dist/hooks/usePrepareBlockchainList/usePrepareBlockchainList.helpers.d.ts +2 -2
  118. package/dist/hooks/useSwapInput.d.ts.map +1 -1
  119. package/dist/hooks/useSyncStoresWithConfig.d.ts.map +1 -1
  120. package/dist/index.d.ts +6 -6
  121. package/dist/index.d.ts.map +1 -1
  122. package/dist/index.js +2 -1
  123. package/dist/index.js.map +4 -4
  124. package/dist/pages/ConfirmSwapPage.d.ts.map +1 -1
  125. package/dist/pages/HistoryPage.d.ts.map +1 -1
  126. package/dist/pages/Home.d.ts.map +1 -1
  127. package/dist/pages/LanguagePage.d.ts.map +1 -1
  128. package/dist/pages/LiquiditySourcePage.d.ts.map +1 -1
  129. package/dist/pages/SelectSwapItemsPage.d.ts.map +1 -1
  130. package/dist/pages/SettingsPage.d.ts.map +1 -1
  131. package/dist/pages/ThemePage.d.ts.map +1 -1
  132. package/dist/pages/WalletsPage.d.ts.map +1 -1
  133. package/dist/store/AppStore.d.ts +2 -2
  134. package/dist/store/app.d.ts +2 -2
  135. package/dist/store/slices/data.d.ts.map +1 -1
  136. package/dist/store/slices/settings.d.ts +2 -2
  137. package/dist/store/slices/settings.d.ts.map +1 -1
  138. package/dist/types/config.d.ts +16 -3
  139. package/dist/types/config.d.ts.map +1 -1
  140. package/dist/types/notification.d.ts +1 -2
  141. package/dist/types/notification.d.ts.map +1 -1
  142. package/dist/utils/configs.d.ts +8 -0
  143. package/dist/utils/configs.d.ts.map +1 -1
  144. package/dist/utils/date.d.ts.map +1 -1
  145. package/dist/utils/quote.d.ts +5 -1
  146. package/dist/utils/quote.d.ts.map +1 -1
  147. package/dist/utils/settings.d.ts +1 -1
  148. package/dist/utils/swap.d.ts +5 -1
  149. package/dist/utils/swap.d.ts.map +1 -1
  150. package/dist/utils/ui.d.ts +2 -0
  151. package/dist/utils/ui.d.ts.map +1 -1
  152. package/package.json +6 -6
  153. package/src/components/BlockchainList/BlockchainList.styles.ts +4 -3
  154. package/src/components/BlockchainList/BlockchainList.tsx +1 -1
  155. package/src/components/ConfirmWalletsModal/ConfirmWallets.styles.ts +27 -96
  156. package/src/components/ConfirmWalletsModal/ConfirmWalletsModal.tsx +25 -40
  157. package/src/components/CustomCollapsible/CustomCollapsible.styles.ts +75 -0
  158. package/src/components/CustomCollapsible/CustomCollapsible.tsx +55 -0
  159. package/src/components/CustomCollapsible/CustomCollapsible.types.ts +10 -0
  160. package/src/components/HeaderButtons/HeaderButtons.styles.ts +16 -1
  161. package/src/components/HeaderButtons/HeaderButtons.types.ts +0 -2
  162. package/src/components/HeaderButtons/HomeButtons.tsx +19 -33
  163. package/src/components/HeaderButtons/RefreshButton.tsx +81 -0
  164. package/src/components/Layout/Layout.helpers.ts +16 -0
  165. package/src/components/Layout/Layout.styles.ts +17 -31
  166. package/src/components/Layout/Layout.tsx +23 -21
  167. package/src/components/Layout/Layout.types.ts +9 -8
  168. package/src/components/Layout/PageContainer.tsx +24 -0
  169. package/src/components/Layout/ScrollableArea.tsx +11 -0
  170. package/src/components/Layout/index.ts +2 -0
  171. package/src/components/NotificationContent/NotificationContent.tsx +10 -1
  172. package/src/components/Quote/Quote.styles.ts +44 -5
  173. package/src/components/Quote/Quote.tsx +10 -77
  174. package/src/components/Quote/Quote.types.ts +22 -0
  175. package/src/components/Quote/QuoteCostDetails.styles.ts +50 -0
  176. package/src/components/Quote/QuoteCostDetails.tsx +218 -0
  177. package/src/components/Quote/QuoteSummary.tsx +3 -2
  178. package/src/components/Quote/QuoteTrigger .tsx +215 -0
  179. package/src/components/QuoteWarningsAndErrors/QuoteWarningsAndErrors.styles.ts +0 -1
  180. package/src/components/SettingsContainer/SettingsContainer.style.ts +0 -5
  181. package/src/components/SettingsContainer/index.ts +0 -1
  182. package/src/components/Slippage/Slippage.tsx +5 -5
  183. package/src/components/Slippage/SlippageTooltipContent.tsx +1 -1
  184. package/src/components/SwapDetails/SwapDetails.Placeholder.tsx +12 -13
  185. package/src/components/SwapDetails/SwapDetails.helpers.tsx +43 -3
  186. package/src/components/SwapDetails/SwapDetails.styles.ts +18 -6
  187. package/src/components/SwapDetails/SwapDetails.tsx +13 -5
  188. package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.tsx +13 -7
  189. package/src/components/SwapDetailsAlerts/SwapDetailsAlerts.types.ts +2 -0
  190. package/src/components/SwapsGroup/SwapsGroup.tsx +18 -7
  191. package/src/components/TokenList/TokenList.styles.ts +2 -0
  192. package/src/components/TokenList/TokenList.tsx +1 -1
  193. package/src/components/WidgetEvents.tsx +2 -14
  194. package/src/constants/index.ts +1 -0
  195. package/src/constants/quote.ts +23 -0
  196. package/src/containers/App/App.styles.ts +2 -0
  197. package/src/containers/App/App.tsx +1 -4
  198. package/src/containers/QuoteInfo/QuoteInfo.styles.ts +0 -15
  199. package/src/containers/QuoteInfo/QuoteInfo.tsx +30 -77
  200. package/src/containers/QuoteInfo/QuoteInfo.types.ts +0 -7
  201. package/src/containers/Wallets/Wallets.tsx +11 -2
  202. package/src/containers/WidgetInfo/WidgetInfo.tsx +8 -0
  203. package/src/containers/WidgetInfo/WidgetInfo.types.ts +5 -0
  204. package/src/containers/WidgetProvider/WidgetProvider.tsx +2 -1
  205. package/src/hooks/useLanguage.ts +6 -4
  206. package/src/hooks/useSwapInput.ts +6 -2
  207. package/src/hooks/useSyncStoresWithConfig.ts +17 -34
  208. package/src/index.ts +4 -2
  209. package/src/pages/ConfirmSwapPage.tsx +59 -50
  210. package/src/pages/HistoryPage.tsx +4 -11
  211. package/src/pages/Home.tsx +40 -38
  212. package/src/pages/LanguagePage.tsx +3 -4
  213. package/src/pages/LiquiditySourcePage.tsx +8 -6
  214. package/src/pages/SelectBlockchainPage.tsx +41 -41
  215. package/src/pages/SelectSwapItemsPage.tsx +45 -39
  216. package/src/pages/SettingsPage.tsx +3 -4
  217. package/src/pages/ThemePage.tsx +3 -4
  218. package/src/pages/WalletsPage.tsx +12 -13
  219. package/src/store/slices/data.ts +5 -7
  220. package/src/store/slices/settings.ts +3 -3
  221. package/src/types/config.ts +16 -3
  222. package/src/types/notification.ts +0 -7
  223. package/src/utils/configs.ts +41 -0
  224. package/src/utils/date.ts +5 -4
  225. package/src/utils/quote.ts +18 -1
  226. package/src/utils/swap.ts +35 -0
  227. package/src/utils/ui.ts +20 -0
@@ -15,7 +15,7 @@ import {
15
15
  Typography,
16
16
  WalletIcon,
17
17
  } from '@rango-dev/ui';
18
- import React, { useEffect, useLayoutEffect, useRef, useState } from 'react';
18
+ import React, { useEffect, useState } from 'react';
19
19
  import { useNavigate } from 'react-router-dom';
20
20
 
21
21
  import { RANGO_SWAP_BOX_ID } from '../../constants';
@@ -26,23 +26,20 @@ import { useQuoteStore } from '../../store/quote';
26
26
  import { useWalletsStore } from '../../store/wallets';
27
27
  import { getBlockchainShortNameFor } from '../../utils/meta';
28
28
  import { confirmSwapDisabled } from '../../utils/swap';
29
+ import { CustomCollapsible } from '../CustomCollapsible/CustomCollapsible';
30
+ import { ExpandedIcon } from '../CustomCollapsible/CustomCollapsible.styles';
29
31
 
30
32
  import { getRequiredWallets, isValidAddress } from './ConfirmWallets.helpers';
31
33
  import {
32
34
  alarmsStyles,
33
- CollapsibleContent,
34
- CollapsibleRoot,
35
35
  ConfirmButton,
36
36
  CustomDestination,
37
37
  CustomDestinationButton,
38
- EXPANDABLE_TRANSITION_DURATION,
39
- ExpandedIcon,
40
38
  ListContainer,
41
39
  NavigateBack,
42
40
  ShowMoreHeader,
43
41
  StyledTextField,
44
42
  Title,
45
- Trigger,
46
43
  Wallets,
47
44
  WalletsContainer,
48
45
  walletsListStyles,
@@ -76,7 +73,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
76
73
  const [showCustomDestination, setShowCustomDestination] = useState(
77
74
  !!customDestination
78
75
  );
79
- const customDestinationRef = useRef<HTMLDivElement | null>(null);
80
76
 
81
77
  const requiredWallets = getRequiredWallets(quote);
82
78
 
@@ -231,14 +227,6 @@ export function ConfirmWalletsModal(props: PropTypes) {
231
227
  );
232
228
  }, [connectedWallets.length]);
233
229
 
234
- useLayoutEffect(() => {
235
- if (showCustomDestination && customDestinationRef.current) {
236
- setTimeout(() => {
237
- customDestinationRef?.current?.scrollIntoView({ behavior: 'smooth' });
238
- }, EXPANDABLE_TRANSITION_DURATION);
239
- }
240
- }, [showCustomDestination]);
241
-
242
230
  const modalContainer = document.getElementById(
243
231
  RANGO_SWAP_BOX_ID
244
232
  ) as HTMLDivElement;
@@ -274,7 +262,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
274
262
  type="primary"
275
263
  fullWidth
276
264
  size="large">
277
- Confirm
265
+ {i18n.t('Confirm')}
278
266
  </Button>
279
267
  </ConfirmButton>
280
268
  ),
@@ -394,10 +382,7 @@ export function ConfirmWalletsModal(props: PropTypes) {
394
382
  {!isLastWallet && <Divider size={32} />}
395
383
  {isLastWallet && config?.customDestination && (
396
384
  <CustomDestination>
397
- <CollapsibleRoot
398
- ref={customDestinationRef}
399
- selected={showCustomDestination}
400
- open={showCustomDestination}
385
+ <CustomCollapsible
401
386
  onOpenChange={(checked) => {
402
387
  if (!checked) {
403
388
  resetCustomDestination();
@@ -423,11 +408,11 @@ export function ConfirmWalletsModal(props: PropTypes) {
423
408
  );
424
409
  }
425
410
  }
426
- }}>
427
- <Trigger
428
- onClick={() =>
429
- setShowCustomDestination((prevState) => !prevState)
430
- }>
411
+ }}
412
+ hasSelected
413
+ open={showCustomDestination}
414
+ triggerAnchor="top"
415
+ trigger={
431
416
  <CustomDestinationButton
432
417
  fullWidth
433
418
  variant="default"
@@ -447,21 +432,21 @@ export function ConfirmWalletsModal(props: PropTypes) {
447
432
  </Typography>
448
433
  </div>
449
434
  </CustomDestinationButton>
450
- </Trigger>
451
- <CollapsibleContent open={showCustomDestination}>
452
- <>
453
- <Divider size={4} />
454
- <StyledTextField
455
- autoFocus
456
- placeholder={i18n.t('Your destination address')}
457
- value={destination}
458
- onChange={(e) => {
459
- setDestination(e.target.value);
460
- }}
461
- />
462
- </>
463
- </CollapsibleContent>
464
- </CollapsibleRoot>
435
+ }
436
+ onClickTrigger={() =>
437
+ setShowCustomDestination((prev) => !prev)
438
+ }>
439
+ <Divider size={4} />
440
+ <StyledTextField
441
+ autoFocus
442
+ placeholder={i18n.t('Your destination address')}
443
+ value={destination}
444
+ onChange={(e) => {
445
+ setDestination(e.target.value);
446
+ }}
447
+ />
448
+ </CustomCollapsible>
449
+
465
450
  {isAddressMatched && (
466
451
  <div className={alarmsStyles()}>
467
452
  <Alert
@@ -0,0 +1,75 @@
1
+ import * as Collapsible from '@radix-ui/react-collapsible';
2
+ import { keyframes, styled } from '@rango-dev/ui';
3
+
4
+ export const EXPANDABLE_TRANSITION_DURATION = 300;
5
+
6
+ const slideDown = keyframes({
7
+ from: {
8
+ height: 0,
9
+ },
10
+ to: {
11
+ height: 'var(--radix-collapsible-content-height)',
12
+ },
13
+ });
14
+
15
+ const slideUp = keyframes({
16
+ from: {
17
+ height: 'var(--radix-collapsible-content-height)',
18
+ },
19
+ to: {
20
+ height: 0,
21
+ },
22
+ });
23
+
24
+ export const CollapsibleRoot = styled(Collapsible.Root, {
25
+ borderRadius: '$sm',
26
+ variants: {
27
+ selected: {
28
+ true: {
29
+ outlineWidth: 1,
30
+ outlineColor: '$secondary500',
31
+ outlineStyle: 'solid',
32
+ },
33
+ },
34
+ },
35
+ });
36
+
37
+ export const Trigger = styled(Collapsible.Trigger, {
38
+ padding: '$0',
39
+ border: 'none',
40
+ outline: 'none',
41
+ width: '100%',
42
+ backgroundColor: 'transparent',
43
+ fontFamily: 'inherit',
44
+ cursor: 'pointer',
45
+ });
46
+
47
+ export const CollapsibleContent = styled(Collapsible.Content, {
48
+ overflow: 'hidden',
49
+ variants: {
50
+ open: {
51
+ true: {
52
+ animation: `${slideDown} ${EXPANDABLE_TRANSITION_DURATION}ms ease-out`,
53
+ },
54
+ false: {
55
+ animation: `${slideUp} ${EXPANDABLE_TRANSITION_DURATION}ms ease-out`,
56
+ },
57
+ },
58
+ },
59
+ });
60
+
61
+ export const ExpandedIcon = styled('div', {
62
+ transition: `all ${EXPANDABLE_TRANSITION_DURATION}ms ease`,
63
+ display: 'flex',
64
+ alignItems: 'center',
65
+ variants: {
66
+ orientation: {
67
+ down: {
68
+ transform: 'rotate(0)',
69
+ },
70
+ up: {
71
+ transform: 'rotate(180deg)',
72
+ },
73
+ },
74
+ },
75
+ });
@@ -0,0 +1,55 @@
1
+ import type { PropTypes } from './CustomCollapsible.types';
2
+ import type { PropsWithChildren } from 'react';
3
+
4
+ import React, { useLayoutEffect, useRef } from 'react';
5
+
6
+ import {
7
+ CollapsibleContent,
8
+ CollapsibleRoot,
9
+ EXPANDABLE_TRANSITION_DURATION,
10
+ Trigger,
11
+ } from './CustomCollapsible.styles';
12
+
13
+ export function CustomCollapsible(props: PropsWithChildren<PropTypes>) {
14
+ const {
15
+ open,
16
+ hasSelected,
17
+ onOpenChange,
18
+ children,
19
+ onClickTrigger,
20
+ trigger,
21
+ triggerAnchor,
22
+ } = props;
23
+ const ref = useRef<HTMLDivElement | null>(null);
24
+
25
+ useLayoutEffect(() => {
26
+ if (open && ref.current) {
27
+ setTimeout(() => {
28
+ ref?.current?.scrollIntoView({ behavior: 'smooth' });
29
+ }, EXPANDABLE_TRANSITION_DURATION);
30
+ }
31
+ }, [open]);
32
+
33
+ return (
34
+ <CollapsibleRoot
35
+ ref={ref}
36
+ className="collapsible_root"
37
+ selected={hasSelected && open}
38
+ open={open}
39
+ onOpenChange={onOpenChange}>
40
+ {triggerAnchor === 'top' && (
41
+ <Trigger className="collapsible_trigger" onClick={onClickTrigger}>
42
+ {trigger}
43
+ </Trigger>
44
+ )}
45
+ <CollapsibleContent className="collapsible_content" open={open}>
46
+ {children}
47
+ </CollapsibleContent>
48
+ {triggerAnchor === 'bottom' && (
49
+ <Trigger className="collapsible_trigger" onClick={onClickTrigger}>
50
+ {trigger}
51
+ </Trigger>
52
+ )}
53
+ </CollapsibleRoot>
54
+ );
55
+ }
@@ -0,0 +1,10 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ export type PropTypes = {
4
+ open: boolean;
5
+ hasSelected?: boolean;
6
+ onOpenChange?: (checked: boolean) => void;
7
+ onClickTrigger: () => void;
8
+ trigger: ReactNode;
9
+ triggerAnchor: 'top' | 'bottom';
10
+ };
@@ -23,7 +23,10 @@ export const ConnectedIcon = styled('div', {
23
23
  export const SuffixContainer = styled('div', {
24
24
  display: 'flex',
25
25
  justifyContent: 'flex-end',
26
- width: '$40',
26
+ minWidth: '$40',
27
+ button: {
28
+ padding: 0,
29
+ },
27
30
  });
28
31
 
29
32
  export const NotificationsBadgeContainer = styled('div', {
@@ -38,3 +41,15 @@ export const NotificationsBadgeContainer = styled('div', {
38
41
  top: '$0',
39
42
  right: '$0',
40
43
  });
44
+
45
+ export const ProgressIcon = styled('div', {
46
+ padding: '$2',
47
+ variants: {
48
+ isRefetched: {
49
+ true: {
50
+ transform: `rotate(360deg)`,
51
+ transition: 'transform 1s ease-in-out',
52
+ },
53
+ },
54
+ },
55
+ });
@@ -4,9 +4,7 @@ export interface PropTypes {
4
4
  container?: HTMLElement;
5
5
  }
6
6
  export interface HomeButtonsPropTypes {
7
- layoutRef: HTMLDivElement | null;
8
7
  onClickRefresh?: () => void;
9
8
  onClickHistory?: () => void;
10
9
  onClickSettings?: () => void;
11
- onClickNotifications?: () => void;
12
10
  }
@@ -4,7 +4,6 @@ import { i18n } from '@lingui/core';
4
4
  import {
5
5
  NotificationsIcon,
6
6
  Popover,
7
- RefreshIcon,
8
7
  SettingsIcon,
9
8
  Tooltip,
10
9
  TransactionIcon,
@@ -17,16 +16,11 @@ import { isFeatureHidden } from '../../utils/settings';
17
16
  import { NotificationContent } from '../NotificationContent';
18
17
 
19
18
  import { HeaderButton } from './HeaderButtons.styles';
19
+ import { RefreshButton } from './RefreshButton';
20
20
  import { UnreadNotificationsBadge } from './UnreadNotificationsBadge';
21
21
 
22
22
  export function HomeButtons(props: HomeButtonsPropTypes) {
23
- const {
24
- layoutRef,
25
- onClickRefresh,
26
- onClickHistory,
27
- onClickSettings,
28
- onClickNotifications,
29
- } = props;
23
+ const { onClickRefresh, onClickHistory, onClickSettings } = props;
30
24
 
31
25
  const {
32
26
  config: { features },
@@ -40,35 +34,27 @@ export function HomeButtons(props: HomeButtonsPropTypes) {
40
34
  container={getContainer()}
41
35
  side="top"
42
36
  content={i18n.t('Refresh')}>
43
- <HeaderButton
44
- variant="ghost"
45
- size="small"
46
- onClick={onClickRefresh}
47
- disabled={!onClickRefresh}>
48
- <RefreshIcon size={16} color={!onClickRefresh ? 'gray' : 'black'} />
49
- </HeaderButton>
37
+ <RefreshButton onClick={onClickRefresh} />
50
38
  </Tooltip>
51
39
 
52
40
  {!isNotificationsHidden && (
53
- <Tooltip
41
+ <Popover
42
+ align="center"
43
+ collisionPadding={{ right: 20, left: 20 }}
54
44
  container={getContainer()}
55
- side="top"
56
- content={i18n.t('Notifications')}>
57
- <Popover
58
- align="center"
59
- collisionBoundary={layoutRef}
60
- collisionPadding={{ right: 20, left: 20 }}
61
- container={getContainer()}
62
- content={<NotificationContent />}>
63
- <HeaderButton
64
- size="small"
65
- variant="ghost"
66
- onClick={onClickNotifications}>
67
- <NotificationsIcon size={18} color="black" />
68
- <UnreadNotificationsBadge />
69
- </HeaderButton>
70
- </Popover>
71
- </Tooltip>
45
+ content={<NotificationContent />}>
46
+ <div>
47
+ <Tooltip
48
+ container={getContainer()}
49
+ side="top"
50
+ content={i18n.t('Notifications')}>
51
+ <HeaderButton size="small" variant="ghost">
52
+ <NotificationsIcon size={18} color="black" />
53
+ <UnreadNotificationsBadge />
54
+ </HeaderButton>
55
+ </Tooltip>
56
+ </div>
57
+ </Popover>
72
58
  )}
73
59
  <Tooltip
74
60
  container={getContainer()}
@@ -0,0 +1,81 @@
1
+ import { RefreshProgressButton } from '@rango-dev/ui';
2
+ import React, { useEffect, useState } from 'react';
3
+
4
+ import { HeaderButton, ProgressIcon } from './HeaderButtons.styles';
5
+
6
+ const REFRESH_INTERVAL = 1000;
7
+ const MAX_ELAPSED_TIME = 60;
8
+ const MAX_PERCENTAGE = 100;
9
+
10
+ function RefreshButton({ onClick }: { onClick: (() => void) | undefined }) {
11
+ const [elapsedTime, setElapsedTime] = useState(0);
12
+ const [isRefetched, setIsRefetched] = useState(false);
13
+
14
+ const handleVisibilityChange = (interval?: number) => {
15
+ if (document.hidden && interval) {
16
+ // Tab is inactive, clear the interval
17
+ clearTimeout(interval);
18
+ }
19
+ };
20
+
21
+ useEffect(() => {
22
+ let interval: number | undefined;
23
+ if (onClick) {
24
+ interval = window.setInterval(() => {
25
+ setElapsedTime((prevTime) => prevTime + 1);
26
+
27
+ if (elapsedTime === MAX_ELAPSED_TIME) {
28
+ handleRefreshClick();
29
+ }
30
+ }, REFRESH_INTERVAL);
31
+ } else {
32
+ clearTimeout(interval);
33
+ }
34
+
35
+ document.addEventListener('visibilitychange', () =>
36
+ handleVisibilityChange(interval)
37
+ );
38
+
39
+ return () => {
40
+ document.removeEventListener('visibilitychange', () =>
41
+ handleVisibilityChange(interval)
42
+ );
43
+ if (interval) {
44
+ clearInterval(interval);
45
+ }
46
+ };
47
+ }, [elapsedTime, onClick]);
48
+
49
+ const clearTimeout = (interval?: number) => {
50
+ if (interval) {
51
+ clearInterval(interval);
52
+ }
53
+ setElapsedTime(0);
54
+ };
55
+
56
+ const handleRefreshClick = () => {
57
+ onClick?.();
58
+ setElapsedTime(0);
59
+ setIsRefetched(true);
60
+ };
61
+
62
+ return (
63
+ <HeaderButton
64
+ variant="ghost"
65
+ size="small"
66
+ onClick={handleRefreshClick}
67
+ disabled={!onClick}>
68
+ <ProgressIcon
69
+ onTransitionEnd={() => setIsRefetched(false)}
70
+ isRefetched={isRefetched}>
71
+ <RefreshProgressButton
72
+ size={24}
73
+ color={!onClick ? 'gray' : 'black'}
74
+ progress={(elapsedTime / MAX_ELAPSED_TIME) * MAX_PERCENTAGE}
75
+ />
76
+ </ProgressIcon>
77
+ </HeaderButton>
78
+ );
79
+ }
80
+
81
+ export { RefreshButton };
@@ -0,0 +1,16 @@
1
+ import { getContainer } from '../../utils/common';
2
+
3
+ export function onScrollContentAttachStatusToContainer(e: Event) {
4
+ const contentElement = e.target as HTMLElement | null;
5
+
6
+ if (contentElement) {
7
+ const fromTop = contentElement.scrollTop;
8
+ const container = getContainer();
9
+
10
+ if (fromTop > 1) {
11
+ container.classList.add('rng-scrolled');
12
+ } else {
13
+ container.classList.remove('rng-scrolled');
14
+ }
15
+ }
16
+ }
@@ -1,54 +1,40 @@
1
- import { darkTheme, styled } from '@rango-dev/ui';
1
+ import { styled } from '@rango-dev/ui';
2
2
 
3
+ const WIDGET_HEIGHT = '700px';
3
4
  export const Container = styled('div', {
4
5
  position: 'relative',
5
6
  display: 'flex',
6
7
  flexDirection: 'column',
7
8
  borderRadius: '$primary',
8
- overflow: 'hidden !important',
9
- boxShadow: '15px 15px 15px 0px rgba(0, 0, 0, 0.05)',
10
- width: '100vw',
9
+ width: '100vh',
11
10
  minWidth: '300px',
12
11
  maxWidth: '390px',
13
- maxHeight: '700px',
14
- textAlign: 'left',
15
- $$color: '$colors$neutral100',
16
- [`.${darkTheme} &`]: {
17
- $$color: '$colors$neutral300',
18
- },
19
- backgroundColor: '$$color',
12
+ boxShadow: '15px 15px 15px 0px rgba(0, 0, 0, 0.05)',
13
+ overflow: 'hidden',
14
+ backgroundColor: '$background',
15
+
20
16
  variants: {
21
- fixedHeight: {
22
- true: {
23
- height: '100vh',
17
+ height: {
18
+ auto: {
19
+ height: 'auto',
20
+ maxHeight: WIDGET_HEIGHT,
24
21
  },
25
- false: {
26
- height: 'auto !important',
22
+ fixed: {
23
+ height: WIDGET_HEIGHT,
27
24
  },
28
25
  },
29
26
  },
30
27
  });
31
28
 
32
29
  export const Content = styled('div', {
33
- borderTopLeftRadius: '20px',
34
- borderTopRightRadius: '20px',
30
+ position: 'relative',
31
+ overflow: 'hidden',
32
+ flexGrow: 1,
35
33
  display: 'flex',
36
34
  flexDirection: 'column',
37
- flex: 1,
38
- padding: '$20 $20 $10 $20',
39
- backgroundColor: '$background',
40
- position: 'relative',
35
+ padding: 0,
41
36
  overflowY: 'auto',
42
- overflowX: 'hidden',
43
- variants: {
44
- noPadding: {
45
- true: {
46
- padding: '0',
47
- },
48
- },
49
- },
50
37
  });
51
-
52
38
  export const Footer = styled('div', {
53
39
  backgroundColor: '$background',
54
40
  '& .footer__content': {
@@ -1,8 +1,8 @@
1
- import type { PropTypes, Ref } from './Layout.types';
1
+ import type { PropTypes } from './Layout.types';
2
2
  import type { PropsWithChildren } from 'react';
3
3
 
4
4
  import { BottomLogo, Divider, Header } from '@rango-dev/ui';
5
- import React from 'react';
5
+ import React, { useEffect, useRef } from 'react';
6
6
 
7
7
  import { RANGO_SWAP_BOX_ID } from '../../constants';
8
8
  import { useNavigateBack } from '../../hooks/useNavigateBack';
@@ -14,17 +14,11 @@ import { getContainer } from '../../utils/common';
14
14
  import { isFeatureHidden } from '../../utils/settings';
15
15
  import { BackButton, CancelButton, WalletButton } from '../HeaderButtons';
16
16
 
17
+ import { onScrollContentAttachStatusToContainer } from './Layout.helpers';
17
18
  import { Container, Content, Footer } from './Layout.styles';
18
19
 
19
- function LayoutComponent(props: PropsWithChildren<PropTypes>, ref: Ref) {
20
- const {
21
- children,
22
- header,
23
- footer,
24
- noPadding,
25
- hasLogo = true,
26
- fixedHeight = true,
27
- } = props;
20
+ function Layout(props: PropsWithChildren<PropTypes>) {
21
+ const { children, header, footer, hasLogo = true, height = 'fixed' } = props;
28
22
  const connectedWallets = useWalletsStore.use.connectedWallets();
29
23
  const {
30
24
  config: { features, theme },
@@ -49,12 +43,24 @@ function LayoutComponent(props: PropsWithChildren<PropTypes>, ref: Ref) {
49
43
  const showBackButton =
50
44
  typeof header.hasBackButton === 'undefined' || header.hasBackButton;
51
45
 
46
+ const scrollViewRef = useRef<HTMLDivElement>(null);
47
+
48
+ useEffect(() => {
49
+ scrollViewRef.current?.addEventListener(
50
+ 'scroll',
51
+ onScrollContentAttachStatusToContainer
52
+ );
53
+
54
+ return () => {
55
+ scrollViewRef.current?.removeEventListener(
56
+ 'scroll',
57
+ onScrollContentAttachStatusToContainer
58
+ );
59
+ };
60
+ }, []);
61
+
52
62
  return (
53
- <Container
54
- ref={ref}
55
- fixedHeight={fixedHeight}
56
- id={RANGO_SWAP_BOX_ID}
57
- className={activeTheme()}>
63
+ <Container height={height} id={RANGO_SWAP_BOX_ID} className={activeTheme()}>
58
64
  <Header
59
65
  prefix={<>{showBackButton && <BackButton onClick={navigateBack} />}</>}
60
66
  title={header.title}
@@ -72,7 +78,7 @@ function LayoutComponent(props: PropsWithChildren<PropTypes>, ref: Ref) {
72
78
  </>
73
79
  }
74
80
  />
75
- <Content noPadding={noPadding}>{children}</Content>
81
+ <Content ref={scrollViewRef}>{children}</Content>
76
82
  {(hasLogo || footer) && (
77
83
  <Footer>
78
84
  <div className="footer__content">{footer}</div>
@@ -87,8 +93,4 @@ function LayoutComponent(props: PropsWithChildren<PropTypes>, ref: Ref) {
87
93
  </Container>
88
94
  );
89
95
  }
90
-
91
- const Layout = React.forwardRef(LayoutComponent);
92
- Layout.displayName = 'Layout';
93
-
94
96
  export { Layout };
@@ -1,3 +1,11 @@
1
+ import type { Container } from './Layout.styles';
2
+ import type * as Stitches from '@stitches/react';
3
+
4
+ type ContainerProps = Stitches.VariantProps<typeof Container>;
5
+ type ContainerHeightProp = NonNullable<
6
+ Exclude<ContainerProps['height'], object>
7
+ >;
8
+
1
9
  export interface PropTypes {
2
10
  header: {
3
11
  title: string;
@@ -9,12 +17,5 @@ export interface PropTypes {
9
17
  };
10
18
  hasLogo?: boolean;
11
19
  footer?: React.ReactNode;
12
- noPadding?: boolean;
13
- fixedHeight?: boolean;
20
+ height?: ContainerHeightProp;
14
21
  }
15
-
16
- export type Ref =
17
- | ((instance: HTMLDivElement | null) => void)
18
- | React.RefObject<HTMLDivElement>
19
- | null
20
- | undefined;