forked from ourworld_web/www_engage_os
feat: add animated grid background with randomly activating cells in AboutSolutions
This commit is contained in:
@@ -1,38 +1,56 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
export function AboutSolutions() {
|
export function AboutSolutions() {
|
||||||
|
const totalCells = 2000;
|
||||||
|
const [active, setActive] = useState<number[]>([]);
|
||||||
|
|
||||||
|
// randomly activate some squares every 0.8 s
|
||||||
|
useEffect(() => {
|
||||||
|
const interval = setInterval(() => {
|
||||||
|
const newActive = Array.from({ length: 20 }, () =>
|
||||||
|
Math.floor(Math.random() * totalCells)
|
||||||
|
);
|
||||||
|
setActive(newActive);
|
||||||
|
}, 800);
|
||||||
|
return () => clearInterval(interval);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section
|
<section
|
||||||
className="relative bg-[#121212] text-gray-200 overflow-hidden"
|
className="relative bg-[#121212] text-gray-200 overflow-hidden"
|
||||||
style={{
|
style={
|
||||||
"--cell": "4rem",
|
{
|
||||||
height: "74vh",
|
"--cell": "4rem",
|
||||||
} as React.CSSProperties}
|
height: "74vh",
|
||||||
|
} as React.CSSProperties
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{/* Square grid background */}
|
{/* Animated grid background */}
|
||||||
<div
|
<div
|
||||||
className="absolute inset-0 z-0 grid"
|
className="absolute inset-0 z-0 grid"
|
||||||
style={{
|
style={{
|
||||||
gridTemplateColumns: "repeat(auto-fill, var(--cell))",
|
gridTemplateColumns: "repeat(auto-fill, var(--cell))",
|
||||||
gridAutoRows: "var(--cell)",
|
gridAutoRows: "var(--cell)",
|
||||||
justifyContent: "center", // ✅ centers grid horizontally
|
justifyContent: "center",
|
||||||
}}
|
}}
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
>
|
>
|
||||||
{Array.from({ length: 2000 }).map((_, i) => (
|
{Array.from({ length: totalCells }).map((_, i) => (
|
||||||
<div
|
<div
|
||||||
key={i}
|
key={i}
|
||||||
className="border border-[#1f1f1f] hover:bg-[#00FFD1] transition-colors duration-300 cursor-pointer"
|
className={`border border-[#1f1f1f] transition-colors duration-500 cursor-pointer ${
|
||||||
|
active.includes(i) ? "bg-[#00FFD1]" : "bg-transparent"
|
||||||
|
}`}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Foreground content aligned to the same grid */}
|
{/* Foreground content aligned to same grid */}
|
||||||
<div
|
<div
|
||||||
className="relative z-10 grid grid-cols-[repeat(auto-fill,var(--cell))] auto-rows-[var(--cell)] gap-0 pointer-events-none w-full h-full"
|
className="relative z-10 grid grid-cols-[repeat(auto-fill,var(--cell))] auto-rows-[var(--cell)] gap-0 pointer-events-none w-full h-full"
|
||||||
style={{
|
style={{ justifyContent: "center" }}
|
||||||
justifyContent: "center", // ✅ centers foreground grid too
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{/* Top-left card */}
|
{/* Top-left card */}
|
||||||
<div className="col-start-2 row-start-2 col-span-5 row-span-3 pointer-events-auto">
|
<div className="col-start-2 row-start-2 col-span-5 row-span-3 pointer-events-auto">
|
||||||
|
|||||||
Reference in New Issue
Block a user