add badge component

Signed-off-by: Tobias Erbshäußer <tobias@tesoft.dev>
This commit is contained in:
2026-05-24 09:22:40 +02:00
parent 51f07e0543
commit 4c9a9512b8
2 changed files with 50 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
<template id="tesoft-badge-template">
<style>
@import "/src/styles/default.css";
:host {
display: block;
}
:host > div {
background-color: var(--gold);
border-radius: 0.4rem;
color: var(--gray);
font-weight: 600;
padding: 0.2rem 0.5rem;
}
slot {
align-items: center;
display: grid;
gap: 0.5rem;
grid-auto-flow: column;
justify-content: start;
}
::slotted(svg) {
fill: var(--gray);
}
</style>
<div>
<slot></slot>
</div>
</template>
<script src="/src/components/badge.ts" type="module"></script>
+15
View File
@@ -0,0 +1,15 @@
import {TesoftComponent} from "../scripts/main.ts";
export class TesoftBadge extends TesoftComponent {
constructor() {
super();
const template = document.getElementById("tesoft-badge-template") as HTMLTemplateElement;
const templateContent = template.content;
const shadowRoot = this.attachShadow({mode: "open"});
shadowRoot.appendChild(templateContent.cloneNode(true));
}
}
customElements.define("tesoft-badge", TesoftBadge);