Improve typing, improve layout of MapillaryLink-button

This commit is contained in:
Pieter Vander Vennet 2023-01-06 03:43:24 +01:00
parent 9b0b87c878
commit 297aabf2b7

View file

@ -1,14 +1,13 @@
import { VariableUiElement } from "../Base/VariableUIElement" import { VariableUiElement } from "../Base/VariableUIElement"
import { UIEventSource } from "../../Logic/UIEventSource" import { Store } from "../../Logic/UIEventSource"
import Loc from "../../Models/Loc" import Loc from "../../Models/Loc"
import Translations from "../i18n/Translations" import Translations from "../i18n/Translations"
import { SubtleButton } from "../Base/SubtleButton" import { SubtleButton } from "../Base/SubtleButton"
import Svg from "../../Svg" import Svg from "../../Svg"
import Combine from "../Base/Combine" import Combine from "../Base/Combine"
import Title from "../Base/Title"
export class MapillaryLink extends VariableUiElement { export class MapillaryLink extends VariableUiElement {
constructor(state: { locationControl: UIEventSource<Loc> }, iconStyle?: string) { constructor(state: { readonly locationControl: Store<Loc> }, iconStyle?: string) {
const t = Translations.t.general.attribution const t = Translations.t.general.attribution
super( super(
state.locationControl.map((location) => { state.locationControl.map((location) => {
@ -17,12 +16,14 @@ export class MapillaryLink extends VariableUiElement {
}&lng=${location?.lon ?? 0}&z=${Math.max((location?.zoom ?? 2) - 1, 1)}` }&lng=${location?.lon ?? 0}&z=${Math.max((location?.zoom ?? 2) - 1, 1)}`
return new SubtleButton( return new SubtleButton(
Svg.mapillary_black_ui().SetStyle(iconStyle), Svg.mapillary_black_ui().SetStyle(iconStyle),
new Combine([t.openMapillary.SetClass("font-bold"), t.mapillaryHelp]), new Combine([t.openMapillary.SetClass("font-bold"), t.mapillaryHelp]).SetClass(
"flex flex-col link-no-underline"
),
{ {
url: mapillaryLink, url: mapillaryLink,
newTab: true, newTab: true,
} }
).SetClass("flex flex-col link-no-underline") )
}) })
) )
} }