Refactoring: small tweaks to PointRenderingConfig.ts

This commit is contained in:
Pieter Vander Vennet 2025-09-01 00:06:37 +02:00
parent 5f408b5183
commit 34cc65b240

View file

@ -129,7 +129,8 @@ export default class PointRenderingConfig extends WithContextLoader {
context + ".rotationAlignment" context + ".rotationAlignment"
) )
} }
private static FromHtmlMulti(
private static fromHtmlMulti(
multiSpec: string, multiSpec: string,
tags: Store<Record<string, string>> tags: Store<Record<string, string>>
): BaseUIElement { ): BaseUIElement {
@ -207,7 +208,7 @@ export default class PointRenderingConfig extends WithContextLoader {
: undefined : undefined
let badges = undefined let badges = undefined
if (options?.includeBadges ?? true) { if (options?.includeBadges ?? true) {
badges = this.GetBadges(tags, options?.metatags) badges = this.getBadges(tags, options?.metatags)
} }
const iconAndBadges = new Combine([icon, badges]).SetClass("block relative") const iconAndBadges = new Combine([icon, badges]).SetClass("block relative")
@ -235,7 +236,7 @@ export default class PointRenderingConfig extends WithContextLoader {
} else if (label === undefined) { } else if (label === undefined) {
htmlEl = new Combine([iconAndBadges]) htmlEl = new Combine([iconAndBadges])
} else { } else {
htmlEl = new Combine([iconAndBadges, label]).SetStyle("flex flex-col") htmlEl = new Combine([iconAndBadges, label])
} }
if (css !== undefined) { if (css !== undefined) {
@ -251,7 +252,7 @@ export default class PointRenderingConfig extends WithContextLoader {
} }
} }
private GetBadges( private getBadges(
tags: Store<Record<string, string>>, tags: Store<Record<string, string>>,
metaTags?: Store<Record<string, string>> metaTags?: Store<Record<string, string>>
): BaseUIElement { ): BaseUIElement {
@ -283,15 +284,14 @@ export default class PointRenderingConfig extends WithContextLoader {
if (htmlDefs.startsWith("<") && htmlDefs.endsWith(">")) { if (htmlDefs.startsWith("<") && htmlDefs.endsWith(">")) {
// This is probably an HTML-element // This is probably an HTML-element
return new FixedUiElement(Utils.SubstituteKeys(htmlDefs, tagsData)) return new FixedUiElement(Utils.SubstituteKeys(htmlDefs, tagsData))
.SetStyle("width: 1.5rem") .SetClass("block w-6")
.SetClass("block")
} }
if (!htmlDefs) { if (!htmlDefs) {
return undefined return undefined
} }
const badgeElement = PointRenderingConfig.FromHtmlMulti( const badgeElement = PointRenderingConfig.fromHtmlMulti(
htmlDefs, htmlDefs,
tags tags
)?.SetClass("block relative") )?.SetClass("block relative")
@ -299,8 +299,7 @@ export default class PointRenderingConfig extends WithContextLoader {
return undefined return undefined
} }
return new Combine([badgeElement]) return new Combine([badgeElement])
.SetStyle("width: 1.5rem") .SetClass("block w-6")
.SetClass("block")
}) })
return new Combine(badgeElements).SetClass("inline-flex h-full") return new Combine(badgeElements).SetClass("inline-flex h-full")