Fix: remove 'icons.defaults' from favourite layers, cleanup of various small typing errors
This commit is contained in:
parent
98ca6aa8aa
commit
e8569ec540
7 changed files with 37 additions and 26 deletions
|
@ -1089,14 +1089,14 @@ video {
|
|||
height: 6rem;
|
||||
}
|
||||
|
||||
.h-full {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.h-screen {
|
||||
height: 100vh;
|
||||
}
|
||||
|
||||
.h-full {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.h-32 {
|
||||
height: 8rem;
|
||||
}
|
||||
|
@ -1172,14 +1172,14 @@ video {
|
|||
height: 10rem;
|
||||
}
|
||||
|
||||
.h-80 {
|
||||
height: 20rem;
|
||||
}
|
||||
|
||||
.h-64 {
|
||||
height: 16rem;
|
||||
}
|
||||
|
||||
.h-80 {
|
||||
height: 20rem;
|
||||
}
|
||||
|
||||
.max-h-12 {
|
||||
max-height: 3rem;
|
||||
}
|
||||
|
@ -2989,10 +2989,6 @@ a.link-underline {
|
|||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.md\:p-4 {
|
||||
padding: 1rem;
|
||||
}
|
||||
|
||||
.md\:p-3 {
|
||||
padding: 0.75rem;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@ import { TagConfigJson } from "../src/Models/ThemeConfig/Json/TagConfigJson"
|
|||
import { TagUtils } from "../src/Logic/Tags/TagUtils"
|
||||
import { TagRenderingConfigJson } from "../src/Models/ThemeConfig/Json/TagRenderingConfigJson"
|
||||
import { Translatable } from "../src/Models/ThemeConfig/Json/Translatable"
|
||||
import Icon from "../src/UI/Map/Icon.svelte"
|
||||
|
||||
export class GenerateFavouritesLayer extends Script {
|
||||
private readonly layers: LayerConfigJson[] = []
|
||||
|
@ -53,6 +52,7 @@ export class GenerateFavouritesLayer extends Script {
|
|||
|
||||
return sortedMappings
|
||||
}
|
||||
|
||||
private addTagRenderings(proto: LayerConfigJson) {
|
||||
const blacklistedIds = new Set([
|
||||
"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<
|
||||
string,
|
||||
TagRenderingConfigJson[]
|
||||
|
@ -186,7 +190,7 @@ export class GenerateFavouritesLayer extends Script {
|
|||
}
|
||||
}
|
||||
}
|
||||
proto.titleIcons = []
|
||||
let titleIcons: TagRenderingConfigJson[] = []
|
||||
const seenTitleIcons = new Set<string>()
|
||||
for (const layer of this.layers) {
|
||||
for (const titleIcon of layer.titleIcons) {
|
||||
|
@ -198,7 +202,7 @@ export class GenerateFavouritesLayer extends Script {
|
|||
}
|
||||
if (titleIcon.id === "rating") {
|
||||
if (!seenTitleIcons.has("rating")) {
|
||||
proto.titleIcons.unshift(...iconsLibrary.get("rating"))
|
||||
titleIcons.unshift(...iconsLibrary.get("rating"))
|
||||
seenTitleIcons.add("rating")
|
||||
}
|
||||
continue
|
||||
|
@ -208,10 +212,11 @@ export class GenerateFavouritesLayer extends Script {
|
|||
}
|
||||
seenTitleIcons.add(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) {
|
||||
|
@ -302,14 +307,18 @@ export class GenerateFavouritesLayer extends Script {
|
|||
const proto = this.readLayer("favourite/favourite.proto.json")
|
||||
this.addTagRenderings(proto)
|
||||
this.addTitle(proto)
|
||||
this.addTitleIcons(proto)
|
||||
proto.titleIcons = this.generateTitleIcons()
|
||||
const targetContent = JSON.stringify(proto, null, " ")
|
||||
const path = "./assets/layers/favourite/favourite.json"
|
||||
if (existsSync(path)) {
|
||||
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)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import {
|
||||
Bypass,
|
||||
Concat,
|
||||
Conversion,
|
||||
DesugaringContext,
|
||||
|
@ -1252,6 +1253,10 @@ export class AddRatingBadge extends DesugaringStep<LayerConfigJson> {
|
|||
// already added
|
||||
return json
|
||||
}
|
||||
if (json.id === "favourite") {
|
||||
// handled separately
|
||||
return json
|
||||
}
|
||||
|
||||
const specialVis: Exclude<RenderingSpecification, string>[] = <
|
||||
Exclude<RenderingSpecification, string>[]
|
||||
|
@ -1266,6 +1271,7 @@ export class AddRatingBadge extends DesugaringStep<LayerConfigJson> {
|
|||
return json
|
||||
}
|
||||
}
|
||||
|
||||
export class AutoTitleIcon extends DesugaringStep<LayerConfigJson> {
|
||||
constructor() {
|
||||
super(
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
import type { SpecialVisualizationState } from "../SpecialVisualization";
|
||||
import TagRenderingAnswer from "../Popup/TagRendering/TagRenderingAnswer.svelte";
|
||||
import type { Feature } from "geojson";
|
||||
import { ImmutableStore } from "../../Logic/UIEventSource";
|
||||
import { ImmutableStore, UIEventSource } from "../../Logic/UIEventSource";
|
||||
import { GeoOperations } from "../../Logic/GeoOperations";
|
||||
import Center from "../../assets/svg/Center.svelte";
|
||||
|
||||
export let feature: Feature;
|
||||
let properties: Record<string, string> = feature.properties;
|
||||
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 favConfig = favLayer?.layerDef;
|
||||
|
@ -52,7 +52,7 @@
|
|||
{#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">
|
||||
<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} />
|
||||
</button>
|
||||
|
||||
|
@ -66,7 +66,7 @@
|
|||
{tags}
|
||||
selectedElement={feature}
|
||||
{state}
|
||||
layer={favLayer}
|
||||
layer={favLayer.layerDef}
|
||||
extraClasses="h-full justify-center"
|
||||
/>
|
||||
</div>
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
import { twMerge } from "tailwind-merge"
|
||||
|
||||
export let tags: UIEventSource<Record<string, string> | undefined>
|
||||
let _tags: Record<string, string>
|
||||
|
||||
export let state: SpecialVisualizationState
|
||||
export let selectedElement: Feature
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -59,7 +59,7 @@
|
|||
</p>
|
||||
</div>
|
||||
|
||||
<div class="flex justify-between items-end w-full">
|
||||
<div class="flex justify-between items-start w-full">
|
||||
|
||||
<!-- IMAGE-START -->
|
||||
<img class="p-8 h-32 w-32 self-start" src="./assets/svg/add.svg">
|
||||
|
|
Loading…
Reference in a new issue