-
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.
Merge branch 'main' into gas-station-add-logos
- Loading branch information
Showing
15 changed files
with
350 additions
and
81 deletions.
There are no files selected for viewing
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,85 @@ | ||
import { useTransform } from 'framer-motion' | ||
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' | ||
import { formatDate } from '@/lib/formatDate' | ||
import { LAST_UPDATED_FALLBACK } from '@/components/DataRoom/IndustryComparison' | ||
import type { BaseBlock } from '@/components/Home/types' | ||
import css from './styles.module.css' | ||
|
||
export default function Content({ | ||
title, | ||
leaders, | ||
containerRef, | ||
}: Omit<BaseBlock, 'text'> & { leaders: TvlComparisonProps[]; containerRef: RefObject<HTMLDivElement> }) { | ||
const { tvlLido, tvlEigenLayer, tvlUniswap, tvlAAVE, tvlSafe, lastUpdated } = 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 timestamp = lastUpdated || LAST_UPDATED_FALLBACK | ||
const formattedDate = formatDate(timestamp) | ||
|
||
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} | ||
<span>as of {formattedDate}</span> | ||
</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,82 @@ | ||
.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; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-end; | ||
} | ||
|
||
.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; | ||
} | ||
} |
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
Oops, something went wrong.