From aa984f577c3828f89adfdd620c44076d0a942356 Mon Sep 17 00:00:00 2001 From: Joel Keyser Date: Thu, 18 Jul 2024 12:04:13 -0500 Subject: [PATCH] refactor: css breakpoints instead of js for navbar mui's js breakpoints will initially render with default values and therefore e.g. the hamburger menu will flicker on desktop --- src/web/common/components/Layout.tsx | 70 +++++++++++----------------- 1 file changed, 28 insertions(+), 42 deletions(-) diff --git a/src/web/common/components/Layout.tsx b/src/web/common/components/Layout.tsx index 00436507..71040f90 100644 --- a/src/web/common/components/Layout.tsx +++ b/src/web/common/components/Layout.tsx @@ -1,13 +1,5 @@ import { Menu } from "@mui/icons-material"; -import { - AppBar, - IconButton, - Link as MuiLink, - Toolbar, - Tooltip, - useMediaQuery, - useTheme, -} from "@mui/material"; +import { AppBar, IconButton, Link as MuiLink, Toolbar, Tooltip, useTheme } from "@mui/material"; import { NextPage } from "next"; import { Roboto } from "next/font/google"; import Image from "next/image"; @@ -42,8 +34,6 @@ const Layout: NextPage = ({ children }) => { const { sessionUser, authUser } = useSessionUser(); const { asPath } = useRouter(); - const usingBigScreen = useMediaQuery(theme.breakpoints.up("sm")); - const [isInitialRender, setIsInitialRender] = useState(true); const [isUserDrawerOpen, setIsUserDrawerOpen] = useState(false); const [isSiteDrawerOpen, setIsSiteDrawerOpen] = useState(false); @@ -67,11 +57,9 @@ const Layout: NextPage = ({ children }) => {
- {!usingBigScreen && ( - setIsSiteDrawerOpen(true)} sx={{ padding: "0" }}> - - - )} + setIsSiteDrawerOpen(true)} className="block p-0 sm:hidden"> + + = ({ children }) => { Alpha
- {usingBigScreen && ( - <> - Playground - {sessionUser && My Topics} - + + + Playground + + {sessionUser && ( + + My Topics + )}
@@ -104,27 +95,22 @@ const Layout: NextPage = ({ children }) => { Docs - - {usingBigScreen && ( - <> - - discord link - - - github link - - - )} + + discord link + + + github link + {!isLoggedIn && (