) as HTMLDivElement;
const toggle = (
) as HTMLButtonElement;
menu.id = "project-menu";
// opens under its button
menu.addEventListener("beforetoggle", e => {
if ((e as ToggleEvent).newState !== "open") return;
const at = toggle.getBoundingClientRect();
Object.assign(menu.style, { left: `${at.left}px`, top: `${at.bottom + 4}px` });
});
// a press outside only closes it. the browser would close it too, but not when the press
// redraws what's under it (as clicking the timeline does), and the press would still edit
addEventListener(
"pointerdown",
e => {
const target = e.target as Node;
if (!menu.matches(":popover-open") || menu.contains(target) || toggle.contains(target))
return;
e.stopPropagation();
e.preventDefault();
menu.hidePopover();
},
true,
);
return [toggle, menu];
}
export function Toolbar(): JSX.Element {
const projects = (