Skip to content

Commit

Permalink
πŸ› fix: pR 리뷰 반영 μ½”λ“œ μˆ˜μ •
Browse files Browse the repository at this point in the history
  • Loading branch information
froggy1014 committed Jul 24, 2024
1 parent 549d4e0 commit c676c16
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 26 deletions.
27 changes: 3 additions & 24 deletions src/layout/Mobile/MobileBottomNavBar.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"use client";

import * as NM from "@radix-ui/react-navigation-menu";
import NextLink, { LinkProps } from "next/link";
import { usePathname } from "next/navigation";

import NavLink from "./MobileBottomNavLink";

const navigations = [
{ name: "ν™ˆ", slug: "/" },
Expand All @@ -12,32 +10,13 @@ const navigations = [
{ name: "내정보", slug: "/mypage" },
];

const Link = ({
href,
...props
}: LinkProps & { children: React.ReactNode }) => {
const pathname = usePathname();
const isActive = href === pathname;

return (
<NM.Link asChild active={isActive}>
<NextLink
href={href}
prefetch
className={` ${isActive ? "text-red-600" : ""}`}
{...props}
/>
</NM.Link>
);
};

const MobileBottomNavBar = () => {
return (
<NM.Root className="items-between fixed bottom-0 flex min-h-btm-nav-bar w-full max-w-screen-m-lg flex-col justify-center bg-slate-400 px-4">
<NM.List className="flex h-full w-full items-center justify-between">
{navigations.map((nav) => (
<NM.Item key={nav.name}>
<Link href={nav.slug}>{nav.name}</Link>
<NavLink href={nav.slug}>{nav.name}</NavLink>
</NM.Item>
))}
</NM.List>
Expand Down
26 changes: 26 additions & 0 deletions src/layout/Mobile/MobileBottomNavLink.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
"use client";

import * as NM from "@radix-ui/react-navigation-menu";
import NextLink, { LinkProps } from "next/link";
import { usePathname } from "next/navigation";

const NavLink = ({
href,
...props
}: LinkProps & { children: React.ReactNode }) => {
const pathname = usePathname();
const isActive = href === pathname;

return (
<NM.Link asChild active={isActive}>
<NextLink
href={href}
prefetch
className={` ${isActive ? "text-red-600" : ""}`}
{...props}
/>
</NM.Link>
);
};

export default NavLink;
2 changes: 0 additions & 2 deletions src/layout/Mobile/MobileLayout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from "react";

import MobileBottomNavBar from "./MobileBottomNavBar";

const MobileLayout = ({ children }: { children: React.ReactNode }) => {
Expand Down

0 comments on commit c676c16

Please sign in to comment.