Refactoring: more removal of old-style SVG bundling

This commit is contained in:
Pieter Vander Vennet 2023-11-19 16:20:47 +01:00
parent 6c75553f3f
commit e4aedc9696
7 changed files with 70 additions and 49 deletions

View file

@ -4,6 +4,30 @@ function genImages(dryrun = false) {
console.log("Generating images") console.log("Generating images")
// These images are not referenced via 'Svg.ts' anymore and can be ignored // These images are not referenced via 'Svg.ts' anymore and can be ignored
const blacklist: string[] = [ const blacklist: string[] = [
"add",
"addSmall",
"brick_wall_square",
"clock",
"community",
"copyright",
"cross",
"cross_bottom_right",
"crosshair_locked",
"delete_not_allowed",
"direction_gradient",
"direction_stroke",
"duplicate",
"elevator",
"elevator_wheelchair",
"liberapay",
"length_crosshair",
"speech_bubble_black_outline",
"square",
"star_half",
"star_outline",
"star",
"osm_logo_us",
"SocialImageForeground", "SocialImageForeground",
"wikipedia", "wikipedia",
"Upload", "Upload",

View file

@ -1,21 +1,21 @@
<script lang="ts"> <script lang="ts">
import Translations from "../i18n/Translations" import Translations from "../i18n/Translations";
import Svg from "../../Svg" import Tr from "../Base/Tr.svelte";
import Tr from "../Base/Tr.svelte" import NextButton from "../Base/NextButton.svelte";
import NextButton from "../Base/NextButton.svelte" import Geosearch from "./Geosearch.svelte";
import Geosearch from "./Geosearch.svelte" import ThemeViewState from "../../Models/ThemeViewState";
import ToSvelte from "../Base/ToSvelte.svelte" import { UIEventSource } from "../../Logic/UIEventSource";
import ThemeViewState from "../../Models/ThemeViewState" import { SearchIcon } from "@rgossiaux/svelte-heroicons/solid";
import { UIEventSource } from "../../Logic/UIEventSource" import { twJoin } from "tailwind-merge";
import { SearchIcon } from "@rgossiaux/svelte-heroicons/solid" import { Utils } from "../../Utils";
import { twJoin } from "tailwind-merge" import type { GeolocationPermissionState } from "../../Logic/State/GeoLocationState";
import { Utils } from "../../Utils" import { GeoLocationState } from "../../Logic/State/GeoLocationState";
import type { GeolocationPermissionState } from "../../Logic/State/GeoLocationState" import If from "../Base/If.svelte";
import { GeoLocationState } from "../../Logic/State/GeoLocationState" import { ExclamationTriangleIcon } from "@babeard/svelte-heroicons/mini";
import If from "../Base/If.svelte" import type { Readable } from "svelte/store";
import { ExclamationTriangleIcon } from "@babeard/svelte-heroicons/mini"
import type { Readable } from "svelte/store"
import Add from "../../assets/svg/Add.svelte"; import Add from "../../assets/svg/Add.svelte";
import Location_refused from "../../assets/svg/Location_refused.svelte";
import Crosshair from "../../assets/svg/Crosshair.svelte";
/** /**
* The theme introduction panel * The theme introduction panel
@ -71,7 +71,7 @@
<If condition={state.featureSwitches.featureSwitchGeolocation}> <If condition={state.featureSwitches.featureSwitchGeolocation}>
{#if $currentGPSLocation !== undefined || $geopermission === "prompt"} {#if $currentGPSLocation !== undefined || $geopermission === "prompt"}
<button class="flex w-full items-center gap-x-2" on:click={jumpToCurrentLocation}> <button class="flex w-full items-center gap-x-2" on:click={jumpToCurrentLocation}>
<ToSvelte construct={Svg.crosshair_svg().SetClass("w-8 h-8")} /> <Crosshair class="w-8 h-8"/>
<Tr t={Translations.t.general.openTheMapAtGeolocation} /> <Tr t={Translations.t.general.openTheMapAtGeolocation} />
</button> </button>
<!-- No geolocation granted - we don't show the button --> <!-- No geolocation granted - we don't show the button -->
@ -81,25 +81,17 @@
on:click={jumpToCurrentLocation} on:click={jumpToCurrentLocation}
> >
<!-- Even though disabled, when clicking we request the location again in case the contributor dismissed the location popup --> <!-- Even though disabled, when clicking we request the location again in case the contributor dismissed the location popup -->
<ToSvelte <Crosshair class="w-8 h-8" style="animation: 3s linear 0s infinite normal none running spin;" />
construct={Svg.crosshair_svg()
.SetClass("w-8 h-8")
.SetStyle("animation: 3s linear 0s infinite normal none running spin;")}
/>
<Tr t={Translations.t.general.waitingForGeopermission} /> <Tr t={Translations.t.general.waitingForGeopermission} />
</button> </button>
{:else if $geopermission === "denied"} {:else if $geopermission === "denied"}
<button class="disabled flex w-full items-center gap-x-2"> <button class="disabled flex w-full items-center gap-x-2">
<ToSvelte construct={Svg.location_refused_svg().SetClass("w-8 h-8")} /> <Location_refused class="w-8 h-8"/>
<Tr t={Translations.t.general.geopermissionDenied} /> <Tr t={Translations.t.general.geopermissionDenied} />
</button> </button>
{:else} {:else}
<button class="disabled flex w-full items-center gap-x-2"> <button class="disabled flex w-full items-center gap-x-2">
<ToSvelte <Crosshair class="w-8 h-8" style="animation: 3s linear 0s infinite normal none running spin;" />
construct={Svg.crosshair_svg()
.SetClass("w-8 h-8")
.SetStyle("animation: 3s linear 0s infinite normal none running spin;")}
/>
<Tr t={Translations.t.general.waitingForLocation} /> <Tr t={Translations.t.general.waitingForLocation} />
</button> </button>
{/if} {/if}

View file

@ -6,6 +6,7 @@
import MaplibreMap from "../../Map/MaplibreMap.svelte" import MaplibreMap from "../../Map/MaplibreMap.svelte"
import ToSvelte from "../../Base/ToSvelte.svelte" import ToSvelte from "../../Base/ToSvelte.svelte"
import Svg from "../../../Svg.js" import Svg from "../../../Svg.js"
import Direction_stroke from "../../../assets/svg/Direction_stroke.svelte";
/** /**
* A visualisation to pick a direction on a map background. * A visualisation to pick a direction on a map background.
@ -67,6 +68,6 @@
</div> </div>
<div bind:this={directionElem} class="absolute top-0 left-0 h-full w-full"> <div bind:this={directionElem} class="absolute top-0 left-0 h-full w-full">
<ToSvelte construct={Svg.direction_stroke_svg} /> <Direction_stroke/>
</div> </div>
</div> </div>

View file

@ -85,8 +85,6 @@
<Checkmark {color} /> <Checkmark {color} />
{:else if icon === "help"} {:else if icon === "help"}
<Help {color} /> <Help {color} />
{:else if icon === "clock"}
<Clock {color} />
{:else if icon === "close"} {:else if icon === "close"}
<Close {color} /> <Close {color} />
{:else if icon === "invalid"} {:else if icon === "invalid"}

View file

@ -2,6 +2,9 @@
import ToSvelte from "../Base/ToSvelte.svelte" import ToSvelte from "../Base/ToSvelte.svelte"
import Svg from "../../Svg" import Svg from "../../Svg"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
import Star from "../../assets/svg/Star.svelte";
import Star_half from "../../assets/svg/Star_half.svelte";
import Star_outline from "../../assets/svg/Star_outline.svelte";
export let score: number export let score: number
export let cutoff: number export let cutoff: number
@ -23,10 +26,10 @@
on:mousemove={(e) => dispatch("hover", { score: getScore(e) })} on:mousemove={(e) => dispatch("hover", { score: getScore(e) })}
> >
{#if score >= cutoff} {#if score >= cutoff}
<ToSvelte construct={Svg.star_svg().SetClass(starSize)} /> <Star class={starSize}/>
{:else if score + 10 >= cutoff} {:else if score + 10 >= cutoff}
<ToSvelte construct={Svg.star_half_svg().SetClass(starSize)} /> <Star_half class={starSize}/>
{:else} {:else}
<ToSvelte construct={Svg.star_outline_svg().SetClass(starSize)} /> <Star_outline class={starSize}/>
{/if} {/if}
</div> </div>

View file

@ -2,6 +2,7 @@
import Svg from "../Svg"; import Svg from "../Svg";
import Loading from "./Base/Loading.svelte"; import Loading from "./Base/Loading.svelte";
import ToSvelte from "./Base/ToSvelte.svelte"; import ToSvelte from "./Base/ToSvelte.svelte";
import Community from "../assets/svg/Community.svelte";
</script> </script>
<div> <div>
@ -40,16 +41,16 @@
<div class="flex"> <div class="flex">
<button class="primary"> <button class="primary">
<ToSvelte construct={Svg.community_svg().SetClass("w-6 h-6")} /> <Community class="w-6 h-6" />
Main action Main action
</button> </button>
<button class="primary disabled"> <button class="primary disabled">
<ToSvelte construct={Svg.community_svg().SetClass("w-6 h-6")} /> <Community class="w-6 h-6" />
Main action (disabled) Main action (disabled)
</button> </button>
<button class="small"> <button class="small">
<ToSvelte construct={Svg.community_svg().SetClass("w-6 h-6")} /> <Community class="w-6 h-6" />
Small button Small button
</button> </button>
@ -59,11 +60,11 @@
</div> </div>
<div class="flex"> <div class="flex">
<button> <button>
<ToSvelte construct={Svg.community_svg().SetClass("w-6 h-6")} /> <Community class="w-6 h-6" />
Secondary action Secondary action
</button> </button>
<button class="disabled"> <button class="disabled">
<ToSvelte construct={Svg.community_svg().SetClass("w-6 h-6")} /> <Community class="w-6 h-6" />
Secondary action (disabled) Secondary action (disabled)
</button> </button>
</div> </div>
@ -82,7 +83,7 @@
</label> </label>
<label for="javascript"> <label for="javascript">
<input id="javascript" name="fav_language" type="radio" value="JavaScript" /> <input id="javascript" name="fav_language" type="radio" value="JavaScript" />
<ToSvelte construct={Svg.community_svg().SetClass("w-8 h-8")} /> <Community class="w-8 h-8"/>
JavaScript JavaScript
</label> </label>
</div> </div>
@ -106,26 +107,26 @@
<div class="flex"> <div class="flex">
<button class="primary"> <button class="primary">
<ToSvelte construct={Svg.community_svg().SetClass("w-6 h-6")} /> <Community class="w-6 h-6" />
Main action Main action
</button> </button>
<button class="primary disabled"> <button class="primary disabled">
<ToSvelte construct={Svg.community_svg().SetClass("w-6 h-6")} /> <Community class="w-6 h-6" />
Main action (disabled) Main action (disabled)
</button> </button>
<button class="small"> <button class="small">
<ToSvelte construct={Svg.community_svg().SetClass("w-6 h-6")} /> <Community class="w-6 h-6" />
Small button Small button
</button> </button>
</div> </div>
<div class="flex"> <div class="flex">
<button> <button>
<ToSvelte construct={Svg.community_svg().SetClass("w-6 h-6")} /> <Community class="w-6 h-6" />
Secondary action Secondary action
</button> </button>
<button class="disabled"> <button class="disabled">
<ToSvelte construct={Svg.community_svg().SetClass("w-6 h-6")} /> <Community class="w-6 h-6" />
Secondary action (disabled) Secondary action (disabled)
</button> </button>
</div> </div>

View file

@ -36,7 +36,6 @@
import LevelSelector from "./BigComponents/LevelSelector.svelte"; import LevelSelector from "./BigComponents/LevelSelector.svelte";
import ExtraLinkButton from "./BigComponents/ExtraLinkButton"; import ExtraLinkButton from "./BigComponents/ExtraLinkButton";
import SelectedElementTitle from "./BigComponents/SelectedElementTitle.svelte"; import SelectedElementTitle from "./BigComponents/SelectedElementTitle.svelte";
import Svg from "../Svg";
import ThemeIntroPanel from "./BigComponents/ThemeIntroPanel.svelte"; import ThemeIntroPanel from "./BigComponents/ThemeIntroPanel.svelte";
import type { RasterLayerPolygon } from "../Models/RasterLayers"; import type { RasterLayerPolygon } from "../Models/RasterLayers";
import { AvailableRasterLayers } from "../Models/RasterLayers"; import { AvailableRasterLayers } from "../Models/RasterLayers";
@ -62,6 +61,9 @@
import Filter from "../assets/svg/Filter.svelte"; import Filter from "../assets/svg/Filter.svelte";
import Add from "../assets/svg/Add.svelte"; import Add from "../assets/svg/Add.svelte";
import Statistics from "../assets/svg/Statistics.svelte"; import Statistics from "../assets/svg/Statistics.svelte";
import Community from "../assets/svg/Community.svelte";
import Download from "../assets/svg/Download.svelte";
import Share from "../assets/svg/Share.svelte";
export let state: ThemeViewState; export let state: ThemeViewState;
let layout = state.layout; let layout = state.layout;
@ -371,7 +373,7 @@
<div class="flex" slot="title2"> <div class="flex" slot="title2">
<If condition={state.featureSwitches.featureSwitchEnableExport}> <If condition={state.featureSwitches.featureSwitchEnableExport}>
<ToSvelte construct={Svg.download_svg().SetClass("w-4 h-4")} /> <Download class="w-4 h-4"/>
<Tr t={Translations.t.general.download.title} /> <Tr t={Translations.t.general.download.title} />
</If> </If>
</div> </div>
@ -386,7 +388,7 @@
<ToSvelte construct={() => new CopyrightPanel(state)} slot="content3" /> <ToSvelte construct={() => new CopyrightPanel(state)} slot="content3" />
<div class="flex" slot="title4"> <div class="flex" slot="title4">
<ToSvelte construct={Svg.share_svg().SetClass("w-4 h-4")} /> <Share class="w-4 h-4"/>
<Tr t={Translations.t.general.sharescreen.title} /> <Tr t={Translations.t.general.sharescreen.title} />
</div> </div>
<div class="m-2" slot="content4"> <div class="m-2" slot="content4">
@ -492,7 +494,7 @@
</div> </div>
<div class="flex" slot="title2"> <div class="flex" slot="title2">
<ToSvelte construct={Svg.community_svg().SetClass("w-6 h-6")} /> <Community class="w-6 h-6"/>
<Tr t={Translations.t.communityIndex.title} /> <Tr t={Translations.t.communityIndex.title} />
</div> </div>
<div class="m-2" slot="content2"> <div class="m-2" slot="content2">