Check for builtin SVG's in mapping-icons

This commit is contained in:
Pieter Vander Vennet 2023-01-13 02:47:06 +01:00
parent ec84cd11aa
commit 9202cbe8e2

View file

@ -17,6 +17,7 @@ import {
} from "./Json/QuestionableTagRenderingConfigJson" } from "./Json/QuestionableTagRenderingConfigJson"
import { FixedUiElement } from "../../UI/Base/FixedUiElement" import { FixedUiElement } from "../../UI/Base/FixedUiElement"
import { Paragraph } from "../../UI/Base/Paragraph" import { Paragraph } from "../../UI/Base/Paragraph"
import Svg from "../../Svg"
export interface Mapping { export interface Mapping {
readonly if: UploadableTag readonly if: UploadableTag
@ -398,7 +399,17 @@ export default class TagRenderingConfig {
let iconClass = commonSize let iconClass = commonSize
if (mapping.icon !== undefined) { if (mapping.icon !== undefined) {
if (typeof mapping.icon === "string" && mapping.icon !== "") { if (typeof mapping.icon === "string" && mapping.icon !== "") {
if (
Svg.All[mapping.icon] !== undefined ||
Svg.All[mapping.icon + ".svg"] !== undefined
) {
icon = "./assets/svg/" + mapping.icon
if (!icon.endsWith(".svg")) {
icon += ".svg"
}
} else {
icon = mapping.icon icon = mapping.icon
}
} else { } else {
icon = mapping.icon["path"] icon = mapping.icon["path"]
iconClass = mapping.icon["class"] ?? iconClass iconClass = mapping.icon["class"] ?? iconClass