From f09e73e194460820c92671b3ab74dbdbfd324f2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Erbsh=C3=A4u=C3=9Fer?= Date: Sun, 24 May 2026 09:22:58 +0200 Subject: [PATCH] allow to disable tags MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Tobias Erbshäußer --- frontend/src/components/tag.njk | 1 + frontend/src/components/tag.ts | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/tag.njk b/frontend/src/components/tag.njk index 1399f0f..bd845df 100644 --- a/frontend/src/components/tag.njk +++ b/frontend/src/components/tag.njk @@ -12,6 +12,7 @@ gap: var(--small-padding); grid-template-columns: auto auto; grid-template-rows: auto; + padding: var(--small-padding) var(--medium-padding); } svg { diff --git a/frontend/src/components/tag.ts b/frontend/src/components/tag.ts index 4710031..22a2ba4 100644 --- a/frontend/src/components/tag.ts +++ b/frontend/src/components/tag.ts @@ -2,7 +2,7 @@ import {TesoftComponent} from "../scripts/main.ts"; import {TesoftButton} from "./button.ts"; export class TesoftTag extends TesoftComponent { - static observedAttributes = ["href", "selected"]; + static observedAttributes = ["disabled", "href", "selected"]; private readonly button: TesoftButton; @@ -20,7 +20,11 @@ export class TesoftTag extends TesoftComponent { // noinspection JSUnusedGlobalSymbols 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(() => { 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) { if (value) { this.setAttribute("href", value);