Skip to content

Commit 1897edd

Browse files
authored
Merge pull request #252 from harshmishra19/Add/animation
Added animation
2 parents c5efbcb + 9ee1e25 commit 1897edd

File tree

5 files changed

+563
-7
lines changed

5 files changed

+563
-7
lines changed

package-lock.json

Lines changed: 7 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@
5353
"redux": "^5.0.1",
5454
"rehype-katex": "^7.0.0",
5555
"remark-math": "^6.0.0",
56-
"styled-components": "^6.1.8"
56+
"styled-components": "^6.1.8",
57+
"vanilla-tilt": "^1.8.1"
5758
},
5859
"devDependencies": {
5960
"@docusaurus/module-type-aliases": "^3.3.2",

src/components/HomePage/Header.tsx

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
// skipcq: JS-W1028
2-
import React from "react";
2+
import React, { useEffect, useRef } from "react";
33
import "./header.css";
4-
import Link from "@docusaurus/Link";
4+
import Link from "@docusaurus/Link";
5+
import VanillaTilt from "vanilla-tilt";
56

67
/**
78
* Renders the header component of the application.
@@ -13,7 +14,10 @@ const HeaderContent = () => {
1314
<div className="chh__header-content">
1415
<h1 className="gradient__text">Level Up Skills with CodeHarborHub</h1>
1516
<p>
16-
Tired of limitations? CodeHarborHub shatters them. We&apos;re the exclusive platform offering a comprehensive tech curriculum, taught by industry masters, completely free. Join our vibrant community, master in-demand skills, and launch your dream tech career.
17+
Tired of limitations? CodeHarborHub shatters them. We&apos;re the
18+
exclusive platform offering a comprehensive tech curriculum, taught by
19+
industry masters, completely free. Join our vibrant community, master
20+
in-demand skills, and launch your dream tech career.
1721
</p>
1822

1923
<div className="chh__header-content__input">
@@ -37,9 +41,35 @@ const HeaderContent = () => {
3741
* @returns The header image element.
3842
*/
3943
const HeaderImage = () => {
44+
const imgRef = useRef<HTMLImageElement>(null);
45+
46+
useEffect(() => {
47+
if (imgRef.current) {
48+
VanillaTilt.init(imgRef.current, {
49+
max: 25,
50+
speed: 400,
51+
glare: true,
52+
"max-glare": 0.5,
53+
});
54+
}
55+
56+
// Cleanup function to destroy VanillaTilt instance
57+
return () => {
58+
if (imgRef.current && imgRef.current.vanillaTilt) {
59+
imgRef.current.vanillaTilt.destroy();
60+
}
61+
};
62+
}, []);
63+
4064
return (
4165
<div className="chh__header-image">
42-
<img src="/img/hero-img.png" alt="ai" />
66+
<img
67+
src="/img/hero-img.png"
68+
alt="ai"
69+
className="float-animation"
70+
data-tilt
71+
ref={imgRef}
72+
/>
4373
</div>
4474
);
4575
};
@@ -59,4 +89,4 @@ const Header: React.FC = () => {
5989
);
6090
};
6191

62-
export default Header;
92+
export default Header;

src/components/HomePage/header.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,4 +298,22 @@
298298
font-size: 12px;
299299
line-height: 16px;
300300
}
301+
}
302+
303+
@keyframes float {
304+
0% {
305+
transform: translateY(0);
306+
}
307+
308+
50% {
309+
transform: translateY(-10px);
310+
}
311+
312+
100% {
313+
transform: translateY(0);
314+
}
315+
}
316+
317+
.float-animation {
318+
animation: float 2s ease-in-out infinite;
301319
}

0 commit comments

Comments
 (0)