import { SidebarLeft, TriangleRightMini, XMark } from "@medusajs/icons"
import { IconButton, clx } from "@medusajs/ui"
import { AnimatePresence } from "motion/react"
import { Dialog as RadixDialog } from "radix-ui"
import { PropsWithChildren, ReactNode, useEffect, useState } from "react"
import { useTranslation } from "react-i18next"
import {
Link,
Outlet,
UIMatch,
useMatches,
useNavigation,
} from "react-router-dom"
import { KeybindProvider } from "../../../providers/keybind-provider"
import { useGlobalShortcuts } from "../../../providers/keybind-provider/hooks"
import { useSidebar } from "../../../providers/sidebar-provider"
import { ProgressBar } from "../../common/progress-bar"
import { Notifications } from "../notifications"
export const Shell = ({ children }: PropsWithChildren) => {
const globalShortcuts = useGlobalShortcuts()
const navigation = useNavigation()
const loading = navigation.state === "loading"
return (
{children}{children}
)
}
const NavigationBar = ({ loading }: { loading: boolean }) => {
const [showBar, setShowBar] = useState(false)
/**
* If the loading state is true, we want to show the bar after a short delay.
* The delay is used to prevent the bar from flashing on quick navigations.
*/
useEffect(() => {
let timeout: ReturnType
if (loading) {
timeout = setTimeout(() => {
setShowBar(true)
}, 200)
} else {
setShowBar(false)
}
return () => {
clearTimeout(timeout)
}
}, [loading])
return (