Fix: remove 'icons.defaults' from favourite layers, cleanup of various small typing errors

This commit is contained in:
Pieter Vander Vennet 2023-12-08 00:12:21 +01:00
parent 98ca6aa8aa
commit e8569ec540
7 changed files with 37 additions and 26 deletions

View file

@ -1089,14 +1089,14 @@ video {
height: 6rem; height: 6rem;
} }
.h-full {
height: 100%;
}
.h-screen { .h-screen {
height: 100vh; height: 100vh;
} }
.h-full {
height: 100%;
}
.h-32 { .h-32 {
height: 8rem; height: 8rem;
} }
@ -1172,14 +1172,14 @@ video {
height: 10rem; height: 10rem;
} }
.h-80 {
height: 20rem;
}
.h-64 { .h-64 {
height: 16rem; height: 16rem;
} }
.h-80 {
height: 20rem;
}
.max-h-12 { .max-h-12 {
max-height: 3rem; max-height: 3rem;
} }
@ -2989,10 +2989,6 @@ a.link-underline {
padding: 1.5rem; padding: 1.5rem;
} }
.md\:p-4 {
padding: 1rem;
}
.md\:p-3 { .md\:p-3 {
padding: 0.75rem; padding: 0.75rem;
} }

View file

@ -13,7 +13,6 @@ import { TagConfigJson } from "../src/Models/ThemeConfig/Json/TagConfigJson"
import { TagUtils } from "../src/Logic/Tags/TagUtils" import { TagUtils } from "../src/Logic/Tags/TagUtils"
import { TagRenderingConfigJson } from "../src/Models/ThemeConfig/Json/TagRenderingConfigJson" import { TagRenderingConfigJson } from "../src/Models/ThemeConfig/Json/TagRenderingConfigJson"
import { Translatable } from "../src/Models/ThemeConfig/Json/Translatable" import { Translatable } from "../src/Models/ThemeConfig/Json/Translatable"
import Icon from "../src/UI/Map/Icon.svelte"
export class GenerateFavouritesLayer extends Script { export class GenerateFavouritesLayer extends Script {
private readonly layers: LayerConfigJson[] = [] private readonly layers: LayerConfigJson[] = []
@ -53,6 +52,7 @@ export class GenerateFavouritesLayer extends Script {
return sortedMappings return sortedMappings
} }
private addTagRenderings(proto: LayerConfigJson) { private addTagRenderings(proto: LayerConfigJson) {
const blacklistedIds = new Set([ const blacklistedIds = new Set([
"images", "images",
@ -164,7 +164,11 @@ export class GenerateFavouritesLayer extends Script {
] ]
} }
private addTitleIcons(proto: LayerConfigJson) { /**
* const titleIcons = new GenerateFavouritesLayer().generateTitleIcons()
* JSON.stringify(titleIcons).indexOf("icons.defaults") // => -1
* */
private generateTitleIcons(): TagRenderingConfigJson[] {
let iconsLibrary: Map<string, TagRenderingConfigJson[]> = new Map< let iconsLibrary: Map<string, TagRenderingConfigJson[]> = new Map<
string, string,
TagRenderingConfigJson[] TagRenderingConfigJson[]
@ -186,7 +190,7 @@ export class GenerateFavouritesLayer extends Script {
} }
} }
} }
proto.titleIcons = [] let titleIcons: TagRenderingConfigJson[] = []
const seenTitleIcons = new Set<string>() const seenTitleIcons = new Set<string>()
for (const layer of this.layers) { for (const layer of this.layers) {
for (const titleIcon of layer.titleIcons) { for (const titleIcon of layer.titleIcons) {
@ -198,7 +202,7 @@ export class GenerateFavouritesLayer extends Script {
} }
if (titleIcon.id === "rating") { if (titleIcon.id === "rating") {
if (!seenTitleIcons.has("rating")) { if (!seenTitleIcons.has("rating")) {
proto.titleIcons.unshift(...iconsLibrary.get("rating")) titleIcons.unshift(...iconsLibrary.get("rating"))
seenTitleIcons.add("rating") seenTitleIcons.add("rating")
} }
continue continue
@ -208,10 +212,11 @@ export class GenerateFavouritesLayer extends Script {
} }
seenTitleIcons.add(titleIcon.id) seenTitleIcons.add(titleIcon.id)
console.log("Adding ", titleIcon.id) console.log("Adding ", titleIcon.id)
proto.titleIcons.push(titleIcon) titleIcons.push(titleIcon)
} }
} }
proto.titleIcons.push(...(iconsLibrary.get("defaults") ?? [])) titleIcons.push(...(iconsLibrary.get("defaults") ?? []))
return titleIcons
} }
private addTitle(proto: LayerConfigJson) { private addTitle(proto: LayerConfigJson) {
@ -302,14 +307,18 @@ export class GenerateFavouritesLayer extends Script {
const proto = this.readLayer("favourite/favourite.proto.json") const proto = this.readLayer("favourite/favourite.proto.json")
this.addTagRenderings(proto) this.addTagRenderings(proto)
this.addTitle(proto) this.addTitle(proto)
this.addTitleIcons(proto) proto.titleIcons = this.generateTitleIcons()
const targetContent = JSON.stringify(proto, null, " ") const targetContent = JSON.stringify(proto, null, " ")
const path = "./assets/layers/favourite/favourite.json" const path = "./assets/layers/favourite/favourite.json"
if (existsSync(path)) { if (existsSync(path)) {
if (readFileSync(path, "utf8") === targetContent) { if (readFileSync(path, "utf8") === targetContent) {
return // No need to actually write the file, it is identical console.log(
"Already existing favourite layer is identical to the generated one, not writing"
)
return
} }
} }
console.log("Written favourite layer to", path)
writeFileSync(path, targetContent) writeFileSync(path, targetContent)
} }

View file

@ -1,4 +1,5 @@
import { import {
Bypass,
Concat, Concat,
Conversion, Conversion,
DesugaringContext, DesugaringContext,
@ -1252,6 +1253,10 @@ export class AddRatingBadge extends DesugaringStep<LayerConfigJson> {
// already added // already added
return json return json
} }
if (json.id === "favourite") {
// handled separately
return json
}
const specialVis: Exclude<RenderingSpecification, string>[] = < const specialVis: Exclude<RenderingSpecification, string>[] = <
Exclude<RenderingSpecification, string>[] Exclude<RenderingSpecification, string>[]
@ -1266,6 +1271,7 @@ export class AddRatingBadge extends DesugaringStep<LayerConfigJson> {
return json return json
} }
} }
export class AutoTitleIcon extends DesugaringStep<LayerConfigJson> { export class AutoTitleIcon extends DesugaringStep<LayerConfigJson> {
constructor() { constructor() {
super( super(

View file

@ -3,14 +3,14 @@
import type { SpecialVisualizationState } from "../SpecialVisualization"; import type { SpecialVisualizationState } from "../SpecialVisualization";
import TagRenderingAnswer from "../Popup/TagRendering/TagRenderingAnswer.svelte"; import TagRenderingAnswer from "../Popup/TagRendering/TagRenderingAnswer.svelte";
import type { Feature } from "geojson"; import type { Feature } from "geojson";
import { ImmutableStore } from "../../Logic/UIEventSource"; import { ImmutableStore, UIEventSource } from "../../Logic/UIEventSource";
import { GeoOperations } from "../../Logic/GeoOperations"; import { GeoOperations } from "../../Logic/GeoOperations";
import Center from "../../assets/svg/Center.svelte"; import Center from "../../assets/svg/Center.svelte";
export let feature: Feature; export let feature: Feature;
let properties: Record<string, string> = feature.properties; let properties: Record<string, string> = feature.properties;
export let state: SpecialVisualizationState; export let state: SpecialVisualizationState;
let tags = state.featureProperties.getStore(properties.id) ?? new ImmutableStore(properties); let tags = state.featureProperties.getStore(properties.id) ?? new UIEventSource<Record<string, string>>(properties);
const favLayer = state.layerState.filteredLayers.get("favourite"); const favLayer = state.layerState.filteredLayers.get("favourite");
const favConfig = favLayer?.layerDef; const favConfig = favLayer?.layerDef;
@ -52,7 +52,7 @@
{#if favLayer !== undefined} {#if favLayer !== undefined}
<div class="px-1 my-1 border-2 border-dashed border-gray-300 rounded flex justify-between flex-wrap grid-cols-2 items-center no-weblate"> <div class="px-1 my-1 border-2 border-dashed border-gray-300 rounded flex justify-between flex-wrap grid-cols-2 items-center no-weblate">
<button class="cursor-pointer ml-1 m-0 link justify-self-start" on:click={() => select()}> <button class="cursor-pointer ml-1 m-0 link justify-self-start" on:click={() => select()}>
<TagRenderingAnswer config={titleConfig} extraClasses="underline" layer={favConfig} selectedElement={feature} <TagRenderingAnswer {state} config={titleConfig} extraClasses="underline" layer={favConfig} selectedElement={feature}
{tags} /> {tags} />
</button> </button>
@ -66,7 +66,7 @@
{tags} {tags}
selectedElement={feature} selectedElement={feature}
{state} {state}
layer={favLayer} layer={favLayer.layerDef}
extraClasses="h-full justify-center" extraClasses="h-full justify-center"
/> />
</div> </div>

View file

@ -11,7 +11,6 @@
import { twMerge } from "tailwind-merge" import { twMerge } from "tailwind-merge"
export let tags: UIEventSource<Record<string, string> | undefined> export let tags: UIEventSource<Record<string, string> | undefined>
let _tags: Record<string, string>
export let state: SpecialVisualizationState export let state: SpecialVisualizationState
export let selectedElement: Feature export let selectedElement: Feature

File diff suppressed because one or more lines are too long

View file

@ -59,7 +59,7 @@
</p> </p>
</div> </div>
<div class="flex justify-between items-end w-full"> <div class="flex justify-between items-start w-full">
<!-- IMAGE-START --> <!-- IMAGE-START -->
<img class="p-8 h-32 w-32 self-start" src="./assets/svg/add.svg"> <img class="p-8 h-32 w-32 self-start" src="./assets/svg/add.svg">