1
- import React , { useState } from "react" ;
1
+ import React , { useState , useEffect } from "react" ;
2
2
import { Link , useNavigate } from "react-router-dom" ;
3
3
import { useAuth } from "../middleware/AuthContext" ;
4
4
import ThemeToggle from "./ThemeToggle" ;
5
+ import gsap from 'gsap'
6
+ import { tl } from './gsap.js'
5
7
6
8
const Header = ( ) => {
7
9
const [ isOpen , setIsOpen ] = useState ( false ) ;
8
10
const { user, logout } = useAuth ( ) ;
9
11
const navigate = useNavigate ( ) ;
10
12
13
+ //gsap starts
14
+ useEffect ( ( ) => {
15
+ const ctx = gsap . context ( ( ) => {
16
+ tl . fromTo ( '.navGsap' ,
17
+ {
18
+ y : - 100 , // Starting position (from)
19
+ opacity : 0 , // Starting opacity (from)
20
+ } ,
21
+ {
22
+ y : 0 , // Ending position (to)
23
+ opacity : 1 , // Ending opacity (to)
24
+ duration : 0.5 , // Animation duration
25
+ ease : "sine.in" , // Easing function
26
+ stagger : 0.1 ,
27
+
28
+ }
29
+ ) ;
30
+ } ) ;
31
+
32
+ return ( ) => ctx . revert ( ) ; // Cleanup when the component unmounts
33
+ } , [ ] ) ;
34
+
35
+ //gsap ends
36
+
37
+
38
+
11
39
const handleLogout = ( ) => {
12
40
logout ( ) ;
13
41
navigate ( "/login" ) ;
@@ -17,8 +45,8 @@ const Header = () => {
17
45
< header className = "bg-black text-white shadow-lg" >
18
46
< div className = "container mx-auto flex justify-between items-center px-6 py-4" >
19
47
{ /* Logo */ }
20
- < div >
21
- < a href = "/" className = "text-xl font-bold text-white" >
48
+ < div className = "navGsap" >
49
+ < a href = "/" className = " text-xl font-bold text-white" >
22
50
MCA Alumni Network
23
51
</ a >
24
52
</ div >
@@ -27,25 +55,25 @@ const Header = () => {
27
55
< nav className = "hidden md:flex space-x-4 lg:space-x-6 text-base font-medium" >
28
56
< Link
29
57
to = "/"
30
- className = "relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
58
+ className = "navGsap relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
31
59
>
32
60
Home
33
61
</ Link >
34
62
< Link
35
63
to = "/about-us"
36
- className = "relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
64
+ className = "navGsap relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
37
65
>
38
66
About Us
39
67
</ Link >
40
68
< Link
41
69
to = "/alumni"
42
- className = "relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
70
+ className = "navGsap relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
43
71
>
44
72
Our Alumni
45
73
</ Link >
46
74
< Link
47
75
to = "/contact-us"
48
- className = "relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
76
+ className = "navGsap relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
49
77
>
50
78
Contact Us
51
79
</ Link >
@@ -55,13 +83,13 @@ const Header = () => {
55
83
< >
56
84
< Link
57
85
to = "/user/dashboard"
58
- className = "relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
86
+ className = "navGsap relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
59
87
>
60
88
Dashboard
61
89
</ Link >
62
90
< button
63
91
onClick = { handleLogout }
64
- className = "relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
92
+ className = "navGsap relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
65
93
>
66
94
Logout
67
95
</ button >
@@ -70,13 +98,13 @@ const Header = () => {
70
98
< >
71
99
< Link
72
100
to = "/register"
73
- className = "relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
101
+ className = "navGsap relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
74
102
>
75
103
Register as Alumni
76
104
</ Link >
77
105
< Link
78
106
to = "/login"
79
- className = "relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
107
+ className = "navGsap relative text-white px-3 py-2 rounded-lg hover:text-gray-300 transition duration-300 ease-in-out hover:scale-110"
80
108
>
81
109
Log In
82
110
</ Link >
0 commit comments