2023-12-05 18:35:18 +01:00
|
|
|
<script lang="ts">
|
2023-12-19 22:08:00 +01:00
|
|
|
/**
|
|
|
|
* Shows an image with attribution
|
|
|
|
*/
|
|
|
|
import ImageAttribution from "./ImageAttribution.svelte"
|
|
|
|
import type { ProvidedImage } from "../../Logic/ImageProviders/ImageProvider"
|
|
|
|
import { Mapillary } from "../../Logic/ImageProviders/Mapillary"
|
2023-12-19 23:02:02 +01:00
|
|
|
import { UIEventSource } from "../../Logic/UIEventSource"
|
2024-08-28 15:07:18 +02:00
|
|
|
import { MagnifyingGlassPlusIcon } from "@babeard/svelte-heroicons/outline"
|
2023-12-05 18:35:18 +01:00
|
|
|
|
2024-02-26 02:24:46 +01:00
|
|
|
export let image: Partial<ProvidedImage>
|
2023-12-19 22:08:00 +01:00
|
|
|
let fallbackImage: string = undefined
|
|
|
|
if (image.provider === Mapillary.singleton) {
|
|
|
|
fallbackImage = "./assets/svg/blocked.svg"
|
|
|
|
}
|
2023-12-05 18:35:18 +01:00
|
|
|
|
2023-12-19 22:08:00 +01:00
|
|
|
let imgEl: HTMLImageElement
|
|
|
|
export let imgClass: string = undefined
|
2023-12-19 23:02:02 +01:00
|
|
|
export let previewedImage: UIEventSource<ProvidedImage> = undefined
|
2024-08-28 15:07:18 +02:00
|
|
|
export let attributionFormat: "minimal" | "medium" | "large" = "medium"
|
|
|
|
let canZoom = previewedImage !== undefined // We check if there is a SOURCE, not if there is data in it!
|
2023-12-05 18:35:18 +01:00
|
|
|
</script>
|
|
|
|
|
2024-01-16 04:21:46 +01:00
|
|
|
<div class="relative shrink-0">
|
2024-08-28 15:07:18 +02:00
|
|
|
<div class="relative w-fit">
|
|
|
|
<img
|
|
|
|
bind:this={imgEl}
|
|
|
|
class={imgClass ?? ""}
|
|
|
|
class:cursor-zoom-in={previewedImage !== undefined}
|
|
|
|
on:click={() => {
|
2023-12-21 01:46:18 +01:00
|
|
|
previewedImage?.setData(image)
|
|
|
|
}}
|
2024-08-28 15:07:18 +02:00
|
|
|
on:error={() => {
|
2023-12-21 01:46:18 +01:00
|
|
|
if (fallbackImage) {
|
|
|
|
imgEl.src = fallbackImage
|
|
|
|
}
|
|
|
|
}}
|
2024-08-28 15:07:18 +02:00
|
|
|
src={image.url}
|
|
|
|
/>
|
2023-12-05 18:35:18 +01:00
|
|
|
|
2024-08-28 15:07:18 +02:00
|
|
|
{#if canZoom}
|
|
|
|
<div class="absolute right-0 top-0 bg-black-transparent rounded-bl-full">
|
|
|
|
<MagnifyingGlassPlusIcon class="w-8 h-8 pl-3 pb-3 cursor-zoom-in" color="white" />
|
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
</div>
|
2023-12-05 18:35:18 +01:00
|
|
|
<div class="absolute bottom-0 left-0">
|
2024-08-28 15:07:18 +02:00
|
|
|
<ImageAttribution {image} {attributionFormat} />
|
2023-12-05 18:35:18 +01:00
|
|
|
</div>
|
|
|
|
</div>
|