import { settings } from "../settings.js"; const sizes = ["small", "large"]; const styles = ["purple", "gray", "red", "green", "yellow", "blue"]; class DevToolbarBadge extends HTMLElement { _size = "small"; _badgeStyle = "purple"; get size() { return this._size; } set size(value) { if (!sizes.includes(value)) { settings.logger.error( `Invalid size: ${value}, expected one of ${sizes.join(", ")}, got ${value}.` ); return; } this._size = value; this.updateStyle(); } get badgeStyle() { return this._badgeStyle; } set badgeStyle(value) { if (!styles.includes(value)) { settings.logger.error( `Invalid style: ${value}, expected one of ${styles.join(", ")}, got ${value}.` ); return; } this._badgeStyle = value; this.updateStyle(); } shadowRoot; static observedAttributes = ["badge-style", "size"]; constructor() { super(); this.shadowRoot = this.attachShadow({ mode: "open" }); this.shadowRoot.innerHTML = `
`; } connectedCallback() { this.updateStyle(); } attributeChangedCallback() { if (this.hasAttribute("badge-style")) this.badgeStyle = this.getAttribute("badge-style"); if (this.hasAttribute("size")) this.size = this.getAttribute("size"); } updateStyle() { const style = this.shadowRoot.querySelector("#selected-style"); if (style) { style.innerHTML = ` .badge { --text-color: var(--${this.badgeStyle}-text); --border-color: var(--${this.badgeStyle}-border); --size: var(--${this.size}); }`; } } } export { DevToolbarBadge };