Skip to content

Commit

Permalink
Pre-Demo Updates (#92)
Browse files Browse the repository at this point in the history
* replace filter icon with search icon

* add clear button to the left panel

* update button text
  • Loading branch information
GalMunGral authored Nov 3, 2023
1 parent 0714037 commit 8ab4281
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
32 changes: 29 additions & 3 deletions src/components/Explore/LeftSidebar/StationList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import React, { FC, ReactNode, useContext, useEffect, useRef } from 'react';
import React, { FC, ReactNode, useContext, useEffect, useMemo, useRef } from 'react';
import Box from '@mui/material/Box';

import { Button, Stack, Typography } from '@mui/material';
import { DataActionDispatcherContext, DataStateContext } from '@app/store/contexts';
import { theme } from '@app/theme';
import { requestScrollIntoView } from '@app/utils/scrollIntoView';
import { ArrowBackOutlined } from '@mui/icons-material';
import { ArrowBackOutlined, CloseOutlined } from '@mui/icons-material';
import RegionCard from './RegionCard';
import RegionIcon from './RegionIcon';
import StationCard from './StationCard';
Expand All @@ -32,7 +32,12 @@ const Scroll: FC<{ children: ReactNode }> = ({ children }) => {

const StationsList = () => {
const dataActionDispatcher = useContext(DataActionDispatcherContext);
const { filteredStations, selectedFaoArea } = useContext(DataStateContext);
const { filteredStations, selectedFaoArea, allStationsList } = useContext(DataStateContext);

const filteredStationCount = useMemo(
() => filteredStations.reduce((cnt, group) => cnt + group.stations.length, 0),
[filteredStations]
);

const selectedGroup = filteredStations.find((g) => g.faoArea.code === selectedFaoArea?.code) ?? null;

Expand Down Expand Up @@ -177,6 +182,27 @@ const StationsList = () => {
<RegionCard key={group.faoArea.code} stationGroup={group} />
))}
</Scroll>
{filteredStationCount < allStationsList.length ? (
<Button
variant="explore-text"
sx={{
margin: '4px',
position: 'absolute',
left: 0,
bottom: 0,
color: theme.palette.explore.secondary
}}
onClick={() => {
dataActionDispatcher({
type: 'updateFilteredStations',
stations: allStationsList
});
}}
startIcon={<CloseOutlined />}
>
Clear Filter
</Button>
) : null}
</Stack>
)}
</Box>
Expand Down
10 changes: 7 additions & 3 deletions src/components/Explore/RightSidebar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { Box, Button, Stack, Typography } from '@mui/material';
import React, { FC, useCallback, useState } from 'react';
import FilterListIcon from '@mui/icons-material/FilterList';
import { KeyboardDoubleArrowLeftOutlined, KeyboardDoubleArrowRightOutlined, LayersOutlined } from '@mui/icons-material';
import {
KeyboardDoubleArrowLeftOutlined,
KeyboardDoubleArrowRightOutlined,
LayersOutlined,
SearchOutlined
} from '@mui/icons-material';
import { theme } from '@app/theme';
import SearchPanel from './Search/SearchPanel';
import LayerControl from './Layer/LayerControl';
Expand Down Expand Up @@ -48,7 +52,7 @@ const RightSidebar: FC = () => {
textTransform: 'none'
}}
>
<FilterListIcon />
<SearchOutlined />
{expanded ? <Typography ml="12px">Filter</Typography> : null}
</Button>
<Button
Expand Down

0 comments on commit 8ab4281

Please sign in to comment.