import { alpha, ListItem, ListItemButton, ListItemText, ListItemIcon, } from "@mui/material"; import { useMatch, useResolvedPath, useNavigate } from "react-router-dom"; import { useVerge } from "@/hooks/use-verge"; interface Props { to: string; children: string; icon: React.ReactNode[]; } export const LayoutItem = (props: Props) => { const { to, children, icon } = props; const { verge } = useVerge(); const { menu_icon } = verge ?? {}; const resolved = useResolvedPath(to); const match = useMatch({ path: resolved.pathname, end: true }); const navigate = useNavigate(); return ( { const bgcolor = mode === "light" ? alpha(primary.main, 0.15) : alpha(primary.main, 0.35); const color = mode === "light" ? "#1f1f1f" : "#ffffff"; return { "&.Mui-selected": { bgcolor }, "&.Mui-selected:hover": { bgcolor }, "&.Mui-selected .MuiListItemText-primary": { color }, }; }, ]} onClick={() => navigate(to)} > {(menu_icon === "monochrome" || !menu_icon) && ( {icon[0]} )} {menu_icon === "colorful" && {icon[1]}} ); };