From 6018a2235a4982ee0f8d1b6fe05b67def681b5a1 Mon Sep 17 00:00:00 2001 From: Zhenya Goroh Date: Tue, 8 Oct 2024 21:23:27 +0300 Subject: [PATCH] Refactored mobile-nav component --- src/components/mobile-nav.tsx | 70 +++++++++++++++++++---------------- src/components/navigation.tsx | 4 ++ 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/components/mobile-nav.tsx b/src/components/mobile-nav.tsx index e57f764..9332546 100644 --- a/src/components/mobile-nav.tsx +++ b/src/components/mobile-nav.tsx @@ -12,6 +12,37 @@ import Logo from "./logo"; import { ny } from "@/lib/utils"; import { components } from "./navigation"; +interface MobileLinkProps + extends React.AnchorHTMLAttributes { + onOpenChange?: (open: boolean) => void; + children: React.ReactNode; + className?: string; + href: string; +} + +function MobileLink({ + href, + onOpenChange, + className, + children, + ...props +}: MobileLinkProps) { + const router = useRouter(); + return ( + { + router.push(href); + onOpenChange?.(false); + }} + className={ny(className, "my-4")} + {...props} + > + {children} + + ); +} + export function MobileNav() { const [open, setOpen] = React.useState(false); @@ -60,12 +91,18 @@ export function MobileNav() {
Donate {"<"}3

Support the project

- {components.map(({ title, href, description }) => ( - + {components.map(({ title, href, description, isTargetBlank }) => ( +
{title}

{description}

@@ -76,32 +113,3 @@ export function MobileNav() { ); } - -interface MobileLinkProps extends LinkProps { - onOpenChange?: (open: boolean) => void; - children: React.ReactNode; - className?: string; -} - -function MobileLink({ - href, - onOpenChange, - className, - children, - ...props -}: MobileLinkProps) { - const router = useRouter(); - return ( - { - router.push(href.toString()); - onOpenChange?.(false); - }} - className={ny(className, "my-4")} - {...props} - > - {children} - - ); -} diff --git a/src/components/navigation.tsx b/src/components/navigation.tsx index c532e02..236f147 100644 --- a/src/components/navigation.tsx +++ b/src/components/navigation.tsx @@ -21,6 +21,7 @@ export const components: { title: string; href: string; description: string; + isTargetBlank?: boolean; }[] = [ { title: "Privacy Policy", @@ -33,12 +34,14 @@ export const components: { href: "https://discord.gg/zen-browser", description: "Join our Discord server to chat with the community and get support.", + isTargetBlank: true, }, { title: "Source Code", href: "https://github.com/zen-browser", description: "View the source code on GitHub and contribute to the project.", + isTargetBlank: true, }, { title: "Branding Assets", @@ -55,6 +58,7 @@ export const components: { title: "Documentation", href: "https://docs.zen-browser.app/", description: "Read the documentation to learn more about Zen Browser.", + isTargetBlank: true, }, ];