generated from defi-wonderland/web3-nextjs-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
219 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,150 @@ | ||
import { Box, Typography, Grid, styled } from '@mui/material'; | ||
import { TvlData } from '~/types'; | ||
import { Box } from '@mui/material'; | ||
import { TvlContentBox } from './TvlContentBox'; | ||
|
||
interface TotalValueLockedProps { | ||
tvl: TvlData[]; | ||
} | ||
|
||
export const TotalValueLocked = ({ tvl }: TotalValueLockedProps) => { | ||
console.log(tvl); | ||
return <Box>{/* Token graph tvl */}</Box>; | ||
const firstTvl = tvl[0]; | ||
const secondTvl = tvl[1]; | ||
const thirdTvl = tvl[2]; | ||
const fourthTvl = tvl[3]; | ||
const fifthTvl = tvl[4]; | ||
const sixthTvl = tvl[5]; | ||
|
||
return ( | ||
<TvlContainer container spacing={0.5}> | ||
{/* First tvl row */} | ||
<Grid item xs={12}> | ||
<GridContainer imageUrl={firstTvl.imageUrl} height={'12rem'}> | ||
<TvlContentBox | ||
avatar={firstTvl.imageUrl} | ||
token={firstTvl.token} | ||
total={firstTvl.total} | ||
tokenName={firstTvl.tokenName} | ||
/> | ||
</GridContainer> | ||
</Grid> | ||
|
||
{/* Second tvl row */} | ||
<Grid item container xs={12} spacing={0.5}> | ||
<Grid item xs={6}> | ||
<GridContainer imageUrl={secondTvl.imageUrl} height={'12rem'}> | ||
<TvlContentBox | ||
avatar={secondTvl.imageUrl} | ||
token={secondTvl.token} | ||
total={secondTvl.total} | ||
tokenName={secondTvl.tokenName} | ||
/> | ||
</GridContainer> | ||
</Grid> | ||
|
||
<Grid item container xs={6} spacing={0.5}> | ||
<Grid item xs={4}> | ||
<GridContainer imageUrl={thirdTvl.imageUrl} height={'12rem'}> | ||
<TvlContentBox | ||
avatar={thirdTvl.imageUrl} | ||
token={thirdTvl.token} | ||
total={thirdTvl.total} | ||
tokenName={thirdTvl.tokenName} | ||
/> | ||
</GridContainer> | ||
</Grid> | ||
|
||
<Grid item xs={4}> | ||
<GridContainer imageUrl={fourthTvl.imageUrl} height={'12rem'}> | ||
<TvlContentBox | ||
avatar={fourthTvl.imageUrl} | ||
token={fourthTvl.token} | ||
total={fourthTvl.total} | ||
tokenName={fourthTvl.tokenName} | ||
/> | ||
</GridContainer> | ||
</Grid> | ||
|
||
{/* Last tvl container */} | ||
<Grid item container xs={4} direction='column'> | ||
<Grid item xs={6}> | ||
<GridContainer imageUrl={fifthTvl.imageUrl} height={'5.75rem'}> | ||
<TvlContentBox | ||
avatar={fifthTvl.imageUrl} | ||
token={fifthTvl.token} | ||
total={fifthTvl.total} | ||
tokenName={fifthTvl.tokenName} | ||
isLast={true} | ||
/> | ||
</GridContainer> | ||
</Grid> | ||
|
||
<Grid item container xs={6} spacing={0.5}> | ||
<Grid item xs={9}> | ||
<GridContainer imageUrl={sixthTvl.imageUrl} height={'5.75rem'}> | ||
<TvlContentBox | ||
avatar={sixthTvl.imageUrl} | ||
token={sixthTvl.token} | ||
total={sixthTvl.total} | ||
tokenName={sixthTvl.tokenName} | ||
isLast={true} | ||
/> | ||
</GridContainer> | ||
</Grid> | ||
|
||
<Grid item xs={3}> | ||
<GridContainer height={'5.75rem'}> | ||
<OthersBox> | ||
<Typography style={{ writingMode: 'vertical-rl', transform: 'rotate(180deg)' }}>Others</Typography> | ||
</OthersBox> | ||
</GridContainer> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
</TvlContainer> | ||
); | ||
}; | ||
|
||
const TvlContainer = styled(Grid)({ | ||
display: 'flex', | ||
flexWrap: 'wrap', | ||
width: '75rem', | ||
}); | ||
|
||
interface GridContainerProps { | ||
imageUrl?: string; | ||
height?: string; | ||
} | ||
|
||
const GridContainer = styled(Grid)(({ imageUrl, height }: GridContainerProps) => ({ | ||
position: 'relative', | ||
height: height || 'fit-content', | ||
display: 'flex', | ||
color: '#fff', | ||
textShadow: '0 0 5px rgba(0, 0, 0, 0.5)', | ||
overflow: 'hidden', | ||
backgroundColor: 'rgba(250, 250, 250, 0.2)', | ||
borderRadius: '1rem', | ||
padding: '1rem', | ||
'&::before': { | ||
content: '""', | ||
position: 'absolute', | ||
top: -20, | ||
left: -450, | ||
right: 0, | ||
bottom: 0, | ||
backgroundImage: `url(${imageUrl})`, | ||
backgroundSize: 'cover', | ||
backgroundPosition: 'center', | ||
filter: 'blur(130px)', | ||
}, | ||
})); | ||
|
||
const OthersBox = styled(Box)({ | ||
position: 'relative', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import { Box, Avatar, Typography, styled } from '@mui/material'; | ||
import { useCustomTheme } from '~/hooks'; | ||
import { formatDataNumber } from '~/utils'; | ||
|
||
interface TvlContentBoxProps { | ||
avatar: string; | ||
token: string; | ||
total: number; | ||
tokenName: string; | ||
isLast?: boolean; | ||
} | ||
|
||
export const TvlContentBox = ({ avatar, token, total, tokenName, isLast }: TvlContentBoxProps) => { | ||
return ( | ||
<ContentBox> | ||
<TopBox> | ||
<TokenLogo src={avatar} alt={token} isLast={isLast || false} /> | ||
<TokenName>{tokenName}</TokenName> | ||
<TokenTicker>{token}</TokenTicker> | ||
</TopBox> | ||
|
||
<Typography>{formatDataNumber(total, 0, true)}</Typography> | ||
</ContentBox> | ||
); | ||
}; | ||
|
||
const ContentBox = styled(Box)({ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
justifyContent: 'space-between', | ||
alignItems: 'center', | ||
zIndex: 1, | ||
}); | ||
|
||
const TopBox = styled(Box)({ | ||
display: 'flex', | ||
alignItems: 'center', | ||
gap: '0.5rem', | ||
}); | ||
|
||
interface TokenLogoProps { | ||
isLast: boolean; | ||
} | ||
|
||
const TokenLogo = styled(Avatar)<TokenLogoProps>(({ isLast }) => ({ | ||
width: `${isLast ? '1.25rem' : '2rem'}`, | ||
height: `${isLast ? '1.25rem' : '2rem'}`, | ||
})); | ||
|
||
const TokenTicker = styled(Typography)(() => { | ||
const { currentTheme } = useCustomTheme(); | ||
return { | ||
fontSize: '0.75rem', | ||
fontWeight: 400, | ||
color: currentTheme.textSecondary, | ||
}; | ||
}); | ||
|
||
const TokenName = styled(Typography)({ | ||
fontSize: '0.75rem', | ||
fontWeight: 400, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters