11import { motion , useScroll , useTransform } from "framer-motion" ;
22import { Link } from "react-router-dom" ;
33import { ArrowRight , Play } from "lucide-react" ;
4- import { useRef } from "react" ;
4+ import { useRef , useMemo } from "react" ;
55import googleLogo from "../../assets/google.png" ;
6- import amazonLogo from "../../assets/amazon.png"
6+ import amazonLogo from "../../assets/amazon.png" ;
77import metaLogo from "../../assets/meta.svg" ;
88import uberLogo from "../../assets/uber.png" ;
99
1010const COMPANIES = [
11- { name : "Google" , logo : googleLogo } ,
12- { name : "Amazon" , logo :amazonLogo } ,
11+ { name : "Google" , logo : googleLogo } ,
12+ { name : "Amazon" , logo : amazonLogo } ,
1313 { name : "Meta" , logo : metaLogo } ,
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+ } , [ ] ) ;
30+
31+ return (
32+ < div className = "absolute inset-0 overflow-hidden pointer-events-none" >
33+ { stars . map ( ( star ) => (
34+ < motion . div
35+ key = { star . id }
36+ className = "absolute rounded-full bg-emerald-800/40 dark:bg-white"
37+ style = { {
38+ top : star . top ,
39+ left : star . left ,
40+ width : star . size ,
41+ height : star . size ,
42+ } }
43+ animate = { {
44+ opacity : [ 0.2 , 1 , 0.2 ] ,
45+ scale : [ 1 , 1.2 , 1 ] ,
46+ } }
47+ transition = { {
48+ duration : star . duration ,
49+ repeat : Infinity ,
50+ delay : star . delay ,
51+ ease : "easeInOut" ,
52+ } }
53+ />
54+ ) ) }
55+ </ div >
56+ ) ;
57+ }
58+
1759export function HeroSection ( ) {
1860 const ref = useRef ( null ) ;
1961 const { scrollYProgress } = useScroll ( {
@@ -28,13 +70,17 @@ export function HeroSection() {
2870 return (
2971 < 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" >
3072
73+ { /* Container de Background Animado (Grid + Estrelas) */ }
3174 < motion . div
3275 style = { { y : backgroundY } }
3376 className = "absolute inset-0 pointer-events-none w-full h-[150%]
3477 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)]
3578 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)]
3679 bg-[size:60px_60px]"
37- />
80+ >
81+ { /* Renderiza as estrelas dentro do container parallax do background */ }
82+ < StarsBackground />
83+ </ motion . div >
3884
3985 < div className = "absolute top-0 left-1/2 -translate-x-1/2 w-[800px] h-[600px] bg-emerald-100/30 dark:bg-emerald-950/15 blur-[120px] rounded-full pointer-events-none" />
4086
0 commit comments