Skip to content

Commit

Permalink
💄 add styled scroll bar and improve search page UI
Browse files Browse the repository at this point in the history
  • Loading branch information
NekoLyn committed Aug 27, 2024
1 parent 8dff9b6 commit 30abcc7
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 116 deletions.
3 changes: 2 additions & 1 deletion src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
// React import is not required in React 17 or later
import { RouterProvider } from "react-router-dom";

import Fallback from "./pages/Fallback";
import { ThemeProvider } from "@mui/material/styles";
import AppTheme from "./utils/AppTheme";
import AppRouter from "./utils/AppRouter";
import { CssBaseline } from "@mui/material";
import Scrollbar from "./components/common/ScrollBar";

const app = () => {
return (
<div>
<ThemeProvider theme={AppTheme}>
<CssBaseline />
<Scrollbar />
<RouterProvider router={AppRouter} fallbackElement={<Fallback />} />
</ThemeProvider>
</div>
Expand Down
35 changes: 35 additions & 0 deletions src/components/common/ScrollBar.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { GlobalStyles } from "@mui/material";
import { color } from "../../styles/constants";

// TODO: firefox browser does not support webkit, need to find a way to fix
const Scrollbar = () => (
<GlobalStyles
styles={{
"*::-webkit-scrollbar": {
width: "8px",
borderRadius: "4px",
},
"*::-webkit-scrollbar-button": {
display: "none",
},
"*::-webkit-scrollbar-thumb": {
borderRadius: "4px",
backgroundColor: color.blue.dark,
minHeight: "24px",
border: "none",
cursor: "pointer",
},
"*::-webkit-scrollbar-corner": {
backgroundColor: color.blue.xLight,
},
"*::-webkit-scrollbar-track": {
backgroundColor: color.blue.xLight,
border: "none",
borderRadius: "4px",
cursor: "pointer",
},
}}
/>
);

export default Scrollbar;
12 changes: 5 additions & 7 deletions src/components/common/buttons/ActionButtonPaper.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Paper } from "@mui/material";
import { margin } from "../../../styles/constants";
import { borderRadius, margin } from "../../../styles/constants";
import React from "react";

interface StyledActionButtonPaperProps {}
Expand All @@ -9,15 +9,13 @@ const ActionButtonPaper = ({
}: React.PropsWithChildren<StyledActionButtonPaperProps>) => {
return (
<Paper
component="form"
variant="outlined"
elevation={0}
sx={{
paddingLeft: "5px",
marginLeft: margin.md,
display: "flex",
alignItems: "center",
maxHeight: "40px",
width: { md: "100px" },
justifyContent: "center",
width: "100%",
borderRadius: borderRadius.medium,
}}
>
{children}
Expand Down
17 changes: 7 additions & 10 deletions src/components/common/filters/ResultPanelIconFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
import { Grid, Stack } from "@mui/material";
import { Stack } from "@mui/material";
import TimeRangeIcon from "../../icon/TimeRangeIcon";
import SpatialIcon from "../../icon/SpatialIcon";
import DimensionsIcon from "../../icon/Dimensions";
import { padding } from "../../../styles/constants";

const ResultPanelIconFilter = () => {
return (
<Grid container sx={{ pl: 2 }}>
<Grid item xs={12}>
<Stack direction="column" spacing={2}>
<TimeRangeIcon />
<SpatialIcon />
<DimensionsIcon />
</Stack>
</Grid>
</Grid>
<Stack direction="column" spacing={2} paddingTop={padding.large}>
<TimeRangeIcon />
<SpatialIcon />
<DimensionsIcon />
</Stack>
);
};

Expand Down
29 changes: 10 additions & 19 deletions src/components/common/filters/ResultPanelSimpleFilter.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import {
FormControl,
Grid,
IconButton,
InputBase,
MenuItem,
Paper,
Select,
styled,
SxProps,
Theme,
Expand All @@ -16,12 +12,7 @@ import MapListToggleButton, {
} from "../buttons/MapListToggleButton";
import SortButton, { SortButtonProps } from "../buttons/SortButton";
import { FC } from "react";

const SlimSelect = styled(InputBase)(() => ({
"& .MuiInputBase-input": {
border: "none",
},
}));
import { borderRadius, fontSize } from "../../../styles/constants";

interface ResultPanelSimpleFilterProps
extends MapListToggleButtonProps,
Expand All @@ -39,27 +30,27 @@ const ResultPanelSimpleFilter: FC<ResultPanelSimpleFilterProps> = ({
onChangeSorting,
}) => {
return (
<Grid sx={sx} padding={1} container justifyContent="center">
<Grid item xs={6} sx={{ pb: 1 }}>
<Grid sx={sx} container justifyContent="center" spacing={1}>
<Grid item md={6} xs={12}>
<Paper
variant="outlined"
component="form"
elevation={0}
sx={{
p: "2px 4px",
display: "flex",
justifyContent: "center",
alignItems: "center",
width: { md: "250px" },
height: "100%",
borderRadius: borderRadius.medium,
}}
>
<Typography>
<Typography fontSize={fontSize.info} padding={0}>
Showing 1-{count} of {total} results
</Typography>
</Paper>
</Grid>
<Grid item xs={3} sx={{ pb: 1 }}>
<Grid item md={3} xs={6}>
<SortButton onChangeSorting={onChangeSorting} />
</Grid>
<Grid item xs={3} sx={{ pb: 1 }}>
<Grid item md={3} xs={6}>
<MapListToggleButton onChangeLayout={onChangeLayout} />
</Grid>
</Grid>
Expand Down
33 changes: 19 additions & 14 deletions src/pages/detail-page/subpages/side-cards/TimePeriodCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ const TimePeriodCard: FC = () => {
<RoundCard
sxProps={{ border: `${border.xs} ${theme.palette.success.main}` }}
>
<DataUsageIcon
sx={{ fontSize: "16px", paddingRight: padding.medium }}
color="success"
/>
<Typography padding={0} color={theme.palette.success.main}>
<DataUsageIcon sx={{ fontSize: "16px" }} color="success" />
<Typography
padding={0}
paddingLeft={padding.small}
color={theme.palette.success.main}
>
On Going
</Typography>
</RoundCard>
Expand All @@ -90,11 +91,12 @@ const TimePeriodCard: FC = () => {
backgroundColor: color.blue.extraLightSemiTransparent,
}}
>
<DoneAllIcon
sx={{ fontSize: "18px", paddingRight: padding.medium }}
color="primary"
/>
<Typography padding={0} color={color.blue.dark}>
<DoneAllIcon sx={{ fontSize: "18px" }} color="primary" />
<Typography
padding={0}
paddingLeft={padding.small}
color={color.blue.dark}
>
Completed
</Typography>
</RoundCard>
Expand All @@ -111,11 +113,13 @@ const TimePeriodCard: FC = () => {
backgroundColor: color.blue.extraLightSemiTransparent,
}}
>
<Typography padding={0}>{startDate}</Typography>
<Typography padding={0} paddingRight={padding.small}>
{startDate}
</Typography>
<KeyboardDoubleArrowRightIcon
sx={{
fontSize: "18px",
paddingLeft: padding.small,

color: color.gray.light,
}}
/>
Expand All @@ -132,11 +136,12 @@ const TimePeriodCard: FC = () => {
<KeyboardDoubleArrowRightIcon
sx={{
fontSize: "18px",
paddingRight: padding.small,
color: color.gray.light,
}}
/>
<Typography padding={0}>{endDate}</Typography>
<Typography padding={0} paddingLeft={padding.small}>
{endDate}
</Typography>
</RoundCard>
)}
</Stack>
Expand Down
118 changes: 55 additions & 63 deletions src/pages/search-page/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "../../components/common/store/searchReducer";
import Layout from "../../components/layout/layout";
import { useLocation, useNavigate } from "react-router-dom";
import { useDispatch, useSelector } from "react-redux";
import { useDispatch } from "react-redux";
import {
formatToUrlParam,
ParameterState,
Expand Down Expand Up @@ -40,7 +40,7 @@ import { LngLatBoundsLike, MapboxEvent as MapEvent } from "mapbox-gl";
import ResultSection from "./subpages/ResultSection";
import ResultPanelIconFilter from "../../components/common/filters/ResultPanelIconFilter";
import MapSection from "./subpages/MapSection";
import { color, margin } from "../../styles/constants";
import { color } from "../../styles/constants";
import ComplexTextSearch from "../../components/search/ComplexTextSearch";
import { SearchResultLayoutEnum } from "../../components/common/buttons/MapListToggleButton";
import { bboxPolygon } from "@turf/turf";
Expand All @@ -50,6 +50,8 @@ import {
} from "../../components/common/store/OGCCollectionDefinitions";
import { SortResultEnum } from "../../components/common/buttons/SortButton";

const SEARCH_BAR_HEIGHT = 56;

const SearchPage = () => {
const location = useLocation();
const navigate = useNavigate();
Expand Down Expand Up @@ -250,80 +252,70 @@ const SearchPage = () => {

return (
<Layout>
<Grid
container
spacing={2}
sx={{
// backgroundImage: "url(/bg_search_results.png)",
// backgroundSize: "cover",
bgcolor: color.blue.light,
marginTop: margin.sm,
}}
<Box
display="flex"
flexDirection="row"
justifyContent="center"
bgcolor={color.blue.light}
gap={2}
padding={2}
>
<Grid item xs={12}>
<Grid container>
<Grid item xs={1} />
<Grid item xs={10}>
<ComplexTextSearch />
</Grid>
<Grid item xs={1} />
</Grid>
</Grid>
<Grid item xs={1}>
<Box paddingTop={`${SEARCH_BAR_HEIGHT}px`}>
<ResultPanelIconFilter />
</Grid>
<Grid item xs={11}>
{
// Must group the ResultSection and MapSection together so that show hide works
}
<Box
sx={{
display: "flex",
flexDirection: "row",
justifyContent: "space-between",
alignItems: "stretch",
width: "100%",
}}
>
{visibility === SearchResultLayoutEnum.VISIBLE && (
</Box>
<Grid container flex={1} gap={2}>
<Grid item xs={12} height={`${SEARCH_BAR_HEIGHT}px`}>
<ComplexTextSearch />
</Grid>
<Grid item xs={12}>
<Box
sx={{
display: "flex",
flexDirection: "row",
justifyContent: "space-between",
alignItems: "stretch",
width: "100%",
}}
gap={2}
>
{visibility === SearchResultLayoutEnum.VISIBLE && (
<Box
sx={{
flex: 1,
}}
>
<ResultSection
sx={{
height: "80vh",
}}
onVisibilityChanged={onVisibilityChanged}
onClickCard={handleNavigateToDetailPage}
onChangeSorting={onChangeSorting}
datasetSelected={datasetsSelected}
/>
</Box>
)}
<Box
sx={{
flex: 1,
flex: visibility === SearchResultLayoutEnum.VISIBLE ? 2 : 1,
}}
>
<ResultSection
<MapSection
sx={{
height: "80vh",
}}
onVisibilityChanged={onVisibilityChanged}
onClickCard={handleNavigateToDetailPage}
onChangeSorting={onChangeSorting}
datasetSelected={datasetsSelected}
collections={layers}
bbox={bbox}
showFullMap={visibility === SearchResultLayoutEnum.INVISIBLE}
onMapZoomOrMove={onMapZoomOrMove}
onToggleClicked={onToggleDisplay}
onDatasetSelected={onDatasetSelected}
/>
</Box>
)}
<Box
sx={{
flex: visibility === SearchResultLayoutEnum.VISIBLE ? 2 : 1,
paddingLeft: 2,
paddingRight: 2,
}}
>
<MapSection
sx={{
height: "80vh",
}}
collections={layers}
bbox={bbox}
showFullMap={visibility === SearchResultLayoutEnum.INVISIBLE}
onMapZoomOrMove={onMapZoomOrMove}
onToggleClicked={onToggleDisplay}
onDatasetSelected={onDatasetSelected}
/>
</Box>
</Box>
</Grid>
</Grid>
</Grid>
</Box>
</Layout>
);
};
Expand Down
Loading

0 comments on commit 30abcc7

Please sign in to comment.