Skip to content

Commit

Permalink
Merge branch 'dev' into feat/misc-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
0xtiti committed Aug 15, 2024
2 parents 225f230 + 31b80fb commit 7e8d07b
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 16 deletions.
87 changes: 79 additions & 8 deletions src/components/ChainTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
TableBody,
Typography,
Avatar,
Box,
} from '@mui/material';

import { EcosystemChainData } from '~/types';
Expand All @@ -35,7 +36,7 @@ export const ChainTable = ({ chains }: TableProps) => {
{/* Table titles */}
<STableHead>
<STableRow>
<STableCellHead sx={{ width: '60%' }}>{t('HOME.DASHBOARD.chain')}</STableCellHead>
<TableCellHeadFirst sx={{ width: '60%' }}>{t('HOME.DASHBOARD.chain')}</TableCellHeadFirst>
<STableCellHead sx={{ width: '10%' }}>{t('HOME.DASHBOARD.chainId')}</STableCellHead>
<STableCellHead sx={{ width: '10%' }}>{t('HOME.DASHBOARD.nativeToken')}</STableCellHead>
<STableCellHead sx={{ width: '10%' }}>{t('HOME.DASHBOARD.tvl')}</STableCellHead>
Expand All @@ -49,12 +50,14 @@ export const ChainTable = ({ chains }: TableProps) => {
return (
<STableBodyRow key={index} onClick={() => handleChainNavigation(data.chainId)}>
{/* Chain Name with Logo and Tags */}
<LogoCell sx={{ width: '60%' }}>
<FirstCellWithLogo>
<ChainAvatar alt={`${data.chainName} logo`} src={data.iconUrl} />
<Typography>{data.chainName}</Typography>
{!data.rpc && <InfoTag information={t('HOME.DASHBOARD.noRPC')} />}
{!data.metadata && <InfoTag information={t('HOME.DASHBOARD.noMetadata')} />}
</LogoCell>
<ChainName>{data.chainName}</ChainName>
<InfoTagsContainer>
{!data.rpc && <InfoTag information={t('HOME.DASHBOARD.noRPC')} />}
{!data.metadata && <InfoTag information={t('HOME.DASHBOARD.noMetadata')} />}
</InfoTagsContainer>
</FirstCellWithLogo>

<STableCell sx={{ width: '10%' }}>{data.chainId}</STableCell>

Expand All @@ -81,7 +84,16 @@ export const STableContainer = styled(TableContainer)(() => {
width: '100%',
borderRadius: currentTheme.borderRadius,
border: currentTheme.border,
overflow: 'hidden',
overflow: 'auto',

// Hide scrollbar for WebKit browsers
'&::-webkit-scrollbar': {
display: 'none',
},

// Hide scrollbar for Firefox
scrollbarWidth: 'none',
'-ms-overflow-style': 'none', // Hide scrollbar for Internet Explorer and Edge
};
});

Expand Down Expand Up @@ -134,12 +146,46 @@ export const STableCellHead = styled(TableCell)(() => {
};
});

export const STableCell = styled(TableCell)(() => {
export const TableCellHeadFirst = styled(TableCell)(() => {
const { currentTheme } = useCustomTheme();
return {
color: currentTheme.textSecondary,
textAlign: 'left',
borderBottom: 'none',
position: 'sticky',
left: 0,
zIndex: 1,
backgroundColor: currentTheme.backgroundTertiary,
};
});

export const STableCell = styled(TableCell)(({ theme }) => {
const { currentTheme } = useCustomTheme();
return {
color: currentTheme.textPrimary,
textAlign: 'left',
border: 'none',
fontSize: '1rem',
[theme.breakpoints.down('sm')]: {
fontSize: '0.875rem',
},
};
});

export const FirstCellWithLogo = styled(TableCell)(() => {
const { currentTheme } = useCustomTheme();
return {
color: currentTheme.textPrimary,
display: 'flex',
alignItems: 'center',
gap: currentTheme.gap,
border: 'none',
textAlign: 'left',
position: 'sticky',
left: 0,
backgroundColor: currentTheme.backgroundSecondary,
zIndex: 1,
minWidth: 'max-content',
};
});

Expand Down Expand Up @@ -170,3 +216,28 @@ export const TokenAvatar = styled(Avatar)(() => {
backgroundColor: currentTheme.emptyBackground,
};
});

export const ChainName = styled(Typography)(({ theme }) => {
const { currentTheme } = useCustomTheme();
return {
fontSize: '1rem',
color: currentTheme.textPrimary,
[theme.breakpoints.down('sm')]: {
fontSize: '0.875rem',
},
};
});

export const InfoTagsContainer = styled(Box)(({ theme }) => {
const { currentTheme } = useCustomTheme();
return {
fontSize: '1rem',
color: currentTheme.textPrimary,
display: 'flex',
gap: currentTheme.gap,
[theme.breakpoints.down('sm')]: {
fontSize: '0.875rem',
display: 'grid',
},
};
});
17 changes: 14 additions & 3 deletions src/components/InfoTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const InfoTag = ({ information }: InfoTagProps) => {
const { theme } = useCustomTheme();
return (
<InfoTagContainer>
<Image src={theme === 'dark' ? informationIconDark : informationIconLight} alt={information} />
<InfoIcon src={theme === 'dark' ? informationIconDark : informationIconLight} alt={information} />
<InfoText>{information}</InfoText>
</InfoTagContainer>
);
Expand All @@ -25,20 +25,31 @@ const InfoTagContainer = styled(Box)(() => {
return {
display: 'flex',
alignItems: 'center',
fontSize: '0.7rem',
gap: currentTheme.gap,
backgroundColor: currentTheme.warningBackground,
borderRadius: currentTheme.borderRadius,
padding: '0.1rem 0.5rem 0.1rem 0.1rem',
border: currentTheme.warningBorder,
width: 'max-content',
};
});

const InfoText = styled(Typography)(() => {
const InfoText = styled(Typography)(({ theme }) => {
const { currentTheme } = useCustomTheme();

return {
fontSize: '0.7rem',
color: currentTheme.warningText,
[theme.breakpoints.down('sm')]: {
fontSize: '0.5rem',
},
};
});

const InfoIcon = styled(Image)(({ theme }) => {
return {
[theme.breakpoints.down('sm')]: {
width: '1rem',
},
};
});
10 changes: 5 additions & 5 deletions src/components/TVL.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import {
STableCellHead,
STableCell,
STableBody,
LogoCell,
FirstCellWithLogo,
TokenAvatar,
STitle,
STableBodyRow,
TableCellHeadFirst,
} from '~/components';

export const TVL = () => {
Expand All @@ -26,7 +27,7 @@ export const TVL = () => {
<Table>
<STableHead>
<STableRow>
<STableCellHead>{t('CHAIN.TVL.chain')}</STableCellHead>
<TableCellHeadFirst>{t('CHAIN.TVL.chain')}</TableCellHeadFirst>
<STableCellHead>{t('CHAIN.TVL.price')}</STableCellHead>
<STableCellHead>{t('CHAIN.TVL.tvl')}</STableCellHead>
</STableRow>
Expand All @@ -35,13 +36,12 @@ export const TVL = () => {
<STableBody>
{tvl.map((token, index) => (
<STableBodyRow key={index}>
<LogoCell>
<FirstCellWithLogo>
<TokenAvatar alt={token.name} src={token.imageUrl} />
<Typography>
{token.name} ({token.symbol})
</Typography>
</LogoCell>

</FirstCellWithLogo>
<STableCell>${token.price.toLocaleString()}</STableCell>
<STableCell>${((token.amountUsd * token.price) / 1e18).toLocaleString()}</STableCell>
</STableBodyRow>
Expand Down

0 comments on commit 7e8d07b

Please sign in to comment.