mobile header
This commit is contained in:
@@ -1,25 +1,59 @@
|
||||
import { isMobile } from "react-device-detect";
|
||||
|
||||
import Button from "../Button";
|
||||
|
||||
interface AuthProps {
|
||||
isAuth: boolean;
|
||||
userName: string;
|
||||
}
|
||||
|
||||
const Auth = () => {
|
||||
const isAuth = false;
|
||||
const username = "Name";
|
||||
const userName = "Name";
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex gap-4 py-2 pr-6 text-black col-span-2 justify-end">
|
||||
{isAuth ? (
|
||||
<>
|
||||
<p>{username}</p>
|
||||
<div className="rounded-full w-10 h-10 bg-[#E2E2DC] overflow-clip">
|
||||
{/* <img src="" alt="avatar" className="bg-[#E2E2DC]" /> */}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<Button buttonType="cta" text="Login" />
|
||||
)}
|
||||
</div>
|
||||
{isMobile ? (
|
||||
<AuthMobile isAuth={isAuth} userName={userName} />
|
||||
) : (
|
||||
<AuthDesktop isAuth={isAuth} userName={userName} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const AuthMobile = ({ isAuth, userName }: AuthProps) => {
|
||||
return (
|
||||
<div className="flex gap-4 p-4 text-black justify-center w-full items-center">
|
||||
{isAuth ? (
|
||||
<>
|
||||
<p>{userName}</p>
|
||||
<div className="rounded-full w-10 h-10 bg-[#E2E2DC] overflow-clip">
|
||||
{/* <img src="" alt="avatar" className="bg-[#E2E2DC]" /> */}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<Button buttonType="cta" text="Login" className="w-full" />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const AuthDesktop = ({ isAuth, userName }: AuthProps) => {
|
||||
return (
|
||||
<div className="flex gap-4 py-2 pr-6 text-black col-span-2 justify-end">
|
||||
{isAuth ? (
|
||||
<>
|
||||
<p>{userName}</p>
|
||||
<div className="rounded-full w-10 h-10 bg-[#E2E2DC] overflow-clip">
|
||||
{/* <img src="" alt="avatar" className="bg-[#E2E2DC]" /> */}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<Button buttonType="cta" text="Login" />
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Auth;
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
import { Outlet } from "react-router-dom";
|
||||
import Logo from "./Logo";
|
||||
import Location from "./Location";
|
||||
import Auth from "./Auth";
|
||||
import Navbar from "./Navbar";
|
||||
import useModal from "../../store/useModal";
|
||||
|
||||
const Header = () => {
|
||||
const { modal } = useModal();
|
||||
return (
|
||||
<>
|
||||
{modal}
|
||||
<header className="bg-white w-full text-white grid grid-cols-6 text-sm">
|
||||
<div className="flex gap-4 col-span-2">
|
||||
<Logo />
|
||||
<Location />
|
||||
</div>
|
||||
<Navbar />
|
||||
<Auth />
|
||||
</header>
|
||||
<Outlet />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Header;
|
||||
@@ -0,0 +1,17 @@
|
||||
import Auth from "../Auth";
|
||||
import Logo from "../Logo";
|
||||
import Navbar from "../Navbar";
|
||||
import Location from "../Location";
|
||||
|
||||
const DesktopHeader = () => (
|
||||
<header className="bg-white w-full text-white sm:grid grid-cols-6 text-sm">
|
||||
<div className="flex gap-4 col-span-2">
|
||||
<Logo />
|
||||
<Location />
|
||||
</div>
|
||||
<Navbar />
|
||||
<Auth />
|
||||
</header>
|
||||
);
|
||||
|
||||
export default DesktopHeader;
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Outlet } from "react-router-dom";
|
||||
import { isMobile } from "react-device-detect";
|
||||
import useModal from "../../../store/useModal";
|
||||
import DesktopHeader from "./DesktopHeader";
|
||||
import MobileHeader from "./MobileHeader";
|
||||
|
||||
const Header = () => {
|
||||
const { modal } = useModal();
|
||||
return (
|
||||
<>
|
||||
{modal}
|
||||
{isMobile ? <MobileHeader /> : <DesktopHeader />}
|
||||
<Outlet />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default Header;
|
||||
@@ -0,0 +1,43 @@
|
||||
import { useState } from "react";
|
||||
import LogoIcon from "../../icons/LogoIcon";
|
||||
import Auth from "../Auth";
|
||||
import Navbar from "../Navbar";
|
||||
import Location from "../Location";
|
||||
|
||||
const MobileHeader = () => {
|
||||
const [isToggled, setIsToggled] = useState(false);
|
||||
|
||||
const handleOnToggleClick = () => {
|
||||
setIsToggled((prev) => !prev);
|
||||
};
|
||||
return (
|
||||
<header
|
||||
className={`bg-white w-full text-white flex flex-col text-sm items-center transition-[height] duration-500 ease-in-out absolute top-0 left-0 z-30 overflow-hidden ${
|
||||
isToggled ? "h-[472px]" : "h-14"
|
||||
}`}
|
||||
>
|
||||
<div className="flex justify-between w-full p-4">
|
||||
<div
|
||||
className={`text-[#0D1922] transition-opacity duration-500 ${
|
||||
isToggled ? "opacity-0" : "opacity-100"
|
||||
}`}
|
||||
>
|
||||
<LogoIcon />
|
||||
</div>
|
||||
<div className="bg-black w-6 h-6" onClick={handleOnToggleClick}></div>
|
||||
</div>
|
||||
<div className="flex flex-col justify-between h-full items-center w-full ">
|
||||
<div className="flex flex-col gap-4">
|
||||
<div className="text-[#0D1922] items-center">
|
||||
<LogoIcon />
|
||||
</div>
|
||||
<Location />
|
||||
</div>
|
||||
<Navbar />
|
||||
<Auth />
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
};
|
||||
|
||||
export default MobileHeader;
|
||||
@@ -2,7 +2,7 @@ import LocationIcon from "../icons/LocationIcon";
|
||||
|
||||
const Location = () => {
|
||||
return (
|
||||
<div className="text-[#73787C] flex gap-1 items-center">
|
||||
<div className="text-[#73787C] flex gap-1 items-center justify-center">
|
||||
<LocationIcon />
|
||||
<p className="">Dubai</p>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useState } from "react";
|
||||
import { isMobile } from "react-device-detect";
|
||||
import { Tab } from "../../types/tab";
|
||||
import NavbarTab from "./NavbarTab";
|
||||
|
||||
@@ -32,20 +33,47 @@ const Navbar = () => {
|
||||
};
|
||||
|
||||
return (
|
||||
<nav className="flex text-[#73787C] self-center col-span-2 justify-center">
|
||||
{tabs.map((tab) => (
|
||||
<NavbarTab
|
||||
key={tab.id}
|
||||
tab={tab}
|
||||
isSelected={selectedTab?.id === tab.id}
|
||||
onClick={onTabClick}
|
||||
/>
|
||||
// <button key={tab} className="px-4 py-[10px]">
|
||||
// {tab}
|
||||
// </button>
|
||||
))}
|
||||
</nav>
|
||||
<>
|
||||
{isMobile ? (
|
||||
<NavbarMobile selectedTab={selectedTab} onTabClick={onTabClick} />
|
||||
) : (
|
||||
<NavbarDesktop selectedTab={selectedTab} onTabClick={onTabClick} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
interface NavbarProps {
|
||||
selectedTab: Tab | null;
|
||||
onTabClick: (tab: Tab) => void;
|
||||
}
|
||||
|
||||
const NavbarDesktop = ({ selectedTab, onTabClick }: NavbarProps) => (
|
||||
<nav className={`text-[#73787C] self-center col-span-2 justify-center flex`}>
|
||||
{tabs.map((tab) => (
|
||||
<NavbarTab
|
||||
key={tab.id}
|
||||
tab={tab}
|
||||
isSelected={selectedTab?.id === tab.id}
|
||||
onClick={onTabClick}
|
||||
/>
|
||||
))}
|
||||
</nav>
|
||||
);
|
||||
|
||||
const NavbarMobile = ({ selectedTab, onTabClick }: NavbarProps) => (
|
||||
<nav
|
||||
className={`text-[#73787C] self-center justify-center flex w-full flex-col items-center`}
|
||||
>
|
||||
{tabs.map((tab) => (
|
||||
<NavbarTab
|
||||
key={tab.id}
|
||||
tab={tab}
|
||||
isSelected={selectedTab?.id === tab.id}
|
||||
onClick={onTabClick}
|
||||
/>
|
||||
))}
|
||||
</nav>
|
||||
);
|
||||
|
||||
export default Navbar;
|
||||
|
||||
@@ -9,7 +9,7 @@ interface NavbarTabProps {
|
||||
const NavbarTab = ({ tab, onClick, isSelected = false }: NavbarTabProps) => {
|
||||
return (
|
||||
<button
|
||||
className="px-4 text-[#73787C] hover:text-black relative"
|
||||
className="px-4 text-[#73787C] hover:text-black relative w-fit"
|
||||
onClick={() => onClick(tab)}
|
||||
>
|
||||
<div
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";
|
||||
import ImageMarker from "react-image-marker";
|
||||
import { MarkerComponentProps } from "react-image-marker";
|
||||
import { isMobile } from "react-device-detect";
|
||||
import Marker from "./Marker";
|
||||
import { markers } from "../../consts/markers";
|
||||
import useMarker from "../../store/useMarker";
|
||||
@@ -31,7 +32,9 @@ const Map = () => {
|
||||
// animationType: "easeOut",
|
||||
// }}
|
||||
>
|
||||
<TransformComponent wrapperClass="h-[calc(100vh-60px)]">
|
||||
<TransformComponent
|
||||
wrapperClass={`${isMobile ? "h-screen" : "h-[calc(100vh-60px)]"}`}
|
||||
>
|
||||
<ImageMarker
|
||||
src="images/Map.jpg"
|
||||
markers={imageMarkers}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
import ReactDOM from "react-dom/client";
|
||||
import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
||||
import Header from "./components/header/Header";
|
||||
import Header from "./components/header/Header/Header";
|
||||
import Main from "./pages/Main";
|
||||
import "./index.css";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user