-
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
feat: 🎸 Add Industry Comparison Section #427
Merged
DiogoSoaress
merged 16 commits into
safe-global:main
from
Malayvasa:industry-comparison
Aug 20, 2024
Merged
Changes from 10 commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
918350c
Open branch
iamacook c4aebba
feat: 🎸 Add Industry Comparison Section
Malayvasa c119de2
fix: 🐛 address PR comments
Malayvasa 1a6f721
Merge branch 'main' into industry-comparison
Malayvasa 01d5a3b
refactor: 💡 address PR comments
Malayvasa ccf8dfe
docs: ✏️ add descripition for useMousePosition hook
Malayvasa fffb8ab
refactor: 💡 remove container ref from useMousePosition
Malayvasa 74afb38
refactor: 💡 add SlidingPanel component and update Cryptopunks
Malayvasa a8a5d94
refactor: 💡 dynamic import for framer motion
Malayvasa 9f82803
refactor: 💡 address PR comments
Malayvasa 27b64ca
refactor: 💡 conditionally call drawDots to improve performance
Malayvasa 3daff57
style: 💄 remove unused title style
Malayvasa 42bee79
Merge branch 'main' into industry-comparison
Malayvasa 07dd56a
refactor: 💡 remove unused prop dimensions from drawDots
Malayvasa 4e7f180
perf: ⚡️ remove mouse hover effect from dot grid animation
Malayvasa c090e6b
Merge branch 'main' into industry-comparison
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { Typography } from '@mui/material' | ||
import type { BaseBlock } from '@/components/Home/types' | ||
import type { MotionValue } from 'framer-motion' | ||
import { motion, useTransform } from 'framer-motion' | ||
import dynamic from 'next/dynamic' | ||
import LinksWrapper from '../LinksWrapper' | ||
import css from './styles.module.css' | ||
import { useSafeDataRoomStats } from '@/hooks/useSafeDataRoomStats' | ||
import { useIsMediumScreen } from '@/hooks/useMaxWidth' | ||
|
||
const PunksGrid = dynamic(() => import('./PunksGrid')) | ||
const SlidingPanel = dynamic(() => import('@/components/common/SlidingPanel')) | ||
|
||
const CRYPTOPUNKS_TOTAL = 10000 | ||
const CRYPTOPUNKS_PERCENTAGE_STORED_FALLBACK = 0.092 | ||
|
||
const Content = ({ scrollYProgress, title, text, link }: BaseBlock & { scrollYProgress: MotionValue<number> }) => { | ||
const { cryptoPunksStoredPercentage } = useSafeDataRoomStats() | ||
const isMobile = useIsMediumScreen() | ||
|
||
const opacityParams = isMobile ? [0.4, 0.45, 0.65, 0.66] : [0.25, 0.35, 0.65, 0.7] | ||
const opacity = useTransform(scrollYProgress, opacityParams, [0, 1, 1, 0]) | ||
|
||
const percentageValue = cryptoPunksStoredPercentage || CRYPTOPUNKS_PERCENTAGE_STORED_FALLBACK | ||
// Converts to percentage with 1 decimal place | ||
const percentageToDisplay = (percentageValue * 100).toFixed(1) + '%' | ||
|
||
const cryptoPunksStored = (percentageValue * CRYPTOPUNKS_TOTAL).toFixed(0) | ||
const fractionToDisplay = `${cryptoPunksStored}/${CRYPTOPUNKS_TOTAL}` | ||
|
||
return ( | ||
<motion.div | ||
className={css.slidingPanelContent} | ||
style={{ | ||
opacity, | ||
}} | ||
> | ||
<Typography variant="h2" className={css.text}> | ||
{text} | ||
</Typography> | ||
|
||
<Typography variant="h2">{title}</Typography> | ||
|
||
<div className={css.statsContainer}> | ||
<Typography variant="h1" className={css.percentage}> | ||
{percentageToDisplay} | ||
</Typography> | ||
<Typography variant="h2" className={css.fraction}> | ||
{fractionToDisplay} | ||
</Typography> | ||
</div> | ||
|
||
{link && <LinksWrapper link={link} variant="dark" />} | ||
</motion.div> | ||
) | ||
} | ||
|
||
export default Content |
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,53 @@ | ||
import { getRandomColor } from '@/components/DataRoom/CryptoPunks/utils/getRandomColor' | ||
import CryptoPunk from '@/public/images/DataRoom/cryptopunk-silhouette.svg' | ||
import type { MotionValue } from 'framer-motion' | ||
import { motion, useTransform } from 'framer-motion' | ||
import css from './styles.module.css' | ||
|
||
const CRYPTOPUNK_ROWS_NR = 8 | ||
const CRYPTOPUNK_COLUMNS_NR = 24 | ||
|
||
const PunksGrid = ({ scrollYProgress, isMobile }: { scrollYProgress: MotionValue<number>; isMobile: boolean }) => { | ||
const translateParams = isMobile ? [0, 1] : [0.25, 0.75] | ||
const opacity = useTransform(scrollYProgress, [0, 0.25, 0.7, 0.75], [0, 1, 1, 0]) | ||
const translateLTR = useTransform(scrollYProgress, translateParams, ['-50%', '0%']) | ||
const translateRTL = useTransform(scrollYProgress, translateParams, ['0%', '-50%']) | ||
|
||
const translateDirection = (index: number) => (index % 2 === 1 ? translateLTR : translateRTL) | ||
|
||
return ( | ||
<motion.div | ||
style={{ | ||
opacity, | ||
}} | ||
className={css.punksGrid} | ||
> | ||
{Array.from({ length: CRYPTOPUNK_ROWS_NR }).map((_, outerIndex) => ( | ||
<motion.div | ||
style={{ translateX: translateDirection(outerIndex) }} | ||
className={css.cryptoPunkColumns} | ||
key={outerIndex} | ||
> | ||
{Array.from({ length: CRYPTOPUNK_COLUMNS_NR }).map((_, innerIndex) => ( | ||
<motion.div | ||
key={innerIndex} | ||
initial={{ opacity: 0, scale: 0.5 }} | ||
whileInView={{ opacity: 1, scale: 1 }} | ||
transition={{ | ||
duration: 0.3, | ||
}} | ||
style={{ | ||
transformOrigin: 'center', | ||
color: getRandomColor(), | ||
}} | ||
> | ||
<CryptoPunk className={css.cryptopunk} /> | ||
</motion.div> | ||
))} | ||
</motion.div> | ||
))} | ||
</motion.div> | ||
) | ||
} | ||
|
||
export default PunksGrid |
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,40 @@ | ||
import type { BaseBlock } from '@/components/Home/types' | ||
import { Typography } from '@mui/material' | ||
import type { MotionValue } from 'framer-motion' | ||
import { motion, useTransform } from 'framer-motion' | ||
import DotGrid from './DotGrid' | ||
import css from './styles.module.css' | ||
import { useIsMediumScreen } from '@/hooks/useMaxWidth' | ||
import type { RefObject } from 'react' | ||
|
||
const Content = ({ | ||
scrollYProgress, | ||
title, | ||
containerRef, | ||
}: { | ||
title: BaseBlock['title'] | ||
scrollYProgress: MotionValue<number> | ||
containerRef: RefObject<HTMLDivElement> | ||
}) => { | ||
const isMobile = useIsMediumScreen() | ||
|
||
const scrollParams = [0.25, 0.35, 0.65, 0.75] | ||
const opacityParams = [0, 1, 1, 0] | ||
const opacity = useTransform(scrollYProgress, scrollParams, opacityParams) | ||
|
||
return ( | ||
<motion.div | ||
className={css.slidingPanelContent} | ||
style={{ | ||
opacity: isMobile ? 1 : opacity, | ||
}} | ||
> | ||
<Typography className={css.title} variant="h1"> | ||
{title} | ||
</Typography> | ||
<DotGrid containerRef={containerRef} scrollYProgress={scrollYProgress} /> | ||
</motion.div> | ||
) | ||
} | ||
|
||
export default Content |
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.
You don't need this
title
class, do you?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.
I need it to apply
z-index
andpointer-events
properties. Will remove any font size attributes.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.
Addressed in 9f82803