Skip to content

Commit

Permalink
Merge branch 'main' into feat/add-storybook
Browse files Browse the repository at this point in the history
  • Loading branch information
NoamGaash authored Nov 13, 2023
2 parents 9fa648d + 9ef8c8c commit 301f33d
Show file tree
Hide file tree
Showing 8 changed files with 134 additions and 56 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@ yarn-error.log*

**/traces
**/node_modules

# yarn
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,5 @@
"prettier": "^2.7.1",
"storybook": "^7.5.3",
"vitest": "^0.34.6"
},
"packageManager": "yarn@1.22.19"
}
}
33 changes: 1 addition & 32 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
21 changes: 13 additions & 8 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)`
Expand Down Expand Up @@ -107,14 +109,17 @@ const App = () => {
<LocalizationProvider dateAdapter={AdapterMoment} adapterLocale="he">
<ConfigProvider direction="rtl" locale={heIL}>
<StyledLayout className="main">
<SideBar />
<Layout>
<StyledContent>
<StyledBody>
<RoutesList />
</StyledBody>
</StyledContent>
</Layout>
<LayoutContext>
<SideBar />
<Layout>
<MainHeader />
<StyledContent>
<StyledBody>
<RoutesList />
</StyledBody>
</StyledContent>
</Layout>
</LayoutContext>
</StyledLayout>
</ConfigProvider>
</LocalizationProvider>
Expand Down
12 changes: 12 additions & 0 deletions src/layout/LayoutContext.tsx
Original file line number Diff line number Diff line change
@@ -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<PropsWithChildren> = ({ children }) => {
const [drawerOpen, setDrawerOpen] = useState(false)
return <LayoutCtx.Provider value={{ drawerOpen, setDrawerOpen }}>{children}</LayoutCtx.Provider>
}
export default LayoutContext
16 changes: 16 additions & 0 deletions src/pages/components/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -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<LayoutContextInterface>(LayoutCtx)
return (
<Header style={{ background: 'white' }} className="hideOnDesktop">
<MenuOutlined onClick={() => setDrawerOpen(true)} />
</Header>
)
}
export default MainHeader
37 changes: 23 additions & 14 deletions src/pages/components/header/sidebar/SideBar.tsx
Original file line number Diff line number Diff line change
@@ -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 }) => (
<div className="sidebar-menu-toggle" onClick={() => setOpen(!open)}>
<MenuOutlined />
const Logo = () => (
<div style={{ overflow: 'hidden' }}>
<h1 className={'sidebar-logo'}>דאטאבוס</h1>
</div>
)

const Logo = () => <h1 className={'sidebar-logo'}>דאטאבוס</h1>

export default function SideBar() {
const [open, setOpen] = useState(false)
const { drawerOpen, setDrawerOpen } = useContext<LayoutContextInterface>(LayoutCtx)

return (
<aside className={cn('sidebar', { open })}>
<Logo />
<SidebarToggle open={open} setOpen={setOpen} />
<Menu />
</aside>
<>
<Drawer
placement="right"
mask
width={280}
onClose={() => setDrawerOpen(false)}
open={drawerOpen}
className="hideOnDesktop">
<Menu />
</Drawer>
<aside className={'sidebar hideOnMobile'}>
<Logo />
<Menu />
</aside>
</>
)
}
59 changes: 59 additions & 0 deletions src/pages/components/header/sidebar/sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

0 comments on commit 301f33d

Please sign in to comment.