diff --git a/src/App.scss b/src/App.scss index cd322e27..0cb361bd 100644 --- a/src/App.scss +++ b/src/App.scss @@ -9,37 +9,6 @@ > .sidebar { height: 100vh; background-color: white; - padding: 10px; - - .sidebar-logo { - position: relative; - margin: 20px 50px 26px 0; - width: 119px; - font-size: 30px; - border-top: 6px solid gray; - border-bottom: 8px solid gray; - padding-bottom: 0; - line-height: 25px; - } - .sidebar-logo::before { - height: 10px; - width: 10px; - border-radius: 5px; - position: absolute; - background: gray; - top: 28px; - right: 24px; - content: ' ' - } - .sidebar-logo::after { - height: 10px; - width: 10px; - border-radius: 5px; - position: absolute; - background: gray; - top: 28px; - left: 17px; - content: ' ' - } + padding: 10px; } } \ No newline at end of file diff --git a/src/App.tsx b/src/App.tsx index 9db05a50..3eb147da 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -22,6 +22,8 @@ import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment' import { LocalizationProvider } from '@mui/x-date-pickers' import RoutesList, { PAGES } from './routes' +import MainHeader from './pages/components/header/Header' +import LayoutContext from './layout/LayoutContext' const { Content } = Layout const StyledLayout = styled(Layout)` @@ -107,14 +109,17 @@ const App = () => { - - - - - - - - + + + + + + + + + + + diff --git a/src/layout/LayoutContext.tsx b/src/layout/LayoutContext.tsx new file mode 100644 index 00000000..61f9ca01 --- /dev/null +++ b/src/layout/LayoutContext.tsx @@ -0,0 +1,12 @@ +import { FC, PropsWithChildren, createContext, useState } from 'react' + +export interface LayoutContextInterface { + setDrawerOpen: (isOpen: boolean) => void + drawerOpen: boolean +} +export const LayoutCtx = createContext({} as LayoutContextInterface) +const LayoutContext: FC = ({ children }) => { + const [drawerOpen, setDrawerOpen] = useState(false) + return {children} +} +export default LayoutContext diff --git a/src/pages/components/header/Header.tsx b/src/pages/components/header/Header.tsx new file mode 100644 index 00000000..ef46195e --- /dev/null +++ b/src/pages/components/header/Header.tsx @@ -0,0 +1,16 @@ +import { Layout } from 'antd' +import { MenuOutlined } from '@ant-design/icons' +import { useContext } from 'react' +import { LayoutContextInterface, LayoutCtx } from 'src/layout/LayoutContext' + +const { Header } = Layout + +const MainHeader = () => { + const { setDrawerOpen } = useContext(LayoutCtx) + return ( +
+ setDrawerOpen(true)} /> +
+ ) +} +export default MainHeader diff --git a/src/pages/components/header/sidebar/SideBar.tsx b/src/pages/components/header/sidebar/SideBar.tsx index 9c8c5e87..a58ace33 100644 --- a/src/pages/components/header/sidebar/SideBar.tsx +++ b/src/pages/components/header/sidebar/SideBar.tsx @@ -1,24 +1,33 @@ -import { useState } from 'react' import Menu from './menu/Menu' -import { MenuOutlined } from '@ant-design/icons' import './sidebar.scss' -import cn from 'classnames' +import { Drawer } from 'antd' +import { useContext } from 'react' +import { LayoutContextInterface, LayoutCtx } from 'src/layout/LayoutContext' -const SidebarToggle = ({ open, setOpen }: { open: boolean; setOpen: (open: boolean) => void }) => ( -
setOpen(!open)}> - +const Logo = () => ( +
+

דאטאבוס

) -const Logo = () =>

דאטאבוס

- export default function SideBar() { - const [open, setOpen] = useState(false) + const { drawerOpen, setDrawerOpen } = useContext(LayoutCtx) + return ( - + <> + setDrawerOpen(false)} + open={drawerOpen} + className="hideOnDesktop"> + + + + ) } diff --git a/src/pages/components/header/sidebar/sidebar.scss b/src/pages/components/header/sidebar/sidebar.scss index 7d8fd8d4..a72c187e 100644 --- a/src/pages/components/header/sidebar/sidebar.scss +++ b/src/pages/components/header/sidebar/sidebar.scss @@ -37,3 +37,62 @@ } } +.hideOnMobile { + display: none; + } + @media only screen and (min-width: 768px) { + .hideOnMobile { + display: block; + } + } + + .hideOnDesktop { + display: block; + } + @media only screen and (min-width: 768px) { + .hideOnDesktop { + display: none; + } + } + +.sidebar-logo { + position: relative; + margin: 20px auto; + width: 119px; + font-size: 30px; + border-top: 6px solid gray; + border-bottom: 8px solid gray; + padding-bottom: 0; + line-height: 25px; + &::before { + height: 10px; + width: 10px; + border-radius: 5px; + position: absolute; + background: gray; + top: 28px; + right: 24px; + content: ' ' + } + &::after { + height: 10px; + width: 10px; + border-radius: 5px; + position: absolute; + background: gray; + top: 28px; + left: 17px; + content: ' ' + } +} + +.sidebar-logo-collapsed { + position: relative; + margin: 20px auto; + text-align: center; + font-size: 30px; + border-top: 6px solid gray; + border-bottom: 8px solid gray; + padding-bottom: 0; + line-height: 25px; +} \ No newline at end of file