bottom menu
This commit is contained in:
1 parent
1db5f4b70f
commit
0f6c273dad
2 files changed
+61
-8
No files matched your search
@@ -11,6 +11,12 @@ import {
|
|||||||
Wrench,
|
Wrench,
|
||||||
Database,
|
Database,
|
||||||
Settings,
|
Settings,
|
||||||
|
HelpCircle,
|
||||||
|
MessageCircle,
|
||||||
|
Code,
|
||||||
|
User,
|
||||||
|
Lock,
|
||||||
|
Users,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
|
|
||||||
export const getMenu = (t: Function) => {
|
export const getMenu = (t: Function) => {
|
||||||
@@ -39,3 +45,16 @@ export const getMenu = (t: Function) => {
|
|||||||
},
|
},
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getBottomMenu = (t: Function) => {
|
||||||
|
return [
|
||||||
|
{ name: t("menu.support"), path: "support", icon: <Icon icon={HelpCircle} /> },
|
||||||
|
{
|
||||||
|
name: t("menu.discussions"),
|
||||||
|
path: "discussions",
|
||||||
|
icon: <Icon icon={MessageCircle} />,
|
||||||
|
},
|
||||||
|
{ name: t("menu.docs"), path: "docs", icon: <Icon icon={FileText} /> },
|
||||||
|
{ name: t("menu.changelog"), path: "changelog", icon: <Icon icon={Code} /> },
|
||||||
|
];
|
||||||
|
};
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
import Stack from "@mui/material/Stack";
|
import Stack from "@mui/material/Stack";
|
||||||
import List from "@mui/material/List";
|
import List from "@mui/material/List";
|
||||||
|
import Divider from "@mui/material/Divider";
|
||||||
import { useSidebar } from "@/Hooks/useSidebar.js";
|
import { useSidebar } from "@/Hooks/useSidebar.js";
|
||||||
import { Logo } from "@/Components/v2/sidebar/Logo";
|
import { Logo } from "@/Components/v2/sidebar/Logo";
|
||||||
import { getMenu } from "@/Components/v2/sidebar/Menu";
|
import { getMenu, getBottomMenu } from "@/Components/v2/sidebar/Menu";
|
||||||
import { NavItem } from "@/Components/v2/sidebar/NavItem";
|
import { NavItem } from "@/Components/v2/sidebar/NavItem";
|
||||||
|
|
||||||
import { useNavigate, useLocation } from "react-router";
|
import { useNavigate, useLocation } from "react-router";
|
||||||
@@ -12,6 +13,13 @@ import { useTheme, useMediaQuery } from "@mui/material";
|
|||||||
import { useDispatch } from "react-redux";
|
import { useDispatch } from "react-redux";
|
||||||
import { setCollapsed } from "@/Features/UI/uiSlice";
|
import { setCollapsed } from "@/Features/UI/uiSlice";
|
||||||
|
|
||||||
|
const URL_MAP: Record<string, string> = {
|
||||||
|
support: "https://discord.com/invite/NAb6H3UTjK",
|
||||||
|
discussions: "https://github.com/bluewave-labs/checkmate/discussions",
|
||||||
|
docs: "https://bluewavelabs.gitbook.io/checkmate",
|
||||||
|
changelog: "https://github.com/bluewave-labs/checkmate/releases",
|
||||||
|
};
|
||||||
|
|
||||||
export const Sidebar = () => {
|
export const Sidebar = () => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@@ -21,11 +29,24 @@ export const Sidebar = () => {
|
|||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
const isSmall = useMediaQuery(theme.breakpoints.down("md"));
|
||||||
const menu = getMenu(t);
|
const menu = getMenu(t);
|
||||||
|
const bottomMenu = getBottomMenu(t);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(setCollapsed({ collapsed: isSmall }));
|
dispatch(setCollapsed({ collapsed: isSmall }));
|
||||||
}, [isSmall, dispatch]);
|
}, [isSmall, dispatch]);
|
||||||
|
|
||||||
|
const handleNavClick = (path: string) => {
|
||||||
|
const url = URL_MAP[path];
|
||||||
|
if (url) {
|
||||||
|
window.open(url, "_blank", "noreferrer");
|
||||||
|
} else {
|
||||||
|
navigate(`/${path}`);
|
||||||
|
}
|
||||||
|
if (isSmall) {
|
||||||
|
dispatch(setCollapsed({ collapsed: true }));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
component="aside"
|
component="aside"
|
||||||
@@ -49,7 +70,7 @@ export const Sidebar = () => {
|
|||||||
disablePadding
|
disablePadding
|
||||||
sx={{
|
sx={{
|
||||||
px: theme.spacing(6),
|
px: theme.spacing(6),
|
||||||
height: "100%",
|
flex: 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Logo
|
<Logo
|
||||||
@@ -63,16 +84,29 @@ export const Sidebar = () => {
|
|||||||
key={item.path}
|
key={item.path}
|
||||||
item={item}
|
item={item}
|
||||||
selected={selected}
|
selected={selected}
|
||||||
onClick={() => {
|
onClick={() => handleNavClick(item.path)}
|
||||||
navigate(`/${item.path}`);
|
|
||||||
if (isSmall) {
|
|
||||||
dispatch(setCollapsed({ collapsed: true }));
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</List>
|
</List>
|
||||||
|
<List
|
||||||
|
component="nav"
|
||||||
|
disablePadding
|
||||||
|
sx={{ px: theme.spacing(6) }}
|
||||||
|
>
|
||||||
|
{bottomMenu.map((item) => {
|
||||||
|
const selected = location.pathname.startsWith(`/${item.path}`);
|
||||||
|
return (
|
||||||
|
<NavItem
|
||||||
|
key={item.path}
|
||||||
|
item={item}
|
||||||
|
selected={selected}
|
||||||
|
onClick={() => handleNavClick(item.path)}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</List>
|
||||||
|
<Divider sx={{ borderColor: theme.palette.divider }} />
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
Reference in new issue
Block a user