diff --git a/src/components/Dashboard/Dashboard.tsx b/src/components/Dashboard/Dashboard.tsx index fc504de..ffdcf4f 100644 --- a/src/components/Dashboard/Dashboard.tsx +++ b/src/components/Dashboard/Dashboard.tsx @@ -1,4 +1,4 @@ -import React from 'react' +import React, { useEffect } from 'react' import { ThemeProvider, CssBaseline, @@ -43,6 +43,7 @@ import { clearInfos, clearTemplates } from '../../store/action/Actions' import DashboardIcon from '@mui/icons-material/Dashboard' import { restfulApiConfig } from '../../api/Config' import { muiColorTheme } from '../Theme' +import useMediaQuery from '@mui/material/useMediaQuery'; const drawerWidth = 240 @@ -62,9 +63,11 @@ const closedMixin = (theme: Theme): CSSObject => ({ }), overflowX: 'hidden', width: `calc(${theme.spacing(7)} + 1px)`, - [theme.breakpoints.up('sm')]: { - width: `calc(${theme.spacing(9)} + 1px)`, - }, + // 大きい画面の時に、drawerを閉じた時に、アイコンが中心にならないため、コメントアウト + // width: `calc(${theme.spacing(7)} + 1px)`, + // [theme.breakpoints.up('sm')]: { + // width: `calc(${theme.spacing(9)} + 1px)`, + // }, }) interface AppBarProps extends MuiAppBarProps { @@ -106,10 +109,34 @@ const Drawer = styled(MuiDrawer, { }), })) -export default function Dashboard(props: any) { + +interface DashboardProps { + title?: string + children?: React.ReactNode + sx?: CSSObject + forceDrawerClosed?: boolean +} +export default function Dashboard(props: DashboardProps) { const navigate = useNavigate() // Menu Bar - const [open, setOpen] = React.useState(true) + // useMediaQuery("(min-width:800px)")でmobileかどうかを判定 + const [open, setOpen] = React.useState(useMediaQuery("(min-width:600px)")) + + // 画面サイズが変わったときにopenを変更 + // closeが強制されているときは、openをfalseにする + const isMobile = !useMediaQuery("(min-width:600px)"); + useEffect(() => { + if(props.forceDrawerClosed){ + setOpen(false) + } + else if(isMobile){ + setOpen(false) + } + else{ + setOpen(true) + } + }, [isMobile, props.forceDrawerClosed]) + const handleDrawerOpen = () => { setOpen(true) } @@ -233,14 +260,13 @@ export default function Dashboard(props: any) { - + {props.title} diff --git a/src/index.tsx b/src/index.tsx index b492253..37bc843 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -2,17 +2,27 @@ import React from 'react' import './index.css' import App from './App' import reportWebVitals from './reportWebVitals' -import { SnackbarProvider } from 'notistack' +import { SnackbarProvider, closeSnackbar } from 'notistack' import { Provider } from 'react-redux' import { createRoot } from 'react-dom/client' import store from './store' +import { IconButton } from '@mui/material' +import CloseIcon from '@mui/icons-material/Close'; const container = document.getElementById('root') if (container) { const root = createRoot(container) root.render( - + ( + closeSnackbar(snackbarId)}> + + + )} + > diff --git a/src/pages/Dashboard/Dashboard.tsx b/src/pages/Dashboard/Dashboard.tsx index d6d74ac..b378850 100644 --- a/src/pages/Dashboard/Dashboard.tsx +++ b/src/pages/Dashboard/Dashboard.tsx @@ -18,6 +18,8 @@ import Cookies from 'js-cookie' import { useNavigate } from 'react-router-dom' import { restfulApiConfig } from '../../api/Config' import { StyledCardRoot3, StyledTypographyTitle } from '../../style' +import ReactMarkdown from 'react-markdown' +import remarkGfm from 'remark-gfm' export default function Dashboard() { const [data, setData] = React.useState() @@ -110,7 +112,7 @@ export default function Dashboard() { return ( - + {restfulApiConfig.enableMoney && data?.group?.is_expired && !data?.info?.length && ( @@ -177,7 +179,12 @@ export default function Dashboard() { {notice.fault && }
- {notice.data} + + {notice.data} + {/*