Skip to content
TypeScript

feat: build app shell with title bar, sidebar and global search

Vipul Kumard471f23846b7
diff --git a/src/app/layout.tsx b/src/app/layout.tsx
index 9852c15..01a15a6 100644
--- a/src/app/layout.tsx
+++ b/src/app/layout.tsx
@@ -1,29 +1,31 @@
import type { Metadata } from "next";
-import { Geist, Geist_Mono } from "next/font/google";
+import { Geist, Geist_Mono, Inter } from "next/font/google";
+import { AppShell } from "@/components/shell/app-shell";
+import { Providers } from "@/components/providers";
import "./globals.css";
-const geistSans = Geist({
- variable: "--font-geist-sans",
- subsets: ["latin"],
-});
-
-const geistMono = Geist_Mono({
- variable: "--font-geist-mono",
- subsets: ["latin"],
-});
+const geistSans = Geist({ variable: "--font-geist-sans", subsets: ["latin"] });
+const geistMono = Geist_Mono({ variable: "--font-geist-mono", subsets: ["latin"] });
+const inter = Inter({ variable: "--font-inter", subsets: ["latin"], weight: ["600"] });
export const metadata: Metadata = {
- title: "Create Next App",
- description: "Generated by create next app",
+ title: { default: "Time off · Workspace", template: "%s · Workspace" },
+ description: "Plan time off, track leave requests and manage your work calendar.",
};
export default function RootLayout({ children }: LayoutProps<"/">) {
return (
<html
lang="en"
- className={`${geistSans.variable} ${geistMono.variable} h-full antialiased`}
+ data-theme="light"
+ suppressHydrationWarning
+ className={`${geistSans.variable} ${geistMono.variable} ${inter.variable} h-full`}
>
- <body className="min-h-full flex flex-col">{children}</body>
+ <body className="h-full overflow-hidden">
+ <Providers>
+ <AppShell>{children}</AppShell>
+ </Providers>
+ </body>
</html>
);
}
diff --git a/src/app/page.tsx b/src/app/page.tsx
index c887311..8f6acb8 100644
--- a/src/app/page.tsx
+++ b/src/app/page.tsx
@@ -1,69 +1,5 @@
-import Image from "next/image";
+import { redirect } from "next/navigation";
export default function Home() {
- return (
- <div className="flex flex-col flex-1 items-center justify-center bg-zinc-50 font-sans dark:bg-black">
- <main className="flex flex-1 w-full max-w-3xl flex-col items-center justify-between py-32 px-16 bg-white dark:bg-black sm:items-start">
- <Image
- className="dark:invert h-5 w-[100px]"
- src="/next.svg"
- alt="Next.js logo"
- width={100}
- height={20}
- priority
- />
- <div className="flex flex-col items-center gap-6 text-center sm:items-start sm:text-left">
- <h1 className="max-w-xs text-3xl font-semibold leading-10 tracking-tight text-black dark:text-zinc-50">
- To get started, edit the{" "}
- <code className="rounded bg-black/[.06] px-1.5 py-0.5 font-mono text-[0.9em] dark:bg-white/[.08]">
- page.tsx
- </code>{" "}
- file.
- </h1>
- <p className="max-w-md text-lg leading-8 text-zinc-600 dark:text-zinc-400">
- Looking for a starting point or more instructions? Head over to{" "}
- <a
- href="https://vercel.com/templates?framework=next.js&utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
- className="font-medium text-zinc-950 dark:text-zinc-50"
- >
- Templates
- </a>{" "}
- or the{" "}
- <a
- href="https://nextjs.org/learn?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
- className="font-medium text-zinc-950 dark:text-zinc-50"
- >
- Learning
- </a>{" "}
- center.
- </p>
- </div>
- <div className="flex flex-col gap-4 text-base font-medium sm:flex-row">
- <a
- className="flex h-12 w-full items-center justify-center gap-2 rounded-full bg-foreground px-5 text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] md:w-[158px]"
- href="https://vercel.com/new?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
- target="_blank"
- rel="noopener noreferrer"
- >
- <Image
- className="dark:invert h-[14px] w-4"
- src="/vercel.svg"
- alt="Vercel logomark"
- width={16}
- height={14}
- />
- Deploy Now
- </a>
- <a
- className="flex h-12 w-full items-center justify-center rounded-full border border-solid border-black/[.08] px-5 transition-colors hover:border-transparent hover:bg-black/[.04] dark:border-white/[.145] dark:hover:bg-[#1a1a1a] md:w-[158px]"
- href="https://nextjs.org/docs?utm_source=create-next-app&utm_medium=appdir-template-tw&utm_campaign=create-next-app"
- target="_blank"
- rel="noopener noreferrer"
- >
- Documentation
- </a>
- </div>
- </main>
- </div>
- );
+ redirect("/time-off");
}
diff --git a/src/app/time-off/page.tsx b/src/app/time-off/page.tsx
new file mode 100644
index 0000000..5397c51
--- /dev/null
+++ b/src/app/time-off/page.tsx
@@ -0,0 +1,3 @@
+export default function TimeOffPage() {
+ return null;
+}
diff --git a/src/components/icon.tsx b/src/components/icon.tsx
new file mode 100644
index 0000000..e5d355f
--- /dev/null
+++ b/src/components/icon.tsx
@@ -0,0 +1,61 @@
+import { cn } from "@/lib/utils";
+
+export type IconName =
+ | "nav-dashboard"
+ | "nav-analytics"
+ | "nav-personal"
+ | "nav-documents"
+ | "nav-calendar"
+ | "nav-time-tracking"
+ | "nav-benefits"
+ | "nav-invoice"
+ | "nav-withdrawal"
+ | "workspace-switcher"
+ | "search"
+ | "help"
+ | "bell"
+ | "request-time-off"
+ | "moon"
+ | "settings"
+ | "arrow-left"
+ | "arrow-right"
+ | "filter"
+ | "more"
+ | "status-approved"
+ | "status-declined";
+
+/**
+ * Monochrome Figma icon rendered as a CSS mask so it inherits `currentColor`
+ * (defaults to the design's icon grey) and follows the theme.
+ */
+export function Icon({
+ name,
+ size = 14,
+ className,
+ style,
+}: {
+ name: IconName;
+ size?: number;
+ className?: string;
+ style?: React.CSSProperties;
+}) {
+ const url = `url(/icons/${name}.svg)`;
+ return (
+ <span
+ aria-hidden
+ data-icon
+ className={cn("inline-block shrink-0 bg-current text-icon", className)}
+ style={{
+ width: size,
+ height: size,
+ maskImage: url,
+ WebkitMaskImage: url,
+ maskSize: "100% 100%",
+ WebkitMaskSize: "100% 100%",
+ maskRepeat: "no-repeat",
+ WebkitMaskRepeat: "no-repeat",
+ ...style,
+ }}
+ />
+ );
+}
diff --git a/src/components/providers.tsx b/src/components/providers.tsx
new file mode 100644
index 0000000..aed32e1
--- /dev/null
+++ b/src/components/providers.tsx
@@ -0,0 +1,27 @@
+"use client";
+
+import { ThemeProvider } from "next-themes";
+import { useEffect } from "react";
+import { Toaster } from "@/components/ui/sonner";
+import { TooltipProvider } from "@/components/ui/tooltip";
+import { useAppStore } from "@/stores/app-store";
+
+/** Loads persisted data once the client has hydrated the seed markup. */
+function StoreHydrator() {
+ useEffect(() => {
+ void useAppStore.persist.rehydrate();
+ }, []);
+ return null;
+}
+
+export function Providers({ children }: { children: React.ReactNode }) {
+ return (
+ <ThemeProvider attribute="data-theme" defaultTheme="light" enableSystem={false} disableTransitionOnChange>
+ <TooltipProvider delayDuration={400} skipDelayDuration={300}>
+ <StoreHydrator />
+ {children}
+ <Toaster position="bottom-right" />
+ </TooltipProvider>
+ </ThemeProvider>
+ );
+}
diff --git a/src/components/shell/app-shell.tsx b/src/components/shell/app-shell.tsx
new file mode 100644
index 0000000..4628649
--- /dev/null
+++ b/src/components/shell/app-shell.tsx
@@ -0,0 +1,20 @@
+import { GlobalDialogs } from "@/components/dialogs/global-dialogs";
+import { GlobalSearch } from "./global-search";
+import { KeyboardShortcuts } from "./keyboard-shortcuts";
+import { Sidebar } from "./sidebar";
+import { TitleBar } from "./title-bar";
+
+export function AppShell({ children }: { children: React.ReactNode }) {
+ return (
+ <div className="flex h-full min-w-[1100px] flex-col bg-app">
+ <TitleBar />
+ <div className="flex min-h-0 flex-1 overflow-hidden">
+ <Sidebar />
+ <main className="relative flex min-w-0 flex-1 flex-col overflow-hidden">{children}</main>
+ </div>
+ <GlobalSearch />
+ <GlobalDialogs />
+ <KeyboardShortcuts />
+ </div>
+ );
+}
diff --git a/src/components/shell/global-search.tsx b/src/components/shell/global-search.tsx
new file mode 100644
index 0000000..45851d5
--- /dev/null
+++ b/src/components/shell/global-search.tsx
@@ -0,0 +1,173 @@
+"use client";
+
+import { useRouter } from "next/navigation";
+import { useTheme } from "next-themes";
+import { useEffect, useMemo } from "react";
+import { CalendarDaysIcon, CalendarPlusIcon, FileTextIcon, MoonIcon, PlaneIcon, ReceiptIcon, SunIcon } from "lucide-react";
+import { Icon } from "@/components/icon";
+import {
+ CommandDialog,
+ CommandEmpty,
+ CommandGroup,
+ CommandInput,
+ CommandItem,
+ CommandList,
+ CommandSeparator,
+ CommandShortcut,
+} from "@/components/ui/command";
+import { formatLong, formatShort, formatTimeRange } from "@/lib/dates";
+import { ALL_PAGES } from "@/lib/nav";
+import { useToday } from "@/hooks/use-today";
+import { useAppStore } from "@/stores/app-store";
+import { useCalendarStore } from "@/stores/calendar-store";
+import { openOverlay, useOverlayStore } from "@/stores/overlay-store";
+
+/** The title-bar search field. Opens a command palette (⌘K / "/"). */
+export function GlobalSearchTrigger() {
+ return (
+ <button
+ type="button"
+ onClick={() => openOverlay({ kind: "search" })}
+ className="flex h-[30px] w-60 items-center gap-2 rounded-lg border border-control bg-surface px-2.5 text-left outline-none transition-[border-color,box-shadow] duration-150 hover-fine:border-segment focus-visible:ring-3 focus-visible:ring-brand/15"
+ aria-label="Search"
+ aria-keyshortcuts="Meta+K"
+ >
+ <Icon name="search" />
+ <span className="t-14 min-w-0 flex-1 text-placeholder">Search...</span>
+ </button>
+ );
+}
+
+export function GlobalSearch() {
+ const router = useRouter();
+ const open = useOverlayStore((s) => s.overlay.kind === "search");
+ const close = useOverlayStore((s) => s.close);
+ const events = useAppStore((s) => s.events);
+ const requests = useAppStore((s) => s.requests);
+ const documents = useAppStore((s) => s.documents);
+ const invoices = useAppStore((s) => s.invoices);
+ const timeFormat = useAppStore((s) => s.settings.timeFormat);
+ const { resolvedTheme, setTheme } = useTheme();
+ const today = useToday();
+
+ // ⌘K / Ctrl+K toggles the palette instantly — no animation for keyboard actions.
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => {
+ if (e.key.toLowerCase() === "k" && (e.metaKey || e.ctrlKey)) {
+ e.preventDefault();
+ const { overlay, open: openO, close: closeO } = useOverlayStore.getState();
+ if (overlay.kind === "search") closeO();
+ else openO({ kind: "search" });
+ }
+ };
+ window.addEventListener("keydown", onKey);
+ return () => window.removeEventListener("keydown", onKey);
+ }, []);
+
+ const sortedEvents = useMemo(() => [...events].sort((a, b) => a.date.localeCompare(b.date) || a.start - b.start), [events]);
+
+ const run = (fn: () => void) => {
+ close();
+ fn();
+ };
+
+ const showInCalendar = (date: string, eventId?: string) => {
+ const cal = useCalendarStore.getState();
+ if (eventId) cal.focusEvent(eventId, date);
+ else cal.setDate(date);
+ router.push("/time-off");
+ };
+
+ return (
+ <CommandDialog
+ open={open}
+ onOpenChange={(v) => !v && close()}
+ title="Search"
+ description="Search pages, events, requests and documents"
+ className="data-open:animate-none data-closed:animate-none sm:max-w-[560px]"
+ >
+ <CommandInput placeholder="Search events, requests, documents…" />
+ <CommandList className="max-h-[380px]">
+ <CommandEmpty className="t-14 text-fg-2">No results found.</CommandEmpty>
+ <CommandGroup heading="Actions">
+ <CommandItem onSelect={() => run(() => openOverlay({ kind: "request" }))}>
+ <PlaneIcon /> Request time-off
+ </CommandItem>
+ <CommandItem onSelect={() => run(() => openOverlay({ kind: "event", date: today }))}>
+ <CalendarPlusIcon /> New event
+ <CommandShortcut>N</CommandShortcut>
+ </CommandItem>
+ <CommandItem onSelect={() => run(() => showInCalendar(today))}>
+ <CalendarDaysIcon /> Go to today
+ <CommandShortcut>T</CommandShortcut>
+ </CommandItem>
+ <CommandItem onSelect={() => run(() => setTheme(resolvedTheme === "dark" ? "light" : "dark"))}>
+ {resolvedTheme === "dark" ? <SunIcon /> : <MoonIcon />} Toggle dark mode
+ </CommandItem>
+ </CommandGroup>
+ <CommandSeparator />
+ <CommandGroup heading="Pages">
+ {ALL_PAGES.map((p) => (
+ <CommandItem key={p.href} value={`page ${p.label}`} onSelect={() => run(() => router.push(p.href))}>
+ <Icon name={p.icon} /> {p.label}
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ <CommandSeparator />
+ <CommandGroup heading="Events">
+ {sortedEvents.map((e) => (
+ <CommandItem
+ key={e.id}
+ value={`event ${e.title} ${e.note ?? ""} ${formatLong(e.date)} ${e.id}`}
+ onSelect={() => run(() => showInCalendar(e.date, e.id))}
+ >
+ <span className="size-2 shrink-0 rounded-full" style={{ background: `var(--event-${e.color}-fg)` }} />
+ <span className="min-w-0 flex-1 truncate">{e.title}</span>
+ <CommandShortcut className="tracking-normal">
+ {formatShort(e.date)}
+ {!e.allDay && ` · ${formatTimeRange(e.start, e.end, timeFormat)}`}
+ </CommandShortcut>
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ <CommandSeparator />
+ <CommandGroup heading="Leave requests">
+ {requests.map((r) => (
+ <CommandItem
+ key={r.id}
+ value={`request ${r.type} ${r.status} ${r.notes} ${formatLong(r.from)} ${r.id}`}
+ onSelect={() => run(() => openOverlay({ kind: "request-details", requestId: r.id }))}
+ >
+ <PlaneIcon />
+ <span className="min-w-0 flex-1 truncate">
+ {r.type} · {r.notes}
+ </span>
+ <CommandShortcut className="tracking-normal capitalize">{r.status}</CommandShortcut>
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ <CommandSeparator />
+ <CommandGroup heading="Documents">
+ {documents.map((d) => (
+ <CommandItem key={d.id} value={`document ${d.name} ${d.category} ${d.id}`} onSelect={() => run(() => router.push("/documents"))}>
+ <FileTextIcon />
+ <span className="min-w-0 flex-1 truncate">{d.name}</span>
+ <CommandShortcut className="tracking-normal">{d.category}</CommandShortcut>
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ <CommandGroup heading="Invoices">
+ {invoices.map((i) => (
+ <CommandItem key={i.id} value={`invoice ${i.number} ${i.client} ${i.id}`} onSelect={() => run(() => router.push(`/invoice?open=${i.id}`))}>
+ <ReceiptIcon />
+ <span className="min-w-0 flex-1 truncate">
+ {i.number} · {i.client}
+ </span>
+ <CommandShortcut className="tracking-normal capitalize">{i.status}</CommandShortcut>
+ </CommandItem>
+ ))}
+ </CommandGroup>
+ </CommandList>
+ </CommandDialog>
+ );
+}
diff --git a/src/components/shell/keyboard-shortcuts.tsx b/src/components/shell/keyboard-shortcuts.tsx
new file mode 100644
index 0000000..393e9b0
--- /dev/null
+++ b/src/components/shell/keyboard-shortcuts.tsx
@@ -0,0 +1,62 @@
+"use client";
+
+import { usePathname, useRouter } from "next/navigation";
+import { useEffect } from "react";
+import { useToday } from "@/hooks/use-today";
+import { useCalendarStore } from "@/stores/calendar-store";
+import { openOverlay, useOverlayStore } from "@/stores/overlay-store";
+
+export const SHORTCUTS: { keys: string[]; label: string }[] = [
+ { keys: ["⌘", "K"], label: "Search" },
+ { keys: ["N"], label: "New event" },
+ { keys: ["R"], label: "Request time-off" },
+ { keys: ["T"], label: "Go to today" },
+ { keys: ["←"], label: "Previous period" },
+ { keys: ["→"], label: "Next period" },
+ { keys: ["D"], label: "Day view" },
+ { keys: ["W"], label: "Week view" },
+ { keys: ["M"], label: "Month view" },
+ { keys: ["?"], label: "Show shortcuts" },
+];
+
+function isTyping(target: EventTarget | null) {
+ if (!(target instanceof HTMLElement)) return false;
+ return target.isContentEditable || ["INPUT", "TEXTAREA", "SELECT"].includes(target.tagName);
+}
+
+/** Single-key shortcuts. These act instantly — keyboard actions never animate. */
+export function KeyboardShortcuts() {
+ const router = useRouter();
+ const pathname = usePathname();
+ const today = useToday();
+
+ useEffect(() => {
+ const onKey = (e: KeyboardEvent) => {
+ if (e.metaKey || e.ctrlKey || e.altKey || isTyping(e.target)) return;
+ if (useOverlayStore.getState().overlay.kind !== "none") return;
+ if (document.querySelector("[role=dialog],[role=menu],[data-radix-popper-content-wrapper]")) return;
+
+ const cal = useCalendarStore.getState();
+ const onCalendar = pathname === "/time-off";
+ const key = e.key;
+
+ if (key === "?") openOverlay({ kind: "shortcuts" });
+ else if (key === "n" || key === "N") openOverlay({ kind: "event", date: cal.date });
+ else if (key === "r" || key === "R") openOverlay({ kind: "request" });
+ else if (key === "t" || key === "T") {
+ cal.setDate(today);
+ if (!onCalendar) router.push("/time-off");
+ } else if (onCalendar && key === "ArrowLeft") cal.step(-1);
+ else if (onCalendar && key === "ArrowRight") cal.step(1);
+ else if (onCalendar && (key === "d" || key === "D")) cal.setView("day");
+ else if (onCalendar && (key === "w" || key === "W")) cal.setView("week");
+ else if (onCalendar && (key === "m" || key === "M")) cal.setView("month");
+ else return;
+ e.preventDefault();
+ };
+ window.addEventListener("keydown", onKey);
+ return () => window.removeEventListener("keydown", onKey);
+ }, [pathname, router, today]);
+
+ return null;
+}
diff --git a/src/components/shell/notifications-popover.tsx b/src/components/shell/notifications-popover.tsx
new file mode 100644
index 0000000..af6a9b7
--- /dev/null
+++ b/src/components/shell/notifications-popover.tsx
@@ -0,0 +1,89 @@
+"use client";
+
+import { useRouter } from "next/navigation";
+import { BellOffIcon } from "lucide-react";
+import { Icon } from "@/components/icon";
+import { Button } from "@/components/ui/button";
+import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
+import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
+import { relativeTime } from "@/lib/dates";
+import { cn } from "@/lib/utils";
+import { useNow } from "@/hooks/use-today";
+import { useAppStore } from "@/stores/app-store";
+
+export function NotificationsPopover() {
+ const router = useRouter();
+ const notifications = useAppStore((s) => s.notifications);
+ const markRead = useAppStore((s) => s.markNotificationRead);
+ const markAll = useAppStore((s) => s.markAllNotificationsRead);
+ const clear = useAppStore((s) => s.clearNotifications);
+ const now = useNow();
+ const unread = notifications.filter((n) => !n.read).length;
+
+ return (
+ <Popover>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <PopoverTrigger asChild>
+ <Button size="icon" aria-label={unread ? `Notifications, ${unread} unread` : "Notifications"} className="relative">
+ <Icon name="bell" />
+ {unread > 0 && (
+ <span className="absolute top-[5px] right-[5px] size-1.5 rounded-full bg-brand ring-2 ring-surface" />
+ )}
+ </Button>
+ </PopoverTrigger>
+ </TooltipTrigger>
+ <TooltipContent>Notifications</TooltipContent>
+ </Tooltip>
+ <PopoverContent align="end" sideOffset={8} className="w-[360px] gap-0 p-0">
+ <div className="flex h-12 items-center gap-2 border-b border-hairline px-4">
+ <span className="t-14 flex-1 text-fg">Notifications</span>
+ {unread > 0 && (
+ <Button variant="ghost" size="sm" onClick={markAll} className="t-12">
+ Mark all read
+ </Button>
+ )}
+ {notifications.length > 0 && (
+ <Button variant="ghost" size="sm" onClick={clear} className="t-12">
+ Clear
+ </Button>
+ )}
+ </div>
+ {notifications.length === 0 ? (
+ <div className="flex flex-col items-center gap-2 px-6 py-10 text-center">
+ <BellOffIcon className="size-5 text-icon" />
+ <p className="t-14 text-fg">You’re all caught up</p>
+ <p className="t-12 text-fg-2">New approvals and reminders will show up here.</p>
+ </div>
+ ) : (
+ <ul className="scroll-thin max-h-[360px] overflow-y-auto p-1">
+ {notifications.map((n) => (
+ <li key={n.id}>
+ <button
+ type="button"
+ onClick={() => {
+ markRead(n.id);
+ if (n.href) router.push(n.href);
+ }}
+ className="flex w-full gap-3 rounded-lg px-3 py-2.5 text-left transition-colors duration-150 hover-fine:bg-hover"
+ >
+ <span
+ className={cn("mt-1 size-1.5 shrink-0 rounded-full", n.read ? "bg-transparent" : "bg-brand")}
+ aria-hidden
+ />
+ <span className="flex min-w-0 flex-1 flex-col gap-1.5">
+ <span className="flex items-baseline gap-2">
+ <span className="t-14 min-w-0 flex-1 truncate text-fg">{n.title}</span>
+ <span className="t-12 shrink-0 text-placeholder">{now ? relativeTime(n.createdAt, now) : ""}</span>
+ </span>
+ <span className="t-12 leading-[1.35] text-fg-2">{n.body}</span>
+ </span>
+ </button>
+ </li>
+ ))}
+ </ul>
+ )}
+ </PopoverContent>
+ </Popover>
+ );
+}
diff --git a/src/components/shell/sidebar.tsx b/src/components/shell/sidebar.tsx
new file mode 100644
index 0000000..b40b58b
--- /dev/null
+++ b/src/components/shell/sidebar.tsx
@@ -0,0 +1,139 @@
+"use client";
+
+import Link from "next/link";
+import { usePathname } from "next/navigation";
+import { useTheme } from "next-themes";
+import { useSyncExternalStore } from "react";
+import { LogOutIcon, SettingsIcon, UserIcon } from "lucide-react";
+import { toast } from "sonner";
+import { Icon } from "@/components/icon";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
+import { Switch } from "@/components/ui/switch";
+import { NAV_GROUPS, SETTINGS_ITEM, type NavItem } from "@/lib/nav";
+import { cn } from "@/lib/utils";
+import { useAppStore } from "@/stores/app-store";
+
+const noopSubscribe = () => () => {};
+
+function NavLink({ item, active }: { item: NavItem; active: boolean }) {
+ return (
+ <Link
+ href={item.href}
+ aria-current={active ? "page" : undefined}
+ className={cn(
+ "flex h-8 w-full items-center gap-2 rounded-lg px-2 outline-none transition-[background-color,color] duration-150",
+ "focus-visible:ring-2 focus-visible:ring-brand/40",
+ active ? "bg-selected text-fg" : "text-fg-2 hover-fine:bg-hover hover-fine:text-fg",
+ )}
+ >
+ <Icon name={item.icon} className={active && item.icon === "nav-calendar" ? "text-brand" : undefined} />
+ <span className="t-14 salt min-w-0 flex-1 truncate">{item.label}</span>
+ </Link>
+ );
+}
+
+function SectionLabel({ children }: { children: React.ReactNode }) {
+ return (
+ <div className="flex h-7 items-center px-2">
+ <span className="salt font-mono text-[12px] leading-none tracking-[-0.24px] text-section">{children}</span>
+ </div>
+ );
+}
+
+function ThemeRow() {
+ const { resolvedTheme, setTheme } = useTheme();
+ // next-themes only knows the stored theme after mount.
+ const mounted = useSyncExternalStore(noopSubscribe, () => true, () => false);
+ const dark = mounted && resolvedTheme === "dark";
+ return (
+ <label className="flex h-8 w-full cursor-pointer items-center gap-2 overflow-hidden rounded-lg px-2 text-fg-2 transition-colors duration-150 hover-fine:bg-hover">
+ <Icon name="moon" />
+ <span className="t-14 salt min-w-0 flex-1">Dark mode</span>
+ <Switch
+ checked={dark}
+ onCheckedChange={(v) => setTheme(v ? "dark" : "light")}
+ aria-label="Dark mode"
+ className="mr-0"
+ />
+ </label>
+ );
+}
+
+function AccountMenu() {
+ const profile = useAppStore((s) => s.profile);
+ return (
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <button
+ type="button"
+ className="flex w-full items-center gap-2.5 overflow-hidden border-t border-hairline px-2 pt-3 text-left outline-none focus-visible:ring-2 focus-visible:ring-brand/40"
+ >
+ <span className="flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-[10px] bg-brand-tint p-2">
+ <span className="font-inter text-[14px] leading-none font-semibold tracking-[-0.21px] whitespace-nowrap text-brand">
+ {profile.initials}
+ </span>
+ </span>
+ <span className="flex min-w-0 flex-1 flex-col gap-1.5 overflow-hidden leading-none whitespace-nowrap">
+ <span className="truncate text-[14px] tracking-[-0.21px] text-fg">{profile.name}</span>
+ <span className="salt truncate text-[12px] tracking-[-0.12px] text-fg-2">{profile.email}</span>
+ </span>
+ </button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent side="top" align="start" sideOffset={8} className="w-[215px]">
+ <DropdownMenuLabel className="t-12 text-fg-2">Signed in as {profile.email}</DropdownMenuLabel>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem asChild>
+ <Link href="/personal-details">
+ <UserIcon /> Personal details
+ </Link>
+ </DropdownMenuItem>
+ <DropdownMenuItem asChild>
+ <Link href="/settings">
+ <SettingsIcon /> Settings
+ </Link>
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ variant="destructive"
+ onSelect={() => toast("Signed out", { description: "This is a demo — your data stays in this browser." })}
+ >
+ <LogOutIcon /> Sign out
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
+
+export function Sidebar() {
+ const pathname = usePathname();
+ const isActive = (href: string) => pathname === href || pathname.startsWith(href + "/");
+
+ return (
+ <aside className="flex h-full w-60 shrink-0 flex-col justify-between overflow-hidden border-r border-hairline bg-app p-3">
+ <nav aria-label="Primary" className="flex w-full flex-col gap-4 overflow-hidden">
+ {NAV_GROUPS.map((group) => (
+ <div key={group.label} className="flex w-full flex-col gap-0.5">
+ <SectionLabel>{group.label}</SectionLabel>
+ {group.items.map((item) => (
+ <NavLink key={item.href} item={item} active={isActive(item.href)} />
+ ))}
+ </div>
+ ))}
+ </nav>
+ <div className="flex w-full flex-col gap-3 overflow-hidden">
+ <div className="flex w-full flex-col gap-0.5">
+ <ThemeRow />
+ <NavLink item={SETTINGS_ITEM} active={isActive(SETTINGS_ITEM.href)} />
+ </div>
+ <AccountMenu />
+ </div>
+ </aside>
+ );
+}
diff --git a/src/components/shell/title-bar.tsx b/src/components/shell/title-bar.tsx
new file mode 100644
index 0000000..d0f2887
--- /dev/null
+++ b/src/components/shell/title-bar.tsx
@@ -0,0 +1,78 @@
+"use client";
+
+import { usePathname } from "next/navigation";
+import { BookOpenIcon, CalendarHeartIcon, KeyboardIcon, LifeBuoyIcon } from "lucide-react";
+import { toast } from "sonner";
+import { Icon } from "@/components/icon";
+import { Button } from "@/components/ui/button";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuSeparator,
+ DropdownMenuShortcut,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
+import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
+import { pageTitle } from "@/lib/nav";
+import { openOverlay } from "@/stores/overlay-store";
+import { GlobalSearchTrigger } from "./global-search";
+import { NotificationsPopover } from "./notifications-popover";
+import { Brand } from "./workspace-switcher";
+
+function HelpMenu() {
+ return (
+ <DropdownMenu>
+ <Tooltip>
+ <TooltipTrigger asChild>
+ <DropdownMenuTrigger asChild>
+ <Button size="icon" aria-label="Help">
+ <Icon name="help" />
+ </Button>
+ </DropdownMenuTrigger>
+ </TooltipTrigger>
+ <TooltipContent>Help</TooltipContent>
+ </Tooltip>
+ <DropdownMenuContent align="end" sideOffset={8} className="w-56">
+ <DropdownMenuItem onSelect={() => openOverlay({ kind: "shortcuts" })}>
+ <KeyboardIcon /> Keyboard shortcuts
+ <DropdownMenuShortcut>?</DropdownMenuShortcut>
+ </DropdownMenuItem>
+ <DropdownMenuItem onSelect={() => openOverlay({ kind: "policy" })}>
+ <BookOpenIcon /> Leave policy
+ </DropdownMenuItem>
+ <DropdownMenuItem onSelect={() => openOverlay({ kind: "holidays" })}>
+ <CalendarHeartIcon /> Holiday list
+ </DropdownMenuItem>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem
+ onSelect={() => toast("Message sent to HR", { description: "Someone from People Ops will reply by email." })}
+ >
+ <LifeBuoyIcon /> Contact HR
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ );
+}
+
+export function TitleBar() {
+ const pathname = usePathname();
+ return (
+ <header className="flex h-[53px] w-full shrink-0 items-center overflow-hidden border-b border-hairline bg-app pr-4">
+ <Brand />
+ <div className="flex h-full min-w-0 flex-1 items-center overflow-hidden pl-4">
+ <h1 className="t-16 min-w-0 flex-1 truncate font-medium text-fg">{pageTitle(pathname)}</h1>
+ </div>
+ <div className="flex shrink-0 items-center gap-2">
+ <GlobalSearchTrigger />
+ <HelpMenu />
+ <NotificationsPopover />
+ <div className="h-4 w-px bg-hairline" aria-hidden />
+ <Button variant="brand" className="gap-1.5" onClick={() => openOverlay({ kind: "request" })}>
+ <Icon name="request-time-off" className="text-white" />
+ Request time-off
+ </Button>
+ </div>
+ </header>
+ );
+}
diff --git a/src/components/shell/workspace-switcher.tsx b/src/components/shell/workspace-switcher.tsx
new file mode 100644
index 0000000..732cd6f
--- /dev/null
+++ b/src/components/shell/workspace-switcher.tsx
@@ -0,0 +1,105 @@
+"use client";
+
+import { useState } from "react";
+import { CheckIcon, PlusIcon } from "lucide-react";
+import { Icon } from "@/components/icon";
+import { Button } from "@/components/ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogDescription,
+ DialogFooter,
+ DialogHeader,
+ DialogTitle,
+} from "@/components/ui/dialog";
+import {
+ DropdownMenu,
+ DropdownMenuContent,
+ DropdownMenuItem,
+ DropdownMenuLabel,
+ DropdownMenuSeparator,
+ DropdownMenuTrigger,
+} from "@/components/ui/dropdown-menu";
+import { Input } from "@/components/ui/input";
+import { Label } from "@/components/ui/label";
+import { selectWorkspaceName, useAppStore } from "@/stores/app-store";
+
+export function Brand() {
+ const name = useAppStore(selectWorkspaceName);
+ const workspaces = useAppStore((s) => s.workspaces);
+ const workspaceId = useAppStore((s) => s.workspaceId);
+ const switchWorkspace = useAppStore((s) => s.switchWorkspace);
+ const addWorkspace = useAppStore((s) => s.addWorkspace);
+ const [creating, setCreating] = useState(false);
+ const [draft, setDraft] = useState("");
+
+ return (
+ <div className="flex h-full w-60 shrink-0 items-center gap-2 overflow-hidden border-r border-hairline px-3">
+ <span className="salt truncate text-[16px] leading-none font-semibold tracking-[-0.48px] text-fg">{name}</span>
+ <span className="h-px min-w-px flex-1" />
+ <DropdownMenu>
+ <DropdownMenuTrigger asChild>
+ <Button size="icon" aria-label="Switch workspace">
+ <Icon name="workspace-switcher" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="end" sideOffset={6} className="w-56">
+ <DropdownMenuLabel className="t-12 text-fg-2">Workspaces</DropdownMenuLabel>
+ {workspaces.map((w) => (
+ <DropdownMenuItem key={w.id} onSelect={() => switchWorkspace(w.id)}>
+ <span className="flex size-5 items-center justify-center rounded-md bg-brand-tint text-[11px] font-semibold text-brand">
+ {w.name[0]}
+ </span>
+ <span className="flex-1 truncate">{w.name}</span>
+ {w.id === workspaceId && <CheckIcon className="text-brand" />}
+ </DropdownMenuItem>
+ ))}
+ <DropdownMenuSeparator />
+ <DropdownMenuItem onSelect={() => setCreating(true)}>
+ <PlusIcon /> Create workspace
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+
+ <Dialog
+ open={creating}
+ onOpenChange={(v) => {
+ setCreating(v);
+ if (!v) setDraft("");
+ }}
+ >
+ <DialogContent className="sm:max-w-[380px]">
+ <form
+ className="contents"
+ onSubmit={(e) => {
+ e.preventDefault();
+ if (!draft.trim()) return;
+ addWorkspace(draft.trim());
+ setCreating(false);
+ setDraft("");
+ }}
+ >
+ <DialogHeader>
+ <DialogTitle className="t-16">Create workspace</DialogTitle>
+ <DialogDescription className="t-14">Workspaces keep calendars and requests for a team together.</DialogDescription>
+ </DialogHeader>
+ <div className="grid gap-2">
+ <Label htmlFor="ws-name" className="t-12 text-fg-2">
+ Name
+ </Label>
+ <Input id="ws-name" autoFocus value={draft} onChange={(e) => setDraft(e.target.value)} placeholder="e.g. Design team" />
+ </div>
+ <DialogFooter>
+ <Button type="button" onClick={() => setCreating(false)}>
+ Cancel
+ </Button>
+ <Button type="submit" variant="brand" disabled={!draft.trim()}>
+ Create
+ </Button>
+ </DialogFooter>
+ </form>
+ </DialogContent>
+ </Dialog>
+ </div>
+ );
+}
diff --git a/src/lib/nav.ts b/src/lib/nav.ts
new file mode 100644
index 0000000..6e2be60
--- /dev/null
+++ b/src/lib/nav.ts
@@ -0,0 +1,40 @@
+import type { IconName } from "@/components/icon";
+
+export type NavItem = { href: string; label: string; icon: IconName; shortcut?: string };
+export type NavGroup = { label: string; items: NavItem[] };
+
+export const NAV_GROUPS: NavGroup[] = [
+ {
+ label: "Main menu",
+ items: [
+ { href: "/dashboard", label: "Dashboard", icon: "nav-dashboard" },
+ { href: "/analytics", label: "Analytics", icon: "nav-analytics" },
+ ],
+ },
+ {
+ label: "Personal",
+ items: [
+ { href: "/personal-details", label: "Personal details", icon: "nav-personal" },
+ { href: "/documents", label: "Documents", icon: "nav-documents" },
+ { href: "/time-off", label: "Time off", icon: "nav-calendar" },
+ { href: "/time-tracking", label: "Time tracking", icon: "nav-time-tracking" },
+ { href: "/benefits", label: "Benefits", icon: "nav-benefits" },
+ ],
+ },
+ {
+ label: "Payments",
+ items: [
+ { href: "/invoice", label: "Invoice", icon: "nav-invoice" },
+ { href: "/withdrawal-methods", label: "Withdrawal methods", icon: "nav-withdrawal" },
+ ],
+ },
+];
+
+export const SETTINGS_ITEM: NavItem = { href: "/settings", label: "Settings", icon: "settings" };
+
+export const ALL_PAGES: NavItem[] = [...NAV_GROUPS.flatMap((g) => g.items), SETTINGS_ITEM];
+
+export function pageTitle(pathname: string): string {
+ const match = ALL_PAGES.find((p) => pathname === p.href || pathname.startsWith(p.href + "/"));
+ return match?.label ?? "Time off";
+}