forked from MapComplete/MapComplete
chore: refactoring, linting, removing obsolete files
This commit is contained in:
parent
b7a4930583
commit
2bc2a6cddf
54 changed files with 125 additions and 457 deletions
|
|
@ -16,7 +16,6 @@
|
|||
import { ariaLabelStore } from "../../Utils/ariaLabel"
|
||||
import type { SpecialVisualizationState } from "../SpecialVisualization"
|
||||
import Center from "../../assets/svg/Center.svelte"
|
||||
import Tr from "./Tr.svelte"
|
||||
|
||||
export let state: SpecialVisualizationState
|
||||
export let feature: Feature
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
<script lang="ts">
|
||||
import { createEventDispatcher } from "svelte"
|
||||
import { ariaLabel } from "../../Utils/ariaLabel"
|
||||
import Translations from "../i18n/Translations"
|
||||
import { XCircleIcon } from "@babeard/svelte-heroicons/solid"
|
||||
import { CloseButton } from "flowbite-svelte"
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { Utils } from "../../Utils"
|
||||
import BaseUIElement from "../BaseUIElement"
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
|
|
@ -56,7 +57,6 @@ export default class Img extends BaseUIElement {
|
|||
}
|
||||
|
||||
protected InnerConstructElement(): HTMLElement {
|
||||
const self = this
|
||||
if (this._rawSvg) {
|
||||
const e = document.createElement("div")
|
||||
e.innerHTML = this._src
|
||||
|
|
@ -69,12 +69,12 @@ export default class Img extends BaseUIElement {
|
|||
el.style.opacity = "1"
|
||||
}
|
||||
el.onerror = () => {
|
||||
if (self._options?.fallbackImage) {
|
||||
if (el.src === self._options.fallbackImage) {
|
||||
if (this._options?.fallbackImage) {
|
||||
if (el.src === this._options.fallbackImage) {
|
||||
// Sigh... nothing to be done anymore
|
||||
return
|
||||
}
|
||||
el.src = self._options.fallbackImage
|
||||
el.src = this._options.fallbackImage
|
||||
}
|
||||
}
|
||||
return el
|
||||
|
|
|
|||
|
|
@ -1,8 +1,5 @@
|
|||
import BaseUIElement from "../BaseUIElement"
|
||||
import { Store } from "../../Logic/UIEventSource"
|
||||
import { UIElement } from "../UIElement"
|
||||
import SvelteUIElement from "./SvelteUIElement"
|
||||
import SubtleLink from "./SubtleLink.svelte"
|
||||
import Translations from "../i18n/Translations"
|
||||
import Combine from "./Combine"
|
||||
import Img from "./Img"
|
||||
|
|
@ -13,44 +10,24 @@ import Img from "./Img"
|
|||
export class SubtleButton extends UIElement {
|
||||
private readonly imageUrl: string | BaseUIElement
|
||||
private readonly message: string | BaseUIElement
|
||||
private readonly options: {
|
||||
url?: string | Store<string>
|
||||
newTab?: boolean
|
||||
imgSize?: string
|
||||
extraClasses?: string
|
||||
}
|
||||
|
||||
constructor(
|
||||
imageUrl: string | BaseUIElement,
|
||||
message: string | BaseUIElement,
|
||||
options: {
|
||||
url?: string | Store<string>
|
||||
newTab?: boolean
|
||||
imgSize?: "h-11 w-11" | string
|
||||
extraClasses?: string
|
||||
} = {}
|
||||
message: string | BaseUIElement
|
||||
) {
|
||||
super()
|
||||
this.imageUrl = imageUrl
|
||||
this.message = message
|
||||
this.options = options
|
||||
}
|
||||
|
||||
protected InnerRender(): string | BaseUIElement {
|
||||
if (this.options.url !== undefined) {
|
||||
return new SvelteUIElement(SubtleLink, {
|
||||
href: this.options.url,
|
||||
newTab: this.options.newTab,
|
||||
})
|
||||
}
|
||||
|
||||
const classes = "button"
|
||||
const message = Translations.W(this.message)?.SetClass(
|
||||
"block overflow-ellipsis no-images flex-shrink"
|
||||
)
|
||||
let img
|
||||
const imgClasses =
|
||||
"block justify-center flex-none mr-4 " + (this.options?.imgSize ?? "h-11 w-11")
|
||||
"block justify-center flex-none mr-4 h-11 w-11"
|
||||
if ((this.imageUrl ?? "") === "") {
|
||||
img = undefined
|
||||
} else if (typeof this.imageUrl === "string") {
|
||||
|
|
|
|||
|
|
@ -1,50 +0,0 @@
|
|||
<script lang="ts">
|
||||
import { onMount } from "svelte"
|
||||
import { twJoin, twMerge } from "tailwind-merge"
|
||||
import BaseUIElement from "../BaseUIElement"
|
||||
import Img from "./Img"
|
||||
|
||||
export let imageUrl: string | BaseUIElement = undefined
|
||||
export let href: string
|
||||
export let newTab = false
|
||||
export let options: {
|
||||
imgSize?: string
|
||||
extraClasses?: string
|
||||
} = {}
|
||||
|
||||
let imgElem: HTMLElement
|
||||
let imgClasses = twJoin("block justify-center shrink-0 mr-4", options?.imgSize ?? "h-11 w-11")
|
||||
|
||||
onMount(() => {
|
||||
// Image
|
||||
if (imgElem && imageUrl) {
|
||||
let img: BaseUIElement
|
||||
|
||||
if ((imageUrl ?? "") === "") {
|
||||
img = undefined
|
||||
} else if (typeof imageUrl !== "string") {
|
||||
img = imageUrl?.SetClass(imgClasses)
|
||||
}
|
||||
if (img) imgElem.replaceWith(img.ConstructElement())
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<a
|
||||
class={twMerge(options.extraClasses, "button text-ellipsis")}
|
||||
{href}
|
||||
target={newTab ? "_blank" : undefined}
|
||||
rel={newTab ? "noopener" : undefined}
|
||||
>
|
||||
<slot name="image">
|
||||
{#if imageUrl !== undefined}
|
||||
{#if typeof imageUrl === "string"}
|
||||
<Img src={imageUrl} class={imgClasses} />
|
||||
{:else}
|
||||
<template bind:this={imgElem} />
|
||||
{/if}
|
||||
{/if}
|
||||
</slot>
|
||||
|
||||
<slot />
|
||||
</a>
|
||||
Loading…
Add table
Add a link
Reference in a new issue