Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/6266 map layout and zoom #271

Merged
merged 3 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/map/mapbox/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,4 @@ const ReactMap = ({

export default ReactMap;

export { styles, MapDefaultConfig as MapDefault };
export { styles };
4 changes: 3 additions & 1 deletion src/components/map/mapbox/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
export const MapDefaultConfig = {
// Magic number, try and error by experience
DEBOUNCE_BEFORE_EVENT_FIRE: 700,
ZOOM: 4,
ZOOM: 3.5,
ZOOM_TABLET: 3,
ZOOM_MOBILE: 2,
MIN_ZOOM: 1,
MAX_ZOOM: 12,
PROJECTION: "equirectangular",
Expand Down
2 changes: 1 addition & 1 deletion src/components/map/mapbox/controls/ToggleControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const ToggleButton: React.FC<ToggleControlProps> = ({
}}
>
{showFullMap ? (
<CloseFullscreenIcon fontSize="medium" />
<CloseFullscreenIcon fontSize="small" />
) : (
<FullscreenIcon fontSize="medium" />
)}
Expand Down
5 changes: 3 additions & 2 deletions src/components/map/mapbox/controls/menu/BaseMapSwitcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
MenuClickedEvent,
} from "./Definition";
import PublicIcon from "@mui/icons-material/Public";
import { styles as mapStyles, MapDefault } from "../../Map";
import { styles as mapStyles } from "../../Map";
import {
Box,
Typography,
Expand All @@ -24,6 +24,7 @@ import { eventEmitter, leftPadding, rightPadding } from "./MenuControl";
import grey from "../../../../common/colors/grey";
import blue from "../../../../common/colors/blue";
import { borderRadius, fontSize } from "../../../../../styles/constants";
import { MapDefaultConfig } from "../../constants";

interface BaseMapSwitcherProps extends ControlProps {
// Static layer to be added to the switch
Expand All @@ -43,7 +44,7 @@ const BaseMapSwitcher: React.FC<BaseMapSwitcherProps> = ({
onEvent,
}) => {
const [currentStyle, setCurrentStyle] = useState<string>(
mapStyles[MapDefault.DEFAULT_STYLE].id
mapStyles[MapDefaultConfig.DEFAULT_STYLE].id
);
// Must init the map so that it will not throw error indicate uncontrol to control component
const [overlaysChecked, setOverlaysChecked] = useState<Map<string, boolean>>(
Expand Down
3 changes: 3 additions & 0 deletions src/components/search/Searchbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ const Searchbar: FC<SearchbarProps> = ({ setShouldExpandSearchbar }) => {
activeButton={activeButton}
handleClickButton={handleClickButton}
shouldExpandAllButtons={isMobile ? false : shouldExpandAllButtons}
shouldShrinkAllButtons={
isMobile && location.pathname === pageDefault.search
}
sx={{ pr: gap.md }}
/>
</Paper>
Expand Down
34 changes: 22 additions & 12 deletions src/components/search/SearchbarButtonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface SearchbarButtonGroupProps {
activeButton: SearchbarButtonNames;
handleClickButton: (button: SearchbarButtonNames) => void;
shouldExpandAllButtons: boolean;
shouldShrinkAllButtons?: boolean;
sx?: SxProps;
}

Expand Down Expand Up @@ -70,6 +71,7 @@ const SearchbarButtonGroup: FC<SearchbarButtonGroupProps> = ({
activeButton,
handleClickButton,
shouldExpandAllButtons = false,
shouldShrinkAllButtons = false,
sx,
}) => {
const componentParams: ParameterState = getComponentState(store.getState());
Expand Down Expand Up @@ -125,9 +127,11 @@ const SearchbarButtonGroup: FC<SearchbarButtonGroupProps> = ({
dotBadge
onClick={() => handleClickButton(SearchbarButtonNames.Date)}
showText={
shouldExpandAllButtons
? true
: activeButton === SearchbarButtonNames.Date
shouldShrinkAllButtons
? false
: shouldExpandAllButtons
? true
: activeButton === SearchbarButtonNames.Date
}
data-testid="date-range-button"
/>
Expand All @@ -138,9 +142,11 @@ const SearchbarButtonGroup: FC<SearchbarButtonGroupProps> = ({
dotBadge
onClick={() => handleClickButton(SearchbarButtonNames.Location)}
showText={
shouldExpandAllButtons
? true
: activeButton === SearchbarButtonNames.Location
shouldShrinkAllButtons
? false
: shouldExpandAllButtons
? true
: activeButton === SearchbarButtonNames.Location
}
data-testid="location-button"
/>
Expand All @@ -150,9 +156,11 @@ const SearchbarButtonGroup: FC<SearchbarButtonGroupProps> = ({
badgeContent={filterCount}
onClick={() => handleClickButton(SearchbarButtonNames.Filter)}
showText={
shouldExpandAllButtons
? true
: activeButton === SearchbarButtonNames.Filter
shouldShrinkAllButtons
? false
: shouldExpandAllButtons
? true
: activeButton === SearchbarButtonNames.Filter
}
data-testid="filtersBtn"
/>
Expand All @@ -161,9 +169,11 @@ const SearchbarButtonGroup: FC<SearchbarButtonGroupProps> = ({
text={capitalizeFirstLetter(SearchbarButtonNames.Search)}
onClick={handleSearchClick}
showText={
shouldExpandAllButtons
? true
: activeButton === SearchbarButtonNames.Search
shouldShrinkAllButtons
? false
: shouldExpandAllButtons
? true
: activeButton === SearchbarButtonNames.Search
}
buttonSx={{
color: "#fff",
Expand Down
25 changes: 18 additions & 7 deletions src/pages/search-page/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ import {
SEARCH_PAGE_CONTENT_CONTAINER_HEIGHT_ABOVE_LAPTOP,
SEARCH_PAGE_CONTENT_CONTAINER_HEIGHT_UNDER_LAPTOP,
SEARCH_PAGE_MAP_CONTAINER_HEIGHT_FULL_LIST,
SEARCH_PAGE_MAP_CONTAINER_HEIGHT_FULL_MAP,
SEARCH_PAGE_MAP_CONTAINER_HEIGHT_ABOVE_LAPTOP,
SEARCH_PAGE_MAP_CONTAINER_HEIGHT_UNDER_LAPTOP,
SEARCH_PAGE_MAP_CONTAINER_HEIGHT_FULL_MAP_TABLET,
SEARCH_PAGE_MAP_CONTAINER_HEIGHT_FULL_MAP_MOBILE,
} from "./constants";
import useBreakpoint from "../../hooks/useBreakpoint";
import { MapDefaultConfig } from "../../components/map/mapbox/constants";

const REFERER = "SEARCH_PAGE";

Expand All @@ -69,7 +71,7 @@ const SearchPage = () => {
const location = useLocation();
const navigate = useNavigate();
const dispatch = useAppDispatch();
const { isUnderLaptop } = useBreakpoint();
const { isUnderLaptop, isMobile } = useBreakpoint();

// Layers contains record with uuid and bbox only
const [layers, setLayers] = useState<Array<OGCCollection>>([]);
Expand All @@ -88,7 +90,13 @@ const SearchPage = () => {
//State to store the uuid of a selected dataset
const [selectedUuids, setSelectedUuids] = useState<Array<string>>([]);
const [bbox, setBbox] = useState<LngLatBounds | undefined>(undefined);
const [zoom, setZoom] = useState<number | undefined>(undefined);
const [zoom, setZoom] = useState<number | undefined>(
isUnderLaptop
? isMobile
? MapDefaultConfig.ZOOM_MOBILE
: MapDefaultConfig.ZOOM_TABLET
: undefined
);
const [loadingThreadCount, setLoadingThreadCount] = useState<number>(0);

const startOneLoadingThread = useCallback(() => {
Expand Down Expand Up @@ -356,6 +364,7 @@ const SearchPage = () => {
// TODO: Optimize call if possible, this happens when navigate from page
// to this page.
useEffect(() => handleNavigation(), [handleNavigation]);

useEffect(() => {
const bookmarkSelected = async (event: BookmarkEvent) => {
if (event.action === EVENT_BOOKMARK.EXPAND) {
Expand All @@ -381,7 +390,7 @@ const SearchPage = () => {
height: {
xs:
selectedLayout === SearchResultLayoutEnum.FULL_MAP
? SEARCH_PAGE_CONTENT_CONTAINER_HEIGHT_ABOVE_LAPTOP
? "auto"
: SEARCH_PAGE_CONTENT_CONTAINER_HEIGHT_UNDER_LAPTOP,
md: SEARCH_PAGE_CONTENT_CONTAINER_HEIGHT_ABOVE_LAPTOP,
},
Expand All @@ -390,15 +399,15 @@ const SearchPage = () => {
padding: padding.small,
bgcolor: color.blue.light,
}}
gap={2}
gap={selectedLayout === SearchResultLayoutEnum.FULL_MAP ? 0 : 2}
>
<Box
sx={{
flex: isUnderLaptop ? 1 : "none",
width:
selectedLayout === SearchResultLayoutEnum.FULL_LIST
? "100%"
: "none",
: "auto",
height:
selectedLayout === SearchResultLayoutEnum.FULL_MAP ? 0 : "auto",
}}
Expand All @@ -423,7 +432,9 @@ const SearchPage = () => {
? selectedLayout === SearchResultLayoutEnum.FULL_LIST
? SEARCH_PAGE_MAP_CONTAINER_HEIGHT_FULL_LIST
: selectedLayout === SearchResultLayoutEnum.FULL_MAP
? SEARCH_PAGE_MAP_CONTAINER_HEIGHT_FULL_MAP
? isMobile
? SEARCH_PAGE_MAP_CONTAINER_HEIGHT_FULL_MAP_MOBILE
: SEARCH_PAGE_MAP_CONTAINER_HEIGHT_FULL_MAP_TABLET
: SEARCH_PAGE_MAP_CONTAINER_HEIGHT_UNDER_LAPTOP
: SEARCH_PAGE_MAP_CONTAINER_HEIGHT_ABOVE_LAPTOP,
}}
Expand Down
5 changes: 3 additions & 2 deletions src/pages/search-page/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ export const SEARCH_PAGE_CONTENT_CONTAINER_HEIGHT_ABOVE_LAPTOP = "85vh";
export const SEARCH_PAGE_CONTENT_CONTAINER_HEIGHT_UNDER_LAPTOP = 1500;

export const SEARCH_PAGE_MAP_CONTAINER_HEIGHT_ABOVE_LAPTOP = "100%";
export const SEARCH_PAGE_MAP_CONTAINER_HEIGHT_UNDER_LAPTOP = 400;
export const SEARCH_PAGE_MAP_CONTAINER_HEIGHT_UNDER_LAPTOP = "65vh";

export const SEARCH_PAGE_MAP_CONTAINER_HEIGHT_FULL_MAP = "80vh";
export const SEARCH_PAGE_MAP_CONTAINER_HEIGHT_FULL_MAP_TABLET = "80vh";
export const SEARCH_PAGE_MAP_CONTAINER_HEIGHT_FULL_MAP_MOBILE = "70vh";
export const SEARCH_PAGE_MAP_CONTAINER_HEIGHT_FULL_LIST = 0;

export const SEARCH_PAGE_RESULT_SECTION_CONTAINER_MIN_WIDTH = 500;
Loading