import { useState, useEffect } from "react" // react-github-btn import GitHubButton from "react-github-btn" // @mui material components import Divider from "@mui/material/Divider" import Switch from "@mui/material/Switch" import IconButton from "@mui/material/IconButton" import Link from "@mui/material/Link" import Icon from "@mui/material/Icon" import { Theme } from "@mui/material/styles" // @mui icons import TwitterIcon from "@mui/icons-material/Twitter" import FacebookIcon from "@mui/icons-material/Facebook" // ThreeD Garden components import MDBox from "~/components/mui/MDBox" import MDTypography from "~/components/mui/MDTypography" import MDButton from "~/components/mui/MDButton" // Custom styles for the Configurator import ConfiguratorRoot from "~/components/elements/Configurator/ConfiguratorRoot" // ThreeD Garden context import { useMaterialUIController, setOpenConfigurator, setTransparentSidenav, setWhiteSidenav, setMiniSidenav, setFixedNavbar, setSidenavColor, setDarkMode, } from "~/context" function Configurator(): JSX.Element { const [controller, dispatch] = useMaterialUIController() const { openConfigurator, miniSidenav, fixedNavbar, sidenavColor, transparentSidenav, whiteSidenav, darkMode, } = controller const [disabled, setDisabled] = useState(false) const sidenavColors: ( | "primary" | "secondary" | "info" | "success" | "warning" | "error" | "light" | "dark" )[] = ["primary", "dark", "info", "success", "warning", "error"] // Use the useEffect hook to change the button state for the sidenav type based on window size. useEffect(() => { // A function that sets the disabled state of the buttons for the sidenav type. function handleDisabled() { return window.innerWidth > 1200 ? setDisabled(false) : setDisabled(true) } // The event listener that's calling the handleDisabled function when resizing the window. window.addEventListener("resize", handleDisabled) // Call the handleDisabled function to set the state with the initial value. handleDisabled() // Remove event listener on cleanup return () => window.removeEventListener("resize", handleDisabled) }, []) const handleCloseConfigurator = () => setOpenConfigurator(dispatch, false) const handleTransparentSidenav = () => { setTransparentSidenav(dispatch, true) setWhiteSidenav(dispatch, false) } const handleWhiteSidenav = () => { setWhiteSidenav(dispatch, true) setTransparentSidenav(dispatch, false) } const handleDarkSidenav = () => { setWhiteSidenav(dispatch, false) setTransparentSidenav(dispatch, false) } const handleMiniSidenav = () => setMiniSidenav(dispatch, !miniSidenav) const handleFixedNavbar = () => setFixedNavbar(dispatch, !fixedNavbar) const handleDarkMode = () => setDarkMode(dispatch, !darkMode) // sidenav type buttons styles const sidenavTypeButtonsStyles = ({ functions: { pxToRem }, palette: { white, dark, background }, borders: { borderWidth }, }: Theme | any) => ({ height: pxToRem(39), background: darkMode ? background.sidenav : white.main, color: darkMode ? white.main : dark.main, border: `${borderWidth[1]} solid ${darkMode ? white.main : dark.main}`, "&:hover, &:focus, &:focus:not(:hover)": { background: darkMode ? background.sidenav : white.main, color: darkMode ? white.main : dark.main, border: `${borderWidth[1]} solid ${darkMode ? white.main : dark.main}`, }, }) // sidenav type active button styles const sidenavTypeActiveButtonStyles = ({ functions: { pxToRem, linearGradient }, palette: { white, gradients, background }, }: Theme | any) => ({ height: pxToRem(39), background: darkMode ? white.main : linearGradient(gradients.dark.main, gradients.dark.state), color: darkMode ? background.sidenav : white.main, "&:hover, &:focus, &:focus:not(:hover)": { background: darkMode ? white.main : linearGradient(gradients.dark.main, gradients.dark.state), color: darkMode ? background.sidenav : white.main, }, }) return ( Dashboard Configurator Set your dashboard options here. ({ fontSize: `${size.lg} !important`, color: darkMode ? white.main : dark.main, stroke: "currentColor", strokeWidth: "2px", cursor: "pointer", transform: "translateY(5px)", })} onClick={handleCloseConfigurator}> close Sidenav Colors {sidenavColors.map((color) => ( ({ width: "24px", height: "24px", padding: 0, border: `${borderWidth[1]} solid ${darkMode ? background.sidenav : white.main }`, borderColor: () => { let borderColorValue = sidenavColor === color && dark.main if (darkMode && sidenavColor === color) { borderColorValue = white.main } return borderColorValue }, transition: transitions.create("border-color", { easing: transitions.easing.sharp, duration: transitions.duration.shorter, }), backgroundImage: ({ functions: { linearGradient }, palette: { gradients }, }) => linearGradient( gradients[color].main, gradients[color].state ), "&:not(:last-child)": { mr: 1, }, "&:hover, &:focus, &:active": { borderColor: darkMode ? white.main : dark.main, }, })} onClick={() => setSidenavColor(dispatch, color)} /> ))} Sidenav Type Choose between different sidenav types. Dark Transparent White Navbar Fixed Sidenav Mini Light / Dark Button info:gradient Button dark:gradient Button mode:outlined Star Thank you for sharing!   Tweet   Share ) } export default Configurator