Skip to content

Commit

Permalink
feat: side menu initialisation
Browse files Browse the repository at this point in the history
  • Loading branch information
ixahmedxi committed Jun 17, 2024
1 parent 4c9abf8 commit 282834d
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 2 deletions.
33 changes: 33 additions & 0 deletions src/app/(dashboard)/app/_components/active-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use client';

import { cn } from '@/lib/utils';
import { Button } from '@/primitives/button';
import Link from 'next/link';
import { usePathname } from 'next/navigation';
import type { ReactNode } from 'react';

interface Props {
href: string;
label: string;
icon: ReactNode;
}

export function ActiveButton({ href, label, icon }: Props) {
const pathname = usePathname();

return (
<Button
variant="ghost"
className={cn(
'w-full justify-start gap-3 font-normal text-foreground-muted hover:text-foreground',
pathname === href && 'text-foreground',
)}
asChild
>
<Link href={href}>
{icon}
{label}
</Link>
</Button>
);
}
62 changes: 62 additions & 0 deletions src/app/(dashboard)/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {
DiamondIcon,
HomeIcon,
ListChecksIcon,
PenLineIcon,
PuzzleIcon,
} from 'lucide-react';
import Image from 'next/image';
import type { PropsWithChildren } from 'react';
import { ActiveButton } from './_components/active-button';

const iconSize = 15;

const sideMenuStaticLinks = [
{
icon: <HomeIcon size={iconSize} />,
label: 'Home',
href: '/app',
},
{
icon: <PuzzleIcon size={iconSize} />,
label: 'Modules',
href: '/modules',
},
{
icon: <ListChecksIcon size={iconSize} />,
label: 'Tasks',
href: '/tasks',
},
{
icon: <PenLineIcon size={iconSize} />,
label: 'Notebooks',
href: '/notes',
},
{
icon: <DiamondIcon size={iconSize} />,
label: 'Flashcards',
href: '/flashcards',
},
];

export default function AppLayout({ children }: PropsWithChildren) {
return (
<main className="flex min-h-dvh gap-8 p-4">
<aside className="w-[220px]">
<div className="flex items-center gap-3 pl-3 pt-4">
<Image src="/logo.svg" width={35} height={35} alt="Noodle Logo" />
<span>Noodle</span>
</div>

<ul className="mt-8">
{sideMenuStaticLinks.map(({ icon, label, href }) => (
<li key={label}>
<ActiveButton icon={icon} label={label} href={href} />
</li>
))}
</ul>
</aside>
<div className="flex-1 rounded-lg border p-6">{children}</div>
</main>
);
}
4 changes: 2 additions & 2 deletions src/app/(dashboard)/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { SignOutButton } from '@clerk/nextjs';
*/
export default function DashboardHome() {
return (
<main>
<div>
<h1>Hello World</h1>
<SignOutButton />
</main>
</div>
);
}

0 comments on commit 282834d

Please sign in to comment.