Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
Top Bar Revamp
Browse files Browse the repository at this point in the history
Top Bar Revamp

Move all filters to top, reformatted containers, added labels

* TBF when browser narrow, date filters stack

Quick fix

Fixed calendar pop up width

more
  • Loading branch information
a-thansen committed Oct 24, 2023
1 parent 6ce51c5 commit 64c9155
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 32 deletions.
39 changes: 26 additions & 13 deletions frontend/src/Components/Conditions/ConditionsMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ import { Feature, FeatureCollection } from 'geojson';
import Search from '../Map/Search';
import MonthFilter from '../Map/MonthFilter';
import MapWrapper from '../Map/MapWrapper';
import Selector from '../Map/Inputs/Selector';

import '../../css/navbar.css';
import '../../css/search.css';
import '../../css/month_filter.css';
import '../../css/slider.css';
import '../../css/selector.css';
import 'react-datepicker/dist/react-datepicker.css';

import { getConditions } from '../../queries/fetchConditions';
Expand Down Expand Up @@ -408,20 +411,29 @@ const ConditionsMap = (props: any) => {
/>
</div>
<div className="filter-container">
<select
className="sweetalert-input"
defaultValue={mode}
onChange={inputChange}
style={{ width: '100px' }}
>
{conditionTypes.map((value) => (
<option value={value} key={value}>
{value}
</option>
))}
</select>
<div className="input-selector-container">
<select
className="input"
defaultValue={mode}
onChange={inputChange}
>
{conditionTypes.map((value) => (
<option value={value} key={value}>
{value}
</option>
))}
</select>
<p className="labelling">Condition Type</p>
</div>
</div>
<div className="nav-container">
<div className="filter-container">
<Selector
options={['ALL', 'Critical', 'High', 'Medium', 'Low']}
onSelect={(e) => console.log(e)}
/>
<p className="labelling"> Severity </p>
</div>
<div className="picker-container">
<MonthFilter
onStartChange={(date: any) => {
rangeChange(dateChange(date), true);
Expand All @@ -430,6 +442,7 @@ const ConditionsMap = (props: any) => {
rangeChange(dateChange(date), false);
}}
/>
<p className="labelling"> Start Date → End Date</p>
</div>
</div>
<div style={{ height: '100%' }}>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Components/Map/Inputs/Selector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface Props {
}

/**
* Selector is the component to show a dropdown menu for conditions.
* Selector is the component to show a dropdown menu for condition severity.
*/
const Selector: React.FC<Props> = ({ options, onSelect }) => {
return (
Expand Down
5 changes: 0 additions & 5 deletions frontend/src/Components/Map/MapWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import '../../css/map.css';
import { MAP_OPTIONS } from './constants';
import React, { FC } from 'react';
import Selector from './Inputs/Selector';

/**
* properties
Expand All @@ -26,10 +25,6 @@ const MapWrapper: FC<IMapWrapper> = ({ children }) => {

return (
<>
<Selector
options={['All', 'Critical', 'High', 'Medium', 'Low']}
onSelect={(e) => console.log(e)}
/>
<MapContainer
preferCanvas={true}
center={center}
Expand Down
15 changes: 14 additions & 1 deletion frontend/src/Components/Map/MonthFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,33 @@ interface Props {
onEndChange: (date: any) => void;
}

const CustomInput = ({
value,
onClick,
}: {
value: string;
onClick: (event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => void;
}) => (
<button className="month-custom-input" onClick={onClick}>
{value}
</button>
);

/**
* Component rendering Month Filter
*/

const MonthFilter: React.FC<Props> = ({ onEndChange, onStartChange }) => {
const [startDate, setStartDate] = useState(new Date('2022/06/08'));
const [endDate, setEndDate] = useState(new Date());

return (
<>
<div className="datepicker">
<DatePicker
selected={startDate}
onSelect={(date: any) => setStartDate(date)}
onChange={onStartChange}
customInput={React.createElement(CustomInput)}
selectsStart
startDate={startDate}
endDate={endDate}
Expand All @@ -38,6 +50,7 @@ const MonthFilter: React.FC<Props> = ({ onEndChange, onStartChange }) => {
selected={endDate}
onSelect={(date: any) => setEndDate(date)}
onChange={onEndChange}
customInput={React.createElement(CustomInput)}
selectsEnd
startDate={startDate}
endDate={endDate}
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/css/month_filter.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
.datepicker {
position: static;
display: inline-block;
align-self: flex-start;
}

.month-custom-input {
align-self: flex-start;
align-items: center;
background-color: white;
color: black;
font-size: 15px;
border-radius: 5px;
margin: 5px 0px;
cursor: pointer;
}

.react-datepicker__input-container {
width: inherit;
}

.react-datepicker-wrapper {
width: 100%;
}
29 changes: 26 additions & 3 deletions frontend/src/css/navbar.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
flex-wrap: wrap;
justify-content: flex-start;
align-content: space-around;
align-items: center;
position: sticky;
gap: 2%;
top: 0;
left: 0;
width: 100%;
Expand All @@ -15,14 +17,25 @@
}

.nav-container {
width: 20%;
position: relative;
width: 15%;
height: 100%;
margin-top: 1%;
margin-top: 0.7%;
margin-left: 0.4%;
align-self: flex-start;
}

.picker-container {
position: relative;
width: 15%;
height: 100%;
margin-top: 0.7%;
align-self: flex-start;
}

.filter-container {
width: 10%;
position: relative;
width: 5%;
height: 100%;
margin-top: 1%;
align-self: flex-start;
Expand All @@ -37,6 +50,16 @@
border-radius: 15%;
}

.labelling {
display: fixed;
flex-direction: column;
justify-content: center;
margin-top: -3%;
font-size: 10px;
/* overflow: hidden; */
white-space: nowrap;
}

.nav-tab:hover {
color: var(--highlight-text);
}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/css/search.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
line-height: 36px;
height: 36px;
padding: 0 31px 0 7px;
width: 200px;
width: 80%;

border: 1px solid rgba(0, 0, 0, 0.2);
border-radius: 5px;
Expand Down Expand Up @@ -65,7 +65,7 @@

.geoapify-close-button {
position: absolute;
right: 25px;
right: 8px;
width: 30px;
top: 0px;

Expand Down
10 changes: 3 additions & 7 deletions frontend/src/css/selector.css
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
.input-selector-container {
z-index: calc(var(--navbar-z-index) - 2);
position: absolute;
margin: 20px 102px;
width: 120px;
height: 30px;
position: relative;
}

.input-selector-container .input {
width: 100%;
height: 100%;
background: var(--background);
color: white;
background: white;
color: black;
cursor: pointer;
font-size: 15px;
border: none;
Expand Down

0 comments on commit 64c9155

Please sign in to comment.