forked from guilhermerodz/input-otp
-
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
1 parent
1f2d88f
commit 8160411
Showing
8 changed files
with
247 additions
and
60 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,5 @@ | ||
import Fireworks from 'react-canvas-confetti/dist/presets/fireworks' | ||
|
||
export function Confetti() { | ||
return <Fireworks autorun={{ speed: 1 }} /> | ||
} |
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,45 @@ | ||
import React, { useCallback, useRef } from 'react' | ||
import ReactCanvasConfetti from 'react-canvas-confetti' | ||
|
||
function randomInRange(min: number, max: number) { | ||
return Math.random() * (max - min) + min | ||
} | ||
|
||
const canvasStyles: React.CSSProperties = { | ||
zIndex: 9999, | ||
position: 'fixed', | ||
pointerEvents: 'none', | ||
width: '100%', | ||
height: '100%', | ||
top: 0, | ||
left: 0, | ||
} | ||
|
||
function getAnimationSettings(originXA: number, originXB: number) { | ||
return { | ||
startVelocity: 30, | ||
spread: 360, | ||
ticks: 60, | ||
zIndex: 0, | ||
particleCount: 150, | ||
origin: { | ||
x: randomInRange(originXA, originXB), | ||
y: Math.random() - 0.2, | ||
}, | ||
} | ||
} | ||
|
||
export default function Confetti() { | ||
const done = useRef(false) | ||
|
||
const getInstance = useCallback((fire: any) => { | ||
if (fire && !done.current) { | ||
fire(getAnimationSettings(0.1, 0.3)) | ||
fire(getAnimationSettings(0.7, 0.9)) | ||
|
||
done.current = true | ||
} | ||
}, []) | ||
|
||
return <ReactCanvasConfetti refConfetti={getInstance} style={canvasStyles} /> | ||
} |
154 changes: 101 additions & 53 deletions
154
website/src/app/(pages)/(home)/_components/showcase.tsx
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.