// hive-warn.js — , the shared inline warning-banner // component. Consolidates three independently-written instances of the // same thing: `.cred-warning` (credentials.html, static // markup), `.tombstone-warn` (core.js, JS-built), `.port-conflict` // (swarm.js, JS-built) — the first two differed only by an // undeliberate 10% vs 8% tint, the strongest evidence this was drift, // not three genuinely different needs. // // Purely presentational — no internal state, no lifecycle beyond // attaching its shadow root once. `severity` ('amber' | 'red', default // amber) and `pulse` (boolean) are read directly by hive-warn.css's // `:host([...])` selectors; unlike ``'s `variant`/`disabled` // there's no inner native element that needs the attribute mirrored // onto it, so no `attributeChangedCallback` is needed at all. // // Content is arbitrary light-DOM children through the shadow tree's // single default `` — same reuse of the existing ``/ // `` markup every call site already writes, no caller-side // rewrite of their message content needed. // // Usage: // `...` (amber, static HTML) // `el('hive-warn', {}, ...)` (amber, JS-built) // `el('hive-warn', { severity: 'red', pulse: '' }, ...)` (urgent) import { attachShadowCss } from '../shadow-css.js'; import hiveWarnCss from './hive-warn.css'; class HiveWarn extends HTMLElement { connectedCallback() { if (this._built) return; // re-parenting re-fires connectedCallback const root = attachShadowCss(this, hiveWarnCss); root.append(document.createElement('slot')); this._built = true; } } customElements.define('hive-warn', HiveWarn);