-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
180 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
"use client"; | ||
import { Link } from "@/components/muiLink"; | ||
import { Wrapper } from "@/components/wrapper"; | ||
import { Close as CloseIcon, Menu as MenuIcon } from "@mui/icons-material"; | ||
import { Box, Drawer, IconButton, Typography } from "@mui/material"; | ||
import { useState } from "react"; | ||
import NymLogo from "../icons/NymLogo"; | ||
import MENU_DATA from "./menuItems"; | ||
|
||
export const MobileHeader = () => { | ||
const [drawerOpen, setDrawerOpen] = useState(false); | ||
|
||
// Mobile menu handlers | ||
const toggleDrawer = (open: boolean) => { | ||
setDrawerOpen(open); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Box sx={{ display: { xs: "block", lg: "none" } }}> | ||
<MobileMenuHeader toggleDrawer={toggleDrawer} drawerOpen={drawerOpen} /> | ||
<Drawer | ||
anchor="left" | ||
open={drawerOpen} | ||
onClose={() => toggleDrawer(false)} | ||
sx={{ | ||
display: { xs: "block", lg: "none" }, | ||
}} | ||
PaperProps={{ | ||
sx: { | ||
width: "100%", | ||
height: "100%", | ||
bgcolor: "base.white", | ||
overflow: "hidden", | ||
position: "relative", | ||
color: "background.main", | ||
}, | ||
}} | ||
> | ||
<MobileMenuHeader | ||
toggleDrawer={toggleDrawer} | ||
drawerOpen={drawerOpen} | ||
/> | ||
{/* Sliding Animation */} | ||
<Box | ||
sx={{ | ||
display: "flex", | ||
width: "200%", | ||
height: "100%", | ||
transition: "transform 0.3s ease-in-out", | ||
position: "relative", | ||
transform: "translateX(0%)", | ||
}} | ||
> | ||
{/* Main Menu */} | ||
<Box sx={{ width: "50%", height: "100%" }}> | ||
{MENU_DATA.map((menu) => ( | ||
<Box key={menu.title} sx={{ marginBottom: 3 }}> | ||
<Link | ||
onClick={() => toggleDrawer(false)} | ||
href={menu.url || ""} | ||
target={menu?.url?.startsWith("http") ? "_blank" : "_self"} | ||
sx={{ | ||
display: "flex", | ||
width: "100%", | ||
padding: 3.75, | ||
color: "background.main", | ||
justifyContent: "space-between", | ||
alignItems: "center", | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "flex-start", | ||
gap: 1.25, | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
display: "block", | ||
width: "10px", | ||
height: "10px", | ||
borderRadius: "100%", | ||
bgcolor: "primary.main", | ||
}} | ||
/> | ||
<Typography color="primary" variant="h4"> | ||
{menu.title} | ||
</Typography> | ||
</Box> | ||
</Link> | ||
</Box> | ||
))} | ||
</Box> | ||
</Box> | ||
</Drawer> | ||
</Box> | ||
</> | ||
); | ||
}; | ||
|
||
const MobileMenuHeader = ({ | ||
toggleDrawer, | ||
drawerOpen, | ||
}: { | ||
toggleDrawer: (open: boolean) => void; | ||
drawerOpen: boolean; | ||
}) => { | ||
return ( | ||
<Wrapper | ||
sx={{ | ||
backgroundColor: "background.default", | ||
}} | ||
> | ||
<Box | ||
sx={{ | ||
height: "115px", | ||
alignItems: "center", | ||
display: "flex", | ||
justifyContent: "space-between", | ||
}} | ||
> | ||
<Link | ||
onClick={() => toggleDrawer(false)} | ||
href={"/"} | ||
style={{ | ||
display: "flex", | ||
alignItems: "center", | ||
width: "100px", | ||
aspectRatio: "89/25", | ||
}} | ||
> | ||
<NymLogo /> | ||
</Link> | ||
<Box | ||
sx={{ | ||
display: "flex", | ||
gap: 2.5, | ||
alignItems: "center", | ||
}} | ||
> | ||
<IconButton sx={{}} onClick={() => toggleDrawer(!drawerOpen)}> | ||
{drawerOpen ? <CloseIcon /> : <MenuIcon />} | ||
</IconButton> | ||
</Box> | ||
</Box> | ||
</Wrapper> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
export type MenuItem = { | ||
id: number; | ||
title: string; | ||
url: string; | ||
}; | ||
|
||
const MENU_DATA: MenuItem[] = [ | ||
{ | ||
id: 1, | ||
title: "Explorer", | ||
url: "/explorer", | ||
}, | ||
{ | ||
id: 2, | ||
title: "Stake", | ||
url: "/stake", | ||
}, | ||
{ | ||
id: 3, | ||
title: "Onboarding", | ||
url: "/onboarding", | ||
}, | ||
]; | ||
|
||
export default MENU_DATA; |