From 5364555bc82ab66b02ea96003e961172ce98f5f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20Erbsh=C3=A4u=C3=9Fer?= Date: Sun, 24 May 2026 09:30:57 +0200 Subject: [PATCH] add styling to button 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/button.njk | 57 ++++++++++++++++++++++++++++-- frontend/src/components/button.ts | 46 ++++++++++++++++++++++++ frontend/src/styles/default.css | 20 ++++++++--- frontend/src/styles/main.css | 4 +-- 4 files changed, 117 insertions(+), 10 deletions(-) diff --git a/frontend/src/components/button.njk b/frontend/src/components/button.njk index 643879b..3bc190d 100644 --- a/frontend/src/components/button.njk +++ b/frontend/src/components/button.njk @@ -1,11 +1,62 @@ diff --git a/frontend/src/components/button.ts b/frontend/src/components/button.ts index 72e14d3..8e330d2 100644 --- a/frontend/src/components/button.ts +++ b/frontend/src/components/button.ts @@ -1,6 +1,10 @@ import {TesoftComponent} from "../scripts/main.ts"; export class TesoftButton extends TesoftComponent { + static observedAttributes = ["href", "selected"]; + + private readonly rootDiv: HTMLDivElement; + constructor() { super(); @@ -9,6 +13,48 @@ export class TesoftButton extends TesoftComponent { const shadowRoot = this.attachShadow({mode: "open"}); shadowRoot.appendChild(templateContent.cloneNode(true)); + + this.rootDiv = shadowRoot.querySelector("div")!; + } + + // noinspection JSUnusedGlobalSymbols + attributeChangedCallback(name: string, _oldValue: string | null, newValue: string | null) { + if (name === "href") { + this.rootDiv.innerHTML = ""; + + let linkOrButton: HTMLElement; + if (newValue) { + linkOrButton = document.createElement("a"); + (linkOrButton as HTMLAnchorElement).href = newValue; + } else { + linkOrButton = document.createElement("button"); + } + linkOrButton.part = "children"; + this.rootDiv.appendChild(linkOrButton); + + const slot = document.createElement("slot"); + linkOrButton.appendChild(slot); + } + } + + get href(): string | null { + return this.getAttribute("href"); + } + + set href(value: string | null) { + if (value) { + this.setAttribute("href", value); + } else { + this.removeAttribute("href"); + } + } + + set selected(value: string | null) { + if (value === null) { + this.removeAttribute("selected"); + } else { + this.setAttribute("selected", ""); + } } } diff --git a/frontend/src/styles/default.css b/frontend/src/styles/default.css index 507f433..a2aa16c 100644 --- a/frontend/src/styles/default.css +++ b/frontend/src/styles/default.css @@ -1,8 +1,13 @@ :root { --dark-gray: #222831; - --gray: #393E46; --gold: #FFD369; + --gray: #393E46; --light-gray: #EEEEEE; + + --small-padding: 0.6rem; + --medium-padding: 0.8rem; + --large-padding: 1.2rem; + --button-border-radius: 0.5rem; } html { @@ -12,12 +17,11 @@ html { * { box-sizing: border-box; + font-family: "Adwaita Sans", sans-serif; + font-size: 1.4rem; + line-height: 2.1rem; margin: 0; padding: 0; - - font-family: "Adwaita Sans", sans-serif; - line-height: 2.1rem; - font-size: 1.4rem; } *::after { @@ -39,3 +43,9 @@ html { a { color: var(--gold); } + +a:focus { + outline-color: var(--gold); + outline-offset: 0.2rem; + outline-style: solid; +} diff --git a/frontend/src/styles/main.css b/frontend/src/styles/main.css index 914c23b..c8fa32d 100644 --- a/frontend/src/styles/main.css +++ b/frontend/src/styles/main.css @@ -1,11 +1,11 @@ @import "default.css"; @font-face { + font-display: swap; font-family: "Adwaita Sans"; + font-stretch: 100%; font-style: normal; font-weight: 300 800; - font-stretch: 100%; - font-display: swap; src: url(/public/assets/AdwaitaSans-Regular.woff2) format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }