import * as Dialog from "@radix-ui/react-dialog"
import { SidebarLeft, TriangleRightMini, XMark } from "@medusajs/icons"
import { IconButton, clx } from "@medusajs/ui"
import { PropsWithChildren, ReactNode } from "react"
import { useTranslation } from "react-i18next"
import { Link, Outlet, UIMatch, useMatches } from "react-router-dom"
import { KeybindProvider } from "../../../providers/keybind-provider"
import { useGlobalShortcuts } from "../../../providers/keybind-provider/hooks"
import { useSidebar } from "../../../providers/sidebar-provider"
import { Notifications } from "../notifications"
export const Shell = ({ children }: PropsWithChildren) => {
const globalShortcuts = useGlobalShortcuts()
return (
)
}
const Gutter = ({ children }: PropsWithChildren) => {
return (
{children}
)
}
const Breadcrumbs = () => {
const matches = useMatches() as unknown as UIMatch<
unknown,
{
breadcrumb?: (match?: UIMatch) => string | ReactNode
}
>[]
const crumbs = matches
.filter((match) => match.handle?.breadcrumb)
.map((match) => {
const handle = match.handle
let label: string | ReactNode | undefined = undefined
try {
label = handle.breadcrumb?.(match)
} catch (error) {
// noop
}
if (!label) {
return null
}
return {
label: label,
path: match.pathname,
}
})
.filter(Boolean) as { label: string | ReactNode; path: string }[]
return (
{crumbs.map((crumb, index) => {
const isLast = index === crumbs.length - 1
const isSingle = crumbs.length === 1
return (
-
{!isLast ? (
{crumb.label}
) : (
{!isSingle && ...}
{crumb.label}
)}
{!isLast && (
)}
)
})}
)
}
const ToggleSidebar = () => {
const { toggle } = useSidebar()
return (
toggle("desktop")}
size="small"
>
toggle("mobile")}
size="small"
>
)
}
const Topbar = () => {
return (
)
}
const DesktopSidebarContainer = ({ children }: PropsWithChildren) => {
const { desktop } = useSidebar()
return (
{children}
)
}
const MobileSidebarContainer = ({ children }: PropsWithChildren) => {
const { t } = useTranslation()
const { mobile, toggle } = useSidebar()
return (
toggle("mobile")}>
{t("app.nav.accessibility.title")}
{t("app.nav.accessibility.description")}
{children}
)
}