mapcomplete/UI/Image/AttributedImage.ts

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

30 lines
1.1 KiB
TypeScript
Raw Normal View History

import Combine from "../Base/Combine"
import Attribution from "./Attribution"
import Img from "../Base/Img"
2022-06-13 00:51:53 +02:00
import ImageProvider from "../../Logic/ImageProviders/ImageProvider"
import BaseUIElement from "../BaseUIElement"
2021-10-01 02:57:41 +02:00
import { Mapillary } from "../../Logic/ImageProviders/Mapillary"
2022-06-13 00:51:53 +02:00
import { UIEventSource } from "../../Logic/UIEventSource"
export class AttributedImage extends Combine {
constructor(imageInfo: { url: string; provider?: ImageProvider; date?: Date }) {
let img: BaseUIElement
2021-10-01 02:57:41 +02:00
img = new Img(imageInfo.url, false, {
2021-11-07 16:34:51 +01:00
fallbackImage:
imageInfo.provider === Mapillary.singleton ? "./assets/svg/blocked.svg" : undefined,
2021-10-01 02:57:41 +02:00
})
2022-09-08 21:40:48 +02:00
let attr: BaseUIElement = undefined
if (imageInfo.provider !== undefined) {
2022-06-13 00:51:53 +02:00
attr = new Attribution(
UIEventSource.FromPromise(imageInfo.provider?.DownloadAttribution(imageInfo.url)),
imageInfo.provider?.SourceIcon(),
imageInfo.date
)
}
super([img, attr])
this.SetClass("block relative h-full")
}
}