diff --git a/commafeed-client/src/pages/app/Layout.tsx b/commafeed-client/src/pages/app/Layout.tsx index da37c77f..91bb0b4a 100644 --- a/commafeed-client/src/pages/app/Layout.tsx +++ b/commafeed-client/src/pages/app/Layout.tsx @@ -19,6 +19,7 @@ import { type ReactNode, Suspense, useEffect } from "react" import Draggable from "react-draggable" import { TbMenu2, TbPlus, TbX } from "react-icons/tb" import { Outlet } from "react-router-dom" +import { tss } from "tss" import useLocalStorage from "use-local-storage" interface LayoutProps { @@ -39,13 +40,36 @@ function LogoAndTitle() { ) } +const useStyles = tss + .withParams<{ + sidebarWidth: number + sidebarPadding: string + sidebarRightBorderWidth: string + }>() + .create(({ sidebarWidth, sidebarPadding, sidebarRightBorderWidth }) => { + return { + sidebarContent: { + maxWidth: `calc(${sidebarWidth}px - ${sidebarPadding} * 2 - ${sidebarRightBorderWidth})`, + [`@media (max-width: ${Constants.layout.mobileBreakpoint}px)`]: { + maxWidth: `calc(100vw - ${sidebarPadding} * 2 - ${sidebarRightBorderWidth})`, + }, + }, + } + }) + export default function Layout(props: LayoutProps) { const theme = useMantineTheme() + const [sidebarWidth, setSidebarWidth] = useLocalStorage("sidebar-width", 350) + const sidebarPadding = theme.spacing.xs + const { classes } = useStyles({ + sidebarWidth, + sidebarPadding, + sidebarRightBorderWidth: "1px", + }) const { loading } = useAppLoading() const mobileMenuOpen = useAppSelector(state => state.tree.mobileMenuOpen) const webSocketConnected = useAppSelector(state => state.server.webSocketConnected) const treeReloadInterval = useAppSelector(state => state.server.serverInfos?.treeReloadInterval) - const [sidebarWidth, setSidebarWidth] = useLocalStorage("sidebar-width", 350) const dispatch = useAppDispatch() useWebSocket() @@ -128,9 +152,9 @@ export default function Layout(props: LayoutProps) { - + - {props.sidebar} + {props.sidebar}