import { ActionIcon, AppShell, Box, Burger, Center, createStyles, DEFAULT_THEME, Group, Header, Navbar, ScrollArea, Title, useMantineTheme, } from "@mantine/core" import { useViewportSize } from "@mantine/hooks" import { Constants } from "app/constants" import { redirectToAdd, redirectToRootCategory } from "app/slices/redirect" import { reloadTree, setMobileMenuOpen, setSidebarWidth } from "app/slices/tree" import { reloadProfile, reloadSettings, reloadTags } from "app/slices/user" import { useAppDispatch, useAppSelector } from "app/store" import { Loader } from "components/Loader" import { Logo } from "components/Logo" import { OnDesktop } from "components/responsive/OnDesktop" import { OnMobile } from "components/responsive/OnMobile" import { useAppLoading } from "hooks/useAppLoading" import { useWebSocket } from "hooks/useWebSocket" import { LoadingPage } from "pages/LoadingPage" import { Resizable } from "re-resizable" import { ReactNode, Suspense, useEffect } from "react" import { TbPlus } from "react-icons/tb" import { Outlet } from "react-router-dom" interface LayoutProps { sidebar: ReactNode sidebarWidth: number header: ReactNode } const sidebarPadding = DEFAULT_THEME.spacing.xs const sidebarRightBorderWidth = "1px" const useStyles = createStyles((theme, props: LayoutProps) => ({ sidebarContentResizeWrapper: { padding: sidebarPadding, minHeight: "100vh", }, sidebarContent: { maxWidth: `calc(${props.sidebarWidth}px - ${sidebarPadding} * 2 - ${sidebarRightBorderWidth})`, [theme.fn.smallerThan(Constants.layout.mobileBreakpoint)]: { maxWidth: `calc(100vw - ${sidebarPadding} * 2 - ${sidebarRightBorderWidth})`, }, }, mainContentWrapper: { paddingTop: Constants.layout.headerHeight, paddingLeft: props.sidebarWidth, paddingRight: 0, paddingBottom: 0, [theme.fn.smallerThan(Constants.layout.mobileBreakpoint)]: { paddingLeft: 0, }, }, mainContent: { maxWidth: `calc(100vw - ${props.sidebarWidth}px)`, padding: theme.spacing.md, [theme.fn.smallerThan(Constants.layout.mobileBreakpoint)]: { maxWidth: "100vw", padding: "6px", }, }, })) function LogoAndTitle() { const dispatch = useAppDispatch() return (