From d82373c8a15a6c57c2fa7c20e489278782c37303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Muhammed=20K=C4=B1l=C4=B1=C3=A7?= Date: Mon, 21 Apr 2025 14:06:47 +0300 Subject: [PATCH] Add useful context --- Lovable/Lovable Prompt.txt | 183 +++++++++++++++++++++++++++++++++++++ 1 file changed, 183 insertions(+) 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} + + + + ))} + + + + + + ) +} +``` + +
+