Skip to content

Commit 62b1288

Browse files
committed
address map controls review
1 parent 7d14133 commit 62b1288

3 files changed

Lines changed: 14 additions & 19 deletions

File tree

src/features/map/components/GeocodingSearch.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ import { css, styled } from "next-yak";
1414
import type { GeocodingFeature, Position } from "@maptiler/client";
1515

1616
import { theme } from "@/styles/theme.yak";
17-
import { useGeocodingSearch } from "../hooks/useGeocodingSearch";
17+
import {
18+
MAP_GEOCODING_MIN_QUERY_LENGTH,
19+
useGeocodingSearch,
20+
} from "../hooks/useGeocodingSearch";
1821

1922
export type GeocodingSearchHandle = {
2023
blur: () => void;
@@ -259,7 +262,8 @@ const GeocodingSearch = forwardRef<GeocodingSearchHandle, GeocodingSearchProps>(
259262
countryCode,
260263
proximity,
261264
});
262-
const hasSearchableQuery = query.trim().length >= 3;
265+
const hasSearchableQuery =
266+
query.trim().length >= MAP_GEOCODING_MIN_QUERY_LENGTH;
263267
const showResults =
264268
hasSearchableQuery && (variant === "palette" || isFocused);
265269
const showNoResults =

src/features/map/components/MapControls.tsx

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,14 @@ const controlButtonStyles = css`
8080
}
8181
`;
8282

83-
const Cluster = styled.div`
84-
position: absolute;
85-
right: 0.75rem;
86-
top: 0.75rem;
87-
z-index: 2;
88-
display: flex;
89-
flex-direction: column;
90-
gap: 0.375rem;
91-
pointer-events: auto;
92-
`;
93-
94-
const ZoomCluster = styled.div`
83+
const ControlAnchor = styled.div<{ $gap?: boolean }>`
9584
position: absolute;
9685
right: 0.75rem;
9786
top: 0.75rem;
9887
z-index: 2;
9988
display: flex;
10089
flex-direction: column;
90+
gap: ${({ $gap }) => ($gap ? "0.375rem" : 0)};
10191
pointer-events: auto;
10292
`;
10393

@@ -139,14 +129,14 @@ export function MapZoomControls({
139129
zoomOutLabel,
140130
}: MapZoomControlsProps) {
141131
return (
142-
<ZoomCluster>
132+
<ControlAnchor>
143133
<ZoomControlGroup
144134
onZoomIn={onZoomIn}
145135
onZoomOut={onZoomOut}
146136
zoomInLabel={zoomInLabel}
147137
zoomOutLabel={zoomOutLabel}
148138
/>
149-
</ZoomCluster>
139+
</ControlAnchor>
150140
);
151141
}
152142

@@ -192,7 +182,7 @@ export default function MapControls({
192182
zoomOutLabel,
193183
}: MapControlClusterProps) {
194184
return (
195-
<Cluster>
185+
<ControlAnchor $gap>
196186
{onSearch && searchLabel ? (
197187
<ControlButton
198188
type="button"
@@ -223,6 +213,6 @@ export default function MapControls({
223213
zoomInLabel={zoomInLabel}
224214
zoomOutLabel={zoomOutLabel}
225215
/>
226-
</Cluster>
216+
</ControlAnchor>
227217
);
228218
}

src/features/map/hooks/useGeocodingSearch.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const MAP_GEOCODING_TYPES: GeocodingPlaceType[] = [
1616
"municipal_district",
1717
"municipality",
1818
];
19+
export const MAP_GEOCODING_MIN_QUERY_LENGTH = 3;
1920

2021
type GeocodingSearchStatus = "idle" | "loading" | "success" | "error";
2122

@@ -34,7 +35,7 @@ export function useGeocodingSearch({
3435
countryCode,
3536
proximity,
3637
enabled = true,
37-
minLength = 3,
38+
minLength = MAP_GEOCODING_MIN_QUERY_LENGTH,
3839
debounceMs = 250,
3940
limit = 5,
4041
}: UseGeocodingSearchOptions) {

0 commit comments

Comments
 (0)