Skip to content
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

Design fixes #42

Merged
merged 3 commits into from
Dec 1, 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
4 changes: 3 additions & 1 deletion src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,6 @@
--chart-5: 340 75% 55%;
}
}

html {
scroll-behavior: smooth;
}
3 changes: 2 additions & 1 deletion src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ import Lottie from "react-lottie-player";
import { IContact } from "@/interfaces/IContacts";
import { getReachUs } from "@/services/reachus.service";
import RegistrationStatus from "@/components/ui/google-gemini-effect";
import BackToTopButton from "@/components/ui/back-to-top";
import CodeEvelPara from "@/components/ui/code-evel-para";
import { HeroVideo } from "@/components/ui/hero-video";

export const products = [
{
title: "Are You Ready?",
Expand Down Expand Up @@ -303,6 +303,7 @@ export default function Home() {

return (
<RootLayout>
<BackToTopButton />
<FloatingNav navItems={navItms} />
{ ( !isLoadingAnimComplete ) && (
<div className="fixed inset-0 z-50 flex items-center justify-center bg-white dark:bg-[#545576]">
Expand Down
49 changes: 49 additions & 0 deletions src/components/ui/back-to-top.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React, { useState, useEffect } from 'react';
import { ArrowUpIcon } from '@heroicons/react/24/solid';

const BackToTopButton: React.FC = () => {
const [isVisible, setIsVisible] = useState<boolean>(false);

// Show button when page is scrolled up to given distance
const toggleVisibility = () => {
if (window.pageYOffset > 300) {
setIsVisible(true);
} else {
setIsVisible(false);
}
};

// Scroll to top when button is clicked
const scrollToTop = () => {
window.scrollTo({
top: 0,
behavior: 'smooth'
});
};

useEffect(() => {
// Add scroll event listener
window.addEventListener('scroll', toggleVisibility);

// Clean up the event listener
return () => {
window.removeEventListener('scroll', toggleVisibility);
};
}, []);

return (
<>
{isVisible && (
<button
onClick={scrollToTop}
className="fixed bottom-6 right-6 z-50 bg-gray-700 text-white p-3 rounded-full shadow-lg hover:bg-gray-900 transition-all duration-300 ease-in-out"
aria-label="Scroll to top"
>
<ArrowUpIcon className="h-6 w-6" />
</button>
)}
</>
);
};

export default BackToTopButton;
Loading