Refactoring: more cleanup of Svg.ts, remove a few old, unused classes
This commit is contained in:
parent
a50620a8ba
commit
114b72f6f7
7 changed files with 30 additions and 20 deletions
|
@ -80,6 +80,7 @@ function genImages(dryrun = false) {
|
||||||
"ring",
|
"ring",
|
||||||
"robot",
|
"robot",
|
||||||
"SocialImageForeground",
|
"SocialImageForeground",
|
||||||
|
"speech_bubble",
|
||||||
"speech_bubble_black_outline",
|
"speech_bubble_black_outline",
|
||||||
"square",
|
"square",
|
||||||
"star",
|
"star",
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import ImageProvider, { ProvidedImage } from "./ImageProvider"
|
import ImageProvider, { ProvidedImage } from "./ImageProvider"
|
||||||
import BaseUIElement from "../../UI/BaseUIElement"
|
import BaseUIElement from "../../UI/BaseUIElement"
|
||||||
import Svg from "../../Svg"
|
|
||||||
import { Utils } from "../../Utils"
|
import { Utils } from "../../Utils"
|
||||||
import { LicenseInfo } from "./LicenseInfo"
|
import { LicenseInfo } from "./LicenseInfo"
|
||||||
import Wikimedia from "../Web/Wikimedia"
|
import Wikimedia from "../Web/Wikimedia"
|
||||||
|
|
|
@ -24,11 +24,12 @@ import Table from "../../UI/Base/Table"
|
||||||
import FilterConfigJson from "./Json/FilterConfigJson"
|
import FilterConfigJson from "./Json/FilterConfigJson"
|
||||||
import { Overpass } from "../../Logic/Osm/Overpass"
|
import { Overpass } from "../../Logic/Osm/Overpass"
|
||||||
import { FixedUiElement } from "../../UI/Base/FixedUiElement"
|
import { FixedUiElement } from "../../UI/Base/FixedUiElement"
|
||||||
import Svg from "../../Svg"
|
|
||||||
import { ImmutableStore } from "../../Logic/UIEventSource"
|
import { ImmutableStore } from "../../Logic/UIEventSource"
|
||||||
import { OsmTags } from "../OsmFeature"
|
import { OsmTags } from "../OsmFeature"
|
||||||
import Constants from "../Constants"
|
import Constants from "../Constants"
|
||||||
import { QuestionableTagRenderingConfigJson } from "./Json/QuestionableTagRenderingConfigJson"
|
import { QuestionableTagRenderingConfigJson } from "./Json/QuestionableTagRenderingConfigJson"
|
||||||
|
import SvelteUIElement from "../../UI/Base/SvelteUIElement"
|
||||||
|
import Statistics from "../../assets/svg/Statistics.svelte"
|
||||||
|
|
||||||
export default class LayerConfig extends WithContextLoader {
|
export default class LayerConfig extends WithContextLoader {
|
||||||
public static readonly syncSelectionAllowed = ["no", "local", "theme-only", "global"] as const
|
public static readonly syncSelectionAllowed = ["no", "local", "theme-only", "global"] as const
|
||||||
|
@ -466,7 +467,7 @@ export default class LayerConfig extends WithContextLoader {
|
||||||
new Link(
|
new Link(
|
||||||
Utils.runningFromConsole
|
Utils.runningFromConsole
|
||||||
? "<img src='https://mapcomplete.org/assets/svg/statistics.svg' height='18px'>"
|
? "<img src='https://mapcomplete.org/assets/svg/statistics.svg' height='18px'>"
|
||||||
: Svg.statistics_svg().SetClass("w-4 h-4 mr-2"),
|
: new SvelteUIElement(Statistics, {class: "w-4 h-4 mr-2"}),
|
||||||
"https://taginfo.openstreetmap.org/keys/" + values.key + "#values",
|
"https://taginfo.openstreetmap.org/keys/" + values.key + "#values",
|
||||||
true
|
true
|
||||||
),
|
),
|
||||||
|
|
|
@ -2,13 +2,14 @@
|
||||||
import ToSvelte from "./ToSvelte.svelte"
|
import ToSvelte from "./ToSvelte.svelte"
|
||||||
import Svg from "../../Svg"
|
import Svg from "../../Svg"
|
||||||
import { twMerge } from "tailwind-merge"
|
import { twMerge } from "tailwind-merge"
|
||||||
|
import Loading from "../../assets/svg/Loading.svelte"
|
||||||
|
|
||||||
export let cls: string = undefined
|
export let cls: string = undefined
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class={twMerge("flex p-1 pl-2", cls)}>
|
<div class={twMerge("flex p-1 pl-2", cls)}>
|
||||||
<div class="min-w-6 h-6 w-6 shrink-0 animate-spin self-center">
|
<div class="min-w-6 h-6 w-6 shrink-0 animate-spin self-center">
|
||||||
<ToSvelte construct={Svg.loading_svg()} />
|
<Loading/>
|
||||||
</div>
|
</div>
|
||||||
<div class="ml-2">
|
<div class="ml-2">
|
||||||
<slot />
|
<slot />
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import BaseUIElement from "../BaseUIElement"
|
import BaseUIElement from "../BaseUIElement"
|
||||||
import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
import { Store, UIEventSource } from "../../Logic/UIEventSource"
|
||||||
import { UIElement } from "../UIElement"
|
import { UIElement } from "../UIElement"
|
||||||
import { VariableUiElement } from "./VariableUIElement"
|
|
||||||
import Lazy from "./Lazy"
|
|
||||||
import Loading from "./Loading"
|
|
||||||
import SvelteUIElement from "./SvelteUIElement"
|
import SvelteUIElement from "./SvelteUIElement"
|
||||||
import SubtleLink from "./SubtleLink.svelte"
|
import SubtleLink from "./SubtleLink.svelte"
|
||||||
import Translations from "../i18n/Translations"
|
import Translations from "../i18n/Translations"
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import Combine from "../../Base/Combine"
|
import Combine from "../../Base/Combine"
|
||||||
import BaseUIElement from "../../BaseUIElement"
|
import BaseUIElement from "../../BaseUIElement"
|
||||||
import Svg from "../../../Svg"
|
|
||||||
import Link from "../../Base/Link"
|
import Link from "../../Base/Link"
|
||||||
import { FixedUiElement } from "../../Base/FixedUiElement"
|
import { FixedUiElement } from "../../Base/FixedUiElement"
|
||||||
import Translations from "../../i18n/Translations"
|
import Translations from "../../i18n/Translations"
|
||||||
|
@ -11,6 +10,10 @@ import { Stores, UIEventSource } from "../../../Logic/UIEventSource"
|
||||||
import { OsmConnection } from "../../../Logic/Osm/OsmConnection"
|
import { OsmConnection } from "../../../Logic/Osm/OsmConnection"
|
||||||
import { VariableUiElement } from "../../Base/VariableUIElement"
|
import { VariableUiElement } from "../../Base/VariableUIElement"
|
||||||
import { SpecialVisualizationState } from "../../SpecialVisualization"
|
import { SpecialVisualizationState } from "../../SpecialVisualization"
|
||||||
|
import SvelteUIElement from "../../Base/SvelteUIElement"
|
||||||
|
import Note from "../../../assets/svg/Note.svelte"
|
||||||
|
import Resolved from "../../../assets/svg/Resolved.svelte"
|
||||||
|
import Speech_bubble from "../../../assets/svg/Speech_bubble.svelte"
|
||||||
|
|
||||||
export default class NoteCommentElement extends Combine {
|
export default class NoteCommentElement extends Combine {
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -32,11 +35,11 @@ export default class NoteCommentElement extends Combine {
|
||||||
|
|
||||||
let actionIcon: BaseUIElement
|
let actionIcon: BaseUIElement
|
||||||
if (comment.action === "opened" || comment.action === "reopened") {
|
if (comment.action === "opened" || comment.action === "reopened") {
|
||||||
actionIcon = Svg.note_svg()
|
actionIcon = new SvelteUIElement(Note)
|
||||||
} else if (comment.action === "closed") {
|
} else if (comment.action === "closed") {
|
||||||
actionIcon = Svg.resolved_svg()
|
actionIcon = new SvelteUIElement(Resolved)
|
||||||
} else {
|
} else {
|
||||||
actionIcon = Svg.speech_bubble_svg()
|
actionIcon = new SvelteUIElement(Speech_bubble)
|
||||||
}
|
}
|
||||||
|
|
||||||
let user: BaseUIElement
|
let user: BaseUIElement
|
||||||
|
|
26
src/index.ts
26
src/index.ts
|
@ -5,11 +5,12 @@ import ThemeViewGUI from "./UI/ThemeViewGUI.svelte"
|
||||||
import { FixedUiElement } from "./UI/Base/FixedUiElement"
|
import { FixedUiElement } from "./UI/Base/FixedUiElement"
|
||||||
import Combine from "./UI/Base/Combine"
|
import Combine from "./UI/Base/Combine"
|
||||||
import { SubtleButton } from "./UI/Base/SubtleButton"
|
import { SubtleButton } from "./UI/Base/SubtleButton"
|
||||||
import Svg from "./Svg"
|
|
||||||
import { Utils } from "./Utils"
|
import { Utils } from "./Utils"
|
||||||
|
import Download from "./assets/svg/Download.svelte"
|
||||||
|
|
||||||
function webgl_support() {
|
function webgl_support() {
|
||||||
try {
|
try {
|
||||||
var canvas = document.createElement("canvas")
|
const canvas = document.createElement("canvas")
|
||||||
return (
|
return (
|
||||||
!!window.WebGLRenderingContext &&
|
!!window.WebGLRenderingContext &&
|
||||||
(canvas.getContext("webgl") || canvas.getContext("experimental-webgl"))
|
(canvas.getContext("webgl") || canvas.getContext("experimental-webgl"))
|
||||||
|
@ -18,6 +19,7 @@ function webgl_support() {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
try {
|
try {
|
||||||
if (!webgl_support()) {
|
if (!webgl_support()) {
|
||||||
|
@ -31,16 +33,22 @@ try {
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error("Error while initializing: ", err, err.stack)
|
console.error("Error while initializing: ", err, err.stack)
|
||||||
|
const customDefinition = DetermineLayout.getCustomDefinition()
|
||||||
new Combine([
|
new Combine([
|
||||||
new FixedUiElement(err).SetClass("block alert"),
|
new FixedUiElement(err).SetClass("block alert"),
|
||||||
|
|
||||||
new SubtleButton(Svg.download_svg(), "Download the raw file").onClick(() =>
|
customDefinition?.length > 0
|
||||||
Utils.offerContentsAsDownloadableFile(
|
? new SubtleButton(
|
||||||
DetermineLayout.getCustomDefinition(),
|
new SvelteUIElement(Download),
|
||||||
"mapcomplete-theme.json",
|
"Download the raw file"
|
||||||
{ mimetype: "application/json" }
|
).onClick(() =>
|
||||||
)
|
Utils.offerContentsAsDownloadableFile(
|
||||||
),
|
DetermineLayout.getCustomDefinition(),
|
||||||
|
"mapcomplete-theme.json",
|
||||||
|
{ mimetype: "application/json" }
|
||||||
|
)
|
||||||
|
)
|
||||||
|
: undefined,
|
||||||
]).AttachTo("maindiv")
|
]).AttachTo("maindiv")
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
Loading…
Reference in a new issue