From aa1e68142b05cc4d9d8e96c93072a952f65aa511 Mon Sep 17 00:00:00 2001 From: Stefan Probst Date: Tue, 6 Feb 2024 11:54:29 +0100 Subject: [PATCH] style: improve map popup layout --- components/data-map-view.vue | 23 +++++++++++++++++------ components/geo-map-popup.client.vue | 29 ++++++++++++++++++----------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/components/data-map-view.vue b/components/data-map-view.vue index f6105c64..2ce64082 100644 --- a/components/data-map-view.vue +++ b/components/data-map-view.vue @@ -80,7 +80,7 @@ function onLayerClick(features: Array - -
- {{ entity.properties.title }} - - {{ t('DataMapView.go-to-details-page') }} + +
+ {{ entity.properties.title }} + + {{ t("DataMapView.go-to-details-page") }}
diff --git a/components/geo-map-popup.client.vue b/components/geo-map-popup.client.vue index bcc90dc0..7d8356f9 100644 --- a/components/geo-map-popup.client.vue +++ b/components/geo-map-popup.client.vue @@ -3,43 +3,50 @@ import { assert } from "@acdh-oeaw/lib"; import { Popup } from "maplibre-gl"; const props = defineProps<{ - coordinates: [number, number] + coordinates: [number, number]; }>(); const emit = defineEmits<{ - (event: 'close'): void -}>() + (event: "close"): void; +}>(); const { map } = useGeoMap(); const elementRef = ref(null); interface Context { - popup: Popup | null + popup: Popup | null; } const context: Context = { - popup: null + popup: null, }; onMounted(async () => { - await nextTick() + await nextTick(); assert(elementRef.value != null); assert(map != null); - const popup = new Popup({ closeButton: false }) + const popup = new Popup({ closeButton: false, maxWidth: "256px" }) .setLngLat(props.coordinates) .setDOMContent(elementRef.value) .addTo(map); - popup.once("close", () => emit("close")) + popup.once("close", () => { + emit("close"); + }); context.popup = popup; }); -watch(() => props.coordinates, (coordinates) => { - context.popup?.setLngLat(coordinates) -}) +watch( + () => { + return props.coordinates; + }, + (coordinates) => { + context.popup?.setLngLat(coordinates); + }, +); onScopeDispose(() => { context.popup?.remove();