Skip to content

Commit e442086

Browse files
committed
✅ Good looking sidenav
1 parent 118f530 commit e442086

File tree

7 files changed

+86
-31
lines changed

7 files changed

+86
-31
lines changed

app/(docs)/docs/layout.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import SideNav from '@/components/SideNav'
2+
import React from 'react'
3+
4+
export default function layout() {
5+
return (
6+
<div>
7+
<SideNav />
8+
layout</div>
9+
)
10+
}

app/(docs)/docs/page.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from 'react'
2+
3+
export default function page() {
4+
return (
5+
<div>page</div>
6+
)
7+
}

components/SideNav.tsx

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
1+
import { navConfig } from "@/config/navigation";
2+
import { H6 } from "@/packages/ui";
13
import Link from "next/link";
24

3-
const navItems = [
4-
{ title: "Getting Started", route: "/components" },
5-
{ title: "Accordions", route: "/components/accordions" },
6-
{ title: "Avatars", route: "/components/avatars" },
7-
// { title: "Badges", route: "/components/badges" },
8-
{ title: "Buttons", route: "/components/buttons" },
9-
{ title: "Cards", route: "/components/cards" },
10-
{ title: "Inputs", route: "/components/inputs" },
11-
{ title: "Textareas", route: "/components/textareas" },
12-
{ title: "Typography", route: "/components/typography" },
13-
];
14-
155
export default function SideNav() {
166
return (
177
<div
188
className={`fixed top-16 left-0 border-r-2 border-black h-full transition-transform transform md:translate-x-0 w-64 bg-white z-50`}
199
>
20-
<nav className="flex flex-col items-start p-6 space-y-2">
21-
{navItems.map((item) => (
22-
<Link key={item.route} href={item.route}>
23-
{item.title}
24-
</Link>
10+
<nav className="flex flex-col items-start p-6 space-y-4">
11+
{navConfig.sideNavItems.map((item) => (
12+
<div key={item.title}>
13+
<H6>{item.title}</H6>
14+
<div className="flex flex-col space-y-2">
15+
{item.children.map((child) => (
16+
<Link key={child.title} href={child.href}>
17+
{child.title}
18+
</Link>
19+
))}
20+
</div>
21+
</div>
2522
))}
2623
</nav>
2724
</div>

components/TopNav.tsx

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Link from "next/link";
33
import { GitBranchIcon, GithubIcon } from "lucide-react";
44
import HamburgerMenu from "./HamburgerMenu";
55
import { Button } from "@/packages/ui";
6+
import { navConfig } from "@/config/navigation";
67

78
export default function TopNav() {
89
return (
@@ -26,18 +27,15 @@ export default function TopNav() {
2627

2728
{/* Navigation Links */}
2829
<div className="hidden md:flex space-x-8">
29-
<a
30-
href="/components"
31-
className="hover:text-primary-500 transition-all"
32-
>
33-
Documentation
34-
</a>
35-
<a
36-
href="/components/buttons"
37-
className="hover:text-primary-500 transition-all"
38-
>
39-
Components
40-
</a>
30+
{navConfig.topNavItems.map((item) => (
31+
<Link
32+
key={item.title}
33+
href={item.href}
34+
className="hover:text-primary-500 transition-all"
35+
>
36+
{item.title}
37+
</Link>
38+
))}
4139
</div>
4240

4341
<div className="flex items-center space-x-4 lg:hidden">
@@ -46,7 +44,7 @@ export default function TopNav() {
4644
target="_blank"
4745
rel="noopener noreferrer"
4846
>
49-
<GithubIcon />
47+
<GithubIcon />
5048
</Link>
5149
<HamburgerMenu />
5250
</div>

config/navigation.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { INavigationConfig } from "@/types";
2+
3+
const componentsRoute = "/docs/components";
4+
5+
export const navConfig: INavigationConfig = {
6+
topNavItems: [
7+
{ title: "Documentation", href: "/docs" },
8+
{ title: "Components", href: `${componentsRoute}/button` },
9+
],
10+
sideNavItems: [
11+
{
12+
title: "Getting Started",
13+
children: [{ title: "Introduction", href: "/docs" }],
14+
},
15+
{
16+
title: "Components",
17+
children: [
18+
{ title: "Accordion", href: `${componentsRoute}/accordion` },
19+
{ title: "Avatar", href: `${componentsRoute}/avatar` },
20+
{ title: "Badge", href: `${componentsRoute}/badge` },
21+
{ title: "Button", href: `${componentsRoute}/button` },
22+
{ title: "Card", href: `${componentsRoute}/card` },
23+
{ title: "Input", href: `${componentsRoute}/input` },
24+
{ title: "Textarea", href: `${componentsRoute}/textarea` },
25+
{ title: "Typography", href: `${componentsRoute}/typography` },
26+
],
27+
},
28+
],
29+
};

packages/ui/Typography/H6.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { ReactNode } from "react";
22

33
export function H6({ children }: { children: ReactNode }) {
4-
return <h6 className="font-head text-lg font-medium">{children}</h6>;
4+
return <h6 className="font-head font-medium">{children}</h6>;
55
}

types/index.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
export interface INavItem {
2+
title: string;
3+
href: string;
4+
}
5+
6+
export interface INavItemWithChildren {
7+
title: string;
8+
children: INavItem[];
9+
}
10+
11+
export interface INavigationConfig {
12+
topNavItems: INavItem[];
13+
sideNavItems: INavItemWithChildren[];
14+
}

0 commit comments

Comments
 (0)