-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 🎸 Add Category Leaders Section * fix: tidy up styles in TvlComparison * styles: clean up styles --------- Co-authored-by: Diogo Soares <[email protected]>
- Loading branch information
1 parent
52dbf57
commit 3b012d2
Showing
11 changed files
with
332 additions
and
79 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import type { BaseBlock } from '@/components/Home/types' | ||
import { useTransform } from 'framer-motion' | ||
import css from './styles.module.css' | ||
import type { RefObject } from 'react' | ||
import { motion } from 'framer-motion' | ||
import { Typography } from '@mui/material' | ||
import { ComparisonType, type TvlComparisonProps } from '@/components/DataRoom/TvlComparison' | ||
import { useSafeDataRoomStats } from '@/hooks/useSafeDataRoomStats' | ||
import { useIsMediumScreen } from '@/hooks/useMaxWidth' | ||
import { formatValue } from '@/lib/formatValue' | ||
import useScrollProgress from '@/hooks/useScrollProgress' | ||
import { TvlComparison } from '@/components/DataRoom/TvlComparison' | ||
|
||
export default function Content({ | ||
title, | ||
leaders, | ||
containerRef, | ||
}: Omit<BaseBlock, 'text'> & { leaders: TvlComparisonProps[]; containerRef: RefObject<HTMLDivElement> }) { | ||
const { tvlLido, tvlEigenLayer, tvlUniswap, tvlAAVE, tvlSafe } = useSafeDataRoomStats() | ||
|
||
const isMobile = useIsMediumScreen() | ||
const { scrollYProgress } = useScrollProgress(containerRef) | ||
|
||
// Create a mapping object for TVL values | ||
const tvlMapping: Record<string, number | null> = { | ||
tvlLido, | ||
tvlUniswap, | ||
tvlSafe, | ||
tvlEigenLayer, | ||
tvlAAVE, | ||
} | ||
|
||
// Get the TVL values for each LEADER | ||
const dynamicTvl = leaders.map(({ name, tvl: tvlFallback }) => { | ||
// get the varibale name of the dynamic TVL | ||
const dynamicTvlString = `tvl${name.split(' ')[0]}` | ||
|
||
return { name, tvl: tvlMapping[dynamicTvlString] || tvlFallback } | ||
}) | ||
|
||
const normalizationFactor = 1_000_000_000 // 1 billion | ||
const squareRatio = formatValue(normalizationFactor) | ||
|
||
const opacity = useTransform(scrollYProgress, isMobile ? [0, 0.35, 0.5, 1.0] : [0.1, 0.35, 0.5, 0.75], [0, 1, 1, 0]) | ||
|
||
return ( | ||
<motion.div | ||
style={{ | ||
opacity, | ||
}} | ||
className={css.leadersContainer} | ||
> | ||
<Typography className={css.title} variant="h1"> | ||
{title} | ||
</Typography> | ||
|
||
<Typography className={css.label} color="primary.light"> | ||
1 square - ${squareRatio} | ||
</Typography> | ||
|
||
<div className={css.columnsGrid}> | ||
{[[0, 1], [2], [3, 4]].map((column, columnIndex) => ( | ||
<div key={columnIndex} className={css.leaderColumn}> | ||
{column.map((index) => ( | ||
<TvlComparison | ||
type={ComparisonType.LEADER} | ||
key={index} | ||
tvl={dynamicTvl.find((item) => item.name === leaders[index].name)?.tvl || leaders[index].tvl} | ||
boxColor={leaders[index].boxColor} | ||
name={leaders[index].name} | ||
normalizationFactor={normalizationFactor} | ||
/> | ||
))} | ||
</div> | ||
))} | ||
</div> | ||
</motion.div> | ||
) | ||
} |
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,21 @@ | ||
import { useRef } from 'react' | ||
import dynamic from 'next/dynamic' | ||
import type { BaseBlock } from '@/components/Home/types' | ||
import type { TvlComparisonProps } from '@/components/DataRoom/TvlComparison' | ||
import css from './styles.module.css' | ||
|
||
const Content = dynamic(() => import('./Content')) | ||
|
||
const Leaders = ({ title, leaders }: BaseBlock & { leaders: TvlComparisonProps[] }) => { | ||
const backgroundRef = useRef<HTMLDivElement>(null) | ||
|
||
return ( | ||
<div ref={backgroundRef} className={css.sectionContainer}> | ||
<div className={css.stickyContainer}> | ||
<Content title={title} leaders={leaders} containerRef={backgroundRef} /> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default Leaders |
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,79 @@ | ||
.sectionContainer { | ||
height: 200vh; | ||
display: flex; | ||
} | ||
|
||
.stickyContainer { | ||
position: sticky; | ||
top: 0; | ||
width: 100%; | ||
height: 100dvh; | ||
display: flex; | ||
flex-direction: column; | ||
padding: 100px 128px; | ||
overflow: hidden; | ||
} | ||
|
||
.leadersContainer { | ||
position: relative; | ||
} | ||
|
||
.label { | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
font-size: 18px; | ||
font-weight: 400; | ||
} | ||
|
||
.columnsGrid { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
margin-top: 100px; | ||
} | ||
|
||
.leaderColumn { | ||
display: flex; | ||
flex-direction: column; | ||
width: 30%; | ||
gap: 100px; | ||
} | ||
|
||
@media (max-width: 1000px) { | ||
.sectionContainer { | ||
height: 200lvh; | ||
} | ||
|
||
.stickyContainer { | ||
padding: 72px 30px 30px; | ||
height: 100lvh; | ||
justify-content: space-between; | ||
} | ||
|
||
.leadersContainer { | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
justify-content: space-between; | ||
} | ||
|
||
.columnsGrid { | ||
flex-direction: column; | ||
margin-top: 12px; | ||
gap: 18px; | ||
} | ||
|
||
.leaderColumn { | ||
width: 100%; | ||
gap: 18px; | ||
justify-items: flex-start; | ||
} | ||
|
||
.title { | ||
margin-top: 0px; | ||
text-align: left; | ||
font-size: 40px; | ||
line-height: 48px; | ||
} | ||
} |
Oops, something went wrong.