From 6df7caf3d6cf6f35d6af419fc11c8e05890c7b89 Mon Sep 17 00:00:00 2001
From: Eugene Chybisov <18644653+chybisov@users.noreply.github.com>
Date: Mon, 26 Feb 2024 13:47:29 +0100
Subject: [PATCH] style: additional theme refinements (#200)
---
.../src/components/Card/Card.style.tsx | 8 +--
.../ActiveTransactions.style.ts | 2 +-
.../src/components/Avatar/AccountAvatar.tsx | 12 ++--
.../src/components/Avatar/Avatar.style.tsx | 18 ++++--
.../widget/src/components/Avatar/Avatar.tsx | 10 +++-
.../src/components/Avatar/TokenAvatar.tsx | 8 +--
.../widget/src/components/Avatar/utils.ts | 11 ++++
.../widget/src/components/ButtonTertiary.tsx | 19 +++++++
packages/widget/src/components/Card/Card.tsx | 16 ++++--
.../src/components/Card/CardIconButton.tsx | 11 ++--
.../src/components/Header/Header.style.ts | 22 ++++---
.../src/components/Header/WalletHeader.tsx | 28 ++++-----
.../src/components/Header/WalletMenu.tsx | 33 ++++++-----
packages/widget/src/components/Input.tsx | 4 --
.../widget/src/components/ListItemButton.tsx | 27 ++++++---
.../components/RouteCard/RouteCard.style.ts | 4 +-
.../widget/src/components/Routes/Routes.tsx | 7 ++-
.../SendToWallet/SendToWallet.style.tsx | 3 +
.../SendToWallet/SendToWalletButton.tsx | 2 +-
.../widget/src/components/SmallAvatar.tsx | 10 ++--
.../src/components/Step/StepProcess.style.tsx | 5 +-
.../StepActions/StepActions.style.tsx | 33 +++++------
.../components/StepActions/StepActions.tsx | 4 +-
.../StepActions/StepFeeBreakdown.tsx | 5 +-
.../widget/src/components/Tabs/Tabs.style.tsx | 8 +--
.../widget/src/components/Token/Token.tsx | 5 --
.../components/TokenList/TokenList.style.tsx | 8 +--
packages/widget/src/config/theme.ts | 4 +-
.../pages/SendToWallet/EmptyListIndicator.tsx | 11 ++--
.../SendToWallet/SendToWalletPage.style.tsx | 57 ++-----------------
.../pages/SendToWallet/SendToWalletPage.tsx | 19 ++++---
.../ResetSettingsButton.style.tsx | 4 +-
packages/widget/src/utils/colors.ts | 11 ++--
33 files changed, 219 insertions(+), 210 deletions(-)
create mode 100644 packages/widget/src/components/Avatar/utils.ts
create mode 100644 packages/widget/src/components/ButtonTertiary.tsx
diff --git a/packages/widget-playground/src/components/Card/Card.style.tsx b/packages/widget-playground/src/components/Card/Card.style.tsx
index 48d4b7d6a..d9050a38b 100644
--- a/packages/widget-playground/src/components/Card/Card.style.tsx
+++ b/packages/widget-playground/src/components/Card/Card.style.tsx
@@ -1,8 +1,8 @@
-import type { MouseEventHandler } from 'react';
import type { BoxProps, Theme } from '@mui/material';
-import { alpha, darken, lighten, styled } from '@mui/material/styles';
-import { Box, ButtonBase, Typography } from '@mui/material';
+import { Box, ButtonBase, Typography, avatarClasses } from '@mui/material';
import { badgeClasses } from '@mui/material/Badge';
+import { alpha, darken, lighten, styled } from '@mui/material/styles';
+import type { MouseEventHandler } from 'react';
type CardVariant = 'default' | 'selected' | 'error';
@@ -71,7 +71,7 @@ export const Card = styled(Box, {
cursor: onClick ? 'pointer' : 'default',
backgroundColor: backgroundHoverColor,
},
- [`&:hover .${badgeClasses.badge} > div`]: {
+ [`&:hover .${badgeClasses.badge} > .${avatarClasses.root}`]: {
borderColor: backgroundHoverColor,
},
transition: theme.transitions.create(['background-color'], {
diff --git a/packages/widget/src/components/ActiveTransactions/ActiveTransactions.style.ts b/packages/widget/src/components/ActiveTransactions/ActiveTransactions.style.ts
index 8beda3bcc..668d52886 100644
--- a/packages/widget/src/components/ActiveTransactions/ActiveTransactions.style.ts
+++ b/packages/widget/src/components/ActiveTransactions/ActiveTransactions.style.ts
@@ -13,7 +13,7 @@ export const ListItemButton = styled(MuiListItemButton)(({ theme }) => ({
paddingRight: theme.spacing(1.5),
height: 64,
'&:hover': {
- backgroundColor: getContrastAlphaColor(theme.palette.mode, '4%'),
+ backgroundColor: getContrastAlphaColor(theme, 0.04),
},
}));
diff --git a/packages/widget/src/components/Avatar/AccountAvatar.tsx b/packages/widget/src/components/Avatar/AccountAvatar.tsx
index 482fee8ec..09e0632a6 100644
--- a/packages/widget/src/components/Avatar/AccountAvatar.tsx
+++ b/packages/widget/src/components/Avatar/AccountAvatar.tsx
@@ -1,10 +1,14 @@
import { getConnectorIcon } from '@lifi/wallet-management';
import { Wallet } from '@mui/icons-material';
-import { Avatar, Badge } from '@mui/material';
+import { Badge } from '@mui/material';
import type { Account } from '../../hooks/useAccount.js';
import { useChain } from '../../hooks/useChain.js';
import { SmallAvatar } from '../SmallAvatar.js';
-import { AvatarDefault, AvatarDefaultBadge } from './Avatar.style.js';
+import {
+ AvatarDefault,
+ AvatarDefaultBadge,
+ AvatarMasked,
+} from './Avatar.style.js';
interface AccountAvatarProps {
chainId?: number;
@@ -20,7 +24,7 @@ export const AccountAvatar = ({
const { chain } = useChain(chainId);
const avatar = account ? (
-
{account.connector?.name[0]}
-
+
) : empty ? (
) : (
diff --git a/packages/widget/src/components/Avatar/Avatar.style.tsx b/packages/widget/src/components/Avatar/Avatar.style.tsx
index 2ad4af4ad..99d71668a 100644
--- a/packages/widget/src/components/Avatar/Avatar.style.tsx
+++ b/packages/widget/src/components/Avatar/Avatar.style.tsx
@@ -2,10 +2,21 @@ import type { CSSObject } from '@mui/material';
import {
AvatarGroup,
Box,
+ Avatar as MuiAvatar,
+ Skeleton,
avatarClasses,
badgeClasses,
styled,
} from '@mui/material';
+import { avatarMask16 } from './utils.js';
+
+export const AvatarMasked = styled(MuiAvatar)(({ theme }) => ({
+ mask: avatarMask16,
+}));
+
+export const AvatarSkeleton = styled(Skeleton)(({ theme }) => ({
+ mask: avatarMask16,
+}));
export const TokenAvatarGroup = styled(AvatarGroup)(({ theme }) => ({
[`& .${badgeClasses.badge}:last-child .${avatarClasses.root}`]: {
@@ -31,19 +42,18 @@ export const AvatarDefault = styled(Box)(({ theme }) => {
height: root?.height,
width: root?.width,
color: theme.palette.text.secondary,
+ mask: avatarMask16,
};
});
export const AvatarDefaultBadge = styled(Box)(({ theme }) => {
- const root = theme.components?.MuiAvatar?.styleOverrides?.root as CSSObject;
return {
background:
theme.palette.mode === 'light'
? theme.palette.grey[300]
: theme.palette.grey[800],
- border: `2px solid ${theme.palette.background.paper}`,
borderRadius: '50%',
- height: ((root?.height ?? 40) as number) / 2,
- width: ((root?.width ?? 40) as number) / 2,
+ height: 16,
+ width: 16,
};
});
diff --git a/packages/widget/src/components/Avatar/Avatar.tsx b/packages/widget/src/components/Avatar/Avatar.tsx
index 5af74f964..1671cc305 100644
--- a/packages/widget/src/components/Avatar/Avatar.tsx
+++ b/packages/widget/src/components/Avatar/Avatar.tsx
@@ -1,7 +1,11 @@
import type { SxProps, Theme } from '@mui/material';
-import { Badge, Skeleton } from '@mui/material';
+import { Badge } from '@mui/material';
import { SmallAvatarSkeleton } from '../SmallAvatar.js';
-import { AvatarDefault, AvatarDefaultBadge } from './Avatar.style.js';
+import {
+ AvatarDefault,
+ AvatarDefaultBadge,
+ AvatarSkeleton,
+} from './Avatar.style.js';
export const AvatarBadgedDefault: React.FC<{
sx?: SxProps;
@@ -28,7 +32,7 @@ export const AvatarBadgedSkeleton: React.FC<{
badgeContent={}
sx={sx}
>
-
+
);
};
diff --git a/packages/widget/src/components/Avatar/TokenAvatar.tsx b/packages/widget/src/components/Avatar/TokenAvatar.tsx
index b9ec11fec..8f77b299a 100644
--- a/packages/widget/src/components/Avatar/TokenAvatar.tsx
+++ b/packages/widget/src/components/Avatar/TokenAvatar.tsx
@@ -1,11 +1,11 @@
import type { Chain, StaticToken } from '@lifi/sdk';
import type { SxProps, Theme } from '@mui/material';
-import { Avatar, Badge } from '@mui/material';
+import { Badge } from '@mui/material';
import { useChain } from '../../hooks/useChain.js';
import { useToken } from '../../hooks/useToken.js';
import { SmallAvatar } from '../SmallAvatar.js';
import { AvatarBadgedSkeleton } from './Avatar.js';
-import { AvatarDefaultBadge } from './Avatar.style.js';
+import { AvatarDefaultBadge, AvatarMasked } from './Avatar.style.js';
export const TokenAvatar: React.FC<{
token?: StaticToken;
@@ -69,9 +69,9 @@ export const TokenAvatarBase: React.FC<{
}
sx={sx}
>
-
+
{token?.symbol?.[0]}
-
+
);
};
diff --git a/packages/widget/src/components/Avatar/utils.ts b/packages/widget/src/components/Avatar/utils.ts
new file mode 100644
index 000000000..e032c30db
--- /dev/null
+++ b/packages/widget/src/components/Avatar/utils.ts
@@ -0,0 +1,11 @@
+/**
+ * Avatar mask for 16px badge
+ */
+export const avatarMask16 =
+ 'radial-gradient(circle 10.5px at calc(100% - 5.5px) calc(100% - 5.5px), #fff0 96%, #fff) 100% 100% / 100% 100% no-repeat';
+
+/**
+ * Avatar mask for 12px badge
+ */
+export const avatarMask12 =
+ 'radial-gradient(circle 8.5px at calc(100% - 3.5px) calc(100% - 3.5px), #fff0 96%, #fff) 100% 100%/100% 100% no-repeat';
diff --git a/packages/widget/src/components/ButtonTertiary.tsx b/packages/widget/src/components/ButtonTertiary.tsx
new file mode 100644
index 000000000..6192bff35
--- /dev/null
+++ b/packages/widget/src/components/ButtonTertiary.tsx
@@ -0,0 +1,19 @@
+import { LoadingButton, loadingButtonClasses } from '@mui/lab';
+import { styled } from '@mui/material';
+import { getContrastAlphaColor } from '../utils/colors.js';
+
+export const ButtonTertiary = styled(LoadingButton)(({ theme }) => ({
+ color: theme.palette.text.primary,
+ height: 40,
+ fontSize: 14,
+ backgroundColor: getContrastAlphaColor(theme, 0.04),
+ '&:hover, &:active': {
+ backgroundColor: getContrastAlphaColor(theme, 0.08),
+ },
+ [`&.${loadingButtonClasses.loading}:disabled`]: {
+ backgroundColor: getContrastAlphaColor(theme, 0.04),
+ },
+ [`.${loadingButtonClasses.loadingIndicator}`]: {
+ color: theme.palette.text.primary,
+ },
+}));
diff --git a/packages/widget/src/components/Card/Card.tsx b/packages/widget/src/components/Card/Card.tsx
index 92ca01019..91f8db06e 100644
--- a/packages/widget/src/components/Card/Card.tsx
+++ b/packages/widget/src/components/Card/Card.tsx
@@ -2,6 +2,7 @@ import type { BoxProps, Theme } from '@mui/material';
import {
Box,
alpha,
+ avatarClasses,
badgeClasses,
darken,
lighten,
@@ -69,7 +70,7 @@ export const Card = styled(Box, {
? theme.palette.grey[300]
: theme.palette.grey[800],
borderRadius: theme.shape.borderRadius,
- // boxShadow: '0px 1px 4px 0px rgba(0, 0, 0, 0.04)',
+ // boxShadow: '0px 1px 8px 0px rgba(0, 0, 0, 0.04)',
overflow: 'hidden',
position: 'relative',
padding: indented ? theme.spacing(2) : 0,
@@ -78,13 +79,16 @@ export const Card = styled(Box, {
cursor: onClick ? 'pointer' : 'default',
backgroundColor: backgroundHoverColor,
},
- [`&:hover .${badgeClasses.badge} > div`]: {
+ [`&:hover .${badgeClasses.badge} > .${avatarClasses.root}`]: {
borderColor: backgroundHoverColor,
},
- transition: theme.transitions.create(['background-color'], {
- duration: theme.transitions.duration.enteringScreen,
- easing: theme.transitions.easing.easeOut,
- }),
+ transition: theme.transitions.create(
+ ['background-color', 'box-shadow', 'border-color'],
+ {
+ duration: theme.transitions.duration.enteringScreen,
+ easing: theme.transitions.easing.easeOut,
+ },
+ ),
pointerEvents,
};
});
diff --git a/packages/widget/src/components/Card/CardIconButton.tsx b/packages/widget/src/components/Card/CardIconButton.tsx
index 731966efc..75dd0179d 100644
--- a/packages/widget/src/components/Card/CardIconButton.tsx
+++ b/packages/widget/src/components/Card/CardIconButton.tsx
@@ -1,15 +1,12 @@
-import { IconButton as MuiIconButton, alpha, styled } from '@mui/material';
+import { IconButton as MuiIconButton, styled } from '@mui/material';
+import { getContrastAlphaColor } from '../../utils/colors.js';
export const CardIconButton = styled(MuiIconButton)(({ theme }) => {
- const backgroundColor =
- theme.palette.mode === 'light'
- ? theme.palette.common.black
- : theme.palette.common.white;
return {
padding: theme.spacing(0.5),
- backgroundColor: alpha(backgroundColor, 0.04),
+ backgroundColor: getContrastAlphaColor(theme, 0.04),
'&:hover': {
- backgroundColor: alpha(backgroundColor, 0.08),
+ backgroundColor: getContrastAlphaColor(theme, 0.08),
},
};
});
diff --git a/packages/widget/src/components/Header/Header.style.ts b/packages/widget/src/components/Header/Header.style.ts
index 175bb3873..8b6360ff2 100644
--- a/packages/widget/src/components/Header/Header.style.ts
+++ b/packages/widget/src/components/Header/Header.style.ts
@@ -1,12 +1,16 @@
import {
AppBar,
+ Avatar,
Box,
Button,
alpha,
+ avatarClasses,
badgeClasses,
buttonClasses,
styled,
} from '@mui/material';
+import { getContrastAlphaColor } from '../../utils/colors.js';
+import { avatarMask12 } from '../Avatar/utils.js';
import { Tabs } from '../Tabs/Tabs.style.js';
export const HeaderAppBar = styled(AppBar)(({ theme }) => ({
@@ -42,10 +46,7 @@ export const WalletButton = styled(Button)(({ theme }) => ({
fontWeight: 600,
borderRadius: theme.shape.borderRadius * 2,
'&:hover': {
- backgroundColor:
- theme.palette.mode === 'light'
- ? alpha(theme.palette.common.black, 0.04)
- : alpha(theme.palette.common.white, 0.08),
+ backgroundColor: getContrastAlphaColor(theme, 0.04),
},
[`.${buttonClasses.endIcon} > *:nth-of-type(1)`]: {
fontSize: '24px',
@@ -53,11 +54,8 @@ export const WalletButton = styled(Button)(({ theme }) => ({
[`.${buttonClasses.startIcon} > *:nth-of-type(1)`]: {
fontSize: '24px',
},
- [`&:hover .${badgeClasses.badge} > div`]: {
- borderColor:
- theme.palette.mode === 'light'
- ? alpha(theme.palette.common.black, 0.04)
- : alpha(theme.palette.common.white, 0.08),
+ [`&:hover .${badgeClasses.badge} > .${avatarClasses.root}`]: {
+ borderColor: getContrastAlphaColor(theme, 0.04),
},
}));
@@ -88,3 +86,9 @@ export const SplitTabs = styled(Tabs)(({ theme }) => ({
? alpha(theme.palette.common.black, 0.04)
: theme.palette.background.paper,
}));
+
+export const WalletAvatar = styled(Avatar)(({ theme }) => ({
+ mask: avatarMask12,
+ width: 24,
+ height: 24,
+}));
diff --git a/packages/widget/src/components/Header/WalletHeader.tsx b/packages/widget/src/components/Header/WalletHeader.tsx
index 94cb6b85a..fb1eb4447 100644
--- a/packages/widget/src/components/Header/WalletHeader.tsx
+++ b/packages/widget/src/components/Header/WalletHeader.tsx
@@ -17,6 +17,7 @@ import { CloseDrawerButton } from './CloseDrawerButton.js';
import {
DrawerWalletContainer,
HeaderAppBar,
+ WalletAvatar,
WalletButton,
} from './Header.style.js';
import { WalletMenu } from './WalletMenu.js';
@@ -117,16 +118,6 @@ const ConnectedButton = ({ account }: { account: Account }) => {
setAnchorEl(null);
};
- const avatar = (
-
- {account.connector?.name[0]}
-
- );
-
return (
<>
{
{chain?.name[0]}
}
>
- {avatar}
+
+ {account.connector?.name[0]}
+
) : (
- avatar
+
+ {account.connector?.name[0]}
+
)
}
sx={{
diff --git a/packages/widget/src/components/Header/WalletMenu.tsx b/packages/widget/src/components/Header/WalletMenu.tsx
index d472aceff..86327ff1f 100644
--- a/packages/widget/src/components/Header/WalletMenu.tsx
+++ b/packages/widget/src/components/Header/WalletMenu.tsx
@@ -19,6 +19,7 @@ import { useAccount } from '../../hooks/useAccount.js';
import { useAvailableChains } from '../../hooks/useAvailableChains.js';
import { navigationRoutes } from '../../utils/navigationRoutes.js';
import { shortenAddress } from '../../utils/wallet.js';
+import { AvatarMasked } from '../Avatar/Avatar.style.js';
import { SmallAvatar } from '../SmallAvatar.js';
import { EVMDisconnectIconButton } from './EVMDisconnectIconButton.js';
import { SVMDisconnectIconButton } from './SVMDisconnectIconButton.js';
@@ -44,17 +45,7 @@ export const WalletMenu = ({ onClose }: { onClose: () => void }) => {
await navigator.clipboard.writeText(account.address ?? '');
onClose();
};
- const avatar = (
-
- {account.connector?.name[0]}
-
- );
+
return (