-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Category Leaders Section #470
Merged
DiogoSoaress
merged 5 commits into
safe-global:dataroom-category-leaders
from
Malayvasa:category-leaders
Oct 2, 2024
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
b14f475
feat: 🎸 Add Category Leaders Section
Malayvasa 2f24519
Merge branch 'main' into category-leaders
Malayvasa 9ca4550
fix: tidy up styles in TvlComparison
DiogoSoaress 5714e5a
styles: clean up styles
DiogoSoaress 9618352
Merge branch 'dataroom-category-leaders' into category-leaders
DiogoSoaress File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,78 @@ | ||
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 { type ComparisonProps } from '@/components/common/ExternalComparison' | ||
import { useSafeDataRoomStats } from '@/hooks/useSafeDataRoomStats' | ||
import { useIsMediumScreen } from '@/hooks/useMaxWidth' | ||
import { formatValue } from '@/lib/formatValue' | ||
import useScrollProgress from '@/hooks/useScrollProgress' | ||
import { ExternalComparison } from '@/components/common/ExternalComparison' | ||
|
||
export default function Content({ | ||
title, | ||
leaders, | ||
containerRef, | ||
}: Omit<BaseBlock, 'text'> & { leaders: ComparisonProps[]; 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 = 1000000000 | ||
|
||
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} variant="h5"> | ||
1 square - ${squareRatio} | ||
</Typography> | ||
<div className={css.columnsContainer}> | ||
{[[0, 1], [2], [3, 4]].map((column, columnIndex) => ( | ||
<div key={columnIndex} className={css.leaderColumn}> | ||
{column.map((index) => ( | ||
<ExternalComparison | ||
type="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 type { BaseBlock } from '@/components/Home/types' | ||
import dynamic from 'next/dynamic' | ||
import { useRef } from 'react' | ||
import css from './styles.module.css' | ||
import type { ComparisonProps } from '@/components/common/ExternalComparison' | ||
|
||
const Content = dynamic(() => import('./Content')) | ||
|
||
const Leaders = ({ title, leaders }: BaseBlock & { leaders: ComparisonProps[] }) => { | ||
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,92 @@ | ||
.sectionContainer { | ||
height: 200vh; | ||
display: flex; | ||
} | ||
|
||
.stickyContainer { | ||
position: sticky; | ||
top: 0; | ||
width: 100%; | ||
height: 100dvh; | ||
display: flex; | ||
flex-direction: column; | ||
padding: 100px 128px; | ||
overflow: hidden; | ||
} | ||
|
||
.columnsContainer { | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
margin-top: 100px; | ||
} | ||
|
||
.leaderColumn { | ||
display: flex; | ||
flex-direction: column; | ||
width: 30%; | ||
gap: 100px; | ||
justify-items: self-start; | ||
} | ||
|
||
.label { | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
padding: 100px 128px; | ||
color: var(--mui-palette-primary-light); | ||
font-size: 18px; | ||
padding-bottom: 12px; | ||
} | ||
|
||
@media (max-width: 1000px) { | ||
.sectionContainer { | ||
height: 200lvh; | ||
} | ||
|
||
.stickyContainer { | ||
padding: 30px; | ||
overflow: hidden; | ||
padding-top: 72px; | ||
height: 100lvh; | ||
justify-content: space-between; | ||
} | ||
|
||
.leadersContainer { | ||
display: flex; | ||
flex-direction: column; | ||
height: 100%; | ||
justify-content: space-around; | ||
} | ||
|
||
.columnsContainer { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: space-between; | ||
margin-top: 12px; | ||
gap: 18px; | ||
} | ||
|
||
.leaderColumn { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
gap: 18px; | ||
justify-items: flex-start; | ||
} | ||
|
||
.label { | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
padding: 80px 30px; | ||
color: var(--mui-palette-primary-light); | ||
} | ||
|
||
.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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this file moved to the
/common
folder? It's a Dataroom component