swarm-ui: show an agent's details in a popover, not a modal dialog
The details open under the agent badge without dimming or blocking the page; a click outside or Escape closes it. New ui/popover primitive (anchored, portal, no backdrop) with a sample on the components page. A confirm or link dialog opened from inside it stays modal, and the popover ignores clicks and Escape that belong to that dialog. AgentDetailDialog becomes AgentDetailPopover.
This commit is contained in:
parent
74e588415b
commit
f957e19d0d
7 changed files with 221 additions and 42 deletions
|
|
@ -30,6 +30,7 @@ import {
|
|||
import { Button, type ButtonVariant } from "../ui/button/Button.js";
|
||||
import { Dialog } from "../ui/dialog/Dialog.js";
|
||||
import { ConfirmDialog } from "../ui/confirm-dialog/ConfirmDialog.js";
|
||||
import { Popover } from "../ui/popover/Popover.js";
|
||||
import { Badge, type BadgeTone } from "@hive/shared/badge.js";
|
||||
import { GearIcon } from "@hive/shared/icons.js";
|
||||
import { Dropdown, type DropdownOption } from "@hive/shared/dropdown.js";
|
||||
|
|
@ -231,6 +232,33 @@ function DialogSample() {
|
|||
);
|
||||
}
|
||||
|
||||
// `Popover` anchors to the trigger it is given and toggles from it, so the
|
||||
// sample needs the trigger's ref and its own `open` state.
|
||||
function PopoverSample() {
|
||||
const [open, setOpen] = useState(false);
|
||||
const anchorRef = useRef<HTMLSpanElement>(null);
|
||||
return (
|
||||
<>
|
||||
<span ref={anchorRef}>
|
||||
<Button onClick={() => setOpen((o) => !o)}>toggle popover</Button>
|
||||
</span>
|
||||
<Popover
|
||||
open={open}
|
||||
onClose={() => setOpen(false)}
|
||||
anchorRef={anchorRef}
|
||||
label="sample popover"
|
||||
>
|
||||
<Panel title="a popover" icon="🔗" onClose={() => setOpen(false)}>
|
||||
<p>
|
||||
Floats under its trigger and leaves the page behind it clickable.
|
||||
Outside click or Escape closes it.
|
||||
</p>
|
||||
</Panel>
|
||||
</Popover>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// `plain`: a `Panel`'s own header bar/border is the dialog's
|
||||
// only card, not a second one nested inside `Dialog`'s own — pair
|
||||
// `plain` with `Panel`'s `onClose` so the close button still exists,
|
||||
|
|
@ -511,6 +539,12 @@ export function ComponentsPage() {
|
|||
</Sample>
|
||||
</Section>
|
||||
|
||||
<Section title="Popover">
|
||||
<Sample label="anchored, no backdrop, content supplies its own card">
|
||||
<PopoverSample />
|
||||
</Sample>
|
||||
</Section>
|
||||
|
||||
<Section title="ConfirmDialog">
|
||||
<Sample label="modal, cancel/confirm button row">
|
||||
<ConfirmDialogSample />
|
||||
|
|
|
|||
Loading…
Reference in a new issue