-
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.
Merge pull request #10 from skunichetty/frontpage-updates
Update frontpage
- Loading branch information
Showing
20 changed files
with
554 additions
and
353 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
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,69 @@ | ||
"use client"; | ||
import { useGSAP } from "@gsap/react"; | ||
import gsap from "gsap"; | ||
import { useEffect, useRef } from "react"; | ||
|
||
function generateNoise(width: number, height: number, opacity: number): string { | ||
const canvas = document.createElement("canvas"); | ||
canvas.width = width; | ||
canvas.height = height; | ||
const ctx = canvas.getContext("2d"); | ||
if (ctx) { | ||
const imageData = ctx.createImageData(width, height); | ||
const data = imageData.data; | ||
for (let i = 0; i < data.length; i += 4) { | ||
const value = Math.floor(Math.random() * 256); | ||
data[i] = value; | ||
data[i + 1] = value; | ||
data[i + 2] = value; | ||
data[i + 3] = Math.floor(opacity * 255); | ||
} | ||
ctx.putImageData(imageData, 0, 0); | ||
return canvas.toDataURL(); | ||
} | ||
return ""; | ||
} | ||
|
||
|
||
export default function Hero() { | ||
const hero = useRef<HTMLDivElement>(null); | ||
const heroContent = useRef<HTMLDivElement>(null); | ||
|
||
useGSAP(() => { | ||
gsap.fromTo( | ||
hero.current, | ||
{ xPercent: 100 }, | ||
{ | ||
opacity: 1, | ||
duration: 2, | ||
xPercent: 0, | ||
ease: "power1.out", | ||
} | ||
); | ||
gsap.to(heroContent.current, { | ||
opacity: 1, | ||
duration: 1, | ||
delay: 2.2, | ||
}); | ||
}); | ||
|
||
useEffect(() => { | ||
if (heroContent.current) { | ||
const noiseImage = generateNoise( | ||
heroContent.current.offsetWidth, | ||
heroContent.current.offsetHeight, | ||
0.02 | ||
); | ||
heroContent.current.style.backgroundImage = `url(${noiseImage})`; | ||
} | ||
}, []); | ||
|
||
return ( | ||
<div | ||
className="opacity-0 bg-gradient-to-l from-blue-500 text-center w-full sm:h-52 h-40 mt-5 relative" | ||
ref={hero} | ||
> | ||
<div ref={heroContent} className="opacity-0 w-full h-full"></div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.