Records as cards in columns that you drag between.
j and k move between cards, x selects, Space peeks, Enter opens. Mod+Left or Right moves the card to the next column.
Todo
4In Progress
3 / 3In Review
3Done
2- JJDown arrow↓
- Next record
- KKUp arrow↑
- Previous record
- Shift J⇧JShift K⇧K
- Extend the selection
- XX
- Select or unselect
- SpaceSpace
- Peek at the record; Escape closes it
- Return↵
- Open the record
- SS
- Change Status on the focused or selected records
- PP
- Change Priority on the focused or selected records
- AA
- Change Assignee on the focused or selected records
- EscapeEsc
- Clear the selection
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { Outcome } from "./ui/uicontext/components/domain/Outcome.ts"import { View, viewOf } from "./ui/uicontext/components/domain/Record.ts"import { Board } from "./ui/uicontext/components/kit/Board.ts"import { Item, Value } from "./ui/uicontext/components/kit/Property.ts"import { collectionKeymap, KeymapLegend } from "./ui/uicontext/components/kit/RecordKeys.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { applyEdit, issueFields, issues, issueShortcuts } from "./issues.ts"const styles = stylex.create({ stack: { display: "grid", gridTemplateColumns: "minmax(0, 1fr)", gap: 20 }, frame: { blockSize: 460, inlineSize: "100%" },})const Message = UiSchema.TaggedEnum({ RequestedEditIssue: { request: Schema.String, item: Schema.String, key: Schema.String, value: Value }, RequestedReorderIssue: { item: Schema.String, before: Schema.NullOr(Schema.String) }, RequestedNewIssue: { group: Schema.optional(Schema.String), title: Schema.optional(Schema.String) }, RequestedIssueView: { view: View },})/** Moves `item` before `before` in the app's order, or to the end. */const reorder = (records: ReadonlyArray<Item>, item: string, before: string | null) => { const moving = records.find((r) => r.id === item) if (moving === undefined) return records const rest = records.filter((r) => r.id !== item) const at = before === null ? rest.length : rest.findIndex((r) => r.id === before) return [...rest.slice(0, at < 0 ? rest.length : at), moving, ...rest.slice(at < 0 ? rest.length : at)]}export const IssueBoard = Html.component({ name: "IssueBoard", model: Schema.Struct({ records: Schema.Array(Item), outcomes: Schema.Array(Outcome), view: View, next: Schema.Number }), message: Message,}).make({ init: () => ({ records: issues, outcomes: [], view: viewOf({ groupBy: "status" }, "board"), next: 145 }), update: { // A move is an edit of the column's field, and so is a pick from s, p or a on a focused card. // The app decides: this one won't close an issue nobody owns, and the card goes back. RequestedEditIssue: ($, { request, item, key, value }) => { const record = $.model.records.find((r) => r.id === item) if (key === "status" && value === "done" && record?.values["assignee"] === null) { return $.evolve({ outcomes: (o) => [...o.slice(-10), { _tag: "Refused", request, reason: "Assign someone before closing it." }], }) } return $.evolve({ records: (records) => records.map((r) => (r.id === item ? applyEdit(r, key, value) : r)), outcomes: (o) => [...o.slice(-10), { _tag: "Accepted", request }], }) }, RequestedReorderIssue: ($, { item, before }) => $.evolve({ records: (records) => reorder(records, item, before) }), // quick add: the title typed in the column, in that column's status RequestedNewIssue: ($, { group, title }) => $.evolve({ next: (n) => n + 1, records: (records) => [ ...records, { id: `eng-${$.model.next}`, prefix: `ENG-${$.model.next}`, title: title ?? "Untitled issue", values: { status: group ?? "todo", priority: null, assignee: null, labels: [] }, }, ], }), RequestedIssueView: ($, { view }) => $.evolve({ view }), }, view: (h, { records, outcomes, view }) => h.div.attrs(sx(styles.stack)).children( h.div.attrs(sx(styles.frame)).children( Board(h, { props: { label: "Issues", records, fields: issueFields, view, card: [{ key: "assignee", at: "corner" }, { key: "priority", compact: true }, { key: "labels" }, { key: "due" }], // single keys open a field's picker on the focused card (or every selected one) shortcuts: issueShortcuts, create: "New issue", quickAdd: true, reorderable: true, // a team that keeps three things in flight limits: { doing: 3 }, outcomes, }, onEmit: { RequestedEdit: (edit) => Message.RequestedEditIssue(edit), RequestedReorder: ({ item, before }) => Message.RequestedReorderIssue({ item, before }), RequestedCreate: ({ group, title }) => Message.RequestedNewIssue({ ...(group === undefined ? {} : { group }), ...(title === undefined ? {} : { title }) }), RequestedView: ({ view }) => Message.RequestedIssueView({ view }), RequestedOpen: () => undefined, RequestedAction: () => undefined, Selected: () => undefined, }, }), ), KeymapLegend(h, collectionKeymap(issueShortcuts), "Board keyboard shortcuts"), ),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/boardUsage
import type { Outcome } from "./ui/uicontext/components/domain/Outcome.ts"import { type Item, type Property, Value } from "./ui/uicontext/components/domain/Record.ts"import { Board } from "./ui/uicontext/components/kit/Board.ts"const Message = UiSchema.TaggedEnum({ RequestedEditTask: { request: Schema.String, item: Schema.String, key: Schema.String, value: Value }, RequestedNewTask: { status: Schema.String },})export const TaskBoard = ( h: Html.H<typeof Message.Type>, tasks: ReadonlyArray<Item>, fields: ReadonlyArray<Property>, outcomes: ReadonlyArray<Outcome>,) => Board(h, { props: { label: "Tasks", records: tasks, fields, view: { groupBy: "status" }, create: "New task", outcomes }, onEmit: { // dropping a card in another column is an edit of `status` RequestedEdit: (edit) => Message.RequestedEditTask(edit), RequestedCreate: ({ group }) => Message.RequestedNewTask({ status: group ?? "" }), RequestedView: () => undefined, RequestedReorder: () => undefined, RequestedOpen: () => undefined, RequestedAction: () => undefined, Selected: () => undefined, }, })Examples
By assignee
Columns from a person field. Drag a card to reassign the issue.
j and k move between cards, x selects, Space peeks, Enter opens. Mod+Left or Right moves the card to the next column.
Ada Lovelace
2Grace Hopper
3Alan Turing
2Scout
2No assignee
1import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { Outcome } from "./ui/uicontext/components/domain/Outcome.ts"import { viewOf } from "./ui/uicontext/components/domain/Record.ts"import { Board } from "./ui/uicontext/components/kit/Board.ts"import { Item, Value } from "./ui/uicontext/components/kit/Property.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { applyEdit, issueFields, issues } from "./issues.ts"// Any choice or person field can make the columns. Grouped by assignee, dragging a card hands the// issue to someone else, and "No assignee" collects the unowned ones.const styles = stylex.create({ frame: { blockSize: 440, inlineSize: "100%" },})const Message = UiSchema.TaggedEnum({ RequestedEditIssue: { request: Schema.String, item: Schema.String, key: Schema.String, value: Value },})export const WorkloadBoard = Html.component({ name: "WorkloadBoard", model: Schema.Struct({ records: Schema.Array(Item), outcomes: Schema.Array(Outcome) }), message: Message,}).make({ init: () => ({ records: issues.filter((issue) => issue.values["status"] !== "done"), outcomes: [] }), update: { RequestedEditIssue: ($, { request, item, key, value }) => $.evolve({ records: (records) => records.map((r) => (r.id === item ? applyEdit(r, key, value) : r)), outcomes: (outcomes) => [...outcomes.slice(-10), { _tag: "Accepted", request }], }), }, view: (h, { records, outcomes }) => h.div.attrs(sx(styles.frame)).children( Board(h, { props: { label: "Open issues by assignee", records, fields: issueFields, view: viewOf({ groupBy: "assignee", sort: [{ key: "priority", direction: "asc" }] }, "board"), card: [{ key: "status", compact: true }, { key: "priority", compact: true }, { key: "estimate" }], showEmptyGroup: true, selectable: false, outcomes, }, onEmit: { RequestedEdit: (edit) => Message.RequestedEditIssue(edit), RequestedView: () => undefined, RequestedReorder: () => undefined, RequestedCreate: () => undefined, RequestedOpen: () => undefined, RequestedAction: () => undefined, Selected: () => undefined, }, }), ),})Read only
A board people can view but not change, with the Done column left out.
j and k move between cards, Space peeks, Enter opens.
Todo
4In Progress
3In Review
3import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { viewOf } from "./ui/uicontext/components/domain/Record.ts"import { Board } from "./ui/uicontext/components/kit/Board.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { issueFields, issues } from "./issues.ts"// A shared board for people who can look but not change: `readOnly` turns off dragging and editing// and says why, and `hiddenColumns` leaves the finished work out.const styles = stylex.create({ frame: { blockSize: 400, inlineSize: "100%" },})export const SharedBoard = Html.component({ name: "SharedBoard", model: Schema.Struct({}), message: Schema.Never,}).make({ init: () => ({}), update: ($) => $.model, view: (h) => h.div.attrs(sx(styles.frame)).children( Board(h, { props: { label: "Roadmap", records: issues, fields: issueFields, view: viewOf({ groupBy: "status" }, "board"), card: [{ key: "assignee", at: "corner" }, { key: "labels" }], hiddenColumns: ["done"], readOnly: "You can view this board, not edit it.", }, onEmit: { RequestedEdit: () => undefined, RequestedView: () => undefined, RequestedReorder: () => undefined, RequestedCreate: () => undefined, RequestedOpen: () => undefined, RequestedAction: () => undefined, Selected: () => undefined, }, }), ),})API reference
Props
| Name | Type | Default | Description |
|---|---|---|---|
labelrequired | string | — | The board's accessible name: "Issues" |
agentId | string | board:<label> | This board's id for agents, unique on the page; board:<label> by default |
recordsrequired | Item[] | — | The records to show, in the order the app gives them |
fieldsrequired | Property[] | — | The fields the records share: their kinds, choices and formats |
view | ViewInput | — | How the records show: groupBy is the field whose choices are the columns (the first select field by default), sort the order within a column, filter which cards show, hidden the fields kept off the cards |
card | BoardCardProperty[] | — | What each card shows besides its title; the view's other visible fields, in the footer, by default |
reorderable | boolean | — | Cards can be put in order within a column (Alt+Arrow, or a drop between cards) |
showEmptyGroup | boolean | — | Show the column for records with no value ("No assignee") even when it has none; by default, when the field names its empty value |
hiddenColumns | string[] | — | Columns to leave out, by value: "canceled" |
create | string | — | A "+" on each column header, emitting RequestedCreate with the column's value |
quickAdd | boolean | — | The "+" opens a title field at the top of the column instead: Enter asks for a record with that title (RequestedCreate with group and title) and leaves the field open for the next one |
limits | Record<string, number> | — | How many cards a column should hold, by its value: { doing: 3 }. A column over its limit says so |
selectable | boolean | — | Show a checkbox on each record, and report the selection |
actions | ItemAction[] | — | Actions offered on each record, such as archive or delete |
shortcuts | FieldShortcut[] | — | Single keys that open a field's picker on the focused card: { key: "s", field: "status" } |
readOnly | string | — | Why cards can't be moved here: "You can view this board, not edit it" |
loading | boolean | — | Show placeholder rows while the records load |
outcomes | Outcome[] | — | How each requested change settled: pending, accepted, or refused with a reason |
notice | string | null | — | A message about the whole view, such as a failed save |
locale | string | — | The locale numbers and dates are formatted in; the browser's by default |
Events
| Event | Payload | Description |
|---|---|---|
RequestedEdit | { request: string; item: string; key: string; value: Value } | A value the person changed; answer through outcomes with the same request |
RequestedOpen | { item: string } | Open the record's page |
RequestedCreate | { group?: string; title?: string; values?: Record<string, Value> } | A new record, in the group it was added from ("" for the empty group) |
RequestedAction | { action: string; items: string[] } | One of the view's actions, on these records |
RequestedReorder | { item: string; before: string | null } | Move item before before, or last when it's null |
RequestedView | { view: View } | The person changed how the view shows records (its sort, grouping, widths); pass it back as view |
Selected | { items: string[] } | The selection changed |
Agent actions
| Action | Description |
|---|---|
MovedCard | Move a card to the column with value to ("" is the empty column); before: a card id in that column, or null for last |
CommittedEdit | Set one field of one card, as on its page: value as the field's kind, or null to clear |
ActivatedCard | Open a card |
ClickedPeek | Peek at a card: its fields in a side sheet, without leaving the board |
RequestedSelection | Select cards by id, replacing the selection ([] clears it) |
ClickedAction | Run one of the board's actions on the selected cards; destructive ones name the selection as the target |
ClickedCreate | Start a new card in the column with this value |
Accessibility
- Each card is a button. Mod+Left and Mod+Right move it between columns; Alt+Up and Alt+Down reorder it in a column.
- Every move is announced, and a refused move puts the card back with the reason.
- A locked card says why when it has focus or is tapped, and screen readers read the reason as its description.