Skip to content

Commit 3d25e9e

Browse files
committed
math.radom for the random
1 parent 7c86e97 commit 3d25e9e

1 file changed

Lines changed: 15 additions & 19 deletions

File tree

frontend/src/components/landing/HeroSection.tsx

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { motion, useScroll, useTransform } from "framer-motion";
22
import { Link } from "react-router-dom";
33
import { ArrowRight, Play } from "lucide-react";
4-
import { useRef, useMemo } from "react";
4+
import { useRef } from "react";
55
import googleLogo from "../../assets/google.png";
66
import amazonLogo from "../../assets/amazon.png";
77
import metaLogo from "../../assets/meta.svg";
@@ -14,23 +14,22 @@ const COMPANIES = [
1414
{ name: "Uber", logo: uberLogo },
1515
];
1616

17-
// Componente Interno para gerar as estrelas de forma otimizada
18-
function StarsBackground() {
19-
// Gera posições aleatórias fixas para evitar recalculado a cada render
20-
const stars = useMemo(() => {
21-
return Array.from({ length: 80 }).map((_, i) => ({
22-
id: i,
23-
top: `${Math.random() * 100}%`,
24-
left: `${Math.random() * 100}%`,
25-
size: Math.random() * 2 + 1, // Tamanhos entre 1px e 3px
26-
delay: Math.random() * 5,
27-
duration: Math.random() * 4 + 2,
28-
}));
29-
}, []);
17+
const STATIC_STARS = Array.from({ length: 80 }).map((_, i) => {
18+
const random = (min: number, max: number) => Math.random() * (max - min) + min;
19+
return {
20+
id: i,
21+
top: `${random(0, 100)}%`,
22+
left: `${random(0, 100)}%`,
23+
size: random(1, 3),
24+
delay: random(0, 5),
25+
duration: random(2, 6),
26+
};
27+
});
3028

29+
function StarsBackground() {
3130
return (
3231
<div className="absolute inset-0 overflow-hidden pointer-events-none">
33-
{stars.map((star) => (
32+
{STATIC_STARS.map((star) => (
3433
<motion.div
3534
key={star.id}
3635
className="absolute rounded-full bg-emerald-800/40 dark:bg-white"
@@ -69,16 +68,13 @@ export function HeroSection() {
6968

7069
return (
7170
<section ref={ref} className="relative min-h-[90vh] flex flex-col items-center justify-start pt-16 md:pt-24 pb-0 overflow-hidden bg-transparent font-sans">
72-
73-
{/* Container de Background Animado (Grid + Estrelas) */}
7471
<motion.div
7572
style={{ y: backgroundY }}
7673
className="absolute inset-0 pointer-events-none w-full h-[150%]
7774
bg-[linear-gradient(to_right,rgba(0,0,0,0.04)_1px,transparent_1px),linear-gradient(to_bottom,rgba(0,0,0,0.04)_1px,transparent_1px)]
7875
dark:bg-[linear-gradient(to_right,rgba(255,255,255,0.02)_1px,transparent_1px),linear-gradient(to_bottom,rgba(255,255,255,0.02)_1px,transparent_1px)]
7976
bg-[size:60px_60px]"
8077
>
81-
{/* Renderiza as estrelas dentro do container parallax do background */}
8278
<StarsBackground />
8379
</motion.div>
8480

@@ -140,7 +136,7 @@ export function HeroSection() {
140136
</motion.div>
141137

142138
<div className="w-full bg-[#10b981] dark:bg-emerald-800 py-8 md:py-10 relative z-20 overflow-hidden flex flex-col items-center border-y border-emerald-400/20 dark:border-emerald-900/30">
143-
<p className="text-center dark:text-white text-sm font-medium uppercase tracking-wider mb-6 w-full px-6">
139+
<p className="text-center dark:text-white text-sm font-medium uppercase tracking-wider mb-6 w-full px-6">
144140
Usado por profissionais que passaram em empresas como :
145141
</p>
146142
<div className="w-full flex overflow-hidden select-none">

0 commit comments

Comments
 (0)