diff --git a/Lovable/Lovable Prompt.txt b/Lovable/Lovable Prompt.txt index 3f7bdbf..864c69f 100644 --- a/Lovable/Lovable Prompt.txt +++ b/Lovable/Lovable Prompt.txt @@ -1358,3 +1358,186 @@ Add appropriate comments for complex logic Follow project's naming conventions + +Here is some useful context that was retrieved from our knowledge base and that you may find useful: + +and + + + +Here follows the documentation for the Shadcn Sidebar component, which you can use to add a sidebar to your Lovable project. +If you use a sidebar, make sure that there's a way to collapse it or bring it back. + +# Usage + +app/layout.tsx + +```typescript +import { SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar" +import { AppSidebar } from "@/components/app-sidebar" + +export default function Layout({ children }: { children: React.ReactNode }) { + return ( + + +
+ + {children} +
+
+ ) +} +``` + +components/app-sidebar.tsx + +```typescript +import { + Sidebar, + SidebarContent, + SidebarFooter, + SidebarGroup, + SidebarHeader, +} from "@/components/ui/sidebar" + +export function AppSidebar() { + return ( + + + + + + + + + ) +} +``` + +Let's start with the most basic sidebar. A collapsible sidebar with a menu. + +### Add a `SidebarProvider` and `SidebarTrigger` at the root of your application. + +app/layout.tsx + +```typescript +import { SidebarProvider, SidebarTrigger } from "@/components/ui/sidebar" +import { AppSidebar } from "@/components/app-sidebar" + +export default function Layout({ children }: { children: React.ReactNode }) { + return ( + + +
+ + {children} +
+
+ ) +} +``` + +IMPORTANT: Make sure that the div that `SidebarProvider` wraps uses `w-full` to avoid layout issues, it won't stretch otherwise. + +```typescript + +
+ ... +
+
+``` + +### Create a new sidebar component at `components/app-sidebar.tsx`. + +components/app-sidebar.tsx + +```typescript +import { Sidebar, SidebarContent } from "@/components/ui/sidebar" + +export function AppSidebar() { + return ( + + + + ) +} +``` + +### Now, let's add a `SidebarMenu` to the sidebar. + +We'll use the `SidebarMenu` component in a `SidebarGroup`. + +components/app-sidebar.tsx + +```typescript +import { Calendar, Home, Inbox, Search, Settings } from "lucide-react" + +import { + Sidebar, + SidebarContent, + SidebarGroup, + SidebarGroupContent, + SidebarGroupLabel, + SidebarMenu, + SidebarMenuButton, + SidebarMenuItem, +} from "@/components/ui/sidebar" + +// Menu items. +const items = [ + { + title: "Home", + url: "#", + icon: Home, + }, + { + title: "Inbox", + url: "#", + icon: Inbox, + }, + { + title: "Calendar", + url: "#", + icon: Calendar, + }, + { + title: "Search", + url: "#", + icon: Search, + }, + { + title: "Settings", + url: "#", + icon: Settings, + }, +] + +export function AppSidebar() { + return ( + + + + Application + + + {items.map((item) => ( + + + + + {item.title} + + + + ))} + + + + + + ) +} +``` + +
+