Skip to content

Commit

Permalink
feat(ui): redo!
Browse files Browse the repository at this point in the history
  • Loading branch information
not-ani committed Aug 22, 2024
1 parent 9d62e20 commit 5eb0553
Show file tree
Hide file tree
Showing 27 changed files with 813 additions and 174 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
"use client";

import React, { memo } from "react";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { ChartArea, House, Settings, User, Workflow } from "lucide-react";

import { Tooltip, TooltipContent, TooltipTrigger } from "@amaxa/ui/tooltip";

export const Sidebar = memo(({ id, name }: { id: string; name: string }) => {
const pathname = usePathname();

console.log(pathname);
return (
<div>
<aside className="fixed inset-y-0 left-0 z-10 hidden w-14 flex-col border-r bg-muted/40 sm:flex">
<nav className="flex flex-col items-center gap-4 px-2 sm:py-4">
<Link
href="/"
className={`group ${
pathname === "/"
? "text-accent-foreground"
: "text-muted-foreground"
} flex h-9 w-9 shrink-0 items-center justify-center gap-2 rounded-full bg-primary text-lg font-semibold md:h-8 md:w-8 md:text-base`}
>
<House className="h-5 w-5" />
<span className="sr-only">{name}</span>
</Link>
<Tooltip>
<TooltipTrigger asChild>
<Link
href={`/project/${id}/`}
className={`flex h-9 w-9 items-center justify-center rounded-lg
${
pathname === `/project/${id}`
? "text-accent-foreground"
: "text-muted-foreground"
}
transition-colors hover:text-foreground md:h-8 md:w-8`}
>
<ChartArea className="h-5 w-5" />
<span className="sr-only">Dashboard</span>
</Link>
</TooltipTrigger>
<TooltipContent side="right">Dashboard</TooltipContent>
</Tooltip>

<Tooltip>
<TooltipTrigger asChild>
<Link
href={`/project/${id}/tasks`}
className={`flex h-9 w-9 items-center justify-center rounded-lg ${
pathname === `/project/${id}/tasks`
? "text-accent-foreground"
: "text-muted-foreground"
} transition-colors hover:text-foreground md:h-8 md:w-8`}
>
<Workflow className="h-5 w-5" />
<span className="sr-only">Tasks</span>
</Link>
</TooltipTrigger>
<TooltipContent side="right">Tasks</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Link
href={`/project/${id}/permissions`}
className={`flex h-9 w-9 items-center justify-center ${
pathname === `/project/${id}/permissions`
? "text-accent-foreground"
: "text-muted-foreground"
} rounded-lg transition-colors hover:text-foreground md:h-8 md:w-8`}
>
<User className="h-5 w-5 " />
<span className="sr-only">Users</span>
</Link>
</TooltipTrigger>
<TooltipContent side="right">Users</TooltipContent>
</Tooltip>
</nav>
<nav className="mt-auto flex flex-col items-center gap-4 px-2 sm:py-4">
<Tooltip>
<TooltipTrigger asChild>
<Link
href={`/project/${id}/settings`}
className={`flex h-9 w-9 items-center justify-center rounded-lg
${
pathname.includes("settings")
? "text-accent-foreground"
: "text-muted-foreground"
}
transition-colors hover:text-foreground md:h-8 md:w-8`}
>
<Settings className="h-5 w-5" />
<span className="sr-only">Settings</span>
</Link>
</TooltipTrigger>
<TooltipContent side="right">Settings</TooltipContent>
</Tooltip>
</nav>
</aside>
</div>
);
});
82 changes: 7 additions & 75 deletions apps/nextjs/src/app/(dashboard)/project/[id]/(root)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import React, { cache } from "react";
import Link from "next/link";
import { notFound } from "next/navigation";
import {
ChartArea,
House,
Search,
Settings,
User,
Workflow,
} from "lucide-react";
import { Search } from "lucide-react";

import { db } from "@amaxa/db/client";
import {
Expand All @@ -20,14 +13,15 @@ import {
BreadcrumbSeparator,
} from "@amaxa/ui/breadcrumb";
import { Input } from "@amaxa/ui/input";
import { Tooltip, TooltipContent, TooltipTrigger } from "@amaxa/ui/tooltip";

import ComingSoon from "~/components/ComingSoon";
import { UserMenu } from "~/components/UserMenu";
import GetLastBreadCrumb from "./_components/LastItem";
import { Sidebar } from "./_components/sidebar";

const getProjectInfo = cache(async () => {
const getProjectInfo = cache(async (id: string) => {
const data = await db.query.Projects.findFirst({
where: (Project, { eq }) => eq(Project.id, id),
columns: {
name: true,
id: true,
Expand All @@ -46,78 +40,16 @@ export default async function Layout({
};
}) {
const { id } = params;
const data = await getProjectInfo();
const data = await getProjectInfo(id);

if (!data) {
return notFound();
}

return (
<div className="flex min-h-screen w-full flex-col ">
<aside className="fixed inset-y-0 left-0 z-10 hidden w-14 flex-col border-r bg-background sm:flex">
<nav className="flex flex-col items-center gap-4 px-2 sm:py-4">
<Link
href="/"
className="group flex h-9 w-9 shrink-0 items-center justify-center gap-2 rounded-full bg-primary text-lg font-semibold text-primary-foreground md:h-8 md:w-8 md:text-base"
>
<House className="h-5 w-5" />
<span className="sr-only">{data.name}</span>
</Link>
<Tooltip>
<TooltipTrigger asChild>
<Link
href={`/project/${id}/`}
className="flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground md:h-8 md:w-8"
>
<ChartArea className="h-5 w-5" />
<span className="sr-only">Dashboard</span>
</Link>
</TooltipTrigger>
<TooltipContent side="right">Dashboard</TooltipContent>
</Tooltip>

<Tooltip>
<TooltipTrigger asChild>
<Link
href={`/project/${id}/tasks`}
className="flex h-9 w-9 items-center justify-center rounded-lg text-accent-foreground transition-colors hover:text-foreground md:h-8 md:w-8"
>
<Workflow className="h-5 w-5 bg-gray-100" />
<span className="sr-only">Tasks</span>
</Link>
</TooltipTrigger>
<TooltipContent side="right">Tasks</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Link
href={`/project/${id}/permissions`}
className="flex h-9 w-9 items-center justify-center rounded-lg text-accent-foreground transition-colors hover:text-foreground md:h-8 md:w-8"
>
<User className="h-5 w-5 bg-gray-100" />
<span className="sr-only">Users</span>
</Link>
</TooltipTrigger>
<TooltipContent side="right">Users</TooltipContent>
</Tooltip>
</nav>
<nav className="mt-auto flex flex-col items-center gap-4 px-2 sm:py-4">
<Tooltip>
<TooltipTrigger asChild>
<Link
href="#"
className="flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground md:h-8 md:w-8"
>
<Settings className="h-5 w-5" />
<span className="sr-only">Settings</span>
</Link>
</TooltipTrigger>
<TooltipContent side="right">Settings</TooltipContent>
</Tooltip>
</nav>
</aside>

<div className="flex flex-col sm:gap-4 sm:py-4 sm:pl-14">
<Sidebar id={data.id} name={data.name} />
<div className="flex flex-col bg-muted/40 sm:gap-4 sm:py-4 sm:pl-14">
<header className="sticky top-0 z-30 flex h-14 items-center gap-4 border-b bg-background px-4 sm:static sm:h-auto sm:border-0 sm:bg-transparent sm:px-6">
<Breadcrumb className="hidden md:flex">
<BreadcrumbList>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
import Link from "next/link";
import { CircleUser, Menu, Package2, Search } from "lucide-react";

import { Button } from "@amaxa/ui/button";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@amaxa/ui/dropdown-menu";
import { Input } from "@amaxa/ui/input";
import { Sheet, SheetContent, SheetTrigger } from "@amaxa/ui/sheet";

import type { NavItem } from "./types";
import Sidebar from "./sidebar";

interface HeaderProps {
navItems: NavItem[];
}

export default function Header({ navItems }: HeaderProps): JSX.Element {
return (
<header className="sticky top-0 flex h-16 items-center gap-4 border-b bg-background px-4 md:px-6">
<nav className="hidden flex-col gap-6 text-lg font-medium md:flex md:flex-row md:items-center md:gap-5 md:text-sm lg:gap-6">
<Link
href="#"
className="flex items-center gap-2 text-lg font-semibold md:text-base"
>
<Package2 className="h-6 w-6" />
<span className="sr-only">Acme Inc</span>
</Link>
{navItems.map((item) => (
<Link
key={item.href}
href={item.href}
className="text-muted-foreground transition-colors hover:text-foreground"
>
{item.label}
</Link>
))}
</nav>
<Sheet>
<SheetTrigger asChild>
<Button variant="outline" size="icon" className="shrink-0 md:hidden">
<Menu className="h-5 w-5" />
<span className="sr-only">Toggle navigation menu</span>
</Button>
</SheetTrigger>
<SheetContent side="left">
<Sidebar navItems={navItems} />
</SheetContent>
</Sheet>
<div className="flex w-full items-center gap-4 md:ml-auto md:gap-2 lg:gap-4">
<form className="ml-auto flex-1 sm:flex-initial">
<div className="relative">
<Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" />
<Input
type="search"
placeholder="Search products..."
className="pl-8 sm:w-[300px] md:w-[200px] lg:w-[300px]"
/>
</div>
</form>
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="secondary" size="icon" className="rounded-full">
<CircleUser className="h-5 w-5" />
<span className="sr-only">Toggle user menu</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>My Account</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem>Settings</DropdownMenuItem>
<DropdownMenuItem>Support</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>Logout</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</header>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"use client";

import Link from "next/link";
import { usePathname } from "next/navigation";

import type { NavItem } from "./types";

interface SidebarProps {
navItems: NavItem[];
}

export default function Sidebar({ navItems }: SidebarProps): JSX.Element {
const pathname = usePathname();

return (
<nav className="grid gap-4 text-sm text-muted-foreground">
{navItems.map((item) => (
<Link
key={item.href}
href={item.href}
className={`font-semibold transition-colors hover:text-foreground ${
pathname === item.href ? "text-primary" : ""
}`}
>
{item.label}
</Link>
))}
</nav>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface NavItem {
href: string;
label: string;
}
Loading

0 comments on commit 5eb0553

Please sign in to comment.