From 41bccf35aeb418d3b2d78d3e0bfeabb15afbb3e7 Mon Sep 17 00:00:00 2001 From: toniocodo Date: Fri, 29 Sep 2023 18:10:57 +0200 Subject: [PATCH 01/14] fix: ens name in AccountLabel, check amount on update --- libs/oeth/swap/src/hooks.ts | 6 ++++-- .../providers/src/wagmi/components/AddressLabel.tsx | 12 ++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/libs/oeth/swap/src/hooks.ts b/libs/oeth/swap/src/hooks.ts index 2508f7ac7..97287999e 100644 --- a/libs/oeth/swap/src/hooks.ts +++ b/libs/oeth/swap/src/hooks.ts @@ -22,8 +22,10 @@ export const useHandleAmountInChange = () => { (amount: bigint) => { setSwapState( produce((state) => { - state.amountIn = amount; - state.isSwapRoutesLoading = amount !== 0n; + if (state.amountIn !== amount) { + state.amountIn = amount; + state.isSwapRoutesLoading = amount !== 0n; + } }), ); }, diff --git a/libs/shared/providers/src/wagmi/components/AddressLabel.tsx b/libs/shared/providers/src/wagmi/components/AddressLabel.tsx index 05d0c79b3..26900dd47 100644 --- a/libs/shared/providers/src/wagmi/components/AddressLabel.tsx +++ b/libs/shared/providers/src/wagmi/components/AddressLabel.tsx @@ -26,12 +26,6 @@ export const AddressLabel = ({ chainId: mainnet.id, }); - if (short) { - return ( - {middleTruncate(address)} - ); - } - if (enableEnsName) { return isEnsNameLoading ? ( @@ -42,5 +36,11 @@ export const AddressLabel = ({ ); } + if (short) { + return ( + {middleTruncate(address)} + ); + } + return {address}; }; From 62696a086cc2ab4a67f380258e66b7111703ba42 Mon Sep 17 00:00:00 2001 From: toniocodo Date: Sat, 30 Sep 2023 00:41:41 +0200 Subject: [PATCH 02/14] fix: account for short and ens name --- .../src/wagmi/components/AddressLabel.tsx | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/libs/shared/providers/src/wagmi/components/AddressLabel.tsx b/libs/shared/providers/src/wagmi/components/AddressLabel.tsx index 26900dd47..4d7046f16 100644 --- a/libs/shared/providers/src/wagmi/components/AddressLabel.tsx +++ b/libs/shared/providers/src/wagmi/components/AddressLabel.tsx @@ -1,6 +1,6 @@ import { Skeleton } from '@mui/material'; import { MiddleTruncated } from '@origin/shared/components'; -import { middleTruncate } from '@origin/shared/utils'; +import { isNilOrEmpty, middleTruncate } from '@origin/shared/utils'; import { mainnet, useEnsName } from 'wagmi'; import type { MiddleTruncatedProps } from '@origin/shared/components'; @@ -26,21 +26,16 @@ export const AddressLabel = ({ chainId: mainnet.id, }); - if (enableEnsName) { - return isEnsNameLoading ? ( - - ) : ( - - {ensName ?? address} - - ); - } + const label = + enableEnsName && !isNilOrEmpty(ensName) + ? ensName + : short + ? middleTruncate(address) + : address; - if (short) { - return ( - {middleTruncate(address)} - ); + if (enableEnsName && isEnsNameLoading) { + return ; } - return {address}; + return {label}; }; From 9122f4f14f516300051a057b3a1ae3fba830eb93 Mon Sep 17 00:00:00 2001 From: toniocodo Date: Sat, 30 Sep 2023 21:48:59 +0200 Subject: [PATCH 03/14] fix: swap card styles, topnav padding block --- apps/oeth/src/App.tsx | 6 +- apps/oeth/src/components/Topnav.tsx | 312 +++++++++--------- libs/oeth/swap/src/components/BestRoutes.tsx | 2 +- .../swap/src/components/SwapRouteCard.tsx | 204 ++++++------ 4 files changed, 260 insertions(+), 264 deletions(-) diff --git a/apps/oeth/src/App.tsx b/apps/oeth/src/App.tsx index e6f6fbea7..04f67ea27 100644 --- a/apps/oeth/src/App.tsx +++ b/apps/oeth/src/App.tsx @@ -11,12 +11,8 @@ export const App = () => { ({ - xs: '112px', - md: `${theme.mixins.toolbar.height}px`, - }), }} maxWidth="sm" > diff --git a/apps/oeth/src/components/Topnav.tsx b/apps/oeth/src/components/Topnav.tsx index 035e03fae..703d55a8f 100644 --- a/apps/oeth/src/components/Topnav.tsx +++ b/apps/oeth/src/components/Topnav.tsx @@ -31,177 +31,187 @@ export function Topnav(props: BoxProps) { useState(null); return ( - ({ - position: 'fixed', - top: 0, - left: 0, - width: 1, - zIndex: theme.zIndex.appBar, - backgroundColor: alpha(theme.palette.background.default, 0.6), - backdropFilter: 'blur(15px)', - height: { - xs: '112px', - md: `${theme.mixins.toolbar.height}px`, - }, - display: 'grid', - borderBottom: { - xs: 'none', - md: `1px solid ${theme.palette.background.paper}`, - }, - columnGap: { xs: 1, md: 10 }, - rowGap: { xs: 0, md: 10 }, - alignItems: 'center', - px: { - xs: 1.5, - md: 3, - }, - pt: { - xs: 1.5, - md: 0, - }, - gridTemplateColumns: { - xs: '1fr 1fr', - md: 'auto 1fr auto', - }, - })} - > + <> ({ + xs: '112px', + md: `${theme.mixins.toolbar.height}px`, + }), + }} + /> + ({ - '& img': { - maxHeight: { - xs: '1rem', - md: '1.5rem', - }, - maxWidth: { - xs: theme.typography.pxToRem(100), - sm: theme.typography.pxToRem(120), - md: theme.typography.pxToRem(180), - }, + position: 'fixed', + top: 0, + left: 0, + width: 1, + zIndex: theme.zIndex.appBar, + backgroundColor: alpha(theme.palette.background.default, 0.6), + backdropFilter: 'blur(15px)', + height: { + xs: '112px', + md: `${theme.mixins.toolbar.height}px`, }, - })} - > - Origin logo - - { - navigate(value); - }} - sx={{ - order: { - xs: 2, - md: 0, + display: 'grid', + borderBottom: { + xs: 'none', + md: `1px solid ${theme.palette.background.paper}`, }, - gridColumn: { - xs: 'span 2', - md: 'span 1', + columnGap: { xs: 1, md: 10 }, + rowGap: { xs: 0, md: 10 }, + alignItems: 'center', + px: { + xs: 1.5, + md: 3, }, - marginBlockStart: { - xs: 2, + pt: { + xs: 1.5, md: 0, }, - '& .MuiTabs-flexContainer': { - justifyContent: { - xs: 'center', - md: 'flex-start', - }, + gridTemplateColumns: { + xs: '1fr 1fr', + md: 'auto 1fr auto', }, - }} - > - {routes[0].children.map((route) => ( - - ))} - - - ({ + '& img': { + maxHeight: { + xs: '1rem', + md: '1.5rem', + }, + maxWidth: { + xs: theme.typography.pxToRem(100), + sm: theme.typography.pxToRem(120), + md: theme.typography.pxToRem(180), + }, + }, + })} + > + Origin logo + + { + navigate(value); + }} sx={{ - borderRadius: 25, - paddingX: { - md: 3, + order: { xs: 2, + md: 0, }, - paddingY: { - md: 1, - xs: 0.75, + gridColumn: { + xs: 'span 2', + md: 'span 1', }, - display: 'flex', - alignItems: 'center', - justifyContent: 'center', - fontWeight: 500, - minHeight: { xs: 36, md: 44 }, - background: `linear-gradient(0deg, ${alpha( - theme.palette.common.white, - 0.05, - )} 0%, ${alpha(theme.palette.common.white, 0.05)} 100%), ${ - theme.palette.background.paper - };`, - '&:hover': { - background: (theme) => theme.palette.background.paper, + marginBlockStart: { + xs: 2, + md: 0, + }, + '& .MuiTabs-flexContainer': { + justifyContent: { + xs: 'center', + md: 'flex-start', + }, }, }} > - {isMd - ? intl.formatMessage({ defaultMessage: 'IPFS' }) - : intl.formatMessage({ defaultMessage: 'View on IPFS' })} - - { - if (isConnected) { - setAccountModalAnchor(e.currentTarget); - } + {routes[0].children.map((route) => ( + + ))} + + + theme.palette.background.paper, + }, + }} + > + {isMd + ? intl.formatMessage({ defaultMessage: 'IPFS' }) + : intl.formatMessage({ defaultMessage: 'View on IPFS' })} + + { + if (isConnected) { + setAccountModalAnchor(e.currentTarget); + } + }} + sx={{ + borderRadius: 25, + paddingX: { + md: 3, + xs: 2, + }, + paddingY: { + md: 1, + xs: 0.75, + }, + minWidth: 36, + maxWidth: { xs: isConnected ? 36 : 160, sm: 160, lg: 220 }, + fontWeight: 500, + minHeight: { xs: 36, md: 44 }, + }} + /> + + + theme.palette.background.paper, + position: 'relative', + width: 'calc(100% + 1.5rem)', + bottom: '-3rem', + left: '-0.75rem', }} /> - - theme.palette.background.paper, - position: 'relative', - width: 'calc(100% + 1.5rem)', - bottom: '-3rem', - left: '-0.75rem', - }} - /> - + ); } diff --git a/libs/oeth/swap/src/components/BestRoutes.tsx b/libs/oeth/swap/src/components/BestRoutes.tsx index 9ca8a76d3..8de1bc56e 100644 --- a/libs/oeth/swap/src/components/BestRoutes.tsx +++ b/libs/oeth/swap/src/components/BestRoutes.tsx @@ -17,7 +17,7 @@ export function BestRoutes(props: Grid2Props) { return ( {swapRoutes.slice(0, 2).map((route, index) => ( - + `1px solid ${theme.palette.grey[800]}`, - borderRadius: 1, + border: `1px solid transparent`, + position: 'relative', height: 1, ...(isSelected ? { @@ -100,110 +91,109 @@ export function SwapRouteCard({ ...rest?.sx, }} role="button" - onClick={() => onSelect(route)} + onClick={() => { + onSelect(route); + }} > - - + {isBest && ( + theme.shape.borderRadius, + background: (theme) => theme.palette.background.gradient1, + fontSize: 12, + top: 0, + right: 0, + px: 1, + pt: 0.25, + }} + > + {intl.formatMessage({ defaultMessage: 'Best' })} + + )} + + + + {isLoading ? ( + + ) : ( + + )} + + + {isLoading ? ( - + ) : ( - + formatAmount(route.estimatedAmount, route.tokenOut.decimals) )} - - - + + + + + {isLoading ? ( + + ) : ( + `(${intl.formatNumber(convertedAmount, currencyFormat)})` + )} + + + + + + {isLoading ? ( + + ) : ( + intl.formatMessage(routeActionLabel[route.action]) + )} + + + + + {intl.formatMessage({ defaultMessage: 'Rate:' })} + + {isLoading ? ( - + ) : ( - formatAmount(route.estimatedAmount, route.tokenOut.decimals) + `1:${intl.formatNumber(route.rate, quantityFormat)}` )} - - - - {isLoading ? ( + + + + {intl.formatMessage({ defaultMessage: 'Gas:' })} + + + {isGasLoading ? ( ) : ( - `(${intl.formatNumber(convertedAmount, currencyFormat)})` + `~${intl.formatNumber(gasPrice, currencyFormat)}` )} - - - {isBest && ( - theme.shape.borderRadius, - background: (theme) => theme.palette.background.gradient1, - fontSize: 12, - top: (theme) => theme.spacing(-3), - right: (theme) => theme.spacing(-1.25), - px: 1, - pt: 0.25, - }} - > - {intl.formatMessage({ defaultMessage: 'Best' })} - - )} - - } - > - - - {isLoading ? ( - - ) : ( - intl.formatMessage(routeActionLabel[route.action]) - )} - - - - - {intl.formatMessage({ defaultMessage: 'Rate:' })} - - - {isLoading ? ( - - ) : ( - `1:${intl.formatNumber(route.rate, quantityFormat)}` - )} - - - - - {intl.formatMessage({ defaultMessage: 'Gas:' })} - - - {isGasLoading ? ( - - ) : ( - `~${intl.formatNumber(gasPrice, currencyFormat)}` - )} - + + From c41d592fc0db85ba0be356bb66f0dc354638f396 Mon Sep 17 00:00:00 2001 From: toniocodo Date: Sat, 30 Sep 2023 21:55:52 +0200 Subject: [PATCH 04/14] fix: table footer and geo fence modal paddings --- libs/oeth/history/src/components/HistoryTable.tsx | 6 ++---- .../providers/src/geoFence/components/GeoFenceProvider.tsx | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/libs/oeth/history/src/components/HistoryTable.tsx b/libs/oeth/history/src/components/HistoryTable.tsx index 53c8008ea..b3357bcf6 100644 --- a/libs/oeth/history/src/components/HistoryTable.tsx +++ b/libs/oeth/history/src/components/HistoryTable.tsx @@ -119,9 +119,7 @@ export function HistoryTable({ return ( - +
{table.getHeaderGroups().map((headerGroup) => ( { sx={{ pl: 0.2 }} /> - +