fix(mobile): strictly align drawer slide direction with button side and make header RTL aware
Deploy Frontend / deploy (push) Successful in 1m20s
Deploy Frontend / deploy (push) Successful in 1m20s
This commit is contained in:
1 parent
24bd9c3c4a
commit
5400fd360a
4 files changed
+21
-16
No files matched your search
@@ -8,12 +8,14 @@ import { ThemeToggle } from "../theme-toggle/theme-toggle";
|
||||
import { getCookie } from "cookies-next";
|
||||
import { getDictionary } from "@/app/lib/functions/dictionaries";
|
||||
import { Dictionary } from "@/app/types/types";
|
||||
import { useSelectedLocale } from "@/app/lib/hooks/use-selected-locale";
|
||||
|
||||
export default function Header() {
|
||||
const [dict, setDict] = useState<Dictionary | null>(null);
|
||||
const [scrolled, setScrolled] = useState(false);
|
||||
|
||||
const selectedLocale = getCookie("selectedLocale") || getCookie("defaultLocale") || "en";
|
||||
const selectedLocale = useSelectedLocale();
|
||||
const isRTL = selectedLocale === "fa";
|
||||
|
||||
useEffect(() => {
|
||||
const loadDict = async () => {
|
||||
@@ -44,6 +46,7 @@ export default function Header() {
|
||||
|
||||
return (
|
||||
<header
|
||||
dir={isRTL ? "rtl" : "ltr"}
|
||||
className={`fixed top-0 left-0 z-50 flex h-20 w-full items-center justify-between px-6 py-4 transition-all duration-300 xl:px-12 ${
|
||||
scrolled
|
||||
? "backdrop-blur-md bg-background/80 border-b border-border shadow-sm"
|
||||
|
||||
@@ -95,12 +95,10 @@ export default function MobileMenu({ clicked, setClicked, dict }: PropsType) {
|
||||
|
||||
{/* Full Height Solid Drawer - slides from the same side as the burger button */}
|
||||
<div
|
||||
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"
|
||||
className={`fixed top-0 bottom-0 z-[9999] flex h-[100dvh] w-[300px] max-w-[85vw] flex-col justify-between bg-zinc-900 dark:bg-zinc-950 text-white shadow-2xl transition-transform duration-300 ease-out overflow-y-auto ${
|
||||
isRTL
|
||||
? `left-0 border-r border-white/10 ${clicked ? "translate-x-0" : "-translate-x-full"}`
|
||||
: `right-0 border-l border-white/10 ${clicked ? "translate-x-0" : "translate-x-full"}`
|
||||
}`}
|
||||
>
|
||||
{/* Header */}
|
||||
|
||||
@@ -11,7 +11,10 @@ import { getDictionary } from "@/app/lib/functions/dictionaries";
|
||||
import { getDefaultLocale } from "@/app/lib/functions/utils";
|
||||
|
||||
export default async function Header() {
|
||||
const dict = await getDictionary(await getDefaultLocale());
|
||||
const cookieStore = await cookies();
|
||||
const currentLocale = cookieStore.get("selectedLocale")?.value || (await getDefaultLocale());
|
||||
const isRTL = currentLocale === "fa";
|
||||
const dict = await getDictionary(currentLocale as "en" | "fa");
|
||||
const subscribeLabels = {
|
||||
buttonTitle: dict.blog.header.button,
|
||||
trigger: dict.blog.header.button,
|
||||
@@ -19,7 +22,10 @@ export default async function Header() {
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="fixed z-50 flex w-full items-center justify-center bg-blog-background/90 dark:bg-zinc-950/90 backdrop-blur-md py-6 transition-colors duration-300 border-b border-border/40">
|
||||
<header
|
||||
dir={isRTL ? "rtl" : "ltr"}
|
||||
className="fixed z-50 flex w-full items-center justify-center bg-blog-background/90 dark:bg-zinc-950/90 backdrop-blur-md py-6 transition-colors duration-300 border-b border-border/40"
|
||||
>
|
||||
<div className="top-10 flex w-[1280px] items-center justify-between px-4">
|
||||
<Link href={"/blog"}>
|
||||
<div className="relative h-[30px] w-[150px] lg:h-[45px] lg:w-[225px]">
|
||||
@@ -53,6 +59,6 @@ export default async function Header() {
|
||||
<BurgerButton />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
);
|
||||
}
|
||||
@@ -108,12 +108,10 @@ export default function MobileMenu({ clicked, setClicked }: PropsType) {
|
||||
|
||||
{/* Full Height Solid Drawer */}
|
||||
<div
|
||||
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"
|
||||
className={`fixed top-0 bottom-0 z-[9999] flex h-[100dvh] w-[300px] max-w-[85vw] flex-col justify-between bg-zinc-900 dark:bg-zinc-950 text-white shadow-2xl transition-transform duration-300 ease-out overflow-y-auto ${
|
||||
isRTL
|
||||
? `left-0 border-r border-white/10 ${clicked ? "translate-x-0" : "-translate-x-full"}`
|
||||
: `right-0 border-l border-white/10 ${clicked ? "translate-x-0" : "translate-x-full"}`
|
||||
}`}
|
||||
>
|
||||
{/* Header */}
|
||||
|
||||
Reference in new issue
Block a user