Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
feat: sidebar collapse trigger
Brad Barbin381b8d649df0
diff --git a/apps/carbon/app/components/Layout/Navigation/CollapsibleSidebar.tsx b/apps/carbon/app/components/Layout/Navigation/CollapsibleSidebar.tsxindex 48dd1227cd..574b3be142 100644--- a/apps/carbon/app/components/Layout/Navigation/CollapsibleSidebar.tsx+++ b/apps/carbon/app/components/Layout/Navigation/CollapsibleSidebar.tsx@@ -1,20 +1,66 @@-import {- Tooltip,- TooltipContent,- TooltipTrigger,- useDisclosure,-} from "@carbon/react";+import { cn, IconButton, useDisclosure } from "@carbon/react";import { motion } from "framer-motion";-import { useMemo, type PropsWithChildren } from "react";-import { LuPanelLeftClose, LuPanelLeftOpen } from "react-icons/lu";+import type { ComponentProps, PropsWithChildren } from "react";+import { createContext, forwardRef, useContext, useMemo } from "react";+import { LuPanelLeft } from "react-icons/lu";++interface CollapsibleSidebarContextValue {+ isOpen: boolean;+ onToggle: () => void;+}++const CollapsibleSidebarContext = createContext<+ CollapsibleSidebarContextValue | undefined+>(undefined);++function useCollapsibleSidebar() {+ const context = useContext(CollapsibleSidebarContext);+ if (!context) {+ throw new Error(+ "useCollapsibleSidebar must be used within CollapsibleSidebarProvider"+ );+ }+ return context;+}++export function CollapsibleSidebarProvider({ children }: PropsWithChildren) {+ const disclosure = useDisclosure({ defaultIsOpen: true });++ return (+ <CollapsibleSidebarContext.Provider+ value={{ isOpen: disclosure.isOpen, onToggle: disclosure.onToggle }}+ >+ {children}+ </CollapsibleSidebarContext.Provider>+ );+}++export const CollapsibleSidebarTrigger = forwardRef<+ HTMLButtonElement,+ Omit<ComponentProps<typeof IconButton>, "aria-label" | "icon">+>(({ className, ...props }, ref) => {+ const { isOpen, onToggle } = useCollapsibleSidebar();++ return (+ <IconButton+ variant="ghost"+ ref={ref}+ onClick={onToggle}+ {...props}+ aria-label={isOpen ? "Collapse sidebar" : "Expand sidebar"}+ icon={<LuPanelLeft />}+ className={cn("-ml-1", className)}+ />+ );+});++CollapsibleSidebarTrigger.displayName = "CollapsibleSidebarTrigger";export const CollapsibleSidebar = ({children,width = 180,}: PropsWithChildren<{ width?: number }>) => {- const sidebar = useDisclosure({- defaultIsOpen: true,- });+ const { isOpen } = useCollapsibleSidebar();const variants = useMemo(() => {return {@@ -29,34 +75,14 @@ export const CollapsibleSidebar = ({return (<motion.div- animate={sidebar.isOpen ? "visible" : "hidden"}+ animate={isOpen ? "visible" : "hidden"}initial={variants.visible}transition={{ duration: 0.2, ease: "easeInOut" }}variants={variants}className="relative flex h-[calc(100vh-49px)]"><div className="h-full w-full overflow-y-scroll bg-card border-r border-border">- <Tooltip>- <TooltipTrigger asChild>- <button- onClick={sidebar.onToggle}- aria-label="Toggle sidebar"- className="bg-transparent inline-block absolute top-[calc(100vh-135px)] text-muted-foreground right-[-31px] left-auto rounded-l-none z-[3] shadow-none w-8 h-8"- >- {sidebar.isOpen ? (- <LuPanelLeftClose className="w-5 h-5 ml-1.5" />- ) : (- <LuPanelLeftOpen className="w-5 h-5 ml-1.5" />- )}- </button>- </TooltipTrigger>-- <TooltipContent side="right">- {<span>{sidebar.isOpen ? "Collapse" : "Expand"}</span>}- </TooltipContent>- </Tooltip>-- {sidebar.isOpen ? children : null}+ {isOpen ? children : null}</div></motion.div>);diff --git a/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsx b/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsxindex d018053350..8690122002 100644--- a/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsx+++ b/apps/carbon/app/components/Layout/Navigation/GroupedContentSidebar.tsx@@ -25,7 +25,7 @@ const GroupedContentSidebar = ({className="border-b border-border p-2 pb-6"spacing={1}>- <h4 className="text-xs text-muted-foreground font-bold pl-4 py-1 uppercase">+ <h4 className="text-xs text-foreground/70 font-medium pl-4 py-1">{group.name}</h4>{group.routes.map((route) => {diff --git a/apps/carbon/app/components/Layout/Navigation/index.ts b/apps/carbon/app/components/Layout/Navigation/index.tsindex 733759a719..7390ad2109 100644--- a/apps/carbon/app/components/Layout/Navigation/index.ts+++ b/apps/carbon/app/components/Layout/Navigation/index.ts@@ -1,4 +1,8 @@-import { CollapsibleSidebar } from "./CollapsibleSidebar";+import {+ CollapsibleSidebar,+ CollapsibleSidebarProvider,+ CollapsibleSidebarTrigger,+} from "./CollapsibleSidebar";import ContentSidebar from "./ContentSidebar";import DetailSidebar from "./DetailSidebar";import DetailsTopbar from "./DetailsTopbar";@@ -7,6 +11,8 @@ import PrimaryNavigation from "./PrimaryNavigation";export {CollapsibleSidebar,+ CollapsibleSidebarProvider,+ CollapsibleSidebarTrigger,ContentSidebar,DetailSidebar,DetailsTopbar,diff --git a/apps/carbon/app/components/Layout/Topbar/Breadcrumbs.tsx b/apps/carbon/app/components/Layout/Topbar/Breadcrumbs.tsxindex 9bc68ebeae..dc6846df10 100644--- a/apps/carbon/app/components/Layout/Topbar/Breadcrumbs.tsx+++ b/apps/carbon/app/components/Layout/Topbar/Breadcrumbs.tsx@@ -20,7 +20,7 @@ import {ModalTitle,VStack,useDisclosure,- useWindowSize,+ useIsMobile,} from "@carbon/react";import { Form, Link, useMatches } from "@remix-run/react";import { BsFillHexagonFill } from "react-icons/bs";@@ -65,12 +65,12 @@ const Breadcrumbs = () => {}).filter(Boolean);- const { width } = useWindowSize();+ const isMobile = useIsMobile();return (<HStack className="items-center h-full -ml-2" spacing={0}><BreadcrumbsBase className="line-clamp-1">- {width && width <= 640 ? (+ {isMobile ? (<BreadcrumbItem><Button isIcon asChild variant="ghost"><Link to="/">diff --git a/apps/carbon/app/components/Table/components/TableHeader.tsx b/apps/carbon/app/components/Table/components/TableHeader.tsxindex 9986a3d528..adf0861286 100644--- a/apps/carbon/app/components/Table/components/TableHeader.tsx+++ b/apps/carbon/app/components/Table/components/TableHeader.tsx@@ -17,6 +17,7 @@ import { BsThreeDotsVertical } from "react-icons/bs";import { LuFileEdit, LuImport, LuLock, LuZap } from "react-icons/lu";import { SearchFilter } from "~/components";import { ImportCSVModal } from "~/components/ImportCSVModal";+import { CollapsibleSidebarTrigger } from "~/components/Layout/Navigation";import { useUrlParams } from "~/hooks";import type { fieldMappings } from "~/modules/shared/imports.models";import Columns from "./Columns";@@ -76,6 +77,7 @@ const TableHeader = <T extends object>({<><HStack className="px-4 py-2 justify-between bg-card border-b border-border w-full"><HStack>+ <CollapsibleSidebarTrigger />{withSearch && (<SearchFilter param="search" size="sm" placeholder="Search" />)}diff --git a/apps/carbon/app/modules/sales/ui/Opportunity/OpportunityNotes.tsx b/apps/carbon/app/modules/sales/ui/Opportunity/OpportunityNotes.tsxindex c683ee05e4..233f4f5e08 100644--- a/apps/carbon/app/modules/sales/ui/Opportunity/OpportunityNotes.tsx+++ b/apps/carbon/app/modules/sales/ui/Opportunity/OpportunityNotes.tsx@@ -7,7 +7,6 @@ import {CardTitle,Editor,generateHTML,- HStack,toast,useThrottle,} from "@carbon/react";@@ -77,23 +76,23 @@ const OpportunityNotes = ({if (!id) return null;return (- <HStack className="w-full justify-between items-stretch">+ <><Card><CardHeader>- <CardTitle>External Notes</CardTitle>+ <CardTitle>Internal Notes</CardTitle></CardHeader><CardContent>{permissions.can("update", "sales") ? (<Editor- initialValue={(externalNotes ?? {}) as JSONContent}+ initialValue={(internalNotes ?? {}) as JSONContent}onUpload={onUploadImage}- onChange={onUpdateExternalNotes}+ onChange={onUpdateInternalNotes}/>) : (<divclassName="prose dark:prose-invert"dangerouslySetInnerHTML={{- __html: generateHTML(externalNotes as JSONContent),+ __html: generateHTML(internalNotes as JSONContent),}}/>)}@@ -101,26 +100,26 @@ const OpportunityNotes = ({</Card><Card><CardHeader>- <CardTitle>Internal Notes</CardTitle>+ <CardTitle>External Notes</CardTitle></CardHeader><CardContent>{permissions.can("update", "sales") ? (<Editor- initialValue={(internalNotes ?? {}) as JSONContent}+ initialValue={(externalNotes ?? {}) as JSONContent}onUpload={onUploadImage}- onChange={onUpdateInternalNotes}+ onChange={onUpdateExternalNotes}/>) : (<divclassName="prose dark:prose-invert"dangerouslySetInnerHTML={{- __html: generateHTML(internalNotes as JSONContent),+ __html: generateHTML(externalNotes as JSONContent),}}/>)}</CardContent></Card>- </HStack>+ </>);};diff --git a/apps/carbon/app/routes/x+/accounting+/_layout.tsx b/apps/carbon/app/routes/x+/accounting+/_layout.tsxindex b62594e295..8b42fa3457 100644--- a/apps/carbon/app/routes/x+/accounting+/_layout.tsx+++ b/apps/carbon/app/routes/x+/accounting+/_layout.tsx@@ -6,6 +6,7 @@ import { Outlet } from "@remix-run/react";import type { LoaderFunctionArgs, MetaFunction } from "@vercel/remix";import { json, redirect } from "@vercel/remix";import { GroupedContentSidebar } from "~/components/Layout";+import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";import {getAccountsList,getBaseCurrency,@@ -56,11 +57,13 @@ export default function AccountingRoute() {const { groups } = useAccountingSubmodules();return (- <div className="grid grid-cols-[auto_1fr] w-full h-full">- <GroupedContentSidebar groups={groups} />- <VStack spacing={0} className="h-full">- <Outlet />- </VStack>- </div>+ <CollapsibleSidebarProvider>+ <div className="grid grid-cols-[auto_1fr] w-full h-full">+ <GroupedContentSidebar groups={groups} />+ <VStack spacing={0} className="h-full">+ <Outlet />+ </VStack>+ </div>+ </CollapsibleSidebarProvider>);}diff --git a/apps/carbon/app/routes/x+/api+/_layout.tsx b/apps/carbon/app/routes/x+/api+/_layout.tsxindex 12dc7b9627..e8054c5585 100644--- a/apps/carbon/app/routes/x+/api+/_layout.tsx+++ b/apps/carbon/app/routes/x+/api+/_layout.tsx@@ -4,6 +4,7 @@ import { Outlet, useLocation, useNavigate } from "@remix-run/react";import type { MetaFunction } from "@vercel/remix";import { LuEye, LuTable2 } from "react-icons/lu";import { GroupedContentSidebar } from "~/components/Layout";+import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";import type { ValidLang } from "~/modules/api";import { useSelectedLang } from "~/modules/api";import DocsStyle from "~/styles/docs.css?url";@@ -49,32 +50,34 @@ export default function ApiDocsRoute() {};return (- <div className="relative grid grid-cols-[auto_1fr] w-full h-full">- <div className="flex absolute top-4 right-4 z-50 gap-2">- <Button- variant={selectedLang === "js" ? "primary" : "secondary"}- onClick={() => {- onChangeLanguage("js");- }}- >- JS- </Button>- <Button- variant={selectedLang === "bash" ? "primary" : "secondary"}- onClick={() => {- onChangeLanguage("bash");- }}- >- Bash- </Button>- </div>- <GroupedContentSidebar groups={groups} width={270} exactMatch />- <div className="Docs Docs--api-page w-full h-full overflow-y-auto">- <div className="Docs--inner-wrapper pt-4">- <Outlet />+ <CollapsibleSidebarProvider>+ <div className="relative grid grid-cols-[auto_1fr] w-full h-full">+ <div className="flex absolute top-4 right-4 z-50 gap-2">+ <Button+ variant={selectedLang === "js" ? "primary" : "secondary"}+ onClick={() => {+ onChangeLanguage("js");+ }}+ >+ JS+ </Button>+ <Button+ variant={selectedLang === "bash" ? "primary" : "secondary"}+ onClick={() => {+ onChangeLanguage("bash");+ }}+ >+ Bash+ </Button>+ </div>+ <GroupedContentSidebar groups={groups} width={270} exactMatch />+ <div className="Docs Docs--api-page w-full h-full overflow-y-auto">+ <div className="Docs--inner-wrapper pt-4">+ <Outlet />+ </div></div></div>- </div>+ </CollapsibleSidebarProvider>);}diff --git a/apps/carbon/app/routes/x+/documents+/_layout.tsx b/apps/carbon/app/routes/x+/documents+/_layout.tsxindex 6a8aaabbc6..69a7328b32 100644--- a/apps/carbon/app/routes/x+/documents+/_layout.tsx+++ b/apps/carbon/app/routes/x+/documents+/_layout.tsx@@ -1,7 +1,10 @@import { VStack } from "@carbon/react";import { Outlet } from "@remix-run/react";import type { MetaFunction } from "@vercel/remix";-import { ContentSidebar } from "~/components/Layout/Navigation";+import {+ CollapsibleSidebarProvider,+ ContentSidebar,+} from "~/components/Layout/Navigation";import { useDocumentsSubmodules } from "~/modules/documents";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -20,11 +23,13 @@ export default function DocumentsRoute() {const { links } = useDocumentsSubmodules();return (- <div className="grid grid-cols-[auto_1fr] w-full h-full">- <ContentSidebar links={links} />- <VStack spacing={0} className="h-full">- <Outlet />- </VStack>- </div>+ <CollapsibleSidebarProvider>+ <div className="grid grid-cols-[auto_1fr] w-full h-full">+ <ContentSidebar links={links} />+ <VStack spacing={0} className="h-full">+ <Outlet />+ </VStack>+ </div>+ </CollapsibleSidebarProvider>);}diff --git a/apps/carbon/app/routes/x+/inventory+/_layout.tsx b/apps/carbon/app/routes/x+/inventory+/_layout.tsxindex 09e55e184c..7933e024b2 100644--- a/apps/carbon/app/routes/x+/inventory+/_layout.tsx+++ b/apps/carbon/app/routes/x+/inventory+/_layout.tsx@@ -3,6 +3,7 @@ import { VStack } from "@carbon/react";import { Outlet } from "@remix-run/react";import type { LoaderFunctionArgs, MetaFunction } from "@vercel/remix";import { GroupedContentSidebar } from "~/components/Layout";+import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";import { getShelvesList, useInventorySubmodules } from "~/modules/inventory";import { getUnitOfMeasuresList } from "~/modules/items";import { getLocationsList } from "~/modules/resources";@@ -41,11 +42,13 @@ export default function InventoryRoute() {const { groups } = useInventorySubmodules();return (- <div className="grid grid-cols-[auto_1fr] w-full h-full">- <GroupedContentSidebar groups={groups} />- <VStack spacing={0} className="h-full">- <Outlet />- </VStack>- </div>+ <CollapsibleSidebarProvider>+ <div className="grid grid-cols-[auto_1fr] w-full h-full">+ <GroupedContentSidebar groups={groups} />+ <VStack spacing={0} className="h-full">+ <Outlet />+ </VStack>+ </div>+ </CollapsibleSidebarProvider>);}diff --git a/apps/carbon/app/routes/x+/invoicing+/_layout.tsx b/apps/carbon/app/routes/x+/invoicing+/_layout.tsxindex c1795c80f6..15038884d2 100644--- a/apps/carbon/app/routes/x+/invoicing+/_layout.tsx+++ b/apps/carbon/app/routes/x+/invoicing+/_layout.tsx@@ -1,6 +1,7 @@import { VStack } from "@carbon/react";import { Outlet } from "@remix-run/react";import { GroupedContentSidebar } from "~/components/Layout";+import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";import { useInvoicingSubmodules } from "~/modules/invoicing";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -15,11 +16,13 @@ export default function InvoicingRoute() {const { groups } = useInvoicingSubmodules();return (- <div className="grid grid-cols-[auto_1fr] w-full h-full">- <GroupedContentSidebar groups={groups} />- <VStack spacing={0} className="h-full">- <Outlet />- </VStack>- </div>+ <CollapsibleSidebarProvider>+ <div className="grid grid-cols-[auto_1fr] w-full h-full">+ <GroupedContentSidebar groups={groups} />+ <VStack spacing={0} className="h-full">+ <Outlet />+ </VStack>+ </div>+ </CollapsibleSidebarProvider>);}diff --git a/apps/carbon/app/routes/x+/items+/_layout.tsx b/apps/carbon/app/routes/x+/items+/_layout.tsxindex e0455e46e6..28dad9b119 100644--- a/apps/carbon/app/routes/x+/items+/_layout.tsx+++ b/apps/carbon/app/routes/x+/items+/_layout.tsx@@ -2,6 +2,7 @@ import { VStack } from "@carbon/react";import { Outlet } from "@remix-run/react";import type { MetaFunction } from "@vercel/remix";import { GroupedContentSidebar } from "~/components/Layout";+import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";import { useItemsSubmodules } from "~/modules/items";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -20,11 +21,13 @@ export default function PartsRoute() {const { groups } = useItemsSubmodules();return (- <div className="grid grid-cols-[auto_1fr] w-full h-full">- <GroupedContentSidebar groups={groups} />- <VStack spacing={0} className="h-full">- <Outlet />- </VStack>- </div>+ <CollapsibleSidebarProvider>+ <div className="grid grid-cols-[auto_1fr] w-full h-full">+ <GroupedContentSidebar groups={groups} />+ <VStack spacing={0} className="h-full">+ <Outlet />+ </VStack>+ </div>+ </CollapsibleSidebarProvider>);}diff --git a/apps/carbon/app/routes/x+/people+/_layout.tsx b/apps/carbon/app/routes/x+/people+/_layout.tsxindex 1e639e3086..6226c26a20 100644--- a/apps/carbon/app/routes/x+/people+/_layout.tsx+++ b/apps/carbon/app/routes/x+/people+/_layout.tsx@@ -2,6 +2,7 @@ import { VStack } from "@carbon/react";import { Outlet } from "@remix-run/react";import type { MetaFunction } from "@vercel/remix";import { GroupedContentSidebar } from "~/components/Layout";+import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";import { usePeopleSubmodules } from "~/modules/people";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -20,11 +21,13 @@ export default function PeopleRoute() {const { groups } = usePeopleSubmodules();return (- <div className="grid grid-cols-[auto_1fr] w-full h-full">- <GroupedContentSidebar groups={groups} />- <VStack spacing={0} className="h-full">- <Outlet />- </VStack>- </div>+ <CollapsibleSidebarProvider>+ <div className="grid grid-cols-[auto_1fr] w-full h-full">+ <GroupedContentSidebar groups={groups} />+ <VStack spacing={0} className="h-full">+ <Outlet />+ </VStack>+ </div>+ </CollapsibleSidebarProvider>);}diff --git a/apps/carbon/app/routes/x+/production+/_layout.tsx b/apps/carbon/app/routes/x+/production+/_layout.tsxindex e0201f5f7b..05bbdc558c 100644--- a/apps/carbon/app/routes/x+/production+/_layout.tsx+++ b/apps/carbon/app/routes/x+/production+/_layout.tsx@@ -2,6 +2,7 @@ import { VStack } from "@carbon/react";import { Outlet } from "@remix-run/react";import type { MetaFunction } from "@vercel/remix";import { GroupedContentSidebar } from "~/components/Layout";+import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";import { useProductionSubmodules } from "~/modules/production";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -20,11 +21,13 @@ export default function ProductionRoute() {const { groups } = useProductionSubmodules();return (- <div className="grid grid-cols-[auto_1fr] w-full h-full">- <GroupedContentSidebar groups={groups} />- <VStack spacing={0} className="h-full">- <Outlet />- </VStack>- </div>+ <CollapsibleSidebarProvider>+ <div className="grid grid-cols-[auto_1fr] w-full h-full">+ <GroupedContentSidebar groups={groups} />+ <VStack spacing={0} className="h-full">+ <Outlet />+ </VStack>+ </div>+ </CollapsibleSidebarProvider>);}diff --git a/apps/carbon/app/routes/x+/purchasing+/_layout.tsx b/apps/carbon/app/routes/x+/purchasing+/_layout.tsxindex d65b9bfc2f..ddc6dcc2af 100644--- a/apps/carbon/app/routes/x+/purchasing+/_layout.tsx+++ b/apps/carbon/app/routes/x+/purchasing+/_layout.tsx@@ -2,6 +2,7 @@ import { VStack } from "@carbon/react";import { Outlet } from "@remix-run/react";import type { MetaFunction } from "@vercel/remix";import { GroupedContentSidebar } from "~/components/Layout";+import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";import { usePurchasingSubmodules } from "~/modules/purchasing";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -20,11 +21,13 @@ export default function UsersRoute() {const { groups } = usePurchasingSubmodules();return (- <div className="grid grid-cols-[auto_1fr] w-full h-full">- <GroupedContentSidebar groups={groups} />- <VStack spacing={0} className="h-full">- <Outlet />- </VStack>- </div>+ <CollapsibleSidebarProvider>+ <div className="grid grid-cols-[auto_1fr] w-full h-full">+ <GroupedContentSidebar groups={groups} />+ <VStack spacing={0} className="h-full">+ <Outlet />+ </VStack>+ </div>+ </CollapsibleSidebarProvider>);}diff --git a/apps/carbon/app/routes/x+/resources+/_layout.tsx b/apps/carbon/app/routes/x+/resources+/_layout.tsxindex a07351a12a..44512d2dde 100644--- a/apps/carbon/app/routes/x+/resources+/_layout.tsx+++ b/apps/carbon/app/routes/x+/resources+/_layout.tsx@@ -2,6 +2,7 @@ import { VStack } from "@carbon/react";import { Outlet } from "@remix-run/react";import type { MetaFunction } from "@vercel/remix";import { GroupedContentSidebar } from "~/components/Layout";+import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";import { useResourcesSubmodules } from "~/modules/resources";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -20,11 +21,13 @@ export default function ResourcesRoute() {const { groups } = useResourcesSubmodules();return (- <div className="grid grid-cols-[auto_1fr] w-full h-full">- <GroupedContentSidebar groups={groups} />- <VStack spacing={0} className="h-full">- <Outlet />- </VStack>- </div>+ <CollapsibleSidebarProvider>+ <div className="grid grid-cols-[auto_1fr] w-full h-full">+ <GroupedContentSidebar groups={groups} />+ <VStack spacing={0} className="h-full">+ <Outlet />+ </VStack>+ </div>+ </CollapsibleSidebarProvider>);}diff --git a/apps/carbon/app/routes/x+/sales+/_layout.tsx b/apps/carbon/app/routes/x+/sales+/_layout.tsxindex 682e4cb70e..88b52f970e 100644--- a/apps/carbon/app/routes/x+/sales+/_layout.tsx+++ b/apps/carbon/app/routes/x+/sales+/_layout.tsx@@ -2,6 +2,7 @@ import { VStack } from "@carbon/react";import { Outlet } from "@remix-run/react";import type { MetaFunction } from "@vercel/remix";import { GroupedContentSidebar } from "~/components/Layout";+import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";import { useSalesSubmodules } from "~/modules/sales";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -20,11 +21,13 @@ export default function SalesRoute() {const { groups } = useSalesSubmodules();return (- <div className="grid grid-cols-[auto_1fr] w-full h-full">- <GroupedContentSidebar groups={groups} />- <VStack spacing={0} className="h-full">- <Outlet />- </VStack>- </div>+ <CollapsibleSidebarProvider>+ <div className="grid grid-cols-[auto_1fr] w-full h-full">+ <GroupedContentSidebar groups={groups} />+ <VStack spacing={0} className="h-full">+ <Outlet />+ </VStack>+ </div>+ </CollapsibleSidebarProvider>);}diff --git a/apps/carbon/app/routes/x+/settings+/_layout.tsx b/apps/carbon/app/routes/x+/settings+/_layout.tsxindex 44e65bfc5a..b8030216ed 100644--- a/apps/carbon/app/routes/x+/settings+/_layout.tsx+++ b/apps/carbon/app/routes/x+/settings+/_layout.tsx@@ -3,6 +3,7 @@ import { Outlet } from "@remix-run/react";import type { MetaFunction } from "@vercel/remix";import { LuKey } from "react-icons/lu";import { GroupedContentSidebar } from "~/components/Layout";+import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";import { usePermissions } from "~/hooks";import { useSettingsSubmodules } from "~/modules/settings";import type { Handle } from "~/utils/handle";@@ -32,11 +33,13 @@ export default function SettingsRoute() {}return (- <div className="grid grid-cols-[auto_1fr] w-full h-full">- <GroupedContentSidebar groups={groups} />- <VStack spacing={0} className="h-full">- <Outlet />- </VStack>- </div>+ <CollapsibleSidebarProvider>+ <div className="grid grid-cols-[auto_1fr] w-full h-full">+ <GroupedContentSidebar groups={groups} />+ <VStack spacing={0} className="h-full">+ <Outlet />+ </VStack>+ </div>+ </CollapsibleSidebarProvider>);}diff --git a/apps/carbon/app/routes/x+/users+/_layout.tsx b/apps/carbon/app/routes/x+/users+/_layout.tsxindex 969c0ccfaa..cd66196dc4 100644--- a/apps/carbon/app/routes/x+/users+/_layout.tsx+++ b/apps/carbon/app/routes/x+/users+/_layout.tsx@@ -2,6 +2,7 @@ import { VStack } from "@carbon/react";import { Outlet } from "@remix-run/react";import type { MetaFunction } from "@vercel/remix";import { GroupedContentSidebar } from "~/components/Layout";+import { CollapsibleSidebarProvider } from "~/components/Layout/Navigation";import { useUsersSubmodules } from "~/modules/users";import type { Handle } from "~/utils/handle";import { path } from "~/utils/path";@@ -20,11 +21,13 @@ export default function UsersRoute() {const { groups } = useUsersSubmodules();return (- <div className="grid grid-cols-[auto_1fr] w-full h-full">- <GroupedContentSidebar groups={groups} />- <VStack spacing={0} className="h-full">- <Outlet />- </VStack>- </div>+ <CollapsibleSidebarProvider>+ <div className="grid grid-cols-[auto_1fr] w-full h-full">+ <GroupedContentSidebar groups={groups} />+ <VStack spacing={0} className="h-full">+ <Outlet />+ </VStack>+ </div>+ </CollapsibleSidebarProvider>);}diff --git a/apps/carbon/app/styles/tailwind.css b/apps/carbon/app/styles/tailwind.cssindex 69f1fb3edb..754fa551e1 100644--- a/apps/carbon/app/styles/tailwind.css+++ b/apps/carbon/app/styles/tailwind.css@@ -68,17 +68,6 @@}}-.forge-viewer {- position: relative;- width: 100%;- height: 100%;- min-height: 400px;-}--.forge-viewer > div {- border-radius: var(--radius);-}-canvas#viewer {border-radius: var(--radius);}diff --git a/apps/developers/app/components/AppSidebar.tsx b/apps/developers/app/components/AppSidebar.tsxnew file mode 100644index 0000000000..cbf5982651--- /dev/null+++ b/apps/developers/app/components/AppSidebar.tsx@@ -0,0 +1,430 @@+import {+ Avatar,+ Collapsible,+ CollapsibleContent,+ CollapsibleTrigger,+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuGroup,+ DropdownMenuIcon,+ DropdownMenuItem,+ DropdownMenuLabel,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+ Sidebar,+ SidebarContent,+ SidebarFooter,+ SidebarGroup,+ SidebarGroupContent,+ SidebarGroupLabel,+ SidebarHeader,+ SidebarMenu,+ SidebarMenuAction,+ SidebarMenuButton,+ SidebarMenuItem,+ SidebarMenuSub,+ SidebarMenuSubButton,+ SidebarMenuSubItem,+ useSidebar,+} from "@carbon/react";+import { Link } from "@remix-run/react";+import type { IconType } from "react-icons/lib";+import {+ LuBadgeCheck,+ LuBell,+ LuBookOpen,+ LuBot,+ LuChevronRight,+ LuChevronsUpDown,+ LuCommand,+ LuCreditCard,+ LuFolder,+ LuFrame,+ LuLifeBuoy,+ LuLogOut,+ LuMap,+ LuMoreHorizontal,+ LuPieChart,+ LuSend,+ LuSettings2,+ LuShare,+ LuSparkles,+ LuTrash,+} from "react-icons/lu";++const data = {+ user: {+ name: "shadcn",+ email: "[email protected]",+ avatar: "/avatars/shadcn.jpg",+ },+ navMain: [+ {+ title: "Models",+ url: "#",+ icon: LuBot,+ items: [+ {+ title: "Genesis",+ url: "#",+ },+ {+ title: "Explorer",+ url: "#",+ },+ {+ title: "Quantum",+ url: "#",+ },+ ],+ },+ {+ title: "Documentation",+ url: "#",+ icon: LuBookOpen,+ items: [+ {+ title: "Introduction",+ url: "#",+ },+ {+ title: "Get Started",+ url: "#",+ },+ {+ title: "Tutorials",+ url: "#",+ },+ {+ title: "Changelog",+ url: "#",+ },+ ],+ },+ {+ title: "Settings",+ url: "#",+ icon: LuSettings2,+ items: [+ {+ title: "General",+ url: "#",+ },+ {+ title: "Team",+ url: "#",+ },+ {+ title: "Billing",+ url: "#",+ },+ {+ title: "Limits",+ url: "#",+ },+ ],+ },+ ],+ navSecondary: [+ {+ title: "Support",+ url: "#",+ icon: LuLifeBuoy,+ },+ {+ title: "Feedback",+ url: "#",+ icon: LuSend,+ },+ ],+ projects: [+ {+ name: "Design Engineering",+ url: "#",+ icon: LuFrame,+ },+ {+ name: "Sales & Marketing",+ url: "#",+ icon: LuPieChart,+ },+ {+ name: "Travel",+ url: "#",+ icon: LuMap,+ },+ ],+};+export function AppSidebar({ ...props }: React.ComponentProps<typeof Sidebar>) {+ return (+ <Sidebar variant="inset" {...props}>+ <SidebarHeader>+ <SidebarMenu>+ <SidebarMenuItem>+ <SidebarMenuButton size="lg" asChild>+ <Link to="/">+ <div className="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">+ <LuCommand className="size-4" />+ </div>+ <div className="grid flex-1 text-left text-sm leading-tight">+ <span className="truncate font-semibold">Acme Inc</span>+ <span className="truncate text-xs">Enterprise</span>+ </div>+ </Link>+ </SidebarMenuButton>+ </SidebarMenuItem>+ </SidebarMenu>+ </SidebarHeader>+ <SidebarContent>+ <NavMain items={data.navMain} />+ <NavProjects projects={data.projects} />+ <NavSecondary items={data.navSecondary} className="mt-auto" />+ </SidebarContent>+ <SidebarFooter>+ <NavUser user={data.user} />+ </SidebarFooter>+ </Sidebar>+ );+}++export function NavMain({+ items,+}: {+ items: {+ title: string;+ url: string;+ icon: IconType;+ isActive?: boolean;+ items?: {+ title: string;+ url: string;+ }[];+ }[];+}) {+ return (+ <SidebarGroup>+ <SidebarGroupLabel>Platform</SidebarGroupLabel>+ <SidebarMenu>+ {items.map((item) => (+ <Collapsible key={item.title} asChild defaultOpen={item.isActive}>+ <SidebarMenuItem>+ <SidebarMenuButton asChild tooltip={item.title}>+ <a href={item.url}>+ <item.icon />+ <span>{item.title}</span>+ </a>+ </SidebarMenuButton>+ {item.items?.length ? (+ <>+ <CollapsibleTrigger asChild>+ <SidebarMenuAction className="data-[state=open]:rotate-90">+ <LuChevronRight />+ <span className="sr-only">Toggle</span>+ </SidebarMenuAction>+ </CollapsibleTrigger>+ <CollapsibleContent>+ <SidebarMenuSub>+ {item.items?.map((subItem) => (+ <SidebarMenuSubItem key={subItem.title}>+ <SidebarMenuSubButton asChild>+ <a href={subItem.url}>+ <span>{subItem.title}</span>+ </a>+ </SidebarMenuSubButton>+ </SidebarMenuSubItem>+ ))}+ </SidebarMenuSub>+ </CollapsibleContent>+ </>+ ) : null}+ </SidebarMenuItem>+ </Collapsible>+ ))}+ </SidebarMenu>+ </SidebarGroup>+ );+}++export function NavProjects({+ projects,+}: {+ projects: {+ name: string;+ url: string;+ icon: IconType;+ }[];+}) {+ const { isMobile } = useSidebar();+ return (+ <SidebarGroup className="group-data-[collapsible=icon]:hidden">+ <SidebarGroupLabel>Projects</SidebarGroupLabel>+ <SidebarMenu>+ {projects.map((item) => (+ <SidebarMenuItem key={item.name}>+ <SidebarMenuButton asChild>+ <a href={item.url}>+ <item.icon />+ <span>{item.name}</span>+ </a>+ </SidebarMenuButton>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <SidebarMenuAction showOnHover>+ <LuMoreHorizontal />+ <span className="sr-only">More</span>+ </SidebarMenuAction>+ </DropdownMenuTrigger>+ <DropdownMenuContent+ className="w-48"+ side={isMobile ? "bottom" : "right"}+ align={isMobile ? "end" : "start"}+ >+ <DropdownMenuItem>+ <DropdownMenuIcon+ icon={<LuFolder className="text-muted-foreground" />}+ />+ <span>View Project</span>+ </DropdownMenuItem>+ <DropdownMenuItem>+ <DropdownMenuIcon+ icon={<LuShare className="text-muted-foreground" />}+ />+ <span>Share Project</span>+ </DropdownMenuItem>+ <DropdownMenuSeparator />+ <DropdownMenuItem>+ <DropdownMenuIcon+ icon={<LuTrash className="text-muted-foreground" />}+ />+ <span>Delete Project</span>+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ </SidebarMenuItem>+ ))}+ <SidebarMenuItem>+ <SidebarMenuButton>+ <LuMoreHorizontal />+ <span>More</span>+ </SidebarMenuButton>+ </SidebarMenuItem>+ </SidebarMenu>+ </SidebarGroup>+ );+}++export function NavSecondary({+ items,+ ...props+}: {+ items: {+ title: string;+ url: string;+ icon: IconType;+ }[];+} & React.ComponentPropsWithoutRef<typeof SidebarGroup>) {+ return (+ <SidebarGroup {...props}>+ <SidebarGroupContent>+ <SidebarMenu>+ {items.map((item) => (+ <SidebarMenuItem key={item.title}>+ <SidebarMenuButton asChild size="sm">+ <a href={item.url}>+ <item.icon />+ <span>{item.title}</span>+ </a>+ </SidebarMenuButton>+ </SidebarMenuItem>+ ))}+ </SidebarMenu>+ </SidebarGroupContent>+ </SidebarGroup>+ );+}++export function NavUser({+ user,+}: {+ user: {+ name: string;+ email: string;+ avatar: string;+ };+}) {+ const { isMobile } = useSidebar();+ return (+ <SidebarMenu>+ <SidebarMenuItem>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <SidebarMenuButton+ size="lg"+ className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"+ >+ <Avatar+ className="h-8 w-8 rounded-lg"+ src={user.avatar}+ name={user.name}+ />++ <div className="grid flex-1 text-left text-sm leading-tight">+ <span className="truncate font-semibold">{user.name}</span>+ <span className="truncate text-xs">{user.email}</span>+ </div>+ <LuChevronsUpDown className="ml-auto size-4" />+ </SidebarMenuButton>+ </DropdownMenuTrigger>+ <DropdownMenuContent+ className="w-[--radix-dropdown-menu-trigger-width] min-w-56 rounded-lg"+ side={isMobile ? "bottom" : "right"}+ align="end"+ sideOffset={4}+ >+ <DropdownMenuLabel className="p-0 font-normal">+ <div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm">+ <Avatar+ className="h-8 w-8 rounded-lg"+ src={user.avatar}+ name={user.name}+ />++ <div className="grid flex-1 text-left text-sm leading-tight">+ <span className="truncate font-semibold">{user.name}</span>+ <span className="truncate text-xs">{user.email}</span>+ </div>+ </div>+ </DropdownMenuLabel>+ <DropdownMenuSeparator />+ <DropdownMenuGroup>+ <DropdownMenuItem>+ <DropdownMenuIcon icon={<LuSparkles />} />+ Upgrade to Pro+ </DropdownMenuItem>+ </DropdownMenuGroup>+ <DropdownMenuSeparator />+ <DropdownMenuGroup>+ <DropdownMenuItem>+ <DropdownMenuIcon icon={<LuBadgeCheck />} />+ Account+ </DropdownMenuItem>+ <DropdownMenuItem>+ <DropdownMenuIcon icon={<LuCreditCard />} />+ Billing+ </DropdownMenuItem>+ <DropdownMenuItem>+ <DropdownMenuIcon icon={<LuBell />} />+ Notifications+ </DropdownMenuItem>+ </DropdownMenuGroup>+ <DropdownMenuSeparator />+ <DropdownMenuItem>+ <DropdownMenuIcon icon={<LuLogOut />} />+ Log out+ </DropdownMenuItem>+ </DropdownMenuContent>+ </DropdownMenu>+ </SidebarMenuItem>+ </SidebarMenu>+ );+}diff --git a/apps/developers/app/components/Topbar/AvatarMenu.tsx b/apps/developers/app/components/AvatarMenu.tsxsimilarity index 100%rename from apps/developers/app/components/Topbar/AvatarMenu.tsxrename to apps/developers/app/components/AvatarMenu.tsxdiff --git a/apps/developers/app/components/Breadcrumbs.tsx b/apps/developers/app/components/Breadcrumbs.tsxindex 9ead67b83c..7f143583b3 100644--- a/apps/developers/app/components/Breadcrumbs.tsx+++ b/apps/developers/app/components/Breadcrumbs.tsx@@ -1,10 +1,32 @@-import { Button, cn, getValidChildren } from "@carbon/react";+import {+ Avatar,+ Badge,+ Button,+ cn,+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuGroup,+ DropdownMenuItem,+ DropdownMenuLabel,+ DropdownMenuSeparator,+ DropdownMenuTrigger,+ getValidChildren,+ HStack,+ useIsMobile,+} from "@carbon/react";import type { LinkProps } from "@remix-run/react";-import { Link } from "@remix-run/react";+import { Form, Link, useMatches } from "@remix-run/react";import type { ComponentProps } from "react";import { cloneElement, forwardRef } from "react";-const Breadcrumbs = forwardRef<+import type { Company } from "@carbon/auth";+import { LuChevronsUpDown } from "react-icons/lu";+import { z } from "zod";++import { useMode, useRouteData } from "~/hooks";+import { path } from "~/utils/path";++const BreadcrumbsBase = forwardRef<HTMLElement,ComponentProps<"nav"> & {useReactRouter?: boolean;@@ -29,7 +51,7 @@ const Breadcrumbs = forwardRef<</nav>);});-Breadcrumbs.displayName = "Breadcrumbs";+BreadcrumbsBase.displayName = "BreadcrumbsBase";const BreadcrumbItem = forwardRef<HTMLLIElement,@@ -78,4 +100,127 @@ const BreadcrumbLink = forwardRef<});BreadcrumbLink.displayName = "BreadcrumbLink";-export { BreadcrumbItem, BreadcrumbLink, Breadcrumbs };+export const BreadcrumbHandle = z.object({+ breadcrumb: z.any(),+ to: z.string().optional(),+});+export type BreadcrumbHandleType = z.infer<typeof BreadcrumbHandle>;++const BreadcrumbHandleMatch = z.object({+ handle: BreadcrumbHandle,+});++const Breadcrumbs = () => {+ const matches = useMatches();++ const breadcrumbs = matches+ .map((m) => {+ const result = BreadcrumbHandleMatch.safeParse(m);+ if (!result.success || !result.data.handle.breadcrumb) return null;++ return {+ breadcrumb: result.data.handle.breadcrumb,+ to: result.data.handle?.to ?? m.pathname,+ };+ })+ .filter(Boolean);++ const isMobile = useIsMobile();++ return (+ <HStack className="items-center h-full -ml-2" spacing={0}>+ <BreadcrumbsBase className="line-clamp-1">+ {!isMobile && <CompanyBreadcrumb />}+ {breadcrumbs.map((breadcrumb, i) => (+ <BreadcrumbItem key={i}>+ <BreadcrumbLink+ isCurrentPage={!breadcrumb?.to}+ to={breadcrumb?.to ?? ""}+ >+ {breadcrumb?.breadcrumb}+ </BreadcrumbLink>+ </BreadcrumbItem>+ ))}+ </BreadcrumbsBase>+ </HStack>+ );+};++function CompanyBreadcrumb() {+ const mode = useMode();+ const routeData = useRouteData<{ company: Company; companies: Company[] }>(+ path.to.authenticatedRoot+ );++ const hasMultipleCompanies = Boolean(+ routeData?.companies && routeData?.companies.length > 1+ );++ const hasCompanyMenu = hasMultipleCompanies;++ return (+ <>+ <BreadcrumbItem isFirstChild>+ <BreadcrumbLink to="/">Developers</BreadcrumbLink>+ </BreadcrumbItem>+ <BreadcrumbItem>+ {hasCompanyMenu ? (+ <>+ <DropdownMenu>+ <DropdownMenuTrigger asChild>+ <Button+ aria-current="page"+ variant="ghost"+ className="px-2 focus-visible:ring-transparent"+ rightIcon={<LuChevronsUpDown />}+ >+ {routeData?.company.name}+ </Button>+ </DropdownMenuTrigger>+ <DropdownMenuContent align="start" className="min-w-[240px]">+ <DropdownMenuLabel>Companies</DropdownMenuLabel>+ <DropdownMenuSeparator />+ <DropdownMenuGroup>+ {routeData?.companies.map((c) => {+ const logo =+ mode === "dark" ? c.logoDarkIcon : c.logoLightIcon;+ return (+ <Form+ key={c.companyId}+ method="post"+ action={path.to.companySwitch(c.companyId!)}+ >+ <DropdownMenuItem+ className="flex items-center justify-between w-full"+ asChild+ >+ <button type="submit">+ <HStack>+ <Avatar+ size="xs"+ name={c.name ?? undefined}+ src={logo ?? undefined}+ />+ <span>{c.name}</span>+ </HStack>+ <Badge variant="secondary" className="ml-2">+ {c.employeeType}+ </Badge>+ </button>+ </DropdownMenuItem>+ </Form>+ );+ })}+ </DropdownMenuGroup>+ </DropdownMenuContent>+ </DropdownMenu>+ </>+ ) : (+ <BreadcrumbLink to="/">{routeData?.company.name}</BreadcrumbLink>+ )}+ </BreadcrumbItem>+ </>+ );+}++export default Breadcrumbs;diff --git a/apps/developers/app/components/PrimaryNavigation.tsx b/apps/developers/app/components/PrimaryNavigation.tsxdeleted file mode 100644index cab7d14abe..0000000000--- a/apps/developers/app/components/PrimaryNavigation.tsx+++ /dev/null@@ -1,7 +0,0 @@-const PrimaryNavigation = () => {- return (- <aside className="flex flex-col h-full w-[210px] bg-background"></aside>- );-};--export default PrimaryNavigation;diff --git a/apps/developers/app/components/Topbar/Breadcrumbs.tsx b/apps/developers/app/components/Topbar/Breadcrumbs.tsxdeleted file mode 100644index de00c09b7b..0000000000--- a/apps/developers/app/components/Topbar/Breadcrumbs.tsx+++ /dev/null@@ -1,162 +0,0 @@-import type { Company } from "@carbon/auth";-import {- Avatar,- Badge,- Button,- DropdownMenu,- DropdownMenuContent,- DropdownMenuGroup,- DropdownMenuItem,- DropdownMenuLabel,- DropdownMenuSeparator,- DropdownMenuTrigger,- HStack,- useWindowSize,-} from "@carbon/react";-import { Form, Link, useMatches } from "@remix-run/react";-import { BsFillHexagonFill } from "react-icons/bs";-import { LuChevronsUpDown } from "react-icons/lu";-import { z } from "zod";-import {- BreadcrumbItem,- BreadcrumbLink,- Breadcrumbs as BreadcrumbsBase,-} from "~/components/Breadcrumbs";--import { useMode, useRouteData } from "~/hooks";-import { path } from "~/utils/path";--export const BreadcrumbHandle = z.object({- breadcrumb: z.any(),- to: z.string().optional(),-});-export type BreadcrumbHandleType = z.infer<typeof BreadcrumbHandle>;--const BreadcrumbHandleMatch = z.object({- handle: BreadcrumbHandle,-});--const Breadcrumbs = () => {- const matches = useMatches();-- const breadcrumbs = matches- .map((m) => {- const result = BreadcrumbHandleMatch.safeParse(m);- if (!result.success || !result.data.handle.breadcrumb) return null;-- return {- breadcrumb: result.data.handle.breadcrumb,- to: result.data.handle?.to ?? m.pathname,- };- })- .filter(Boolean);-- const { width } = useWindowSize();-- return (- <HStack className="items-center h-full -ml-2" spacing={0}>- <BreadcrumbsBase className="line-clamp-1">- {width && width <= 640 ? (- <BreadcrumbItem>- <Button isIcon asChild variant="ghost">- <Link to="/">- <BsFillHexagonFill />- </Link>- </Button>- </BreadcrumbItem>- ) : (- <CompanyBreadcrumb />- )}- {breadcrumbs.map((breadcrumb, i) => (- <BreadcrumbItem key={i}>- <BreadcrumbLink- isCurrentPage={!breadcrumb?.to}- to={breadcrumb?.to ?? ""}- >- {breadcrumb?.breadcrumb}- </BreadcrumbLink>- </BreadcrumbItem>- ))}- </BreadcrumbsBase>- </HStack>- );-};--function CompanyBreadcrumb() {- const mode = useMode();- const routeData = useRouteData<{ company: Company; companies: Company[] }>(- path.to.authenticatedRoot- );-- const hasMultipleCompanies = Boolean(- routeData?.companies && routeData?.companies.length > 1- );-- const hasCompanyMenu = hasMultipleCompanies;-- return (- <>- <BreadcrumbItem isFirstChild>- <BreadcrumbLink to="/">Developers</BreadcrumbLink>- </BreadcrumbItem>- <BreadcrumbItem>- {hasCompanyMenu ? (- <>- <DropdownMenu>- <DropdownMenuTrigger asChild>- <Button- aria-current="page"- variant="ghost"- className="px-2 focus-visible:ring-transparent"- rightIcon={<LuChevronsUpDown />}- >- {routeData?.company.name}- </Button>- </DropdownMenuTrigger>- <DropdownMenuContent align="start" className="min-w-[240px]">- <DropdownMenuLabel>Companies</DropdownMenuLabel>- <DropdownMenuSeparator />- <DropdownMenuGroup>- {routeData?.companies.map((c) => {- const logo =- mode === "dark" ? c.logoDarkIcon : c.logoLightIcon;- return (- <Form- key={c.companyId}- method="post"- action={path.to.companySwitch(c.companyId!)}- >- <DropdownMenuItem- className="flex items-center justify-between w-full"- asChild- >- <button type="submit">- <HStack>- <Avatar- size="xs"- name={c.name ?? undefined}- src={logo ?? undefined}- />- <span>{c.name}</span>- </HStack>- <Badge variant="secondary" className="ml-2">- {c.employeeType}- </Badge>- </button>- </DropdownMenuItem>- </Form>- );- })}- </DropdownMenuGroup>- </DropdownMenuContent>- </DropdownMenu>- </>- ) : (- <BreadcrumbLink to="/">{routeData?.company.name}</BreadcrumbLink>- )}- </BreadcrumbItem>- </>- );-}--export default Breadcrumbs;diff --git a/apps/developers/app/components/Topbar/Topbar.tsx b/apps/developers/app/components/Topbar/Topbar.tsxdeleted file mode 100644index 1c5c22c90f..0000000000--- a/apps/developers/app/components/Topbar/Topbar.tsx+++ /dev/null@@ -1,18 +0,0 @@-import { HStack } from "@carbon/react";--import AvatarMenu from "./AvatarMenu";-import Breadcrumbs from "./Breadcrumbs";--const Topbar = () => {- return (- <div className="flex bg-background text-foreground pl-4 pr-2 top-0 sticky z-10 gap-x-4 justify-between items-center">- <Breadcrumbs />-- <HStack spacing={2} className="justify-end py-2">- <AvatarMenu />- </HStack>- </div>- );-};--export default Topbar;diff --git a/apps/developers/app/components/Topbar/index.ts b/apps/developers/app/components/Topbar/index.tsdeleted file mode 100644index 65efcbb275..0000000000--- a/apps/developers/app/components/Topbar/index.ts+++ /dev/null@@ -1,5 +0,0 @@-import AvatarMenu from "./AvatarMenu";-import Topbar from "./Topbar";--export default Topbar;-export { AvatarMenu };diff --git a/apps/developers/app/components/index.ts b/apps/developers/app/components/index.tsindex 2195ea59a4..164b5bab4a 100644--- a/apps/developers/app/components/index.ts+++ b/apps/developers/app/components/index.ts@@ -1,6 +1,4 @@import Avatar from "./Avatar";import Background from "./Background";-import PrimaryNavigation from "./PrimaryNavigation";-import Topbar from "./Topbar";-export { Avatar, Background, PrimaryNavigation, Topbar };+export { Avatar, Background };diff --git a/apps/developers/app/routes/x+/_layout.tsx b/apps/developers/app/routes/x+/_layout.tsxindex 31745a2aef..9e713b11ee 100644--- a/apps/developers/app/routes/x+/_layout.tsx+++ b/apps/developers/app/routes/x+/_layout.tsx@@ -1,4 +1,9 @@-import { Toaster, TooltipProvider } from "@carbon/react";+import {+ SidebarInset,+ SidebarProvider,+ SidebarTrigger,+ Toaster,+} from "@carbon/react";import { Outlet, useLoaderData, useNavigation } from "@remix-run/react";import type { LoaderFunctionArgs } from "@vercel/remix";import { json, redirect } from "@vercel/remix";@@ -16,8 +21,9 @@ import {destroyAuthSession,requireAuthSession,} from "@carbon/auth/session.server";-import { PrimaryNavigation, Topbar } from "~/components";+import { AppSidebar } from "~/components/AppSidebar";+import Breadcrumbs from "~/components/Breadcrumbs";import { path } from "~/utils/path";export const ERP_URL = VERCEL_URL?.includes("localhost")@@ -81,31 +87,23 @@ export default function AuthenticatedRoute() {return (<CarbonProvider session={session}>- <TooltipProvider>- <div className="min-h-full flex flex-col">- <div className="flex-none" />- <div className="h-screen min-h-[0px] basis-0 flex-1">- <div className="flex h-full">- <div className="flex w-full h-full">- <div className="w-full h-full flex-1 overflow-hidden">- <main className="h-full flex flex-col flex-1 max-w-screen sm:max-w-screen overflow-x-hidden bg-background">- <Topbar />- <main className="grid grid-cols-[auto_1fr] overflow-hidden h-[calc(100vh-49px)]">- <PrimaryNavigation />- <main className="flex-1 h-[calc(100vh-49px)] w-full overflow-hidden p-2 pt-0">- <div className="flex-1 h-full w-full overflow-y-auto border-border border bg-muted rounded-lg">- <Outlet />- </div>- </main>- </main>- </main>- </div>- </div>+ <SidebarProvider>+ <AppSidebar />+ <SidebarInset>+ <header className="flex h-16 shrink-0 items-center gap-2">+ <div className="flex items-center gap-2 px-4">+ <SidebarTrigger className="-ml-1" />+ <Breadcrumbs />+ </div>+ </header>+ <div className="flex flex-1 flex-col">+ <div className="min-h-[100vh] flex-1 rounded-xl bg-muted/50 md:min-h-min">+ <Outlet /></div></div>- </div>+ </SidebarInset><Toaster position="bottom-right" />- </TooltipProvider>+ </SidebarProvider></CarbonProvider>);}diff --git a/apps/developers/app/styles/tailwind.css b/apps/developers/app/styles/tailwind.cssindex 0790d0d1dc..4acd572d14 100644--- a/apps/developers/app/styles/tailwind.css+++ b/apps/developers/app/styles/tailwind.css@@ -45,6 +45,14 @@--input: 240 5.9% 90%;--ring: 240 5% 64.9%;--radius: 0.5rem;+ --sidebar-background: 0 0% 98%;+ --sidebar-foreground: 240 5.3% 26.1%;+ --sidebar-primary: 240 5.9% 10%;+ --sidebar-primary-foreground: 0 0% 98%;+ --sidebar-accent: 240 4.8% 95.9%;+ --sidebar-accent-foreground: 240 5.9% 10%;+ --sidebar-border: 220 13% 91%;+ --sidebar-ring: 217.2 91.2% 59.8%;}.dark {@@ -69,6 +77,14 @@--border: 240 3.7% 15.9%;--input: 240 3.7% 15.9%;--ring: 240 4.9% 83.9%;+ --sidebar-background: 240 5.9% 10%;+ --sidebar-foreground: 240 4.8% 95.9%;+ --sidebar-primary: 224.3 76.3% 48%;+ --sidebar-primary-foreground: 0 0% 100%;+ --sidebar-accent: 240 3.7% 15.9%;+ --sidebar-accent-foreground: 240 4.8% 95.9%;+ --sidebar-border: 240 3.7% 15.9%;+ --sidebar-ring: 217.2 91.2% 59.8%;}}diff --git a/apps/mes/app/styles/tailwind.css b/apps/mes/app/styles/tailwind.cssindex 11cb7b9827..aeeda202ce 100644--- a/apps/mes/app/styles/tailwind.css+++ b/apps/mes/app/styles/tailwind.css@@ -77,17 +77,6 @@}}-.forge-viewer {- position: relative;- width: 100%;- height: 100%;- min-height: 400px;-}--.forge-viewer > div {- border-radius: var(--radius);-}-p.is-editor-empty:first-child:before {color: var(--muted-foreground);content: attr(data-placeholder);diff --git a/packages/react/src/Sidebar.tsx b/packages/react/src/Sidebar.tsxnew file mode 100644index 0000000000..dbab0d2d16--- /dev/null+++ b/packages/react/src/Sidebar.tsx@@ -0,0 +1,764 @@+"use client";++import * as React from "react";++import type { Button } from "./Button";+import { Drawer, DrawerContent } from "./Drawer";++import { Slot } from "@radix-ui/react-slot";+import type { VariantProps } from "class-variance-authority";+import { cva } from "class-variance-authority";+import { LuPanelLeft } from "react-icons/lu";+import { useIsMobile } from "./hooks";+import { IconButton } from "./IconButton";+import { Input } from "./Input";+import { Separator } from "./Separator";+import { Skeleton } from "./Skeleton";+import {+ Tooltip,+ TooltipContent,+ TooltipProvider,+ TooltipTrigger,+} from "./Tooltip";+import { cn } from "./utils/cn";++const SIDEBAR_COOKIE_NAME = "sidebar:state";+const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;+const SIDEBAR_WIDTH = "16rem";+const SIDEBAR_WIDTH_MOBILE = "18rem";+const SIDEBAR_WIDTH_ICON = "3rem";+const SIDEBAR_KEYBOARD_SHORTCUT = "b";++type SidebarContext = {+ state: "expanded" | "collapsed";+ open: boolean;+ setOpen: (open: boolean) => void;+ openMobile: boolean;+ setOpenMobile: (open: boolean) => void;+ isMobile: boolean;+ toggleSidebar: () => void;+};++// eslint-disable-next-line @typescript-eslint/no-redeclare+const SidebarContext = React.createContext<SidebarContext | null>(null);++function useSidebar() {+ const context = React.useContext(SidebarContext);+ if (!context) {+ throw new Error("useSidebar must be used within a SidebarProvider.");+ }++ return context;+}++const SidebarProvider = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div"> & {+ defaultOpen?: boolean;+ open?: boolean;+ onOpenChange?: (open: boolean) => void;+ }+>(+ (+ {+ defaultOpen = true,+ open: openProp,+ onOpenChange: setOpenProp,+ className,+ style,+ children,+ ...props+ },+ ref+ ) => {+ const isMobile = useIsMobile();+ const [openMobile, setOpenMobile] = React.useState(false);++ // This is the internal state of the sidebar.+ // We use openProp and setOpenProp for control from outside the component.+ const [_open, _setOpen] = React.useState(defaultOpen);+ const open = openProp ?? _open;+ const setOpen = React.useCallback(+ (value: boolean | ((value: boolean) => boolean)) => {+ const openState = typeof value === "function" ? value(open) : value;+ if (setOpenProp) {+ setOpenProp(openState);+ } else {+ _setOpen(openState);+ }++ // This sets the cookie to keep the sidebar state.+ document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;+ },+ [setOpenProp, open]+ );++ // Helper to toggle the sidebar.+ const toggleSidebar = React.useCallback(() => {+ return isMobile+ ? setOpenMobile((open) => !open)+ : setOpen((open) => !open);+ }, [isMobile, setOpen, setOpenMobile]);++ // Adds a keyboard shortcut to toggle the sidebar.+ React.useEffect(() => {+ const handleKeyDown = (event: KeyboardEvent) => {+ if (+ event.key === SIDEBAR_KEYBOARD_SHORTCUT &&+ (event.metaKey || event.ctrlKey)+ ) {+ event.preventDefault();+ toggleSidebar();+ }+ };++ window.addEventListener("keydown", handleKeyDown);+ return () => window.removeEventListener("keydown", handleKeyDown);+ }, [toggleSidebar]);++ // We add a state so that we can do data-state="expanded" or "collapsed".+ // This makes it easier to style the sidebar with Tailwind classes.+ const state = open ? "expanded" : "collapsed";++ const contextValue = React.useMemo<SidebarContext>(+ () => ({+ state,+ open,+ setOpen,+ isMobile,+ openMobile,+ setOpenMobile,+ toggleSidebar,+ }),+ [state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]+ );++ return (+ <SidebarContext.Provider value={contextValue}>+ <TooltipProvider delayDuration={0}>+ <div+ style={+ {+ "--sidebar-width": SIDEBAR_WIDTH,+ "--sidebar-width-icon": SIDEBAR_WIDTH_ICON,+ ...style,+ } as React.CSSProperties+ }+ className={cn(+ "group/sidebar-wrapper flex min-h-svh w-full has-[[data-variant=inset]]:bg-sidebar",+ className+ )}+ ref={ref}+ {...props}+ >+ {children}+ </div>+ </TooltipProvider>+ </SidebarContext.Provider>+ );+ }+);+SidebarProvider.displayName = "SidebarProvider";++const Sidebar = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div"> & {+ side?: "left" | "right";+ variant?: "sidebar" | "floating" | "inset";+ collapsible?: "offcanvas" | "icon" | "none";+ }+>(+ (+ {+ side = "left",+ variant = "sidebar",+ collapsible = "offcanvas",+ className,+ children,+ ...props+ },+ ref+ ) => {+ const { isMobile, state, openMobile, setOpenMobile } = useSidebar();++ if (collapsible === "none") {+ return (+ <div+ className={cn(+ "flex h-full w-[--sidebar-width] flex-col bg-sidebar text-sidebar-foreground",+ className+ )}+ ref={ref}+ {...props}+ >+ {children}+ </div>+ );+ }++ if (isMobile) {+ return (+ <Drawer open={openMobile} onOpenChange={setOpenMobile} {...props}>+ <DrawerContent+ data-sidebar="sidebar"+ data-mobile="true"+ className="w-[--sidebar-width] bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden"+ style={+ {+ "--sidebar-width": SIDEBAR_WIDTH_MOBILE,+ } as React.CSSProperties+ }+ >+ <div className="flex h-full w-full flex-col">{children}</div>+ </DrawerContent>+ </Drawer>+ );+ }++ return (+ <div+ ref={ref}+ className="group peer hidden md:block text-sidebar-foreground"+ data-state={state}+ data-collapsible={state === "collapsed" ? collapsible : ""}+ data-variant={variant}+ data-side={side}+ >+ {/* This is what handles the sidebar gap on desktop */}+ <div+ className={cn(+ "duration-200 relative h-svh w-[--sidebar-width] bg-transparent transition-[width] ease-linear",+ "group-data-[collapsible=offcanvas]:w-0",+ "group-data-[side=right]:rotate-180",+ variant === "floating" || variant === "inset"+ ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4))]"+ : "group-data-[collapsible=icon]:w-[--sidebar-width-icon]"+ )}+ />+ <div+ className={cn(+ "duration-200 fixed inset-y-0 z-10 hidden h-svh w-[--sidebar-width] transition-[left,right,width] ease-linear md:flex",+ side === "left"+ ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]"+ : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",+ // Adjust the padding for floating and inset variants.+ variant === "floating" || variant === "inset"+ ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)_+_theme(spacing.4)_+2px)]"+ : "group-data-[collapsible=icon]:w-[--sidebar-width-icon] group-data-[side=left]:border-r group-data-[side=right]:border-l",+ className+ )}+ {...props}+ >+ <div+ data-sidebar="sidebar"+ className="flex h-full w-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:border-sidebar-border group-data-[variant=floating]:shadow"+ >+ {children}+ </div>+ </div>+ </div>+ );+ }+);+Sidebar.displayName = "Sidebar";++const SidebarTrigger = React.forwardRef<+ React.ElementRef<typeof Button>,+ React.ComponentProps<typeof Button>+>(({ className, onClick, ...props }, ref) => {+ const { toggleSidebar } = useSidebar();++ return (+ <IconButton+ ref={ref}+ icon={<LuPanelLeft />}+ aria-label="Toggle Sidebar"+ data-sidebar="trigger"+ variant="ghost"+ className={cn("h-7 w-7", className)}+ onClick={(event) => {+ onClick?.(event);+ toggleSidebar();+ }}+ {...props}+ />+ );+});+SidebarTrigger.displayName = "SidebarTrigger";++const SidebarRail = React.forwardRef<+ HTMLButtonElement,+ React.ComponentProps<"button">+>(({ className, ...props }, ref) => {+ const { toggleSidebar } = useSidebar();++ return (+ <button+ ref={ref}+ data-sidebar="rail"+ aria-label="Toggle Sidebar"+ tabIndex={-1}+ onClick={toggleSidebar}+ title="Toggle Sidebar"+ className={cn(+ "absolute inset-y-0 z-20 hidden w-4 -translate-x-1/2 transition-all ease-linear after:absolute after:inset-y-0 after:left-1/2 after:w-[2px] hover:after:bg-sidebar-border group-data-[side=left]:-right-4 group-data-[side=right]:left-0 sm:flex",+ "[[data-side=left]_&]:cursor-w-resize [[data-side=right]_&]:cursor-e-resize",+ "[[data-side=left][data-state=collapsed]_&]:cursor-e-resize [[data-side=right][data-state=collapsed]_&]:cursor-w-resize",+ "group-data-[collapsible=offcanvas]:translate-x-0 group-data-[collapsible=offcanvas]:after:left-full group-data-[collapsible=offcanvas]:hover:bg-sidebar",+ "[[data-side=left][data-collapsible=offcanvas]_&]:-right-2",+ "[[data-side=right][data-collapsible=offcanvas]_&]:-left-2",+ className+ )}+ {...props}+ />+ );+});+SidebarRail.displayName = "SidebarRail";++const SidebarInset = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"main">+>(({ className, ...props }, ref) => {+ return (+ <main+ ref={ref}+ className={cn(+ "relative flex min-h-svh flex-1 flex-col bg-background",+ "peer-data-[variant=inset]:min-h-[calc(100svh-theme(spacing.4))] md:peer-data-[variant=inset]:m-2 md:peer-data-[state=collapsed]:peer-data-[variant=inset]:ml-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow",+ className+ )}+ {...props}+ />+ );+});+SidebarInset.displayName = "SidebarInset";++const SidebarInput = React.forwardRef<+ React.ElementRef<typeof Input>,+ React.ComponentProps<typeof Input>+>(({ className, ...props }, ref) => {+ return (+ <Input+ ref={ref}+ data-sidebar="input"+ className={cn(+ "h-8 w-full bg-background shadow-none focus-visible:ring-2 focus-visible:ring-sidebar-ring",+ className+ )}+ {...props}+ />+ );+});+SidebarInput.displayName = "SidebarInput";++const SidebarHeader = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div">+>(({ className, ...props }, ref) => {+ return (+ <div+ ref={ref}+ data-sidebar="header"+ className={cn("flex flex-col gap-2 p-2", className)}+ {...props}+ />+ );+});+SidebarHeader.displayName = "SidebarHeader";++const SidebarFooter = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div">+>(({ className, ...props }, ref) => {+ return (+ <div+ ref={ref}+ data-sidebar="footer"+ className={cn("flex flex-col gap-2 p-2", className)}+ {...props}+ />+ );+});+SidebarFooter.displayName = "SidebarFooter";++const SidebarSeparator = React.forwardRef<+ React.ElementRef<typeof Separator>,+ React.ComponentProps<typeof Separator>+>(({ className, ...props }, ref) => {+ return (+ <Separator+ ref={ref}+ data-sidebar="separator"+ className={cn("mx-2 w-auto bg-sidebar-border", className)}+ {...props}+ />+ );+});+SidebarSeparator.displayName = "SidebarSeparator";++const SidebarContent = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div">+>(({ className, ...props }, ref) => {+ return (+ <div+ ref={ref}+ data-sidebar="content"+ className={cn(+ "flex min-h-0 flex-1 flex-col gap-2 overflow-auto group-data-[collapsible=icon]:overflow-hidden",+ className+ )}+ {...props}+ />+ );+});+SidebarContent.displayName = "SidebarContent";++const SidebarGroup = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div">+>(({ className, ...props }, ref) => {+ return (+ <div+ ref={ref}+ data-sidebar="group"+ className={cn("relative flex w-full min-w-0 flex-col p-2", className)}+ {...props}+ />+ );+});+SidebarGroup.displayName = "SidebarGroup";++const SidebarGroupLabel = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div"> & { asChild?: boolean }+>(({ className, asChild = false, ...props }, ref) => {+ const Comp = asChild ? Slot : "div";++ return (+ <Comp+ ref={ref}+ data-sidebar="group-label"+ className={cn(+ "duration-200 flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 outline-none ring-sidebar-ring transition-[margin,opa] ease-linear focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",+ "group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0",+ className+ )}+ {...props}+ />+ );+});+SidebarGroupLabel.displayName = "SidebarGroupLabel";++const SidebarGroupAction = React.forwardRef<+ HTMLButtonElement,+ React.ComponentProps<"button"> & { asChild?: boolean }+>(({ className, asChild = false, ...props }, ref) => {+ const Comp = asChild ? Slot : "button";++ return (+ <Comp+ ref={ref}+ data-sidebar="group-action"+ className={cn(+ "absolute right-3 top-3.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",+ // Increases the hit area of the button on mobile.+ "after:absolute after:-inset-2 after:md:hidden",+ "group-data-[collapsible=icon]:hidden",+ className+ )}+ {...props}+ />+ );+});+SidebarGroupAction.displayName = "SidebarGroupAction";++const SidebarGroupContent = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div">+>(({ className, ...props }, ref) => (+ <div+ ref={ref}+ data-sidebar="group-content"+ className={cn("w-full text-sm", className)}+ {...props}+ />+));+SidebarGroupContent.displayName = "SidebarGroupContent";++const SidebarMenu = React.forwardRef<+ HTMLUListElement,+ React.ComponentProps<"ul">+>(({ className, ...props }, ref) => (+ <ul+ ref={ref}+ data-sidebar="menu"+ className={cn("flex w-full min-w-0 flex-col gap-1", className)}+ {...props}+ />+));+SidebarMenu.displayName = "SidebarMenu";++const SidebarMenuItem = React.forwardRef<+ HTMLLIElement,+ React.ComponentProps<"li">+>(({ className, ...props }, ref) => (+ <li+ ref={ref}+ data-sidebar="menu-item"+ className={cn("group/menu-item relative", className)}+ {...props}+ />+));+SidebarMenuItem.displayName = "SidebarMenuItem";++const sidebarMenuButtonVariants = cva(+ "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm outline-none ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-[[data-sidebar=menu-action]]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:!size-8 group-data-[collapsible=icon]:!p-2 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",+ {+ variants: {+ variant: {+ default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",+ outline:+ "bg-background shadow-[0_0_0_1px_hsl(var(--sidebar-border))] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_hsl(var(--sidebar-accent))]",+ },+ size: {+ default: "h-8 text-sm",+ sm: "h-7 text-xs",+ lg: "h-12 text-sm group-data-[collapsible=icon]:!p-0",+ },+ },+ defaultVariants: {+ variant: "default",+ size: "default",+ },+ }+);++const SidebarMenuButton = React.forwardRef<+ HTMLButtonElement,+ React.ComponentProps<"button"> & {+ asChild?: boolean;+ isActive?: boolean;+ tooltip?: string | React.ComponentProps<typeof TooltipContent>;+ } & VariantProps<typeof sidebarMenuButtonVariants>+>(+ (+ {+ asChild = false,+ isActive = false,+ variant = "default",+ size = "default",+ tooltip,+ className,+ ...props+ },+ ref+ ) => {+ const Comp = asChild ? Slot : "button";+ const { isMobile, state } = useSidebar();++ const button = (+ <Comp+ ref={ref}+ data-sidebar="menu-button"+ data-size={size}+ data-active={isActive}+ className={cn(sidebarMenuButtonVariants({ variant, size }), className)}+ {...props}+ />+ );++ if (!tooltip) {+ return button;+ }++ if (typeof tooltip === "string") {+ tooltip = {+ children: tooltip,+ };+ }++ return (+ <Tooltip>+ <TooltipTrigger asChild>{button}</TooltipTrigger>+ <TooltipContent+ side="right"+ align="center"+ hidden={state !== "collapsed" || isMobile}+ {...tooltip}+ />+ </Tooltip>+ );+ }+);+SidebarMenuButton.displayName = "SidebarMenuButton";++const SidebarMenuAction = React.forwardRef<+ HTMLButtonElement,+ React.ComponentProps<"button"> & {+ asChild?: boolean;+ showOnHover?: boolean;+ }+>(({ className, asChild = false, showOnHover = false, ...props }, ref) => {+ const Comp = asChild ? Slot : "button";++ return (+ <Comp+ ref={ref}+ data-sidebar="menu-action"+ className={cn(+ "absolute right-1 top-1.5 flex aspect-square w-5 items-center justify-center rounded-md p-0 text-sidebar-foreground outline-none ring-sidebar-ring transition-transform hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 peer-hover/menu-button:text-sidebar-accent-foreground [&>svg]:size-4 [&>svg]:shrink-0",+ // Increases the hit area of the button on mobile.+ "after:absolute after:-inset-2 after:md:hidden",+ "peer-data-[size=sm]/menu-button:top-1",+ "peer-data-[size=default]/menu-button:top-1.5",+ "peer-data-[size=lg]/menu-button:top-2.5",+ "group-data-[collapsible=icon]:hidden",+ showOnHover &&+ "group-focus-within/menu-item:opacity-100 group-hover/menu-item:opacity-100 data-[state=open]:opacity-100 peer-data-[active=true]/menu-button:text-sidebar-accent-foreground md:opacity-0",+ className+ )}+ {...props}+ />+ );+});+SidebarMenuAction.displayName = "SidebarMenuAction";++const SidebarMenuBadge = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div">+>(({ className, ...props }, ref) => (+ <div+ ref={ref}+ data-sidebar="menu-badge"+ className={cn(+ "absolute right-1 flex h-5 min-w-5 items-center justify-center rounded-md px-1 text-xs font-medium tabular-nums text-sidebar-foreground select-none pointer-events-none",+ "peer-hover/menu-button:text-sidebar-accent-foreground peer-data-[active=true]/menu-button:text-sidebar-accent-foreground",+ "peer-data-[size=sm]/menu-button:top-1",+ "peer-data-[size=default]/menu-button:top-1.5",+ "peer-data-[size=lg]/menu-button:top-2.5",+ "group-data-[collapsible=icon]:hidden",+ className+ )}+ {...props}+ />+));+SidebarMenuBadge.displayName = "SidebarMenuBadge";++const SidebarMenuSkeleton = React.forwardRef<+ HTMLDivElement,+ React.ComponentProps<"div"> & {+ showIcon?: boolean;+ }+>(({ className, showIcon = false, ...props }, ref) => {+ // Random width between 50 to 90%.+ const width = React.useMemo(() => {+ return `${Math.floor(Math.random() * 40) + 50}%`;+ }, []);++ return (+ <div+ ref={ref}+ data-sidebar="menu-skeleton"+ className={cn("rounded-md h-8 flex gap-2 px-2 items-center", className)}+ {...props}+ >+ {showIcon && (+ <Skeleton+ className="size-4 rounded-md"+ data-sidebar="menu-skeleton-icon"+ />+ )}+ <Skeleton+ className="h-4 flex-1 max-w-[--skeleton-width]"+ data-sidebar="menu-skeleton-text"+ style={+ {+ "--skeleton-width": width,+ } as React.CSSProperties+ }+ />+ </div>+ );+});+SidebarMenuSkeleton.displayName = "SidebarMenuSkeleton";++const SidebarMenuSub = React.forwardRef<+ HTMLUListElement,+ React.ComponentProps<"ul">+>(({ className, ...props }, ref) => (+ <ul+ ref={ref}+ data-sidebar="menu-sub"+ className={cn(+ "mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5",+ "group-data-[collapsible=icon]:hidden",+ className+ )}+ {...props}+ />+));+SidebarMenuSub.displayName = "SidebarMenuSub";++const SidebarMenuSubItem = React.forwardRef<+ HTMLLIElement,+ React.ComponentProps<"li">+>(({ ...props }, ref) => <li ref={ref} {...props} />);+SidebarMenuSubItem.displayName = "SidebarMenuSubItem";++const SidebarMenuSubButton = React.forwardRef<+ HTMLAnchorElement,+ React.ComponentProps<"a"> & {+ asChild?: boolean;+ size?: "sm" | "md";+ isActive?: boolean;+ }+>(({ asChild = false, size = "md", isActive, className, ...props }, ref) => {+ const Comp = asChild ? Slot : "a";++ return (+ <Comp+ ref={ref}+ data-sidebar="menu-sub-button"+ data-size={size}+ data-active={isActive}+ className={cn(+ "flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground outline-none ring-sidebar-ring hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",+ "data-[active=true]:bg-sidebar-accent data-[active=true]:text-sidebar-accent-foreground",+ size === "sm" && "text-xs",+ size === "md" && "text-sm",+ "group-data-[collapsible=icon]:hidden",+ className+ )}+ {...props}+ />+ );+});+SidebarMenuSubButton.displayName = "SidebarMenuSubButton";++export {+ Sidebar,+ SidebarContent,+ SidebarFooter,+ SidebarGroup,+ SidebarGroupAction,+ SidebarGroupContent,+ SidebarGroupLabel,+ SidebarHeader,+ SidebarInput,+ SidebarInset,+ SidebarMenu,+ SidebarMenuAction,+ SidebarMenuBadge,+ SidebarMenuButton,+ SidebarMenuItem,+ SidebarMenuSkeleton,+ SidebarMenuSub,+ SidebarMenuSubButton,+ SidebarMenuSubItem,+ SidebarProvider,+ SidebarRail,+ SidebarSeparator,+ SidebarTrigger,+ useSidebar,+};diff --git a/packages/react/src/hooks/index.ts b/packages/react/src/hooks/index.tsindex 42d75141c9..b958a83e80 100644--- a/packages/react/src/hooks/index.ts+++ b/packages/react/src/hooks/index.ts@@ -4,6 +4,7 @@ import useEscape from "./useEscape";import useHydrated from "./useHydrated";import useInitialDimensions from "./useInitialDimenions";import { useInterval } from "./useInterval";+import useIsMobile from "./useIsMobile";import useKeyboardShortcuts from "./useKeyboardShortcuts";import useLocalStorage from "./useLocalStorage";import useMount from "./useMount";@@ -11,7 +12,6 @@ import useOutsideClick from "./useOutsideClick";import type { Shortcut, ShortcutDefinition } from "./useShortcutKeys";import { useShortcutKeys } from "./useShortcutKeys";import useThrottle from "./useThrottle";-import useWindowSize from "./useWindowSize";export {useDebounce,@@ -20,13 +20,13 @@ export {useHydrated,useInitialDimensions,useInterval,+ useIsMobile,useKeyboardShortcuts,useLocalStorage,useMount,useOutsideClick,useShortcutKeys,useThrottle,- useWindowSize,};export type { Shortcut, ShortcutDefinition };diff --git a/packages/react/src/hooks/useIsMobile.ts b/packages/react/src/hooks/useIsMobile.tsnew file mode 100644index 0000000000..e15cc6fedc--- /dev/null+++ b/packages/react/src/hooks/useIsMobile.ts@@ -0,0 +1,19 @@+import { useEffect, useState } from "react";++const MOBILE_BREAKPOINT = 768;++export default function useIsMobile() {+ const [isMobile, setIsMobile] = useState<boolean | undefined>(undefined);++ useEffect(() => {+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);+ const onChange = () => {+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);+ };+ mql.addEventListener("change", onChange);+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);+ return () => mql.removeEventListener("change", onChange);+ }, []);++ return !!isMobile;+}diff --git a/packages/react/src/hooks/useWindowSize.ts b/packages/react/src/hooks/useWindowSize.tsdeleted file mode 100644index 86848dbaea..0000000000--- a/packages/react/src/hooks/useWindowSize.ts+++ /dev/null@@ -1,29 +0,0 @@-import { useLayoutEffect, useState } from "react";--export default function useWindowSize() {- const [size, setSize] = useState<{- height: number | null;- width: number | null;- }>({- width: null,- height: null,- });-- useLayoutEffect(() => {- const handleResize = () => {- setSize({- width: window.innerWidth,- height: window.innerHeight,- });- };-- handleResize();- window.addEventListener("resize", handleResize);-- return () => {- window.removeEventListener("resize", handleResize);- };- }, []);-- return size;-}diff --git a/packages/react/src/index.tsx b/packages/react/src/index.tsxindex 9ed0350797..7ee010ecda 100644--- a/packages/react/src/index.tsx+++ b/packages/react/src/index.tsx@@ -243,6 +243,32 @@ import {} from "./Select";import { Separator } from "./Separator";import { ShortcutKey, shortcutKeyVariants } from "./ShortcutKey";+import {+ Sidebar,+ SidebarContent,+ SidebarFooter,+ SidebarGroup,+ SidebarGroupAction,+ SidebarGroupContent,+ SidebarGroupLabel,+ SidebarHeader,+ SidebarInput,+ SidebarInset,+ SidebarMenu,+ SidebarMenuAction,+ SidebarMenuBadge,+ SidebarMenuButton,+ SidebarMenuItem,+ SidebarMenuSkeleton,+ SidebarMenuSub,+ SidebarMenuSubButton,+ SidebarMenuSubItem,+ SidebarProvider,+ SidebarRail,+ SidebarSeparator,+ SidebarTrigger,+ useSidebar,+} from "./Sidebar";import { Skeleton } from "./Skeleton";import { Slider } from "./Slider";import { Spinner } from "./Spinner";@@ -478,6 +504,29 @@ export {SelectValue,Separator,ShortcutKey,+ Sidebar,+ SidebarContent,+ SidebarFooter,+ SidebarGroup,+ SidebarGroupAction,+ SidebarGroupContent,+ SidebarGroupLabel,+ SidebarHeader,+ SidebarInput,+ SidebarInset,+ SidebarMenu,+ SidebarMenuAction,+ SidebarMenuBadge,+ SidebarMenuButton,+ SidebarMenuItem,+ SidebarMenuSkeleton,+ SidebarMenuSub,+ SidebarMenuSubButton,+ SidebarMenuSubItem,+ SidebarProvider,+ SidebarRail,+ SidebarSeparator,+ SidebarTrigger,Skeleton,Slider,Spinner,@@ -519,6 +568,7 @@ export {useModalDrawerType,useOperatingSystem,useRichText,+ useSidebar,};export type {AvatarProps,