Skip to content

Commit

Permalink
chore: adjust wallet-button styling + add logo-href (#1411)
Browse files Browse the repository at this point in the history
  • Loading branch information
dennyscode authored Nov 14, 2024
1 parent 483d03b commit 47ab769
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 59 deletions.
25 changes: 11 additions & 14 deletions src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
'use client';
import { usePathname, useRouter } from 'next/navigation';
import { usePathname } from 'next/navigation';

import {
JUMPER_LEARN_PATH,
Expand All @@ -19,7 +19,6 @@ import {
} from '.';

export const Navbar = ({ disableNavbar = false }) => {
const router = useRouter();
const pathname = usePathname();
const isLearnPage = pathname?.includes(JUMPER_LEARN_PATH);
const isScanPage =
Expand All @@ -33,22 +32,20 @@ export const Navbar = ({ disableNavbar = false }) => {
const handleClick = () => {
closeAllMenus();
setWelcomeScreenClosed(false);

if (pathname === '/gas' || pathname === '/buy') {
return;
}
if (isLearnPage) {
router.push(JUMPER_LEARN_PATH);
} else if (isScanPage) {
router.push(JUMPER_SCAN_PATH);
} else {
router.push('/');
}
};

let logoHref;
if (isLearnPage) {
logoHref = JUMPER_LEARN_PATH;
} else if (isScanPage) {
logoHref = JUMPER_SCAN_PATH;
} else {
logoHref = '/';
}

return (
<Container>
<LogoLink id="jumper-logo" onClick={handleClick}>
<LogoLink href={logoHref} id="jumper-logo" onClick={handleClick}>
<Logo
variant={isScanPage ? 'scan' : isLearnPage ? 'learn' : 'default'}
/>
Expand Down
31 changes: 31 additions & 0 deletions src/components/Navbar/NavbarButtons/RedirectToApp.style.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use client';

import SwapHorizIcon from '@mui/icons-material/SwapHoriz';
import { Typography } from '@mui/material';
import { styled } from '@mui/material/styles';
import { ConnectButton } from '../WalletButton.style';

export const RedirectAppButton = styled(ConnectButton)(({ theme }) => ({
[theme.breakpoints.down('md')]: {
width: 48,
minWidth: 48,
},
}));

export const RedirectAppLabel = styled(Typography)(({ theme }) => ({
display: 'none',
[theme.breakpoints.up('md')]: {
overflow: 'hidden',
textOverflow: 'ellipsis',
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical',
},
}));

export const RedirectAppIcon = styled(SwapHorizIcon)(({ theme }) => ({
display: 'block',
[theme.breakpoints.up('md')]: {
display: 'none',
},
}));
22 changes: 9 additions & 13 deletions src/components/Navbar/NavbarButtons/RedirectToApp.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
'use client';
import { Typography, useTheme } from '@mui/material';
import { useTheme } from '@mui/material';
import Link from 'next/link';
import { useTranslation } from 'react-i18next';
import { TrackingAction, TrackingCategory } from 'src/const/trackingKeys';
import { useUserTracking } from 'src/hooks/userTracking';
import { ConnectButton as RedirectAppButton } from '../WalletButton.style';
import {
RedirectAppButton,
RedirectAppIcon,
RedirectAppLabel,
} from './RedirectToApp.style';

interface RedirectToAppProps {
hideConnectButton: boolean;
Expand Down Expand Up @@ -33,18 +37,10 @@ export const RedirectToApp = ({ hideConnectButton }: RedirectToAppProps) => {
...(!hideConnectButton && { marginRight: theme.spacing(1) }),
}}
>
<Typography
variant={'bodyMediumStrong'}
sx={{
overflow: 'hidden',
textOverflow: 'ellipsis',
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical',
}}
>
<RedirectAppIcon />
<RedirectAppLabel variant={'bodyMediumStrong'}>
{t('blog.openApp')}
</Typography>
</RedirectAppLabel>
</RedirectAppButton>
);
};
26 changes: 24 additions & 2 deletions src/components/Navbar/WalletButton.style.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import { ButtonPrimary } from '@/components/Button';
import { alpha, Avatar, Badge, Skeleton, styled } from '@mui/material';
import {
alpha,
Avatar,
Badge,
Skeleton,
styled,
Typography,
} from '@mui/material';
import Image from 'next/image';
import { getContrastAlphaColor } from 'src/utils/colors';
import { ButtonTransparent } from '../Button';
import { avatarMask12 } from '../Mask.style';
import Image from 'next/image';

export const WalletMgmtWalletAvatar = styled(Avatar)(() => ({
height: 32,
Expand Down Expand Up @@ -35,6 +42,14 @@ export const ConnectButton = styled(ButtonPrimary)(({ theme }) => ({
textWrap: 'nowrap',
}));

export const ConnectButtonLabel = styled(Typography)(({ theme }) => ({
display: '-webkit-box',
overflow: 'hidden',
textOverflow: 'ellipsis',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical',
}));

export const WalletMenuButton = styled(ButtonTransparent)(({ theme }) => ({
padding: theme.spacing(1),
paddingRight: theme.spacing(1.5),
Expand Down Expand Up @@ -78,3 +93,10 @@ export const SkeletonWalletMenuButton = styled(Skeleton)(({ theme }) => ({
marginRight: 1.1,
marginLeft: 1.1,
}));

export const WalletLabel = styled(Typography)(({ theme }) => ({
display: 'block',
marginRight: theme.spacing(0.25),
marginLeft: theme.spacing(0.75),
width: 'auto',
}));
24 changes: 6 additions & 18 deletions src/components/Navbar/WalletButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,10 @@ import { XPIcon } from '../illustrations/XPIcon';
import { PromoLabel } from '../PromoLabel.style';
import {
ConnectButton,
ConnectButtonLabel,
ImageWalletMenuButton,
SkeletonWalletMenuButton,
WalletLabel,
WalletMenuButton,
WalletMgmtBadge,
WalletMgmtChainAvatar,
Expand Down Expand Up @@ -73,18 +75,9 @@ export const WalletButtons = () => {
openWalletMenu();
}}
>
<Typography
variant={'bodyMediumStrong'}
sx={{
overflow: 'hidden',
textOverflow: 'ellipsis',
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical',
}}
>
<ConnectButtonLabel variant={'bodyMediumStrong'}>
{t('navbar.connect')}
</Typography>
</ConnectButtonLabel>
</ConnectButton>
) : (
<Stack direction="row" spacing={2}>
Expand Down Expand Up @@ -149,14 +142,9 @@ export const WalletButtons = () => {
/>
</WalletMgmtBadge>
) : null}
<Typography
variant={'bodyMediumStrong'}
width={'auto'}
marginRight={0.25}
marginLeft={0.75}
>
<WalletLabel variant={'bodyMediumStrong'}>
{_walletDigest}
</Typography>
</WalletLabel>
</WalletMenuButton>
</Stack>
)}
Expand Down
16 changes: 5 additions & 11 deletions src/components/Portfolio/Portfolio.styles.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import {
Accordion,
AvatarGroup,
Avatar,
Typography,
circularProgressClasses,
CircularProgress as MuiCircularProgress,
keyframes,
AvatarGroup,
Box,
darken,
Divider,
Box,
Typography,
} from '@mui/material';
import { styled } from '@mui/system';
import { lighten } from '@mui/material/styles';
import { AccordionProps } from '@mui/material/Accordion';
import SvgIcon from '@mui/material/SvgIcon/SvgIcon'; // Import AccordionProps
import { styled } from '@mui/system';

export const TotalValue = styled(Typography)(({ theme }) => ({
color: theme.palette.text.primary,
Expand Down Expand Up @@ -105,9 +101,7 @@ export const PortfolioBox = styled(Box)(({ theme }) => ({
flexDirection: 'column',
display: 'flex',
justifyContent: 'center',
padding: '16px',
paddingTop: '0px',
paddingBottom: '0px',
padding: theme.spacing(0, 2),
}));

export const NoTokenImageBox = styled(Box)(() => ({
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useImageStatus.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useEffect } from 'react';
import { useEffect, useState } from 'react';
import { DEFAULT_EFFIGY } from 'src/const/urls';

const useImageStatus = (address: string | undefined) => {
Expand Down

0 comments on commit 47ab769

Please sign in to comment.