Pure `nix fmt` output from the commit before this one — no hand edits. 203 files: 52 md, 42 tsx, 32 js, 32 css, 21 ts, 13 html, 8 json, 3 mjs. Reproduce with `nix develop -c nix fmt` on the parent commit; the result should be byte-identical to this tree. None of the 13 `.prettierignore` entries appears here — verified by intersecting the changed-file list against the ignore file, with a control proving the intersection finds a match when one exists.
26 lines
1.2 KiB
JavaScript
26 lines
1.2 KiB
JavaScript
// Tiny DOM-builder helper shared by the dashboard and the per-agent UI —
|
|
// both packages built their own copy independently; this is the merged
|
|
// canonical version (dashboard's, which had the extra `data-` branch;
|
|
// functionally identical to the `class`/`html` handling either package
|
|
// used).
|
|
//
|
|
// `el(tag, attrs, ...children)` creates an element, applying `attrs` as
|
|
// either the `class`/`html` special cases or plain attributes, and
|
|
// appending `children` (strings become text nodes, `null`/`undefined`
|
|
// entries are skipped so callers can inline conditional children).
|
|
// `tag` can be any custom element's tag name too (e.g. `el('hive-btn',
|
|
// { variant: 'danger' }, 'label')`) — `document.createElement` upgrades
|
|
// it automatically if the tag is already registered.
|
|
export const el = (tag, attrs = {}, ...children) => {
|
|
const e = document.createElement(tag);
|
|
for (const [k, v] of Object.entries(attrs)) {
|
|
if (k === "class") e.className = v;
|
|
else if (k === "html") e.innerHTML = v;
|
|
else e.setAttribute(k, v);
|
|
}
|
|
for (const c of children) {
|
|
if (c == null) continue;
|
|
e.append(c.nodeType ? c : document.createTextNode(c));
|
|
}
|
|
return e;
|
|
};
|