frontend: move shadow-DOM component CSS to real .css files, not JS strings

mara: 'i dont like sharing css via js, thats not how it should be done.'

Replaced the DIALOG_CSS/TOAST_CSS template-string constants in modal.js
and the inline CSS text in component-styles.js with three real .css
files (hive-dialog.css, hive-toast.css, component-common.css),
imported as raw text via esbuild's 'text' loader and turned into
CSSStyleSheet objects at runtime (same replaceSync() call as before --
only where the CSS text comes from changed). Both packages' build.mjs
gained a '.css': 'text' loader entry on their JS-bundling step; this
doesn't collide with the separate page-stylesheet bundling ('css'
loader), which is a different esbuild invocation over different entry
points.

No behavior change -- same adoptedStyleSheets wiring, same rules,
same output. Verified with a full frontend build (grepped the bundled
JS to confirm the CSS text inlines correctly); nix fmt clean.
This commit is contained in:
iris 2026-07-28 00:30:38 +02:00 committed by mara
commit bce666a9b2
7 changed files with 197 additions and 151 deletions

View file

@ -41,6 +41,10 @@ await build({
target: ['es2022'],
sourcemap: true,
logLevel: 'info',
// `@hive/shared/modal.js` imports its shadow-DOM component CSS as raw
// text (see dashboard/build.mjs's matching comment) — same reasoning
// applies here.
loader: { '.css': 'text' },
});
// Bundle the CSS. `colors.css` re-exports the standalone base16 palette