allow to disable tags

Signed-off-by: Tobias Erbshäußer <tobias@tesoft.dev>
This commit is contained in:
2026-05-24 09:22:58 +02:00
parent c020592c8d
commit f09e73e194
2 changed files with 15 additions and 2 deletions
+1
View File
@@ -12,6 +12,7 @@
gap: var(--small-padding); gap: var(--small-padding);
grid-template-columns: auto auto; grid-template-columns: auto auto;
grid-template-rows: auto; grid-template-rows: auto;
padding: var(--small-padding) var(--medium-padding);
} }
svg { svg {
+14 -2
View File
@@ -2,7 +2,7 @@ import {TesoftComponent} from "../scripts/main.ts";
import {TesoftButton} from "./button.ts"; import {TesoftButton} from "./button.ts";
export class TesoftTag extends TesoftComponent { export class TesoftTag extends TesoftComponent {
static observedAttributes = ["href", "selected"]; static observedAttributes = ["disabled", "href", "selected"];
private readonly button: TesoftButton; private readonly button: TesoftButton;
@@ -20,7 +20,11 @@ export class TesoftTag extends TesoftComponent {
// noinspection JSUnusedGlobalSymbols // noinspection JSUnusedGlobalSymbols
attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null) { attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null) {
if (name === "href") { if (name === "disabled") {
setTimeout(() => {
this.button.disabled = newValue;
});
} else if (name === "href") {
setTimeout(() => { setTimeout(() => {
this.button.href = newValue ?? ""; this.button.href = newValue ?? "";
}); });
@@ -31,6 +35,14 @@ export class TesoftTag extends TesoftComponent {
} }
} }
set disabled(value: string | null) {
if (value === null) {
this.removeAttribute("disabled");
} else {
this.setAttribute("disabled", "");
}
}
set href(value: string | null) { set href(value: string | null) {
if (value) { if (value) {
this.setAttribute("href", value); this.setAttribute("href", value);