Skip to content

Commit

Permalink
Add function to open drawer on brand click in mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
skanderm committed Mar 12, 2024
1 parent d16aa34 commit 6973e10
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
19 changes: 13 additions & 6 deletions ui/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ import wordmark from "@/public/wordmark/wordmark-white.svg";
import { displayDesktopOnly, displayMobileOnly } from "@/styles/responsive";
import { analytics } from "@/utils/analytics";

export default function Header() {
export default function Header({
onBrandClick,
}: {
onBrandClick?: () => void;
}) {
return (
<AppBar
position="static"
Expand All @@ -38,14 +42,14 @@ export default function Header() {
}}
>
<Toolbar>
<Mobile />
<Mobile onBrandClick={onBrandClick} />
<Desktop />
</Toolbar>
</AppBar>
);
}

function Mobile(props: { window?: () => Window }) {
function Mobile(props: { window?: () => Window; onBrandClick?: () => void }) {
const { window } = props;
const drawerWidth = "100%";
const [menuIsOpen, setMenuOpen] = useState(false);
Expand Down Expand Up @@ -96,7 +100,7 @@ function Mobile(props: { window?: () => Window }) {
>
{menuIsOpen ? <Close /> : <Menu />}
</IconButton>
<Brand />
<Brand onClick={props.onBrandClick} />
</Box>
<nav>
<Drawer
Expand Down Expand Up @@ -252,7 +256,7 @@ function Desktop() {
);
}

function Brand() {
function Brand({ onClick }: { onClick?: () => void }) {
return (
<Typography variant="h6" noWrap overflow="visible">
<Link
Expand All @@ -265,7 +269,10 @@ function Brand() {
alignItems: "center",
justifyContent: "center",
}}
onClick={() => analytics.nav.logoClicked()}
onClick={() => {
if (onClick) onClick();
analytics.nav.logoClicked();
}}
>
<Image
src={wordmark.src}
Expand Down
6 changes: 5 additions & 1 deletion ui/src/components/layouts/MapLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ function MapLayout({ children }: { children: ReactNode }) {
flexDirection: "column",
}}
>
<Header />
<Header
onBrandClick={() => {
setDrawerOpen(true);
}}
/>
<Box sx={{ flexGrow: 1, display: "flex" }}>
<Drawer
setOpen={setDrawerOpen}
Expand Down

0 comments on commit 6973e10

Please sign in to comment.