2026-03-31 23:03:52 +07:00

24 lines
562 B
TypeScript

/** PettyAlert — inline status message with variant-driven ARIA role. */
export class PettyAlert extends HTMLElement {
static observedAttributes = ["variant"];
get variant(): string {
return this.getAttribute("variant") ?? "default";
}
connectedCallback(): void {
this.#sync();
}
attributeChangedCallback(): void {
this.#sync();
}
#sync(): void {
const v = this.variant;
this.dataset.variant = v;
const isUrgent = v === "error" || v === "warning";
this.setAttribute("role", isUrgent ? "alert" : "status");
}
}