From 8847560018e9157a4b7ae9c46ce92bd60d0fbfa8 Mon Sep 17 00:00:00 2001 From: Bruno Date: Mon, 25 Jul 2022 16:41:40 +0000 Subject: [PATCH 1/3] feat: Add mobile navbar --- site/src/components/NavbarView/NavbarView.tsx | 149 ++++++++++++------ 1 file changed, 105 insertions(+), 44 deletions(-) diff --git a/site/src/components/NavbarView/NavbarView.tsx b/site/src/components/NavbarView/NavbarView.tsx index 6d7cb201d3a1a..d982b35e3ad29 100644 --- a/site/src/components/NavbarView/NavbarView.tsx +++ b/site/src/components/NavbarView/NavbarView.tsx @@ -1,6 +1,10 @@ +import Drawer from "@material-ui/core/Drawer" +import IconButton from "@material-ui/core/IconButton" import List from "@material-ui/core/List" import ListItem from "@material-ui/core/ListItem" import { fade, makeStyles } from "@material-ui/core/styles" +import MenuIcon from "@material-ui/icons/Menu" +import { useState } from "react" import { NavLink, useLocation } from "react-router-dom" import * as TypesGen from "../../api/typesGenerated" import { navHeight } from "../../theme/constants" @@ -19,41 +23,66 @@ export const Language = { users: "Users", } -export const NavbarView: React.FC = ({ user, onSignOut }) => { +const NavItems: React.FC<{ className?: string; linkClassName?: string }> = ({ className }) => { const styles = useStyles() const location = useLocation() + + return ( + + + + {Language.workspaces} + + + + + {Language.templates} + + + + + {Language.users} + + + + ) +} + +export const NavbarView: React.FC = ({ user, onSignOut }) => { + const styles = useStyles() + const [isDrawerOpen, setIsDrawerOpen] = useState(false) + return ( @@ -64,9 +93,7 @@ const useStyles = makeStyles((theme) => ({ root: { position: "relative", display: "flex", - flex: 0, - flexDirection: "row", - justifyContent: "center", + justifyContent: "space-between", alignItems: "center", height: navHeight, background: theme.palette.background.paper, @@ -76,14 +103,37 @@ const useStyles = makeStyles((theme) => ({ borderTop: `1px solid ${theme.palette.divider}`, }, borderBottom: `1px solid ${theme.palette.divider}`, + + [theme.breakpoints.up("md")]: { + justifyContent: "flex-start", + }, }, - fixed: { - flex: 0, - display: "flex", + drawer: { + width: 250, + }, + drawerHeader: { + padding: theme.spacing(2), + paddingTop: theme.spacing(4), + paddingBottom: theme.spacing(4), + }, + navItems: { padding: 0, }, - fullWidth: { - flex: 1, + desktopNavItems: { + display: "none", + [theme.breakpoints.up("md")]: { + display: "flex", + }, + }, + profileButton: { + [theme.breakpoints.up("md")]: { + marginLeft: "auto", + }, + }, + mobileMenuButton: { + [theme.breakpoints.up("md")]: { + display: "none", + }, }, logo: { alignItems: "center", @@ -107,8 +157,7 @@ const useStyles = makeStyles((theme) => ({ color: "hsl(220, 11%, 71%)", display: "flex", fontSize: 16, - height: navHeight, - padding: `0 ${theme.spacing(3)}px`, + padding: `${theme.spacing(1.5)}px ${theme.spacing(2)}px`, textDecoration: "none", transition: "background-color 0.3s ease", @@ -124,13 +173,25 @@ const useStyles = makeStyles((theme) => ({ "&::before": { content: `" "`, - bottom: 0, - left: theme.spacing(3), + left: 0, + width: 2, + height: "100%", background: theme.palette.secondary.dark, - right: theme.spacing(3), - height: 2, position: "absolute", + + [theme.breakpoints.up("md")]: { + bottom: 0, + left: theme.spacing(3), + width: `calc(100% - 2 * ${theme.spacing(3)}px)`, + right: theme.spacing(3), + height: 2, + }, }, }, + + [theme.breakpoints.up("md")]: { + height: navHeight, + padding: `0 ${theme.spacing(3)}px`, + }, }, })) From 2dcbd6503d40abd2f9eb377f21e2a67874b8ab60 Mon Sep 17 00:00:00 2001 From: Bruno Date: Mon, 25 Jul 2022 17:15:06 +0000 Subject: [PATCH 2/3] Add story for smaller viewports --- .../components/NavbarView/NavbarView.stories.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/site/src/components/NavbarView/NavbarView.stories.tsx b/site/src/components/NavbarView/NavbarView.stories.tsx index c1ff477d5f130..93c472f6eb805 100644 --- a/site/src/components/NavbarView/NavbarView.stories.tsx +++ b/site/src/components/NavbarView/NavbarView.stories.tsx @@ -27,3 +27,16 @@ ForMember.args = { return Promise.resolve() }, } + +export const SmallViewport = Template.bind({}) +SmallViewport.args = { + user: MockUser, + onSignOut: () => { + return Promise.resolve() + }, +} +SmallViewport.parameters = { + viewport: { + defaultViewport: "tablet", + }, +} From c53fd561e6d9f8184ad49844de46fc5f14ffcaf2 Mon Sep 17 00:00:00 2001 From: Bruno Date: Mon, 25 Jul 2022 17:24:45 +0000 Subject: [PATCH 3/3] Add option to chromatic --- site/src/components/NavbarView/NavbarView.stories.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/site/src/components/NavbarView/NavbarView.stories.tsx b/site/src/components/NavbarView/NavbarView.stories.tsx index 93c472f6eb805..83ca018012c4e 100644 --- a/site/src/components/NavbarView/NavbarView.stories.tsx +++ b/site/src/components/NavbarView/NavbarView.stories.tsx @@ -39,4 +39,5 @@ SmallViewport.parameters = { viewport: { defaultViewport: "tablet", }, + chromatic: { viewports: [420] }, }