Skip to content

Commit 334e84b

Browse files
committed
initial-homepage-sicnecher-commit
1 parent b03b419 commit 334e84b

File tree

5 files changed

+96
-50
lines changed

5 files changed

+96
-50
lines changed

src/locale/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"databus_definition": "The open platform for real data on the quality of public transportation lines in Israel",
55
"website_goal": "The purpose of the site is to improve the quality of public transportation in Israel by providing reliable information to journalists, citizens, transportation companies, and government officials in Israel.",
66
"show_button": "Show",
7-
"copyright": "© The Public Knowledge Workshop"
7+
"copyright": "© The Public Knowledge Workshop",
8+
"open_menu": "Start Exploring"
89
},
910
"homepage_title": "Home",
1011
"dashboard_page_title": "Public transport operators according to planned trips",
@@ -19,6 +20,7 @@
1920
"gaps_patterns_page_description": "A graphic display of routes performed according to schedule, grouped by time of day\\severity, by user-given bus operator, route number, route & date",
2021
"singleline_map_page_title": "Map by line",
2122
"singleline_map_page_description": "Display of bus route on map by user-given bus operator, route number, route, date & time",
23+
"open_menu_description": "Displays different options and parameters which are accessible in the application",
2224
"choose_datetime": "Date and time",
2325
"choose_date": "Date",
2426
"choose_time": "Time",

src/locale/he.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"databus_definition": "הפלטפורמה הפתוחה לנתוני אמת על איכות קווי התחבורה הציבורית בישראל",
55
"website_goal": "מטרת האתר היא לשפר את איכות התחבורה הציבורית בארץ ע\"י מתן מידע אמין לעיתונאים, אזרחים, חברות התחבורה, וגורמי ממשל בישראל.",
66
"show_button": "הצג",
7-
"copyright": "© הסדנא לידע ציבורי (ע\"ר)"
7+
"copyright": "© הסדנא לידע ציבורי (ע\"ר)",
8+
"open_menu": "תתחיל לחקור"
89
},
910
"homepage_title": "ראשי",
1011
"dashboard_page_title": "קיום נסיעות",
@@ -19,6 +20,7 @@
1920
"gaps_patterns_page_description": "תצוגה גרפית של אחוז הנסיעות שבוצעו בהתאם ללוח הזמנים בחלוקה לשעות\\רמת חומרה, לפי חברת אוטובוסים, מספר קו, מסלול ותאריך",
2021
"singleline_map_page_title": "מפה לפי קו",
2122
"singleline_map_page_description": "תצוגה של מסלול קו על מפה ע\"פ נתוני חברת אוטובוסים, קו, מסלול, תאריך ושעה",
23+
"open_menu_description": "תצוגה של שלל אפשרויות ופרמטרים שונים הניתנים לביצוע באפליקצייה",
2224
"choose_datetime": "תאריך ושעה",
2325
"choose_date": "תאריך",
2426
"choose_time": "שעה",

src/pages/dashboard/WorstLinesChart/LineHbarChart/HbarChart/HbarChart.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
.HbarChart {
22
.entry {
33
position: relative;
4+
margin-bottom: 2%;
5+
padding: 3px;
6+
border-radius: 8px;
47

58
.entryName {
69
margin-left: 10px;

src/pages/homepage/HomePage.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
footer {
2727
background-color: #b0d0a4;
28-
width: 100%;
28+
width: 100vw;
2929
font-weight: 500;
3030
position: absolute;
3131
bottom: 0;
@@ -37,12 +37,17 @@
3737
display: grid;
3838
grid-template-columns: repeat(4, 1fr);
3939
gap: 1rem;
40-
40+
margin-bottom:10%;
41+
4142
@media (width <=600px) {
4243
margin-bottom: 3rem;
4344
}
4445
}
4546

47+
.menu-link {
48+
margin-bottom: 15%;
49+
}
50+
4651
.page-link {
4752
display: flex;
4853
flex-direction: column;

src/pages/homepage/HomePage.tsx

Lines changed: 80 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -5,70 +5,104 @@ import {
55
DirectionsBusOutlined,
66
HistoryOutlined,
77
MapOutlined,
8+
MenuOutlined,
89
ViewKanbanOutlined,
910
} from '@mui/icons-material'
10-
import { SvgIconProps } from '@mui/material'
11+
import { SvgIconProps, Tooltip } from '@mui/material'
12+
import React, { useContext, useEffect, useState } from 'react'
1113
import busImage from '../../img/busImg.png'
12-
13-
export const HomePage = () => {
14-
const { t } = useTranslation()
15-
16-
return (
17-
<div className="container">
18-
<img src={busImage} alt="Public Transportaion Bus Illustration" />
19-
<h1>{t('homepage.welcome')}</h1>
20-
<h2>{t('homepage.databus_definition')}</h2>
21-
<p>{t('homepage.website_goal')}</p>
22-
<section className="links">
23-
<PageLink
24-
icon={<HistoryOutlined />}
25-
label={t('timeline_page_title')}
26-
description={t('timeline_page_description')}
27-
to="/timeline"
28-
/>
29-
<PageLink
30-
icon={<DirectionsBusOutlined />}
31-
label={t('gaps_page_title')}
32-
description={t('gaps_page_description')}
33-
to="/gaps"
34-
/>
35-
<PageLink
36-
icon={<ViewKanbanOutlined />}
37-
label={t('gaps_patterns_page_title')}
38-
description={t('gaps_patterns_page_description')}
39-
to="/gaps_patterns"
40-
/>
41-
<PageLink
42-
icon={<MapOutlined />}
43-
label={t('time_based_map_page_title')}
44-
description={t('time_based_map_page_description')}
45-
to="/map"
46-
/>
47-
</section>
48-
<footer>{`${t('homepage.copyright')} ${new Date().getFullYear()}`}</footer>
49-
</div>
50-
)
51-
}
14+
import { LayoutContextInterface, LayoutCtx } from 'src/layout/LayoutContext'
5215

5316
const PageLink = ({
5417
icon,
5518
label,
56-
description,
5719
to,
5820
}: {
5921
icon: React.ReactElement<SvgIconProps>
6022
label: string
61-
description: string
62-
to: To
23+
to: To | (() => void)
6324
}) => {
6425
const { t } = useTranslation()
6526

6627
return (
6728
<div className="page-link">
6829
{icon}
6930
<span>{label}</span>
70-
<NavLink to={to}>{t('homepage.show_button')}</NavLink>
71-
<p>{description}</p>
31+
{typeof to == 'function' ? (
32+
<a onClick={to}>{t('homepage.show_button')}</a>
33+
) : (
34+
<NavLink to={to}>{t('homepage.show_button')}</NavLink>
35+
)}
36+
</div>
37+
)
38+
}
39+
40+
const wrapToolTip = (element: React.ReactElement, description: string) => {
41+
return (
42+
<Tooltip
43+
placement={'top'}
44+
title={<div style={{ fontSize: 15, textAlign: 'center' }}>{description}</div>}
45+
followCursor={true}>
46+
{element}
47+
</Tooltip>
48+
)
49+
}
50+
51+
export const HomePage = () => {
52+
const { t } = useTranslation()
53+
const [isWide, setIsWide] = useState(window.innerWidth > 450 ? true : false)
54+
const { setDrawerOpen } = useContext<LayoutContextInterface>(LayoutCtx)
55+
56+
useEffect(() => {
57+
window.addEventListener('resize', () => {
58+
setIsWide(window.innerWidth > 450 ? true : false)
59+
})
60+
return () => {
61+
window.removeEventListener('resize', () => console.log('done'))
62+
}
63+
}, [])
64+
65+
return (
66+
<div className="container">
67+
<img src={busImage} alt="Public Transportaion Bus Illustration" />
68+
<h1>{t('homepage.welcome')}</h1>
69+
<h2>{t('homepage.databus_definition')}</h2>
70+
<p>{t('homepage.website_goal')}</p>
71+
{isWide ? (
72+
<section className="links">
73+
<PageLink
74+
icon={wrapToolTip(<HistoryOutlined />, t('timeline_page_description'))}
75+
label={t('timeline_page_title')}
76+
to="/timeline"
77+
/>
78+
<PageLink
79+
icon={wrapToolTip(<DirectionsBusOutlined />, t('gaps_page_description'))}
80+
label={t('gaps_page_title')}
81+
to="/gaps"
82+
/>
83+
<PageLink
84+
icon={wrapToolTip(<ViewKanbanOutlined />, t('gaps_patterns_page_description'))}
85+
label={t('gaps_patterns_page_title')}
86+
to="/gaps_patterns"
87+
/>
88+
<PageLink
89+
icon={wrapToolTip(<MapOutlined />, t('time_based_map_page_description'))}
90+
label={t('time_based_map_page_title')}
91+
to="/map"
92+
/>
93+
</section>
94+
) : (
95+
<section className="menu-link">
96+
<PageLink
97+
icon={wrapToolTip(<MenuOutlined />, t('open_menu_description'))}
98+
label={t('homepage.open_menu')}
99+
to={() => {
100+
setDrawerOpen(true)
101+
}}
102+
/>
103+
</section>
104+
)}
105+
<footer>{`${t('homepage.copyright')} ${new Date().getFullYear()}`}</footer>
72106
</div>
73107
)
74108
}

0 commit comments

Comments
 (0)