Et2SelectCatagory: Fix missing category icons & colors

This commit is contained in:
nathan 2024-08-26 11:30:37 -06:00
parent 9495dd48b9
commit 0f5a1a2b5a
2 changed files with 2 additions and 12 deletions

View File

@ -123,7 +123,7 @@ export class Et2SelectCategory extends Et2StaticSelectMixin(Et2TreeDropdown)
let css = "";
const catColor = (option) =>
{
css += ".cat_" + option.value + " {--category-color: " + (option.data?.color || "transparent") + ";}\n";
css += ".cat_" + option.value + " {--category-color: var(--cat-" + option.value + "-color ,transparent);}\n";
if (typeof option.children === 'object')
{

View File

@ -872,16 +872,6 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) implements Fin
}
//fallback to try and set icon if everything else failed
if (!img) img = selectOption.icon ?? selectOption.im0 ?? selectOption.im1 ?? selectOption.im2;
if (img?.endsWith(".png"))
{
//sl-icon images need to be svgs if there is a png try to find the corresponding svg
img = img.replace(".png", ".svg");
}
//append image path, if img is only relative (does not start with / or https://)
if (img && typeof img === "string" && !img.match(/^(\/|https?:\/\/)/))
{
img = this.imagePath + img;
}
// lazy iff "child" is set and "item" is empty or item does not exist in the first place
const lazy = (selectOption.item?.length === 0 && selectOption.child) || (selectOption.child && !selectOption.item)
@ -938,7 +928,7 @@ export class Et2Tree extends Et2WidgetWithSelectMixin(LitElement) implements Fin
>
<sl-icon src="${img ?? nothing}"></sl-icon>
<et2-image src="${img ?? nothing}"></et2-image>
<span class="tree-item__label">
${selectOption.label ?? selectOption.text}
</span>