-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/add-storybook
- Loading branch information
Showing
8 changed files
with
134 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -105,6 +105,5 @@ | |
"prettier": "^2.7.1", | ||
"storybook": "^7.5.3", | ||
"vitest": "^0.34.6" | ||
}, | ||
"packageManager": "yarn@1.22.19" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters