@@ -18,6 +18,7 @@ import Stroke from '../../images/stroke.svg';
1818import Logo from '../../../public/lecode-logo.svg' ;
1919import {
2020 AnimatedLogo ,
21+ AnimatedLogoContainer ,
2122 Card ,
2223 CardDescription ,
2324 CardTitle ,
@@ -29,95 +30,29 @@ import {
2930 HeroGroupSecundaryImageRight ,
3031 HeroImage ,
3132 ImagesContainer ,
32- LogoContainer ,
3333 RectangleWithGreenStroke ,
3434 SectionContainer ,
3535 SpanWithStroke ,
3636 Title ,
3737 TitleContainer ,
3838} from './styles' ;
3939
40- const AnimatedImage = motion ( Image ) ;
41- const AnimatedGroupImageLeft = motion ( HeroGroupImageLeft ) ;
42- const AnimatedGroupSecundaryImageLeft = motion ( HeroGroupSecundaryImageLeft ) ;
43- const AnimatedGroupImageRight = motion ( HeroGroupImageRight ) ;
44- const AnimatedGroupSecundaryImageRight = motion ( HeroGroupSecundaryImageRight ) ;
45-
46- const logoContainerVariants = {
47- initial : { opacity : 1 } ,
48- animate : { opacity : 0 , transition : { duration : 0.5 } } ,
49- } ;
50-
51- const logoVariants = {
52- initial : {
53- opacity : 0 ,
54- y : 0 ,
55- } ,
56- fadeIn : {
57- opacity : 1 ,
58- transition : { duration : 1 , ease : 'easeInOut' } ,
59- } ,
60- animate : {
61- opacity : 1 ,
62- width : '9.28125rem' , // 148.5px
63- height : '5.22069rem' , // 83.5px
64- y : '-7.125rem' , // -114px
65- transition : { duration : 0.5 } ,
66- } ,
67- } ;
68-
69- const titleContainerVariants = {
70- hidden : { opacity : 0 } ,
71- visible : { opacity : 1 , transition : { duration : 1 } } ,
72- } ;
73-
74- const strokeVariants = {
75- hidden : { opacity : 0 } ,
76- visible : { opacity : 1 , transition : { duration : 0.8 } } ,
77- } ;
78-
79- const titleVariants = {
80- hidden : { y : 100 , opacity : 1 } ,
81- visible : { y : 0 , opacity : 1 , transition : { duration : 1 } } ,
82- } ;
83-
84- const imagesContainerVariants = {
85- hidden : { y : 200 , opacity : 0 } ,
86- visible : { y : 0 , opacity : 1 , transition : { duration : 1 } } ,
87- } ;
88-
89- const cardsContainerVariants = {
90- hidden : { y : 200 , opacity : 0 } ,
91- visible : { y : 0 , opacity : 1 , transition : { duration : 1 } } ,
92- } ;
93-
94- const groupImageLeftVariants = {
95- hidden : { x : 200 , y : 100 , opacity : 0 } ,
96- visible : { x : 0 , y : 0 , opacity : 1 , transition : { duration : 0.5 } } ,
97- } ;
98-
99- const groupSecundaryImageLeftVariants = {
100- hidden : { x : 200 , y : 100 , opacity : 0 } ,
101- visible : { x : 0 , y : 0 , opacity : 1 , transition : { duration : 0.5 } } ,
102- } ;
103-
104- const groupImageRightVariants = {
105- hidden : { x : - 200 , y : 100 , opacity : 0 } ,
106- visible : { x : 0 , y : 0 , opacity : 1 , transition : { duration : 0.5 } } ,
107- } ;
108-
109- const groupSecundaryImageRightVariants = {
110- hidden : { x : - 200 , y : 100 , opacity : 0 } ,
111- visible : { x : 0 , y : 0 , opacity : 1 , transition : { duration : 0.5 } } ,
112- } ;
113-
114-
115- export const HeroSection = ( ) => {
40+ export const HeroSection = ( ) => {
11641 const { t, i18n } = useTranslation ( ) ;
11742 const currentLanguage = i18n . language ;
11843
11944 const [ isLogoVisible , setIsLogoVisible ] = useState ( true ) ;
12045
46+ const [ isSmallScreen , setIsSmallScreen ] = useState ( false ) ;
47+
48+ const [ headerPosition , setHeaderPosition ] = useState ( { top : 0 , left : 0 , width : 0 } ) ;
49+
50+ const AnimatedImage = motion ( Image ) ;
51+ const AnimatedGroupImageLeft = motion ( HeroGroupImageLeft ) ;
52+ const AnimatedGroupSecundaryImageLeft = motion ( HeroGroupSecundaryImageLeft ) ;
53+ const AnimatedGroupImageRight = motion ( HeroGroupImageRight ) ;
54+ const AnimatedGroupSecundaryImageRight = motion ( HeroGroupSecundaryImageRight ) ;
55+
12156 const logoContainerControls = useAnimation ( ) ;
12257 const logoControls = useAnimation ( ) ;
12358 const titleContainerControls = useAnimation ( ) ;
@@ -130,6 +65,88 @@ export const HeroSection = () =>{
13065 const groupImageRightControls = useAnimation ( ) ;
13166 const groupSecundaryImageRightControls = useAnimation ( ) ;
13267
68+ useEffect ( ( ) => {
69+ const handleResize = ( ) => {
70+ const header = document . querySelector ( 'header' ) ;
71+ if ( header ) {
72+ const rect = header . getBoundingClientRect ( ) ;
73+ setHeaderPosition ( { top : rect . top , left : rect . left , width : rect . width } ) ;
74+ }
75+ setIsSmallScreen ( window . innerWidth <= 768 ) ;
76+ } ;
77+
78+ handleResize ( ) ;
79+ window . addEventListener ( 'resize' , handleResize ) ;
80+ return ( ) => {
81+ window . removeEventListener ( 'resize' , handleResize ) ;
82+ } ;
83+ } , [ ] ) ;
84+
85+ const logoContainerVariants = {
86+ initial : { opacity : 1 , zIndex : 1000 } ,
87+ animate : { opacity : 0 , zIndex : 0 , transition : { duration : 0.5 } } ,
88+ } ;
89+
90+ const logoVariants = {
91+ initial : { opacity : 0 , x : 0 , y : 0 , scale : 4 } ,
92+ fadeIn : {
93+ opacity : 1 ,
94+ transition : { duration : 1 , ease : 'easeInOut' } ,
95+ } ,
96+ animate : {
97+ opacity : 0 ,
98+ x : isSmallScreen ? - window . innerWidth / 2 + 100 : ( headerPosition . left + headerPosition . width / 2 - window . innerWidth / 2 ) + 10 ,
99+ y : isSmallScreen ? headerPosition . top - window . innerHeight / 2 + 33 : headerPosition . top - window . innerHeight / 2 + 55 ,
100+ scale : 1 ,
101+ transition : { duration : 1 } ,
102+ } ,
103+ } ;
104+
105+ const titleContainerVariants = {
106+ hidden : { opacity : 0 } ,
107+ visible : { opacity : 1 , transition : { duration : 1 } } ,
108+ } ;
109+
110+ const strokeVariants = {
111+ hidden : { opacity : 0 } ,
112+ visible : { opacity : 1 , transition : { duration : 0.8 } } ,
113+ } ;
114+
115+ const titleVariants = {
116+ hidden : { y : 100 , opacity : 1 } ,
117+ visible : { y : 0 , opacity : 1 , transition : { duration : 1 } } ,
118+ } ;
119+
120+ const imagesContainerVariants = {
121+ hidden : { y : 200 , opacity : 0 } ,
122+ visible : { y : 0 , opacity : 1 , transition : { duration : 1 } } ,
123+ } ;
124+
125+ const cardsContainerVariants = {
126+ hidden : { y : 200 , opacity : 0 } ,
127+ visible : { y : 0 , opacity : 1 , transition : { duration : 1 } } ,
128+ } ;
129+
130+ const groupImageLeftVariants = {
131+ hidden : { x : 200 , y : 100 , opacity : 0 } ,
132+ visible : { x : 0 , y : 0 , opacity : 1 , transition : { duration : 0.5 } } ,
133+ } ;
134+
135+ const groupSecundaryImageLeftVariants = {
136+ hidden : { x : 200 , y : 100 , opacity : 0 } ,
137+ visible : { x : 0 , y : 0 , opacity : 1 , transition : { duration : 0.5 } } ,
138+ } ;
139+
140+ const groupImageRightVariants = {
141+ hidden : { x : - 200 , y : 100 , opacity : 0 } ,
142+ visible : { x : 0 , y : 0 , opacity : 1 , transition : { duration : 0.5 } } ,
143+ } ;
144+
145+ const groupSecundaryImageRightVariants = {
146+ hidden : { x : - 200 , y : 100 , opacity : 0 } ,
147+ visible : { x : 0 , y : 0 , opacity : 1 , transition : { duration : 0.5 } } ,
148+ } ;
149+
133150 useEffect ( ( ) => {
134151 async function sequence ( ) {
135152 await logoControls . start ( 'fadeIn' ) ; // Fase de fadeIn do logo
@@ -150,7 +167,6 @@ export const HeroSection = () =>{
150167 groupSecundaryImageRightControls . start ( 'visible' ) , // Animação da imagem do grupo secundário à direita
151168 ] ) ;
152169 }
153-
154170 sequence ( ) ;
155171 } , [
156172 logoContainerControls ,
@@ -169,7 +185,8 @@ export const HeroSection = () =>{
169185 return (
170186 < Container id = 'about' >
171187 < SectionContainer >
172- { isLogoVisible ? < LogoContainer
188+ { isLogoVisible ? (
189+ < AnimatedLogoContainer
173190 initial = 'initial'
174191 animate = { logoContainerControls }
175192 variants = { logoContainerVariants }
@@ -181,7 +198,8 @@ export const HeroSection = () =>{
181198 animate = { logoControls }
182199 variants = { logoVariants }
183200 />
184- </ LogoContainer > : null }
201+ </ AnimatedLogoContainer >
202+ ) : null }
185203 < TitleContainer
186204 as = { motion . div }
187205 initial = 'hidden'
0 commit comments