Skip to content

Added animation #252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"redux": "^5.0.1",
"rehype-katex": "^7.0.0",
"remark-math": "^6.0.0",
"styled-components": "^6.1.8"
"styled-components": "^6.1.8",
"vanilla-tilt": "^1.8.1"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.3.2",
Expand Down
40 changes: 35 additions & 5 deletions src/components/HomePage/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// skipcq: JS-W1028
import React from "react";
import React, { useEffect, useRef } from "react";
import "./header.css";
import Link from "@docusaurus/Link";
import Link from "@docusaurus/Link";
import VanillaTilt from "vanilla-tilt";

/**
* Renders the header component of the application.
Expand All @@ -13,7 +14,10 @@ const HeaderContent = () => {
<div className="chh__header-content">
<h1 className="gradient__text">Level Up Skills with CodeHarborHub</h1>
<p>
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.
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.
</p>

<div className="chh__header-content__input">
Expand All @@ -37,9 +41,35 @@ const HeaderContent = () => {
* @returns The header image element.
*/
const HeaderImage = () => {
const imgRef = useRef<HTMLImageElement>(null);

useEffect(() => {
if (imgRef.current) {
VanillaTilt.init(imgRef.current, {
max: 25,
speed: 400,
glare: true,
"max-glare": 0.5,
});
}

// Cleanup function to destroy VanillaTilt instance
return () => {
if (imgRef.current && imgRef.current.vanillaTilt) {
imgRef.current.vanillaTilt.destroy();
}
};
}, []);

return (
<div className="chh__header-image">
<img src="/img/hero-img.png" alt="ai" />
<img
src="/img/hero-img.png"
alt="ai"
className="float-animation"
data-tilt
ref={imgRef}
/>
</div>
);
};
Expand All @@ -59,4 +89,4 @@ const Header: React.FC = () => {
);
};

export default Header;
export default Header;
18 changes: 18 additions & 0 deletions src/components/HomePage/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -298,4 +298,22 @@
font-size: 12px;
line-height: 16px;
}
}

@keyframes float {
0% {
transform: translateY(0);
}

50% {
transform: translateY(-10px);
}

100% {
transform: translateY(0);
}
}

.float-animation {
animation: float 2s ease-in-out infinite;
}
Loading
Loading