fix(mobile): match portfolio menu design with blog drawer, fix dark mode logo, sync drawer slide direction with button
Deploy Frontend / deploy (push) Successful in 1m22s
Deploy Frontend / deploy (push) Successful in 1m22s
This commit is contained in:
1 parent
de6597a6fd
commit
24bd9c3c4a
3 files changed
+154
-65
No files matched your search
@@ -1,22 +1,57 @@
|
||||
import { useRouter } from "next/navigation";
|
||||
import { Dictionary } from "@/app/types/types";
|
||||
import Link from "next/link";
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useEffect, useState } from "react";
|
||||
import { createPortal } from "react-dom";
|
||||
import {
|
||||
X,
|
||||
Globe,
|
||||
Home,
|
||||
User,
|
||||
Wrench,
|
||||
Layers,
|
||||
MessageSquareQuote,
|
||||
Mail,
|
||||
BookOpen,
|
||||
FileDown,
|
||||
} from "lucide-react";
|
||||
|
||||
import { Dictionary } from "@/app/types/types";
|
||||
import {
|
||||
setSelectedLocale,
|
||||
useSelectedLocale,
|
||||
} from "@/app/lib/hooks/use-selected-locale";
|
||||
import { ThemeToggle } from "../theme-toggle/theme-toggle";
|
||||
|
||||
type propsType = {
|
||||
type PropsType = {
|
||||
clicked: boolean;
|
||||
setClicked: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
dict: Dictionary;
|
||||
};
|
||||
|
||||
export default function MobileMenu({ clicked, setClicked, dict }: propsType) {
|
||||
export default function MobileMenu({ clicked, setClicked, dict }: PropsType) {
|
||||
const [mounted, setMounted] = useState(false);
|
||||
const router = useRouter();
|
||||
const selectedLocale = useSelectedLocale();
|
||||
const isRTL = selectedLocale === "fa";
|
||||
|
||||
useEffect(() => {
|
||||
setMounted(true);
|
||||
}, []);
|
||||
|
||||
// Prevent background scrolling when mobile menu is open
|
||||
useEffect(() => {
|
||||
if (clicked) {
|
||||
document.body.style.overflow = "hidden";
|
||||
} else {
|
||||
document.body.style.overflow = "";
|
||||
}
|
||||
return () => {
|
||||
document.body.style.overflow = "";
|
||||
};
|
||||
}, [clicked]);
|
||||
|
||||
const handleLocaleChange = (locale: "fa" | "en") => {
|
||||
setSelectedLocale(locale);
|
||||
@@ -31,71 +66,117 @@ export default function MobileMenu({ clicked, setClicked, dict }: propsType) {
|
||||
|
||||
const closeMenu = () => setClicked(false);
|
||||
|
||||
const navClassName =
|
||||
"block w-full whitespace-nowrap px-4 py-3 text-lg font-medium text-white transition-colors hover:bg-white/20 hover:text-white";
|
||||
|
||||
const navLinks = [
|
||||
{ href: "/#home", label: dict.website.homePage.nav.home },
|
||||
{ href: "/#about-me", label: dict.website.homePage.nav.aboutMe },
|
||||
{ href: "/#services", label: dict.website.homePage.nav.services },
|
||||
{ href: "/#projects", label: dict.website.homePage.nav.projects },
|
||||
{ href: "/#testimonials", label: dict.website.homePage.nav.testimonials },
|
||||
{ href: "/#contact", label: dict.website.homePage.nav.contact },
|
||||
{ href: "/#home", label: dict.website.homePage.nav.home, icon: Home },
|
||||
{ href: "/#about-me", label: dict.website.homePage.nav.aboutMe, icon: User },
|
||||
{ href: "/#services", label: dict.website.homePage.nav.services, icon: Wrench },
|
||||
{ href: "/#projects", label: dict.website.homePage.nav.projects, icon: Layers },
|
||||
{
|
||||
href: "/#testimonials",
|
||||
label: dict.website.homePage.nav.testimonials,
|
||||
icon: MessageSquareQuote,
|
||||
},
|
||||
{ href: "/#contact", label: dict.website.homePage.nav.contact, icon: Mail },
|
||||
{ href: "/blog", label: dict.website.homePage.nav.blog, icon: BookOpen },
|
||||
];
|
||||
|
||||
return (
|
||||
<div className="flex">
|
||||
if (!mounted) return null;
|
||||
|
||||
const content = (
|
||||
<div className="lg:hidden" dir={isRTL ? "rtl" : "ltr"}>
|
||||
{/* Full viewport Backdrop */}
|
||||
<div
|
||||
className={`${clicked ? "fixed end-0" : "end-[-1000px] hidden"} top-0 z-[60] flex h-full w-full lg:hidden`}
|
||||
style={{ backgroundColor: "rgba(2, 6, 23, 0.85)", backdropFilter: "blur(4px)", zIndex: 60 }}
|
||||
className={`fixed inset-0 z-[9998] bg-black/80 backdrop-blur-sm transition-opacity duration-300 ${
|
||||
clicked ? "opacity-100 pointer-events-auto" : "opacity-0 pointer-events-none"
|
||||
}`}
|
||||
onClick={closeMenu}
|
||||
></div>
|
||||
aria-hidden="true"
|
||||
/>
|
||||
|
||||
{/* Full Height Solid Drawer - slides from the same side as the burger button */}
|
||||
<div
|
||||
className={`fixed start-0 top-0 z-[70] flex h-full w-[250px] select-none flex-col items-start ${clicked ? "start-0" : "start-[-260px]"} mobile-menu lg:start-[-260px]`}
|
||||
style={{ backgroundColor: "#fd6f00", zIndex: 70 }}
|
||||
className={`fixed top-0 bottom-0 end-0 z-[9999] flex h-[100dvh] w-[300px] max-w-[85vw] flex-col justify-between border-s border-white/10 bg-zinc-900 dark:bg-zinc-950 text-white shadow-2xl transition-transform duration-300 ease-out overflow-y-auto ${
|
||||
clicked
|
||||
? "translate-x-0"
|
||||
: isRTL
|
||||
? "-translate-x-full"
|
||||
: "translate-x-full"
|
||||
}`}
|
||||
>
|
||||
<div className="z-50 flex w-full flex-wrap items-center justify-start bg-white px-3 py-6">
|
||||
<div className="flex w-[50px]">
|
||||
<img src={"/images/logo.svg"} className="w-full" alt="logo" />
|
||||
</div>
|
||||
<p className="ms-2 text-[20px] font-[900] capitalize text-[#FD6F00] sm:text-[23px] xl:ms-3 xl:text-[30px]">
|
||||
{dict.website.header.Name}
|
||||
</p>
|
||||
</div>
|
||||
<nav className="mt-5 flex w-full flex-col">
|
||||
{navLinks.map(({ href, label }) => (
|
||||
<Link
|
||||
key={href}
|
||||
href={href}
|
||||
className={navClassName}
|
||||
onClick={closeMenu}
|
||||
>
|
||||
{label}
|
||||
{/* Header */}
|
||||
<div>
|
||||
<div className="flex items-center justify-between border-b border-white/10 px-5 py-4">
|
||||
<Link href="/" onClick={closeMenu} className="flex items-center gap-3">
|
||||
<div className="flex h-9 w-9 items-center justify-center rounded-xl bg-primary/20 p-1.5 border border-primary/30">
|
||||
<Image
|
||||
src="/images/logo.svg"
|
||||
width={24}
|
||||
height={24}
|
||||
alt="logo"
|
||||
className="w-full h-full object-contain"
|
||||
/>
|
||||
</div>
|
||||
<span className="text-base font-bold text-white tracking-wide">
|
||||
{dict.website.header.Name}
|
||||
</span>
|
||||
</Link>
|
||||
))}
|
||||
<Link
|
||||
href="/blog"
|
||||
className={navClassName}
|
||||
<button
|
||||
onClick={closeMenu}
|
||||
aria-label="Close menu"
|
||||
className="flex h-9 w-9 items-center justify-center rounded-lg text-zinc-400 transition-colors hover:bg-white/10 hover:text-white"
|
||||
>
|
||||
<X className="h-5 w-5" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Navigation Links */}
|
||||
<nav className="flex flex-col gap-1 p-3">
|
||||
{navLinks.map((link) => {
|
||||
const Icon = link.icon;
|
||||
return (
|
||||
<Link
|
||||
key={link.href}
|
||||
href={link.href}
|
||||
onClick={closeMenu}
|
||||
className="flex items-center gap-3 rounded-xl px-4 py-3 text-sm font-medium text-zinc-300 transition-all hover:bg-white/10 hover:text-white"
|
||||
>
|
||||
<Icon className="h-4 w-4 text-primary" />
|
||||
<span>{link.label}</span>
|
||||
</Link>
|
||||
);
|
||||
})}
|
||||
</nav>
|
||||
</div>
|
||||
|
||||
{/* Footer Area with CV, Theme, and Language */}
|
||||
<div className="border-t border-white/10 p-4 space-y-3 bg-zinc-950/40">
|
||||
<a
|
||||
href="/Parsa Aghayi CV Resume.pdf"
|
||||
download
|
||||
target="_blank"
|
||||
onClick={closeMenu}
|
||||
className="flex items-center justify-center gap-2 w-full rounded-xl bg-primary hover:bg-primary/90 px-4 py-2.5 text-xs font-semibold text-primary-foreground shadow-md transition-all active:scale-95"
|
||||
>
|
||||
{dict.website.homePage.nav.blog}
|
||||
</Link>
|
||||
</nav>
|
||||
<Link
|
||||
href="#"
|
||||
className={navClassName}
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
handleLocaleChange(selectedLocale === "fa" ? "en" : "fa");
|
||||
}}
|
||||
>
|
||||
{selectedLocale === "fa" ? "English" : "فارسی"}
|
||||
</Link>
|
||||
<div className="flex items-center justify-between w-full px-4 py-3 border-t border-white/20 mt-2 text-white">
|
||||
<span className="text-sm font-medium">{selectedLocale === "fa" ? "تغییر تم (تیره / روشن)" : "Switch Theme"}</span>
|
||||
<ThemeToggle />
|
||||
<FileDown className="h-4 w-4" />
|
||||
<span>{dict?.website.header.Button || "دانلود رزومه (CV)"}</span>
|
||||
</a>
|
||||
|
||||
<div className="flex items-center justify-between w-full rounded-xl border border-white/10 bg-white/5 px-3 py-2 text-xs font-medium text-white">
|
||||
<span>{isRTL ? "حالت تم (تیره / روشن)" : "Theme Mode"}</span>
|
||||
<ThemeToggle />
|
||||
</div>
|
||||
|
||||
<button
|
||||
onClick={() => handleLocaleChange(selectedLocale === "fa" ? "en" : "fa")}
|
||||
className="flex items-center justify-center gap-2 w-full rounded-xl border border-white/10 bg-white/5 hover:bg-white/10 py-2.5 text-xs font-medium text-white transition-all"
|
||||
>
|
||||
<Globe className="h-4 w-4 text-primary" />
|
||||
<span>{selectedLocale === "fa" ? "English Version" : "نسخه فارسی"}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return createPortal(content, document.body);
|
||||
}
|
||||
@@ -24,9 +24,17 @@ export default async function Header() {
|
||||
<Link href={"/blog"}>
|
||||
<div className="relative h-[30px] w-[150px] lg:h-[45px] lg:w-[225px]">
|
||||
<Image
|
||||
src={"/images/blog/logo/logo-no-background.png"}
|
||||
src="/images/blog/logo/logo-white.png"
|
||||
fill
|
||||
alt="parsaaghayi's blog logo"
|
||||
className="hidden dark:block object-contain"
|
||||
priority
|
||||
/>
|
||||
<Image
|
||||
src="/images/blog/logo/logo-black.png"
|
||||
fill
|
||||
alt="parsaaghayi's blog logo"
|
||||
className="block dark:hidden object-contain"
|
||||
priority
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -108,21 +108,21 @@ export default function MobileMenu({ clicked, setClicked }: PropsType) {
|
||||
|
||||
{/* Full Height Solid Drawer */}
|
||||
<div
|
||||
className={`fixed top-0 bottom-0 start-0 z-[9999] flex h-[100dvh] w-[300px] max-w-[85vw] flex-col justify-between border-e border-border/80 bg-zinc-900 dark:bg-zinc-950 text-white shadow-2xl transition-transform duration-300 ease-out overflow-y-auto ${
|
||||
className={`fixed top-0 bottom-0 end-0 z-[9999] flex h-[100dvh] w-[300px] max-w-[85vw] flex-col justify-between border-s border-white/10 bg-zinc-900 dark:bg-zinc-950 text-white shadow-2xl transition-transform duration-300 ease-out overflow-y-auto ${
|
||||
clicked
|
||||
? "translate-x-0"
|
||||
: isRTL
|
||||
? "translate-x-full"
|
||||
: "-translate-x-full"
|
||||
? "-translate-x-full"
|
||||
: "translate-x-full"
|
||||
}`}
|
||||
>
|
||||
{/* Header */}
|
||||
<div>
|
||||
<div className="flex items-center justify-between border-b border-white/10 px-5 py-4">
|
||||
<Link href="/blog" onClick={closeMenu} className="flex items-center">
|
||||
<div className="relative h-[32px] w-[140px] brightness-0 invert transition-all">
|
||||
<div className="relative h-[32px] w-[140px]">
|
||||
<Image
|
||||
src="/images/blog/logo/logo-no-background.png"
|
||||
src="/images/blog/logo/logo-white.png"
|
||||
fill
|
||||
alt="parsaaghayi blog"
|
||||
className="object-contain"
|
||||
|
||||
Reference in new issue
Block a user