MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / Sidebar

Function Sidebar

packages/react/src/components/sidebar.tsx:138–241  ·  view source on GitHub ↗
({
  side = "left",
  variant = "sidebar",
  collapsible = "offcanvas",
  className,
  children,
  ...props
}: React.ComponentProps<"div"> & {
  side?: "left" | "right";
  variant?: "sidebar" | "floating" | "inset";
  collapsible?: "offcanvas" | "icon" | "none";
})

Source from the content-addressed store, hash-verified

136}
137
138function Sidebar({
139 side = "left",
140 variant = "sidebar",
141 collapsible = "offcanvas",
142 className,
143 children,
144 ...props
145}: React.ComponentProps<"div"> & {
146 side?: "left" | "right";
147 variant?: "sidebar" | "floating" | "inset";
148 collapsible?: "offcanvas" | "icon" | "none";
149}) {
150 const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
151
152 if (collapsible === "none") {
153 return (
154 <div
155 data-slot="sidebar"
156 className={cn(
157 "flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
158 className,
159 )}
160 {...props}
161 >
162 {children}
163 </div>
164 );
165 }
166
167 if (isMobile) {
168 return (
169 <Sheet open={openMobile} onOpenChange={setOpenMobile} {...props}>
170 <SheetContent
171 // Navigation only. Tapping the page behind it is the normal way to
172 // put the mobile nav away, and nothing is lost.
173 dismissOnOutsideClick
174 data-sidebar="sidebar"
175 data-slot="sidebar"
176 data-mobile="true"
177 className="w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"
178 style={
179 {
180 "--sidebar-width": SIDEBAR_WIDTH_MOBILE,
181 } as React.CSSProperties
182 }
183 side={side}
184 >
185 <SheetHeader className="sr-only">
186 <SheetTitle>Sidebar</SheetTitle>
187 <SheetDescription>Displays the mobile sidebar.</SheetDescription>
188 </SheetHeader>
189 <div className="flex h-full w-full flex-col">{children}</div>
190 </SheetContent>
191 </Sheet>
192 );
193 }
194
195 return (

Callers

nothing calls this directly

Calls 2

cnFunction · 0.90
useSidebarFunction · 0.85

Tested by

no test coverage detected