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

Added a preloader #164

Closed
wants to merge 5 commits into from
Closed
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
2 changes: 2 additions & 0 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import "../styles/global.css";
import {NextAuthProvider} from "../app/provider"
import Navbar from "@/components/Navbar/page";
import Footer from "@/components/Footer/page";
import Preloader from "@/components/Preloader/page";

const inter = Inter({ subsets: ["latin"] });

Expand All @@ -21,6 +22,7 @@ export default function RootLayout({
<html lang="en">
<NextAuthProvider>
<body className={inter.className}>
<Preloader/>
<Navbar />
{children}
<Footer />
Expand Down
39 changes: 15 additions & 24 deletions src/components/Navbar/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import Link from 'next/link'
import React from 'react'
import LoginButton from '../LoginButton/page'
// import { MenuIcon } from 'lucide-react'
import { RxHamburgerMenu } from "react-icons/rx";
import { RxCross1 } from "react-icons/rx";
import { MenuIcon } from 'lucide-react'

const Navbar = () => {
const [state, setState] = React.useState(false)
Expand All @@ -16,46 +14,39 @@ const Navbar = () => {
{ title: "Contact Us", path: "/ContactSection" },
]
return (
<nav className="sticky top-0 z-99 bg-white w-full border-b-3 border-b-[#151d2c] border-2">
<nav className="bg-white w-full border-b md:border-0">
<div className="items-center px-4 max-w-screen-xl mx-auto md:flex md:justify-between md:px-8">
<div className="flex items-center justify-between py-3 md:py-5 md:block">
<Link href="/">
<h1 className="text-3xl font-bold text-primary">OpenZone</h1>
</Link>
<div className="md:hidden mr-3">
<div className="md:hidden">
<button
className="text-gray-700 outline-none p-2 rounded-md focus:border-gray-400 focus:border"
onClick={() => setState(!state)}
>
{state?<RxCross1 />:<RxHamburgerMenu/>}
<MenuIcon />
</button>
</div>
</div>

<div
className={` pb-3 gap-2 mt-8 md:block md:pb-0 max-md:mt-0 md:mt-0 ${state ? "block absolute z-20 bg-white w-full p-0 left-0 mt-0" : "hidden"
className={` pb-3 mt-8 md:block md:pb-0 md:mt-0 ${state ? "block" : "hidden"
}`}
>
<div className="flex flex-col md:flex-row justify-center items-center space-y-8 md:space-x-8 md:space-y-0 pb-3 md:pb-0 md:mt-0">
<ul className="flex flex-col md:flex-row justify-center items-center md:space-y-0 md:space-x-6">
{menus.map((item, idx) => (
<li
key={idx}
className="text-gray-600 text-center transition ease-in-out duration-300 hover:text-indigo-600 hover:bg-slate-200 px-4 py-2 rounded-lg"
>
<Link href={item.path}>{item.title}</Link>
</li>
))}
</ul>
<div className="py-2 px-5 bg-black text-white rounded-md transition ease-in-out duration-200 hover:bg-slate-700">
<LoginButton />
</div>
</div>
<ul className="justify-center items-center space-y-8 md:flex md:space-x-6 md:space-y-0">
{menus.map((item, idx) => (
<li key={idx} className="text-gray-600 hover:transition hover:text-indigo-600 hover:bg-slate-200 hover:p-2 duration-300 ease-in-out rounded-lg">
<Link href={item.path}>{item.title}</Link>
</li>
))}

<li className='py-2 px-5 bg-black text-white rounded hover:transition duration-200 ease hover:bg-slate-700'><LoginButton /></li>
</ul>
</div>
</div>
</nav>
)
}

export default Navbar
export default Navbar;
26 changes: 26 additions & 0 deletions src/components/Preloader/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"use client";
import React, { useState, useEffect } from 'react';

const Preloader: React.FC = () => {
const [isVisible, setIsVisible] = useState(true);

useEffect(() => {
const timer = setTimeout(() => {
setIsVisible(false);
}, 2500);

return () => clearTimeout(timer);
}, []);

return (
<>
{isVisible && (
<div className="fixed inset-0 flex justify-center items-center bg-white z-50">
<div className="animate-spin rounded-full h-20 w-20 border-t-2 border-b-2 border-blue-900"></div>
</div>
)}
</>
);
};

export default Preloader;