generated from acdh-oeaw/template-app-nuxt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement a first version of the detail view, which displays all data of the work + implement an sheet overlay for places with a map display.
- Loading branch information
1 parent
88de27e
commit 1a98913
Showing
28 changed files
with
1,657 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<script lang="ts" setup> | ||
import { EyeIcon, MapPinIcon } from "lucide-vue-next"; | ||
const router = useRouter(); | ||
const props = defineProps<{ | ||
place: { | ||
id: number | undefined; | ||
name: string | undefined; | ||
longitude: number | null | undefined; | ||
latitude: number | null | undefined; | ||
description: string | undefined; | ||
}; | ||
relation: string; | ||
}>(); | ||
function setPlaceQuery(id: number | undefined) { | ||
if (id != null) { | ||
void router.push({ | ||
query: { place: id }, | ||
}); | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<Sheet> | ||
<SheetTrigger as-child @click="setPlaceQuery(props.place.id)"> | ||
<EyeIcon :size="16" class="text-frisch-orange" /> | ||
</SheetTrigger> | ||
<SheetContent> | ||
<div class="flex items-center gap-1 text-sm"> | ||
<MapPinIcon :size="16" /> | ||
{{ props.relation }} | ||
</div> | ||
<SheetTitle class="pb-2">{{ props.place.name }}</SheetTitle> | ||
<SheetDescription> | ||
<div v-if="props.place.longitude != null && props.place.latitude != null"> | ||
<Map :longitude="props.place.longitude" :latitude="props.place.latitude" /> | ||
</div> | ||
<div class="py-2 text-base font-semibold text-black">Beschreibung</div> | ||
<div v-if="props.place.description !== ''"> | ||
{{ props.place.description }} | ||
</div> | ||
<div v-else>Keine Beschreibung vorhanden.</div> | ||
</SheetDescription> | ||
</SheetContent> | ||
</Sheet> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
<script lang="ts" setup> | ||
import "maplibre-gl/dist/maplibre-gl.css"; | ||
import { assert } from "@acdh-oeaw/lib"; | ||
import { FullscreenControl, Map as GeoMap, NavigationControl, ScaleControl } from "maplibre-gl"; | ||
import { type GeoMapContext, geoMapContextKey } from "@/components/map.context"; | ||
const props = defineProps<{ | ||
longitude: number; | ||
latitude: number; | ||
}>(); | ||
const elementRef = ref<HTMLElement | null>(null); | ||
const context: GeoMapContext = { | ||
map: null, | ||
}; | ||
onMounted(create); | ||
onScopeDispose(dispose); | ||
async function create() { | ||
await nextTick(); | ||
assert(elementRef.value != null); | ||
const map = new GeoMap({ | ||
center: [props.longitude, props.latitude], | ||
container: elementRef.value, | ||
maxZoom: 24, | ||
minZoom: 1, | ||
pitch: initialViewState.pitch, | ||
style: "https://basemaps.cartocdn.com/gl/positron-gl-style/style.json", // style URL, | ||
zoom: initialViewState.zoom, | ||
}); | ||
context.map = map; | ||
map.on("load", init); | ||
} | ||
function init() { | ||
assert(context.map != null); | ||
const map = context.map; | ||
// | ||
const nav = new NavigationControl({}); | ||
map.addControl(nav, "top-left"); | ||
// | ||
const fullscreen = new FullscreenControl({}); | ||
map.addControl(fullscreen, "top-right"); | ||
// | ||
const scale = new ScaleControl({}); | ||
map.addControl(scale, "bottom-left"); | ||
// | ||
const placeId = "place-data"; | ||
map.addSource("place-data", { | ||
type: "geojson", | ||
data: { | ||
type: "FeatureCollection", | ||
features: [ | ||
{ | ||
type: "Feature", | ||
properties: {}, | ||
geometry: { | ||
type: "Point", | ||
coordinates: [props.longitude, props.latitude], | ||
}, | ||
}, | ||
], | ||
}, | ||
}); | ||
// | ||
map.addLayer({ | ||
id: "points", | ||
type: "circle", | ||
source: placeId, | ||
filter: ["==", "$type", "Point"], | ||
paint: { | ||
"circle-color": "rgb(236 81 0)", | ||
"circle-radius": 6, | ||
}, | ||
}); | ||
} | ||
function dispose() { | ||
context.map?.remove(); | ||
} | ||
defineExpose(context); | ||
provide(geoMapContextKey, context); | ||
</script> | ||
|
||
<template> | ||
<div class="relative grid h-80 text-black"> | ||
<div ref="elementRef" data-geo-map="true" /> | ||
<slot /> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import type { Map as GeoMap } from "maplibre-gl"; | ||
|
||
export interface GeoMapContext { | ||
map: GeoMap | null; | ||
} | ||
|
||
export const geoMapContextKey = Symbol("geo-map-context"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<script setup lang="ts"> | ||
import { | ||
DialogRoot, | ||
type DialogRootEmits, | ||
type DialogRootProps, | ||
useForwardPropsEmits, | ||
} from "radix-vue"; | ||
const props = defineProps<DialogRootProps>(); | ||
const emits = defineEmits<DialogRootEmits>(); | ||
const forwarded = useForwardPropsEmits(props, emits); | ||
</script> | ||
|
||
<template> | ||
<DialogRoot v-bind="forwarded"> | ||
<slot /> | ||
</DialogRoot> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<script setup lang="ts"> | ||
import { DialogClose, type DialogCloseProps } from "radix-vue"; | ||
const props = defineProps<DialogCloseProps>(); | ||
</script> | ||
|
||
<template> | ||
<DialogClose v-bind="props"> | ||
<slot /> | ||
</DialogClose> | ||
</template> |
Oops, something went wrong.