From 4a24dc5534467ac481b12894a0fe732d8d7ecf8b Mon Sep 17 00:00:00 2001 From: Sidney Alcantara Date: Thu, 9 Jun 2022 16:54:29 +1000 Subject: [PATCH] nav: add HelpMenu --- src/components/Table/BreadcrumbsSubTable.tsx | 4 +- src/components/Table/BreadcrumbsTableRoot.tsx | 4 +- src/constants/routes.tsx | 2 + src/layouts/Navigation/HelpMenu.tsx | 120 ++++++++++++++++++ src/layouts/Navigation/Navigation.tsx | 11 +- 5 files changed, 136 insertions(+), 5 deletions(-) create mode 100644 src/layouts/Navigation/HelpMenu.tsx diff --git a/src/components/Table/BreadcrumbsSubTable.tsx b/src/components/Table/BreadcrumbsSubTable.tsx index dd2583ee..b7e0dbcb 100644 --- a/src/components/Table/BreadcrumbsSubTable.tsx +++ b/src/components/Table/BreadcrumbsSubTable.tsx @@ -28,7 +28,7 @@ export default function BreadcrumbsSubTable({ const splitSubTableId = subTableSettings.id.split("/"); return ( - + - + )} diff --git a/src/components/Table/BreadcrumbsTableRoot.tsx b/src/components/Table/BreadcrumbsTableRoot.tsx index e9888194..bf6dabc9 100644 --- a/src/components/Table/BreadcrumbsTableRoot.tsx +++ b/src/components/Table/BreadcrumbsTableRoot.tsx @@ -41,7 +41,7 @@ export default function BreadcrumbsTableRoot(props: StackProps) { if (!tableSettings) return null; return ( - + - + )} diff --git a/src/constants/routes.tsx b/src/constants/routes.tsx index 841ce0e0..3152979d 100644 --- a/src/constants/routes.tsx +++ b/src/constants/routes.tsx @@ -62,6 +62,7 @@ export const ROUTE_TITLES = { ), titleTransitionProps: { style: { transformOrigin: "0 50%" } }, + leftAligned: true, }, [ROUTES.settings]: "Settings", @@ -79,5 +80,6 @@ export const ROUTE_TITLES = { title: string; titleComponent: (open: boolean, pinned: boolean) => React.ReactNode; titleTransitionProps?: Partial; + leftAligned?: boolean; } >; diff --git a/src/layouts/Navigation/HelpMenu.tsx b/src/layouts/Navigation/HelpMenu.tsx new file mode 100644 index 00000000..c6a9bb49 --- /dev/null +++ b/src/layouts/Navigation/HelpMenu.tsx @@ -0,0 +1,120 @@ +import { useState, useRef } from "react"; + +import { + IconButton, + IconButtonProps, + Menu, + MenuItem, + ListItemIcon, + ListItemSecondaryAction, + Divider, + Grow, +} from "@mui/material"; +import HelpIcon from "@mui/icons-material/HelpOutline"; +import DocsIcon from "@mui/icons-material/DescriptionOutlined"; +import { Discord as DiscordIcon } from "@src/assets/icons"; +import GitHubIcon from "@mui/icons-material/GitHub"; +import TwitterIcon from "@mui/icons-material/Twitter"; + +import { EXTERNAL_LINKS } from "@src/constants/externalLinks"; +import InlineOpenInNewIcon from "@src/components/InlineOpenInNewIcon"; +import { analytics } from "analytics"; + +export default function UserMenu(props: IconButtonProps) { + const anchorEl = useRef(null); + const [open, setOpen] = useState(false); + + const externalLinkIcon = ( + + + + ); + + return ( + <> + + { + setOpen(true); + analytics.logEvent("open_help_menu"); + }} + sx={{ ml: 1.5 }} + > + + + + + setOpen(false)} + sx={{ "& .MuiPaper-root": { minWidth: 160 } }} + > + setOpen(false)} + > + + + + Docs + {externalLinkIcon} + + + + + setOpen(false)} + > + + + + Discord + {externalLinkIcon} + + setOpen(false)} + > + + + + GitHub + {externalLinkIcon} + + setOpen(false)} + > + + + + Twitter + {externalLinkIcon} + + + + ); +} diff --git a/src/layouts/Navigation/Navigation.tsx b/src/layouts/Navigation/Navigation.tsx index 689bf60e..5119bcaf 100644 --- a/src/layouts/Navigation/Navigation.tsx +++ b/src/layouts/Navigation/Navigation.tsx @@ -17,6 +17,7 @@ import { import MenuIcon from "@mui/icons-material/Menu"; import NavDrawer, { NAV_DRAWER_WIDTH } from "./NavDrawer"; +import HelpMenu from "./HelpMenu"; import UserMenu from "./UserMenu"; import ErrorFallback, { IErrorFallbackProps, @@ -157,6 +158,10 @@ export default function Navigation({ children }: React.PropsWithChildren<{}>) { overflowX: "auto", userSelect: "none", pl: open && canPin && pinned ? 48 / 8 : 0, + pr: 1, + ml: (routeTitle as any)?.leftAligned + ? 0 + : { xs: 0, sm: 1.5 + 6 + 1 }, }} > {typeof routeTitle !== "string" ? ( @@ -166,7 +171,10 @@ export default function Navigation({ children }: React.PropsWithChildren<{}>) { variant="h6" component="h1" textAlign="center" - sx={{ typography: { sm: "h5" } }} + sx={{ + typography: { sm: "h5" }, + textAlign: { xs: "left", sm: "center" }, + }} > {title} @@ -174,6 +182,7 @@ export default function Navigation({ children }: React.PropsWithChildren<{}>) { +