treefmt: apply prettier
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.
This commit is contained in:
parent
5d24bedd60
commit
39b95c2ede
203 changed files with 10090 additions and 6085 deletions
|
|
@ -34,7 +34,7 @@
|
|||
/* The trigger is the top-level `slot="trigger"` node — reachable, so its
|
||||
base icon-button chrome (invisible until hover/open, via
|
||||
`--menu-btn-opacity`) lives here rather than duplicated per caller. */
|
||||
::slotted([slot='trigger']) {
|
||||
::slotted([slot="trigger"]) {
|
||||
display: block;
|
||||
background: none;
|
||||
border: none;
|
||||
|
|
@ -45,14 +45,17 @@
|
|||
padding: 0.1em 0.4em;
|
||||
border-radius: 4px;
|
||||
opacity: var(--menu-btn-opacity, 0);
|
||||
transition: opacity 120ms, background 120ms, color 120ms;
|
||||
transition:
|
||||
opacity 120ms,
|
||||
background 120ms,
|
||||
color 120ms;
|
||||
}
|
||||
::slotted([slot='trigger']:hover),
|
||||
::slotted([slot='trigger']:focus-visible) {
|
||||
::slotted([slot="trigger"]:hover),
|
||||
::slotted([slot="trigger"]:focus-visible) {
|
||||
background: color-mix(in srgb, var(--purple) 10%, transparent);
|
||||
color: var(--purple);
|
||||
outline: none;
|
||||
}
|
||||
::slotted([slot='trigger']:focus-visible) {
|
||||
::slotted([slot="trigger"]:focus-visible) {
|
||||
outline: 1px solid var(--purple);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@
|
|||
// slotted content) tests "did this land inside any open menu" — same
|
||||
// reasoning as `<hive-dialog>`'s backdrop-click check.
|
||||
|
||||
import { el } from '../dom.js';
|
||||
import { attachShadowCss } from '../shadow-css.js';
|
||||
import hiveMenuCss from './hive-menu.css';
|
||||
import { el } from "../dom.js";
|
||||
import { attachShadowCss } from "../shadow-css.js";
|
||||
import hiveMenuCss from "./hive-menu.css";
|
||||
|
||||
const openInstances = new Set();
|
||||
|
||||
|
|
@ -46,22 +46,30 @@ export function closeAllMenus() {
|
|||
}
|
||||
|
||||
// Close on any click outside every currently-open instance.
|
||||
document.addEventListener('click', (e) => {
|
||||
if (!openInstances.size) return;
|
||||
const path = e.composedPath();
|
||||
for (const inst of [...openInstances]) {
|
||||
if (!path.includes(inst)) inst.close();
|
||||
}
|
||||
}, true);
|
||||
document.addEventListener(
|
||||
"click",
|
||||
(e) => {
|
||||
if (!openInstances.size) return;
|
||||
const path = e.composedPath();
|
||||
for (const inst of [...openInstances]) {
|
||||
if (!path.includes(inst)) inst.close();
|
||||
}
|
||||
},
|
||||
true,
|
||||
);
|
||||
// Close on Escape. stopImmediatePropagation so a caller's own
|
||||
// selection-clear Escape handler (e.g. swarm.js's) doesn't also fire
|
||||
// while a menu is open.
|
||||
document.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape' && openInstances.size) {
|
||||
closeAll();
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
}, true);
|
||||
document.addEventListener(
|
||||
"keydown",
|
||||
(e) => {
|
||||
if (e.key === "Escape" && openInstances.size) {
|
||||
closeAll();
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
},
|
||||
true,
|
||||
);
|
||||
|
||||
class HiveMenu extends HTMLElement {
|
||||
connectedCallback() {
|
||||
|
|
@ -80,18 +88,18 @@ class HiveMenu extends HTMLElement {
|
|||
|
||||
// Project the caller's opaque nodes via named slots — see module
|
||||
// header for why this has to be slotting, not a shadow-root append.
|
||||
trigger.slot = 'trigger';
|
||||
content.slot = 'content';
|
||||
trigger.slot = "trigger";
|
||||
content.slot = "content";
|
||||
this.append(trigger, content);
|
||||
|
||||
const dropdown = el('div', { class: 'menu-dropdown', hidden: true });
|
||||
dropdown.append(el('slot', { name: 'content' }));
|
||||
root.append(el('slot', { name: 'trigger' }), dropdown);
|
||||
const dropdown = el("div", { class: "menu-dropdown", hidden: true });
|
||||
dropdown.append(el("slot", { name: "content" }));
|
||||
root.append(el("slot", { name: "trigger" }), dropdown);
|
||||
|
||||
this._trigger = trigger;
|
||||
this._dropdown = dropdown;
|
||||
|
||||
trigger.addEventListener('click', (e) => {
|
||||
trigger.addEventListener("click", (e) => {
|
||||
e.stopPropagation();
|
||||
const wasOpen = openInstances.has(this);
|
||||
closeAll();
|
||||
|
|
@ -107,17 +115,17 @@ class HiveMenu extends HTMLElement {
|
|||
|
||||
open() {
|
||||
this._dropdown.hidden = false;
|
||||
this._trigger.setAttribute('aria-expanded', 'true');
|
||||
this.style.setProperty('--menu-btn-opacity', '1');
|
||||
this._trigger.setAttribute("aria-expanded", "true");
|
||||
this.style.setProperty("--menu-btn-opacity", "1");
|
||||
openInstances.add(this);
|
||||
}
|
||||
|
||||
close() {
|
||||
if (!openInstances.has(this)) return;
|
||||
this._dropdown.hidden = true;
|
||||
this._trigger.setAttribute('aria-expanded', 'false');
|
||||
this.style.removeProperty('--menu-btn-opacity');
|
||||
this._trigger.setAttribute("aria-expanded", "false");
|
||||
this.style.removeProperty("--menu-btn-opacity");
|
||||
openInstances.delete(this);
|
||||
}
|
||||
}
|
||||
customElements.define('hive-menu', HiveMenu);
|
||||
customElements.define("hive-menu", HiveMenu);
|
||||
|
|
|
|||
Loading…
Reference in a new issue