diff --git a/frontend/packages/shared/src/hive-btn.css b/frontend/packages/shared/src/hive-btn/hive-btn.css similarity index 100% rename from frontend/packages/shared/src/hive-btn.css rename to frontend/packages/shared/src/hive-btn/hive-btn.css diff --git a/frontend/packages/shared/src/hive-btn.js b/frontend/packages/shared/src/hive-btn/hive-btn.js similarity index 91% rename from frontend/packages/shared/src/hive-btn.js rename to frontend/packages/shared/src/hive-btn/hive-btn.js index 18de2977..35755755 100644 --- a/frontend/packages/shared/src/hive-btn.js +++ b/frontend/packages/shared/src/hive-btn/hive-btn.js @@ -20,6 +20,7 @@ // `disabled`/`type` are likewise plain attributes on the host, mirrored // onto the inner button on connect and on every attribute change. +import { attachShadowCss } from '../shadow-css.js'; import hiveBtnCss from './hive-btn.css'; const OBSERVED = ['disabled', 'type']; @@ -34,10 +35,7 @@ class HiveBtn extends HTMLElement { this._sync(); return; // already built (e.g. re-parenting re-fires connectedCallback) } - const root = this.attachShadow({ mode: 'open', delegatesFocus: true }); - const sheet = new CSSStyleSheet(); - sheet.replaceSync(hiveBtnCss); - root.adoptedStyleSheets = [sheet]; + const root = attachShadowCss(this, hiveBtnCss, { delegatesFocus: true }); const btn = document.createElement('button'); btn.append(document.createElement('slot')); root.append(btn); diff --git a/frontend/packages/shared/src/hive-dialog.css b/frontend/packages/shared/src/hive-dialog/hive-dialog.css similarity index 77% rename from frontend/packages/shared/src/hive-dialog.css rename to frontend/packages/shared/src/hive-dialog/hive-dialog.css index ec760ddb..f602d33b 100644 --- a/frontend/packages/shared/src/hive-dialog.css +++ b/frontend/packages/shared/src/hive-dialog/hive-dialog.css @@ -1,10 +1,11 @@ /* hive-dialog.css — scoped stylesheet for the shadow-DOM - custom element (modal.js). Loaded as raw text at build time (esbuild's - `text` loader) and adopted via `adoptedStyleSheets`. `:host` styles the - element itself, which *is* the fixed-position backdrop — no separate - light-DOM backdrop div. Button styling (base look + cancel/confirm/ - danger variants) lives in hive-btn.css, not here — the dialog's - buttons are elements with their own shadow root. */ + custom element (hive-dialog.js). Loaded as raw text at build time + (esbuild's `text` loader) and appended as a `