Add button to close road info overlay (fixes #275)

This commit is contained in:
Paul Bienkowski 2022-09-12 17:25:49 +02:00
parent 61890c6a5c
commit 0b5fe015d9
4 changed files with 20 additions and 1 deletions

View file

@ -8,6 +8,7 @@ import {
Icon, Icon,
Table, Table,
Message, Message,
Button,
} from "semantic-ui-react"; } from "semantic-ui-react";
import { Layer, Source } from "react-map-gl"; import { Layer, Source } from "react-map-gl";
import { of, from, concat } from "rxjs"; import { of, from, concat } from "rxjs";
@ -140,9 +141,11 @@ function HistogramChart({ bins, counts, zone }) {
export default function RoadInfo({ export default function RoadInfo({
clickLocation, clickLocation,
hasFilters, hasFilters,
onClose,
}: { }: {
clickLocation: Location | null; clickLocation: Location | null;
hasFilters: boolean; hasFilters: boolean;
onClose: () => void;
}) { }) {
const { t } = useTranslation(); const { t } = useTranslation();
const [direction, setDirection] = useState("forwards"); const [direction, setDirection] = useState("forwards");
@ -201,6 +204,15 @@ export default function RoadInfo({
{loading {loading
? "..." ? "..."
: info?.road.name || t("MapPage.roadInfo.unnamedWay")} : info?.road.name || t("MapPage.roadInfo.unnamedWay")}
<Button
style={{ float: "right" }}
onClick={onClose}
title={t("MapPage.roadInfo.closeTooltip")}
size="small"
icon="close"
basic
/>
</Header> </Header>
{hasFilters && ( {hasFilters && (

View file

@ -134,6 +134,9 @@ function MapPage({ login }) {
}, },
[setClickLocation] [setClickLocation]
); );
const onCloseRoadInfo = useCallback(() => {
setClickLocation(null);
}, [setClickLocation]);
const [layerSidebar, setLayerSidebar] = useState(true); const [layerSidebar, setLayerSidebar] = useState(true);
@ -240,7 +243,9 @@ function MapPage({ login }) {
))} ))}
</Source> </Source>
<RoadInfo {...{ clickLocation, hasFilters }} /> <RoadInfo
{...{ clickLocation, hasFilters, onClose: onCloseRoadInfo }}
/>
</Map> </Map>
</div> </div>
</div> </div>

View file

@ -175,6 +175,7 @@ MapPage:
roadInfo: roadInfo:
closeTooltip: Infobox schließen
unnamedWay: Unbenannter Weg unnamedWay: Unbenannter Weg
oneway: Einbahnstraße oneway: Einbahnstraße
direction: Richtung direction: Richtung

View file

@ -179,6 +179,7 @@ MapPage:
after: After after: After
roadInfo: roadInfo:
closeTooltip: Close overlay
unnamedWay: Unnamed way unnamedWay: Unnamed way
oneway: oneway oneway: oneway
direction: Direction direction: Direction