it's crimis time

This commit is contained in:
2024-12-02 22:28:19 -05:00
parent bcbf12c4c4
commit 16b7a6b158
3 changed files with 81 additions and 0 deletions
+2
View File
@@ -1,5 +1,6 @@
import Header from "./Header"
import Footer from "./Footer"
import Snow from "./Snow"
export default function Layout({
children
@@ -9,6 +10,7 @@ export default function Layout({
return (
<main className="bg-black select-none text-white min-h-screen">
<Header />
<Snow />
{children}
<Footer />
</main>
+49
View File
@@ -0,0 +1,49 @@
import { useEffect, useState } from 'react';
import '../assets/snow.css';
type Snowflake = {
id: number;
left: number;
animationDuration: number;
opacity: number;
};
export default function Snow() {
const [snowflakes, setSnowflakes] = useState<Snowflake[]>([]);
useEffect(() => {
const createSnowflake = (): Snowflake => ({
id: Math.random(),
left: Math.random() * 100, // percentage across screen
animationDuration: 3 + Math.random() * 7, // between 3-10 seconds
opacity: 0.4 + Math.random() * 0.6, // between 0.4-1
});
// Create initial snowflakes
const initialSnowflakes = Array.from({ length: 50 }, createSnowflake);
setSnowflakes(initialSnowflakes);
// Add new snowflakes periodically
const interval = setInterval(() => {
setSnowflakes(prev => [...prev.slice(-49), createSnowflake()]);
}, 200);
return () => clearInterval(interval);
}, []);
return (
<div className="snow-container">
{snowflakes.map(flake => (
<div
key={flake.id}
className="snowflake"
style={{
left: `${flake.left}%`,
animationDuration: `${flake.animationDuration}s`,
opacity: flake.opacity,
}}
/>
))}
</div>
);
}