From 1aba2bdc0f8c780ad9562c9c6b98e53b51f29bd0 Mon Sep 17 00:00:00 2001 From: ngc2207 Date: Fri, 13 Dec 2024 17:46:40 +0800 Subject: [PATCH] feat(playground): restructure sidebar components and implement Playground layout --- .../components/dashboard-sidebar.tsx} | 14 +- .../dashboard}/components/nav-main.tsx | 0 .../dashboard}/components/nav-projects.tsx | 0 .../dashboard}/components/nav-secondary.tsx | 0 .../dashboard}/components/nav-user.tsx | 0 src/app/dashboard/layout.tsx | 4 +- src/app/dashboard/playground/page.tsx | 56 ------- .../components/playground-sidebar.tsx | 137 ++++++++++++++++++ src/app/playground/layout.tsx | 47 ++++++ src/app/playground/page.tsx | 12 ++ 10 files changed, 206 insertions(+), 64 deletions(-) rename src/{components/app-sidebar.tsx => app/dashboard/components/dashboard-sidebar.tsx} (90%) rename src/{ => app/dashboard}/components/nav-main.tsx (100%) rename src/{ => app/dashboard}/components/nav-projects.tsx (100%) rename src/{ => app/dashboard}/components/nav-secondary.tsx (100%) rename src/{ => app/dashboard}/components/nav-user.tsx (100%) delete mode 100644 src/app/dashboard/playground/page.tsx create mode 100644 src/app/playground/components/playground-sidebar.tsx create mode 100644 src/app/playground/layout.tsx create mode 100644 src/app/playground/page.tsx diff --git a/src/components/app-sidebar.tsx b/src/app/dashboard/components/dashboard-sidebar.tsx similarity index 90% rename from src/components/app-sidebar.tsx rename to src/app/dashboard/components/dashboard-sidebar.tsx index 7aa9c3a..7494a1c 100644 --- a/src/components/app-sidebar.tsx +++ b/src/app/dashboard/components/dashboard-sidebar.tsx @@ -24,12 +24,14 @@ import { } from "@/components/ui/sidebar"; import { siteConfig } from "@/config/site"; import { useTranslations } from "next-intl"; -import { NavMain } from "@/components/nav-main"; -import { NavUser } from "@/components/nav-user"; -import { NavProjects } from "@/components/nav-projects"; -import { NavSecondary } from "@/components/nav-secondary"; +import { NavMain } from "@/app/dashboard/components/nav-main"; +import { NavUser } from "@/app/dashboard/components/nav-user"; +import { NavProjects } from "@/app/dashboard/components/nav-projects"; +import { NavSecondary } from "@/app/dashboard/components/nav-secondary"; -export function AppSidebar({ ...props }: React.ComponentProps) { +export function DashboardSidebar({ + ...props +}: React.ComponentProps) { const t = useTranslations(); const data = { @@ -41,7 +43,7 @@ export function AppSidebar({ ...props }: React.ComponentProps) { navMain: [ { title: "Playground", - url: "/dashboard/playground", + url: "/playground", icon: SquareTerminal, isActive: true, items: [ diff --git a/src/components/nav-main.tsx b/src/app/dashboard/components/nav-main.tsx similarity index 100% rename from src/components/nav-main.tsx rename to src/app/dashboard/components/nav-main.tsx diff --git a/src/components/nav-projects.tsx b/src/app/dashboard/components/nav-projects.tsx similarity index 100% rename from src/components/nav-projects.tsx rename to src/app/dashboard/components/nav-projects.tsx diff --git a/src/components/nav-secondary.tsx b/src/app/dashboard/components/nav-secondary.tsx similarity index 100% rename from src/components/nav-secondary.tsx rename to src/app/dashboard/components/nav-secondary.tsx diff --git a/src/components/nav-user.tsx b/src/app/dashboard/components/nav-user.tsx similarity index 100% rename from src/components/nav-user.tsx rename to src/app/dashboard/components/nav-user.tsx diff --git a/src/app/dashboard/layout.tsx b/src/app/dashboard/layout.tsx index 3798f36..6f8272d 100644 --- a/src/app/dashboard/layout.tsx +++ b/src/app/dashboard/layout.tsx @@ -10,11 +10,11 @@ import { BreadcrumbPage, } from "@/components/ui/breadcrumb"; import { SessionProvider } from "next-auth/react"; -import { AppSidebar } from "@/components/app-sidebar"; import { Separator } from "@/components/ui/separator"; import { ModeSwitcher } from "@/components/mode-switcher"; import ConfirmationDialog from "@/dialogs/ConfirmationDialog"; import LanguageSwitcher from "@/components/language-switcher"; +import { DashboardSidebar } from "@/app/dashboard/components/dashboard-sidebar"; export default function DashboardLayout({ children, @@ -22,7 +22,7 @@ export default function DashboardLayout({ return ( - +
diff --git a/src/app/dashboard/playground/page.tsx b/src/app/dashboard/playground/page.tsx deleted file mode 100644 index 093cbad..0000000 --- a/src/app/dashboard/playground/page.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { Bot, Columns2, FileCode } from "lucide-react"; -import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; - -export default function PlaygroundPage() { - return ( -
- -
-
-
-
- - - Split - - - - Editor - - - - Diff - - - -
-
-
- -
-
-
-
-
-
- - -
-
-
- - -
-
-
-
-
-
- -
-
-
- -
- ); -} diff --git a/src/app/playground/components/playground-sidebar.tsx b/src/app/playground/components/playground-sidebar.tsx new file mode 100644 index 0000000..7e21b54 --- /dev/null +++ b/src/app/playground/components/playground-sidebar.tsx @@ -0,0 +1,137 @@ +import * as React from "react"; +import { ChevronRight, File, Folder } from "lucide-react"; +import { + Collapsible, + CollapsibleContent, + CollapsibleTrigger, +} from "@/components/ui/collapsible"; +import { + Sidebar, + SidebarContent, + SidebarGroup, + SidebarGroupContent, + SidebarGroupLabel, + SidebarMenu, + SidebarMenuBadge, + SidebarMenuButton, + SidebarMenuItem, + SidebarMenuSub, + SidebarRail, +} from "@/components/ui/sidebar"; +// This is sample data. +const data = { + changes: [ + { + file: "README.md", + state: "M", + }, + { + file: "api/hello/route.ts", + state: "U", + }, + { + file: "app/layout.tsx", + state: "M", + }, + ], + tree: [ + [ + "app", + [ + "api", + ["hello", ["route.ts"]], + "page.tsx", + "layout.tsx", + ["blog", ["page.tsx"]], + ], + ], + [ + "components", + ["ui", "button.tsx", "card.tsx"], + "header.tsx", + "footer.tsx", + ], + ["lib", ["util.ts"]], + ["public", "favicon.ico", "vercel.svg"], + ".eslintrc.json", + ".gitignore", + "next.config.js", + "tailwind.config.js", + "package.json", + "README.md", + ], +}; +export function PlaygroundSidebar({ + ...props +}: React.ComponentProps) { + return ( + + + + Changes + + + {data.changes.map((item, index) => ( + + + + {item.file} + + {item.state} + + ))} + + + + + Files + + + {data.tree.map((item, index) => ( + + ))} + + + + + + + ); +} +function Tree({ item }: { item: string | any[] }) { + const [name, ...items] = Array.isArray(item) ? item : [item]; + if (!items.length) { + return ( + + + {name} + + ); + } + return ( + + + + + + + {name} + + + + + {items.map((subItem, index) => ( + + ))} + + + + + ); +} diff --git a/src/app/playground/layout.tsx b/src/app/playground/layout.tsx new file mode 100644 index 0000000..fc90e5b --- /dev/null +++ b/src/app/playground/layout.tsx @@ -0,0 +1,47 @@ +import { + SidebarInset, + SidebarProvider, + SidebarTrigger, +} from "@/components/ui/sidebar"; +import { + Breadcrumb, + BreadcrumbItem, + BreadcrumbList, + BreadcrumbPage, +} from "@/components/ui/breadcrumb"; +import { Separator } from "@/components/ui/separator"; +import { ModeSwitcher } from "@/components/mode-switcher"; +import LanguageSwitcher from "@/components/language-switcher"; +import { PlaygroundSidebar } from "@/app/playground/components/playground-sidebar"; + +export default function PlaygroundLayout({ + children, +}: Readonly<{ children: React.ReactNode }>) { + return ( + + + +
+
+ + + + + + + + Project Management & Task Tracking + + + + +
+
+ +
+
+ {children} +
+
+ ); +} diff --git a/src/app/playground/page.tsx b/src/app/playground/page.tsx new file mode 100644 index 0000000..d7862c8 --- /dev/null +++ b/src/app/playground/page.tsx @@ -0,0 +1,12 @@ +export default function PlaygroundPage() { + return ( +
+
+
+
+
+
+
+
+ ); +}