Skip to content

Commit 3e592f6

Browse files
fix: fix responsive of navbar
1 parent a868b0a commit 3e592f6

File tree

4 files changed

+33
-29
lines changed

4 files changed

+33
-29
lines changed

src/assets/images/close.svg

Lines changed: 1 addition & 1 deletion
Loading

src/assets/images/menu.svg

Lines changed: 1 addition & 1 deletion
Loading

src/assets/styles/index.css

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
@import "@fontsource/poppins/900.css";
66
@import "@fontsource/league-gothic";
77

8-
98
/* Reset default browser styles */
109
* {
1110
margin: 0;

src/components/Navbar/index.jsx

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,46 +10,51 @@ function Navbar({ links }) {
1010
const location = useLocation();
1111

1212
return (
13-
<nav className=" shadow-md w-full flex justify-between items-center px-6 bg-secondary-dark">
14-
<Link to="/" className="cursor-pointer">
15-
<img src={Logo} alt="logo" />
16-
</Link>
17-
13+
<nav
14+
className={`shadow-md w-full flex xs:flex-col md:flex-row ${isOpen ? "xs:h-screen" : ""} md:h-full justify-between items-center px-6 bg-secondary-dark`}
15+
>
16+
<div className="flex flex-row justify-between xs:w-full md:w-auto items-center">
17+
<Link to="/" className="cursor-pointer">
18+
<img src={Logo} className="w-[10rem]" alt="logo" />
19+
</Link>
20+
<button
21+
type="button"
22+
onClick={() => setIsOpen(!isOpen)}
23+
className="w-7 h-7 text-white cursor-pointer md:hidden"
24+
>
25+
{isOpen ? (
26+
<img src={closeIcon} alt="close" />
27+
) : (
28+
<img src={menuIcon} alt="menu" />
29+
)}
30+
</button>
31+
</div>
1832
<ul
1933
className={`
20-
md:flex pl-0 justify-start md:justify-center md:items-center md:pb-0 md:z-auto left-0
21-
transition-all duration-500 ease-in
22-
${isOpen ? "flex flex-col " : "hidden"}
34+
md:flex pl-0 justify-start md:justify-center md:items-center md:pb-0 md:z-auto left-0 xs:justify-center xs:gap-y-12
35+
${isOpen ? "flex flex-col grow" : "hidden"}
2336
`}
2437
>
2538
{links.map((link) => (
2639
<li
2740
key={link.name}
2841
className={`
29-
font-semibold text-white md:my-0 md:ml-8
30-
border-b-2
31-
${
32-
location.pathname .toLowerCase().includes(link.path.toLowerCase())
33-
? "border-red-500 hover:border-red-700"
34-
: "border-transparent hover:border-red-500"
35-
}
42+
group font-regular text-white md:my-0 md:ml-8 transition-all hover:text-primary
3643
`}
3744
>
3845
<Link to={link.path}>{link.name}</Link>
46+
<span
47+
class={`block group-hover:max-w-full transition-all duration-500 h-0.5 bg-primary rounded ${
48+
location.pathname
49+
.toLowerCase()
50+
.includes(link.path.toLowerCase())
51+
? "w-full"
52+
: "max-w-0"
53+
}`}
54+
></span>
3955
</li>
4056
))}
4157
</ul>
42-
<button
43-
type="button"
44-
onClick={() => setIsOpen(!isOpen)}
45-
className="w-7 h-7 text-white cursor-pointer md:hidden"
46-
>
47-
{isOpen ? (
48-
<img src={closeIcon} alt="close" />
49-
) : (
50-
<img src={menuIcon} alt="menu" />
51-
)}
52-
</button>
5358
</nav>
5459
);
5560
}

0 commit comments

Comments
 (0)