A board

Items in one column per stage, moved by drag, the keys or a menu, each opening in a sheet

7 min readWritten for your agentMarkdown

This recipe draws ListPage arrangement="plain", the one arrangement Meadow draws: every control on the page's own lines, no filter row of its own.

Copy the file below whole (src/screens/board.tsx) beside frame.tsx (docs/screen-frame.md), add the frame block's row to the frame's NAVIGATION before Settings (node goop/agent/start.mjs board does it), and swap the sample stages and items for yours; keep the parts and their props. Use it for items a person moves forward through stages (work, deals, applicants, orders); the same items as rows are docs/screen-list.md. ListPage draws, one line under the other: the owners as view pills (a ToggleGroup, each counting the cards it would show), the heading (the open view's name and its count) with the search at its end, the New item button, then the Board, each stage a column with its count; a column's add button opens the CreateDialog with that stage chosen. A card moves by drag (on a touch screen, held still a moment first), by the keys (Space picks it up, the arrows carry it across stages and places, Space drops it, Escape puts it back; each step said aloud) or by its "Move to" menu (moveMenu); the counts follow. A press on a card (or Enter) opens it in a Sheet at the window's end, its card washed (selected): its stage and its owner are working pickers there (a new stage sends the card to that column's end), Escape or the close puts the focus back on the card. Light, dark, phone (one column at a time, snapping) and desktop are the parts' own: add no class for them.

Show the code331 lines
TSX
// src/screens/board.tsx: the board, one column a stage, a card opening in a sheet
import { useRef, useState } from 'react';
import { CreateDialog } from '@/components/goop/patterns/create-dialog';
import { ListPage } from '@/components/goop/patterns/list-page';
import { Board, type BoardColumnData, type BoardItem, moveBoardItem } from '@/components/ui/goop/board';
import { Button, ButtonIcon } from '@/components/ui/goop/button';
import { PageHeader, PageHeaderContent, PageHeaderTitle } from '@/components/ui/goop/page-header';
import { PersonSelect } from '@/components/ui/goop/person-select';
import { Properties, PropertyRow } from '@/components/ui/goop/properties';
import { SearchInput } from '@/components/ui/goop/search-input';
import {
  Select,
  SelectContent,
  SelectIcon,
  SelectItem,
  SelectTrigger,
  SelectValue,
} from '@/components/ui/goop/select';
import {
  Sheet,
  SheetBody,
  SheetContent,
  SheetDescription,
  SheetHeader,
  SheetTitle,
} from '@/components/ui/goop/sheet';
import { ToggleGroup, ToggleGroupItem } from '@/components/ui/goop/toggle-group';
import { ScreenFrame, ScreenTopBar } from './frame';

// ---- the sample data: swap it for yours
/** The stages, in the board's order: each one a column, its StatusMark before its name. */
const STAGES = [
  { id: 'planned', title: 'Planned', status: 'todo' },
  { id: 'started', title: 'In progress', status: 'in-progress' },
  { id: 'review', title: 'In review', status: 'in-review' },
  { id: 'done', title: 'Done', status: 'done' },
] as const satisfies readonly BoardColumnData[];
type Stage = (typeof STAGES)[number]['id'];
type Priority = 'urgent' | 'high' | 'medium' | 'low';
const PRIORITY_WORDS: Record<Priority, string> = { urgent: 'Urgent', high: 'High', medium: 'Medium', low: 'Low' };
const PEOPLE = [
  { id: 'teodora', name: 'Teodora Valk' },
  { id: 'bilal', name: 'Bilal Rashed' },
  { id: 'ngozi', name: 'Ngozi Ilori' },
  { id: 'dagny', name: 'Dagny Holm' },
];
const ME = 'teodora';
interface Item {
  id: string;
  /** Its stage: the board's `column`, so `moveBoardItem` saves a move as it is. */
  column: Stage;
  title: string;
  site: string;
  priority: Priority;
  /** The owner's id; '' for no one yet. */
  owner: string;
}
const ITEMS: Item[] = [
  {
    id: 'FW-131',
    column: 'planned',
    title: 'Mark out the hedge line',
    site: 'North field',
    priority: 'high',
    owner: 'ngozi',
  },
  { id: 'FW-129', column: 'planned', title: 'Order the hazel trays', site: 'Nursery', priority: 'medium', owner: '' },
  {
    id: 'FW-126',
    column: 'started',
    title: 'Clear the east culvert',
    site: 'East ditch',
    priority: 'urgent',
    owner: ME,
  },
  {
    id: 'FW-124',
    column: 'started',
    title: 'Lime the lower beds',
    site: 'Lower beds',
    priority: 'medium',
    owner: 'dagny',
  },
  {
    id: 'FW-122',
    column: 'review',
    title: 'Write up the soil results',
    site: 'Lower beds',
    priority: 'low',
    owner: ME,
  },
  {
    id: 'FW-115',
    column: 'done',
    title: 'Prune the old pear trees',
    site: 'Orchard',
    priority: 'medium',
    owner: 'bilal',
  },
];
const VIEWS = [
  { value: 'everyone', words: 'Everyone' },
  { value: 'mine', words: 'Yours' },
  { value: 'unassigned', words: 'Unassigned' },
] as const;
type View = (typeof VIEWS)[number]['value'];
const inView = (view: View, item: Item) => view === 'everyone' || item.owner === (view === 'mine' ? ME : '');
const nameOf = (id: string) => PEOPLE.find((person) => person.id === id)?.name;
const itemsWord = (n: number) => `${n} ${n === 1 ? 'item' : 'items'}`;

/** The heading's count after the view's name: the quiet grey, 4 px off. */
const HEADING_COUNT = 'ms-1 font-normal text-muted-foreground';

/** A card's control on the board, by its title: a card a new stage moved is drawn anew in its column. */
const cardNamed = (title: string) =>
  [...document.querySelectorAll<HTMLElement>('[data-slot="board-card-trigger"]')].find(
    (card) => document.getElementById(card.getAttribute('aria-labelledby') ?? '')?.textContent === title,
  );

/** An item as its card: its site on its second line, its priority's mark alone, its owner. */
function cardOf(item: Item): BoardItem {
  const name = nameOf(item.owner);
  return {
    id: item.id,
    column: item.column,
    title: item.title,
    description: item.site,
    chips: [{ label: `${PRIORITY_WORDS[item.priority]} priority`, priority: item.priority, iconOnly: true }],
    owner: name ? { name } : 'unassigned',
  };
}

export default function BoardScreen() {
  const [items, setItems] = useState(ITEMS);
  const [view, setView] = useState<View>('everyone');
  const [query, setQuery] = useState('');
  const [openId, setOpenId] = useState<string | null>(null);
  // the stage a create starts in (null: closed)
  const [creating, setCreating] = useState<string | null>(null);
  // the control a layer was opened from (and the card's title), where the focus goes back as it closes
  const opener = useRef<{ control: HTMLElement | null; card?: string }>({ control: null });
  const words = query.trim().toLowerCase();
  const found = items.filter((item) => `${item.title} ${item.site}`.toLowerCase().includes(words));
  const shown = found.filter((item) => inView(view, item));
  const open = items.find((item) => item.id === openId);
  const change = (id: string, next: Partial<Item>) =>
    setItems((all) => all.map((item) => (item.id === id ? { ...item, ...next } : item)));
  // the board counts its index among the cards it shows: put the item before the same card in the whole list
  const move = (id: string, column: string, index: number) =>
    setItems((all) => {
      const before = shown.filter((item) => item.column === column && item.id !== id)[index];
      const rest = all.filter((item) => item.column === column && item.id !== id);
      return moveBoardItem(all, id, column, before ? rest.findIndex((item) => item.id === before.id) : rest.length);
    });
  const remember = (card?: string) => {
    const control = document.activeElement instanceof HTMLElement ? document.activeElement : null;
    opener.current = card === undefined ? { control } : { control, card };
  };
  const backToOpener = (event: Event) => {
    const { control, card } = opener.current;
    const back = control?.isConnected ? control : card === undefined ? undefined : cardNamed(card);
    if (!back) return;
    event.preventDefault();
    back.focus();
  };
  return (
    <ScreenFrame current="/board">
      <ListPage
        arrangement="plain"
        aria-label="Work"
        header={<ScreenTopBar title="Board" />}
        views={
          <ToggleGroup
            type="single"
            fit
            aria-label="Owners"
            value={view}
            onValueChange={(next) => next && setView(next as View)}
          >
            {VIEWS.map((each) => (
              <ToggleGroupItem
                key={each.value}
                value={each.value}
                count={found.filter((item) => inView(each.value, item)).length}
              >
                {each.words}
              </ToggleGroupItem>
            ))}
          </ToggleGroup>
        }
        heading={
          <PageHeader>
            <PageHeaderContent>
              <PageHeaderTitle asChild>
                <h1>
                  {VIEWS.find((each) => each.value === view)?.words}
                  <span className={HEADING_COUNT}>{shown.length}</span>
                </h1>
              </PageHeaderTitle>
            </PageHeaderContent>
          </PageHeader>
        }
        filters={
          <SearchInput
            label="Search items"
            placeholder="Search"
            value={query}
            onChange={(event) => setQuery(event.currentTarget.value)}
          />
        }
        primaryAction={
          <Button
            onClick={() => {
              remember();
              setCreating(STAGES[0].id);
            }}
          >
            <ButtonIcon icon="plus" />
            New item
          </Button>
        }
        collection={
          <Board
            aria-label="Work by stage"
            columns={STAGES}
            items={shown.map(cardOf)}
            countLabel={itemsWord}
            empty="No items"
            onMove={move}
            moveMenu
            selected={openId}
            onItemSelect={(card) => {
              remember(card.title);
              setOpenId(card.id === openId ? null : card.id);
            }}
            onAdd={(stage) => {
              remember();
              setCreating(stage.id);
            }}
            addLabel={(stage) => `New item in ${stage.title}`}
          />
        }
      />
      <Sheet open={open !== undefined} onOpenChange={(next) => next || setOpenId(null)}>
        <SheetContent onCloseAutoFocus={backToOpener}>
          <SheetHeader>
            <SheetTitle>{open?.title}</SheetTitle>
            <SheetDescription>{open ? `${open.id}, ${open.site}` : null}</SheetDescription>
          </SheetHeader>
          <SheetBody>
            {open ? (
              <Properties aria-label="Item details">
                <PropertyRow label="Stage" icon="circle-dotted">
                  {(control) => (
                    <Select
                      value={open.column}
                      onValueChange={(next) => setItems((all) => moveBoardItem(all, open.id, next, all.length))}
                    >
                      <SelectTrigger {...control} variant="ghost">
                        <SelectValue />
                        <SelectIcon />
                      </SelectTrigger>
                      <SelectContent searchLabel="Stage" search={false}>
                        {STAGES.map((stage) => (
                          <SelectItem key={stage.id} value={stage.id}>
                            {stage.title}
                          </SelectItem>
                        ))}
                      </SelectContent>
                    </Select>
                  )}
                </PropertyRow>
                <PropertyRow label="Owner" icon="tabler-outline:user-circle">
                  <PersonSelect
                    people={PEOPLE}
                    optional
                    value={open.owner}
                    onValueChange={(next) => change(open.id, { owner: next })}
                  />
                </PropertyRow>
                <PropertyRow label="Priority" icon="antenna-bars-3">
                  {PRIORITY_WORDS[open.priority]}
                </PropertyRow>
              </Properties>
            ) : null}
          </SheetBody>
        </SheetContent>
      </Sheet>
      <CreateDialog
        open={creating !== null}
        onOpenChange={(next) => next || setCreating(null)}
        heading="New item"
        titleLabel="Item name"
        titlePlaceholder="Item name"
        summaryPlaceholder="Site"
        submitLabel="Create item"
        properties={[
          {
            name: 'stage',
            label: 'Stage',
            icon: 'circle-dotted',
            options: STAGES.map((stage) => ({ value: stage.id, label: stage.title, status: stage.status })),
          },
          {
            kind: 'person',
            name: 'owner',
            label: 'Owner',
            options: PEOPLE.map((person) => ({ value: person.id, label: person.name })),
            optional: true,
          },
        ]}
        defaultValues={{ properties: { stage: creating ?? STAGES[0].id } }}
        onCreate={(values) => {
          const number = 1 + Math.max(0, ...items.map((item) => Number(item.id.replace(/\D/g, '')) || 0));
          setItems((all) => [
            ...all,
            {
              id: `FW-${number}`,
              column: (values.properties.stage || STAGES[0].id) as Stage,
              title: values.title,
              site: values.summary,
              priority: 'medium',
              owner: values.properties.owner ?? '',
            },
          ]);
        }}
        onCloseAutoFocus={backToOpener}
      />
    </ScreenFrame>
  );
}

`tsx frame { words: 'Board', path: '/board', icon: 'columns-3' },

Code

Where would you like to start?

Free · now

The Goop plugin

A design system for your AI coding agent, so screen ten matches screen one.

/plugin marketplace add goop-so/skillsthen /plugin install goop@goopCodex, Cursor, ChatGPT, the Claude app and more: Connect Goop
FreePro

The components

Every part live, with its props, its keys and what an agent sees. Whole page and app templates, working with sample data.