diff --git a/frontend/src/components/tag.njk b/frontend/src/components/tag.njk index d95bea4..845d13a 100644 --- a/frontend/src/components/tag.njk +++ b/frontend/src/components/tag.njk @@ -6,21 +6,26 @@ display: block; } - :host > div { + tesoft-button::part(children) { + align-items: center; display: grid; + gap: 0.5rem; grid-template-columns: auto auto; grid-template-rows: auto; } + + svg { + height: 2.4rem; + width: 2.4rem; + } - - - - - - - - + + + + + + diff --git a/frontend/src/components/tag.ts b/frontend/src/components/tag.ts index cea72f2..4710031 100644 --- a/frontend/src/components/tag.ts +++ b/frontend/src/components/tag.ts @@ -1,9 +1,10 @@ import {TesoftComponent} from "../scripts/main.ts"; +import {TesoftButton} from "./button.ts"; export class TesoftTag extends TesoftComponent { - static observedAttributes = ["href"]; + static observedAttributes = ["href", "selected"]; - private readonly anchor: HTMLAnchorElement; + private readonly button: TesoftButton; constructor() { super(); @@ -14,13 +15,19 @@ export class TesoftTag extends TesoftComponent { const shadowRoot = this.attachShadow({mode: "open"}); shadowRoot.appendChild(templateContent.cloneNode(true)); - this.anchor = shadowRoot.querySelector("a")!; + this.button = shadowRoot.querySelector("tesoft-button")!; } // noinspection JSUnusedGlobalSymbols attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null) { if (name === "href") { - this.anchor.href = newValue ?? ""; + setTimeout(() => { + this.button.href = newValue ?? ""; + }); + } else if (name === "selected") { + setTimeout(() => { + this.button.selected = newValue; + }); } } @@ -31,6 +38,14 @@ export class TesoftTag extends TesoftComponent { this.removeAttribute("href"); } } + + set selected(value: string | null) { + if (value === null) { + this.removeAttribute("selected"); + } else { + this.setAttribute("selected", ""); + } + } } customElements.define("tesoft-tag", TesoftTag);