diff --git a/src/UI/Base/Img.ts b/src/UI/Base/Img.ts index 96b0b7ac08..fcc413ec0b 100644 --- a/src/UI/Base/Img.ts +++ b/src/UI/Base/Img.ts @@ -1,11 +1,15 @@ import { Utils } from "../../Utils" import BaseUIElement from "../BaseUIElement" - +/** + * @deprecated +*/ export default class Img extends BaseUIElement { private readonly _src: string private readonly _rawSvg: boolean private readonly _options: { readonly fallbackImage?: string } + /** @deprecated + */ constructor( src: string, rawSvg = false, diff --git a/src/UI/Base/Tr.svelte b/src/UI/Base/Tr.svelte index 4a6ebae06e..3d172f98f0 100644 --- a/src/UI/Base/Tr.svelte +++ b/src/UI/Base/Tr.svelte @@ -20,10 +20,17 @@ {#if $txt} + {#if cls} {@html Utils.purify($txt)} + {:else} + + {@html Utils.purify($txt)} + + + {/if} {/if} diff --git a/src/UI/BigComponents/ShareScreen.svelte b/src/UI/BigComponents/ShareScreen.svelte index b7081c1e7b..87cae1ccdf 100644 --- a/src/UI/BigComponents/ShareScreen.svelte +++ b/src/UI/BigComponents/ShareScreen.svelte @@ -11,12 +11,8 @@ import Tr from "../Base/Tr.svelte" import Translations from "../i18n/Translations" import { Utils } from "../../Utils" - import { DocumentDuplicateIcon } from "@rgossiaux/svelte-heroicons/outline" - import ToSvelte from "../Base/ToSvelte.svelte" - import Img from "../Base/Img" import Qr from "../../Utils/Qr" import AccordionSingle from "../Flowbite/AccordionSingle.svelte" - import Share from "@babeard/svelte-heroicons/solid/Share" import Constants from "../../Models/Constants" import Copyable from "../Base/Copyable.svelte" @@ -127,9 +123,7 @@
- new Img(new Qr(linkToShare).toImageElement(125)).SetStyle("width: 125px")} - /> +
diff --git a/src/UI/Popup/QrCode.svelte b/src/UI/Popup/QrCode.svelte new file mode 100644 index 0000000000..ad0ecb2a7f --- /dev/null +++ b/src/UI/Popup/QrCode.svelte @@ -0,0 +1,46 @@ + + +{#if $id.startsWith("node/-")} + + +{:else} + toggleSize()} src={new Qr($url).toImageElement($size)} style={`width: ${$size}px; height: ${$size}px`} /> +{/if} diff --git a/src/UI/SpecialVisualizations.ts b/src/UI/SpecialVisualizations.ts index 6573665ac8..0d01cef9c1 100644 --- a/src/UI/SpecialVisualizations.ts +++ b/src/UI/SpecialVisualizations.ts @@ -100,6 +100,8 @@ import { CombinedFetcher } from "../Logic/Web/NearbyImagesSearch" import { And } from "../Logic/Tags/And" import CloseNoteButton from "./Popup/Notes/CloseNoteButton.svelte" import PendingChangesIndicator from "./BigComponents/PendingChangesIndicator.svelte" +import Loading from "./Base/Loading" +import QrCode from "./Popup/QrCode.svelte" class NearbyImageVis implements SpecialVisualization { // Class must be in SpecialVisualisations due to weird cyclical import that breaks the tests @@ -1686,47 +1688,12 @@ export default class SpecialVisualizations { docs: "Generates a QR-code to share the selected object", constr( state: SpecialVisualizationState, - tagSource: UIEventSource>, + tags: UIEventSource>, argument: string[], feature: Feature - ): BaseUIElement { - const smallSize = 100 - const bigSize = 200 - const size = new UIEventSource(smallSize) - return new VariableUiElement( - tagSource - .map((tags) => tags.id) - .map( - (id) => { - if (id.startsWith("node/-")) { - // Not yet uploaded - return undefined - } - const [lon, lat] = GeoOperations.centerpointCoordinates(feature) - const includeLayout = window.location.pathname - .split("/") - .at(-1) - .startsWith("theme") - const layout = includeLayout - ? "layout=" + state.layout.id + "&" - : "" - const url = - `${window.location.protocol}//${window.location.host}${window.location.pathname}?${layout}lat=${lat}&lon=${lon}&z=15` + - `#${id}` - return new Img(new Qr(url).toImageElement(size.data)).SetStyle( - `width: ${size.data}px` - ) - }, - [size] - ) - ).onClick(() => { - if (size.data !== bigSize) { - size.setData(bigSize) - } else { - size.setData(smallSize) - } - }) - }, + ): SvelteUIElement { + return new SvelteUIElement(QrCode , {state, tags, feature} ) + } }, { funcName: "direction_absolute",