-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
190 additions
and
201 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
File renamed without changes.
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,44 @@ | ||
import Menu from './menu/Menu' | ||
import './sidebar.scss' | ||
import { Drawer, Layout } from 'antd' | ||
import { useContext, useState } from 'react' | ||
import { LayoutContextInterface, LayoutCtx } from '../LayoutContext' | ||
|
||
const { Sider } = Layout | ||
|
||
const Logo = () => ( | ||
<div style={{ overflow: 'hidden' }}> | ||
<h1 className={'sidebar-logo'}>דאטאבוס</h1> | ||
</div> | ||
) | ||
const CollapsedLogo = () => <h1 className={'sidebar-logo-collapsed'}>🚌</h1> | ||
|
||
export default function SideBar() { | ||
const { drawerOpen, setDrawerOpen } = useContext<LayoutContextInterface>(LayoutCtx) | ||
const [collapsed, setCollapsed] = useState(false) | ||
return ( | ||
<> | ||
<Drawer | ||
placement="right" | ||
mask | ||
width={280} | ||
onClose={() => setDrawerOpen(false)} | ||
open={drawerOpen} | ||
className="hideOnDesktop" | ||
bodyStyle={{ padding: '0' }}> | ||
<Menu /> | ||
</Drawer> | ||
<Sider | ||
theme="light" | ||
breakpoint="lg" | ||
collapsedWidth={60} | ||
collapsible | ||
collapsed={collapsed} | ||
onCollapse={(value: boolean) => setCollapsed(value)} | ||
className="hideOnMobile"> | ||
{collapsed ? <CollapsedLogo /> : <Logo />} | ||
<Menu /> | ||
</Sider> | ||
</> | ||
) | ||
} |
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,67 @@ | ||
import React, { useEffect, useState } from 'react' | ||
import { Link, useLocation } from 'react-router-dom' | ||
import './menu.scss' | ||
import { useTranslation } from 'react-i18next' | ||
import { PAGES as pages } from 'src/routes' | ||
|
||
import type { MenuProps } from 'antd' | ||
import { Menu } from 'antd' | ||
|
||
type MenuItem = Required<MenuProps>['items'][number] | ||
function getItem( | ||
label: React.ReactNode, | ||
key: React.Key, | ||
icon?: React.ReactNode, | ||
children?: MenuItem[], | ||
): MenuItem { | ||
return { | ||
key, | ||
icon, | ||
children, | ||
label, | ||
} as MenuItem | ||
} | ||
|
||
const MainMenu = () => { | ||
const { t, i18n } = useTranslation() | ||
const items: MenuItem[] = pages.map((itm) => { | ||
return getItem(<Link to={t(itm.path)}>{t(itm.label)}</Link>, itm.path, itm.icon) | ||
}) | ||
const [currentLanguage, setCurrentLanguage] = useState('en') | ||
|
||
const handleChangeLanguage = () => { | ||
const newLanguage = currentLanguage === 'en' ? 'he' : 'en' | ||
setCurrentLanguage(newLanguage) | ||
i18n.changeLanguage(newLanguage) | ||
} | ||
const location = useLocation() | ||
const [current, setCurrent] = useState( | ||
location.pathname === '/' || location.pathname === '' ? '/dashboard' : location.pathname, | ||
) | ||
|
||
useEffect(() => { | ||
if (location) { | ||
if (current !== location.pathname) { | ||
setCurrent(location.pathname) | ||
} | ||
} | ||
}, [location, current]) | ||
|
||
const handleClick: MenuProps['onClick'] = ({ key }) => { | ||
setCurrent(key) | ||
} | ||
return ( | ||
<> | ||
<Menu | ||
onClick={handleClick} | ||
theme="light" | ||
defaultSelectedKeys={[current]} | ||
mode="inline" | ||
items={items} | ||
/> | ||
{null && <button onClick={handleChangeLanguage}>Change Language</button>} | ||
</> | ||
) | ||
} | ||
|
||
export default MainMenu |
2 changes: 1 addition & 1 deletion
2
.../components/header/sidebar/menu/menu.scss → src/layout/sidebar/menu/menu.scss
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,61 @@ | ||
@import '../../resources/variables'; | ||
|
||
|
||
.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: 22px; | ||
border-top: 6px solid gray; | ||
border-bottom: 8px solid gray; | ||
padding-bottom: 0; | ||
line-height: 25px; | ||
} |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.