Official

ui

The look of the app's components: buttons, list rows, cards, settings, callouts, and the blocks and tables of replies. Edit a component here and the whole app draws with it.

The app opens the listing; nothing installs until an agent in your Plugins workspace has read the files and you enable the plugin. In a terminal: dvg install divergence/ui@0.1.1

Permissions in 0.1.1

  • Change app settings settings.writeHighChanges the app settings.Apply the components' look to the window

Files

components/item.tsx9 KB
/** @jsxRuntime classic */
/** @jsx template */
// A row of a list: a leading mark (an icon, an SVG, a spinner while
// `busy`, or a `<slot name="leading">`), a label with an optional second
// line, trailing content (the children), a badge, and buttons that take
// the trailing content's place while the pointer is on the row
// (`actions`), on the same pitch as the icons they replace. A `stacked` row
// with a second line ends that line with them instead, so its label runs the
// whole row. The div props an instance is given (an `id`, `onClick`, drag
// and drop, `layoutMotion`) are the row's own.
import { FILL, TONES, prop, when, type Condition, type Definition, template } from "../define.ts";

const MARK = {
  display: "flex",
  alignItems: "center",
  justifyContent: "center",
  position: "relative",
  flexGrow: 0,
  flexShrink: 0,
  width: "density.rowLead",
  height: "density.rowLead",
};

// The hover actions take no room at rest. Under the pointer they take the
// resting trailing content's place at the end of their line, ending where
// its icons end, and the text before them truncates where they start, so
// nothing is drawn under them and the row's own ground shows around them.
const actions = (height: string, where: readonly Condition[] = [], props: Readonly<Record<string, unknown>> = {}) => (
  <div $if={["actions", ...where]} display="none" flexDirection="row" alignItems="center" flexShrink={0} height={height} marginRight={-3} groupHover={{ group: "item", display: "flex" }} {...props}>
    <div $each="actions" role="button" id={prop("item.id")} label={prop("item.tooltip")} tooltip={prop("item.tooltip")} isDisabled={prop("item.disabled", { else: false })} stopPropagation={true} display="flex" alignItems="center" justifyContent="center" flexShrink={0} width={20} height={20} borderRadius="sm" color="foreground" onClick={prop("item.onClick")} $when={[
        when("!item.disabled", { hover: { background: "hover" }, active: { background: "accent" } }),
        when("item.disabled", { color: "mutedForeground/50" }),
      ]}><icon name={prop("item.icon")} small /></div>
  </div>
);

// The resting trailing content leaves the layout while the actions show.
const GIVES_WAY = when("actions", { groupHover: { group: "item", display: "none" } });

// Whether the trailing content and the actions end the label's line: not
// on a stacked row with a second line, which they end instead.
const ON_LABEL_LINE = "!stacked|!sublabel";

const sublabel = <text text={prop("sublabel")} fontSize="type.sublabelSize" lineHeight="type.sublabelLine" truncate color={prop("sublabelTone", { map: TONES, else: "mutedForeground" })} />;

// A `<slot name="menu">` child is laid over the row from its top left
// corner, where a right-click menu opens at the pointer.
export const item: Definition = {
  props: {
    label: "",
    sublabel: null,
    sublabelTone: null,
    icon: null,
    // SVG markup drawn instead of the named icon (an agent's mark).
    iconSvg: null,
    iconTone: null,
    // A spinner instead of the icon (after a heading's label, an activity
    // indicator: something is at work).
    busy: false,
    // The icon shown while the pointer is on the mark, which is then a
    // button of its own calling `onIconClick` (a chat's check-off circle).
    hoverIcon: null,
    onIconClick: null,
    // A row that opens a page (a chat, Settings) takes the pointer cursor;
    // every other row keeps the arrow.
    opens: false,
    selected: false,
    // Raised while selected, as the sidebar's open chat is, and on the
    // raised look's transparent edge otherwise, so selecting moves nothing.
    lift: false,
    // A struck-through label, for finished items.
    strike: false,
    // A group's title row: a larger, bolder label.
    strong: false,
    // A section title above a list's rows: a small semibold label in `tone`,
    // written as given, its icon right after it and its children (a count)
    // at the end.
    heading: false,
    tone: null,
    // The second line under the label, with the trailing content and the
    // actions at its end, so the label runs the whole row.
    stacked: false,
    badge: null,
    // `[{ icon, tooltip?, disabled?, onClick }]`.
    actions: [],
  },
  template: (
    <div display="flex" flexDirection="column" justifyContent="center" position="relative" group="item" flexShrink={0} borderRadius="sm" paddingX="density.rowPaddingX" paddingY="density.rowPaddingY" minHeight="density.rowMinHeight" $when={[
          when("selected", { background: "accent" }),
          when("lift", { elevation: "none" }),
          when(["lift", "selected"], { elevation: "raised" }),
          when(["!selected", "onClick"], { hover: { background: "hover" } }),
          when("opens", { cursor: "pointer" }),
          when("heading", { paddingY: 3, minHeight: 0 }),
          when(["stacked", "sublabel", "label"], { gap: 2 }),
        ]}>
      <div display="flex" flexDirection="row" alignItems="center" gap="density.rowLeadGap" minWidth={0}>
          <div $if="slot.leading" {...MARK}><slot name="leading" /></div>
          <div $if={["!slot.leading", "!heading", "busy|icon|iconSvg"]} {...MARK} $when={[
                      when(["hoverIcon", "onIconClick"], {
                        group: "item-mark",
                        borderRadius: "full",
                        hover: { background: "hover" },
                        onClick: prop("onIconClick"),
                        stopPropagation: true,
                      }),
                    ]}>
              <div display="flex" groupHover={{ group: "item-mark", visibility: "hidden" }}>
                  <spinner $if="busy" />
                  <icon $if={["!busy", "icon|iconSvg"]} name={prop("icon", { else: "" })} svg={prop("iconSvg")} small tone={prop("iconTone", { else: "muted" })} $when={[when(["selected", "!iconTone"], { tone: "foreground" })]} />
                </div>
              <div $if={["hoverIcon", "onIconClick"]} position="absolute" top={0} right={0} bottom={0} left={0} display="flex" alignItems="center" justifyContent="center" visibility="hidden" groupHover={{ group: "item-mark", visibility: "visible" }}><icon name={prop("hoverIcon")} small tone="foreground" /></div>
            </div>
          <div $if={["label", "heading"]} display="flex" flexDirection="row" alignItems="center" gap="density.rowLeadGap - 2" {...FILL}>
              <div flexShrink={1} minWidth={0}>
                  <text text={prop("label")} fontSize="type.labelSize - 1" fontWeight={600} lineHeight="type.sublabelLine" color={prop("tone", { map: TONES, else: "mutedForeground" })} truncate />
                </div>
              {/* The spinner fills its box, while a mark's drawing stops 2px short of its own on each side: with this
                  room the spinner stands as far from the label, and from what follows it, as a mark does. */}
              <div $if="busy" display="flex" flexShrink={0} paddingX={2}><spinner activity /></div>
              <icon $if={["!busy", "icon|iconSvg"]} name={prop("icon", { else: "" })} svg={prop("iconSvg")} small tone={prop("iconTone", { else: "muted" })} />
            </div>
          <div $if={["label", "!heading"]} display="flex" flexDirection="column" {...FILL}>
              <text text={prop("label")} fontSize="type.labelSize" fontWeight={500} lineHeight="type.labelLine" color="mutedForeground" truncate $when={[
                            when("strong|selected", { color: "foreground" }),
                            when("strong", { fontSize: "type.strongSize", fontWeight: 600, lineHeight: "type.strongSize + 4" }),
                            when("strike", { textDecoration: "lineThrough" }),
                          ]} />
              <div $if={["sublabel", "!stacked"]} marginTop={2}>{sublabel}</div>
            </div>
          <div $if={["children", ON_LABEL_LINE]} display="flex" flexDirection="row" alignItems="center" gap={6} $when={[
                      when("label", { flexGrow: 0, flexShrink: 0, height: "type.labelLine" }),
                      when(["label", "strong"], { height: "type.strongSize + 4" }),
                      when("!label", FILL),
                      GIVES_WAY,
                    ]}><slot /></div>
          {actions("type.labelLine", ["label", ON_LABEL_LINE])}
          <div $if="badge" flexGrow={0} flexShrink={0} fontSize="type.sublabelSize + 0.44" color="mutedForeground"><text text={prop("badge")} /></div>
        </div>
      <div $if={["stacked", "sublabel", "label"]} display="flex" flexDirection="row" alignItems="center" minWidth={0} $when={[when("slot.leading|busy|icon|iconSvg", { paddingLeft: "density.rowLead + density.rowLeadGap" })]}>
          <div {...FILL}>{sublabel}</div>
          <div $if="children" display="flex" flexDirection="row" alignItems="center" gap={6} flexShrink={0} height="type.sublabelLine" marginLeft="density.rowLeadGap" $when={[GIVES_WAY]}><slot /></div>
          {actions("type.sublabelLine", [], { marginLeft: "density.rowLeadGap" })}
        </div>
      <div $if="slot.menu" position="absolute" top={0} left={0}><slot name="menu" /></div>
    </div>
  ),
};

Versions

VersionPublishedPlugin APISizePermissionsStatus
0.1.2latestNov 21, 2026>=5 <610.6 KB1 permissionListed
0.1.1Nov 16, 2026>=5 <610.2 KB1 permissionListed
0.1.0Nov 9, 2026>=5 <68.8 KB1 permissionListed

Reviews and comments

0 threads · 0 reviews

No comments yet.