Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function to open drawer on brand click in mobile #360

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}) {
skanderm marked this conversation as resolved.
Show resolved Hide resolved
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 }) {
skanderm marked this conversation as resolved.
Show resolved Hide resolved
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);
skanderm marked this conversation as resolved.
Show resolved Hide resolved
}}
/>
<Box sx={{ flexGrow: 1, display: "flex" }}>
<Drawer
setOpen={setDrawerOpen}
Expand Down
Loading