Skip to content

Commit

Permalink
feat: improve sidebar & logo design (#137)
Browse files Browse the repository at this point in the history
* feat: new design of sidebar

* fix: solve types problem
  • Loading branch information
shootermv authored Oct 29, 2023
1 parent 15e07cf commit 22df36e
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 16 deletions.
32 changes: 29 additions & 3 deletions src/App.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,37 @@
> .sidebar {
height: 100vh;
background-color: white;
padding: 30px;
text-align: center;
padding: 10px;

h1 {
.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: ' '
}
}
}
24 changes: 22 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,18 @@ import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment'
import { LocalizationProvider } from '@mui/x-date-pickers'
import About from './pages/About'
import GapsPatternsPage from './pages/GapsPatternsPage'

import {
RadarChartOutlined,
BellOutlined,
DollarOutlined,
HeatMapOutlined,
LaptopOutlined,
FieldTimeOutlined,
BugOutlined,
BarChartOutlined,
LineChartOutlined,
} from '@ant-design/icons'
import { MenuPage } from './pages/components/header/menu/Menu'
const { Content } = Layout

const StyledLayout = styled(Layout)`
Expand All @@ -48,43 +59,52 @@ const PAGES = [
{
label: TEXT_KEYS.dashboard_page_title,
key: '/dashboard',
icon: LaptopOutlined,
},
{
label: TEXT_KEYS.timeline_page_title,
key: '/timeline',
searchParamsRequired: true,
icon: FieldTimeOutlined,
},
{
label: TEXT_KEYS.gaps_page_title,
key: '/gaps',
searchParamsRequired: true,
icon: BarChartOutlined,
},
{
label: TEXT_KEYS.gaps_patterns_page_title,
key: '/gaps_patterns',
icon: LineChartOutlined,
},
{
label: TEXT_KEYS.realtime_map_page_title,
key: '/map',
icon: HeatMapOutlined,
},
{
label: TEXT_KEYS.singleline_map_page_title,
key: '/single-line-map',
searchParamsRequired: true,
icon: RadarChartOutlined,
},
{
label: TEXT_KEYS.about_title,
key: '/about',
icon: BellOutlined,
},
{
label: TEXT_KEYS.report_a_bug_title,
key: 'https://github.com/hasadna/open-bus-map-search/issues',
icon: BugOutlined,
},
{
label: TEXT_KEYS.donate_title,
key: 'https://www.jgive.com/new/he/ils/donation-targets/3268#donation-modal',
icon: DollarOutlined,
},
]
] as MenuPage[]

const theme = createTheme(
{
Expand Down
1 change: 0 additions & 1 deletion src/locale/he.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"timeline_page_title": "לוח זמנים היסטורי",
"realtime_map_page_title": "מפה בזמן אמת",
"gaps_page_title": "נסיעות שלא יצאו",
"gaps_patterns_page_title": "דפוסי נסיעות שלא יצאו",
"singleline_map_page_title": "מפה לפי קו",
"choose_datetime": "תאריך ושעה",
"choose_date": "תאריך",
Expand Down
11 changes: 11 additions & 0 deletions src/pages/components/header/menu/Menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { useLocation, useNavigate } from 'react-router-dom'
import cn from 'classnames'
import './menu.scss'
import { useTranslation } from 'react-i18next'
import { IconBaseProps } from '@ant-design/icons/lib/components/Icon'

export type MenuPage = {
label: string
key: string
searchParamsRequired?: boolean
icon: string | React.FunctionComponent<IconBaseProps>
}

function Menu({ pages }: { pages: MenuPage[] }) {
Expand All @@ -32,6 +35,14 @@ function Menu({ pages }: { pages: MenuPage[] }) {
onClick={() =>
page.key[0] === '/' ? navigate(page.key) : window.open(page.key, '_blank')
}>
{React.createElement(page.icon)}
{
<span
style={{
width: '15px',
}}
/>
}
{t(page.label)}
</li>
))}
Expand Down
14 changes: 8 additions & 6 deletions src/pages/components/header/menu/menu.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
list-style: none;
padding: 0;
.menu-item {
display: flex;
align-items: center;
width: 240px;
padding: 10px;
padding: 12px 23px;
font-size: 16px;
cursor: pointer;
border: 1px solid $gray-5;
border-radius: 5px;
margin-bottom: 20px;
line-height: initial;
border-radius: 9px;
margin-bottom: 4px;
line-height: 21px;
box-sizing: border-box;
transition: all 0.2s ease-in-out;

Expand All @@ -21,7 +22,8 @@
}
&.active {
background-color: $color-active;
color: white;

color: #1677ff;
border: none;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/pages/components/header/sidebar/SideBar.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useState } from 'react'
import Menu, { MenuPage } from '../menu/Menu'
import cn from 'classnames'
import './sidebar.scss'
import { MenuOutlined } from '@ant-design/icons'
import './sidebar.scss'
import cn from 'classnames'

const SidebarToggle = ({ open, setOpen }: { open: boolean; setOpen: (open: boolean) => void }) => (
<div className="sidebar-menu-toggle" onClick={() => setOpen(!open)}>
Expand Down
7 changes: 6 additions & 1 deletion src/pages/components/header/sidebar/sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
max-width: 0;
padding: 0;
transition: all 0.2s ease-in-out;

.sidebar-logo {
display: none;
}
.sidebar-menu-toggle {
display: block;
position: absolute;
Expand All @@ -23,6 +25,9 @@
}

.main > .sidebar.open{
.sidebar-logo {
display: block;
}
display: block;
position: absolute;
z-index: 500;
Expand Down
2 changes: 1 addition & 1 deletion src/resources/variables.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// define variables:
$gray-5: rgba(224, 224, 224);
$color-active: rgba(95, 91, 255);
$color-active: #e6f4ff;

$mobile-max-width: 768px;

Expand Down

0 comments on commit 22df36e

Please sign in to comment.