# Workspace Overview

The parts of the opportunity and contact workspace's Overview: a section head with its count, View all and action; task rows; the overflow link under a cut-short list; and note cards.

- Beta: ready to use; its API can still change in a minor release.
- Category: Patterns · Workspace & pipeline

```tsx
import { WorkspaceSectionHeader, WorkspaceTaskRow, WorkspaceOverflowLink, WorkspaceNoteCard } from "@leap-crm/design-system";
```

## Best practices

- Do: Head each Overview section with `WorkspaceSectionHeader`, with its `count`, `onViewAll` and `action`, like Add or Log. Set `headingLevel` to fit the page's outline.
- Do: Render `WorkspaceOverflowLink` only when a list is cut short, with what's hidden, like “Showing 3 of 5 tasks”.
- Do: Word a task's `due` so it reads without colour, like “Overdue by 2 days”. `urgent` only turns it red.
- Do: Pass `onPinnedChange` to a `WorkspaceNoteCard` only where the reader can pin notes. Without it the pin isn't shown.
- Don't: Use `WorkspaceTaskRow` where tasks edit in place or move when ticked. Use `TaskList`, which sorts by due date and moves ticked tasks to Done.

## Keyboard

| Keys | What they do |
| --- | --- |
| Tab | Moves through its links, buttons and checkboxes in order. |
| Enter | Follows the focused link. |
| Enter, Space | Presses the focused button. |
| Space | Ticks the focused checkbox. |

## Related

- [Workspace Table](./workspace-table.md)
- [Section Header](./section-header.md)
- [Task list](./task-list.md)
- [Note grid](./note-grid.md)

## Examples

What the examples import:

```tsx
import { EllipsisVertical, NotebookPen, Phone, SquareCheckBig } from "lucide-react";
import { useState } from "react";
import { IconButton, WorkspaceNoteCard, WorkspaceOverflowLink, WorkspaceSectionHeader, WorkspaceTaskRow } from "@leap-crm/design-system";
```

Scaffolding the examples call. It lives in the docs page, not in the library:

```tsx
const noop = () => undefined;

const more = (label: string) => (
  <IconButton size="xs" icon={<EllipsisVertical />} aria-label={label} />
);

function Tasks() {
  const [done, setDone] = useState<string[]>([]);
  const tasks = [
    {
      id: "1",
      title: "Order section 32 vendor statement",
      priority: "medium" as const,
      due: "Due in 6 days",
      assignee: { name: "Sam Evans", initials: "SE" },
    },
    {
      id: "2",
      title: "Chase the bank for the signed loan documents before settlement",
      priority: "urgent" as const,
      due: "Overdue by 2 days",
      urgent: true,
      assignee: null,
    },
    {
      id: "3",
      title: "Book the settlement room",
      priority: "low" as const,
      due: "Due today",
      urgent: true,
      assignee: { name: "Mia Grant", initials: "MG" },
    },
  ];
  return (
    <div className="flex w-full max-w-3xl flex-col gap-1">
      <WorkspaceSectionHeader
        icon={<SquareCheckBig />}
        title="Open tasks"
        count={5}
        onViewAll={noop}
        action={{ label: "Add", onClick: noop }}
      />
      <div className="border-neutral-border rounded-md border">
        {tasks.map(task => (
          <WorkspaceTaskRow
            key={task.id}
            {...task}
            done={done.includes(task.id)}
            onDoneChange={checked =>
              setDone(ids =>
                checked ? [...ids, task.id] : ids.filter(id => id !== task.id),
              )
            }
            actions={more(`More actions for ${task.title}`)}
          />
        ))}
      </div>
      <WorkspaceOverflowLink onClick={noop}>
        Showing 3 of 5 tasks
      </WorkspaceOverflowLink>
    </div>
  );
}

function Note() {
  const [pinned, setPinned] = useState(false);
  return (
    <div className="w-full max-w-3xl">
      <WorkspaceNoteCard
        title="Vendor wants a 60-day settlement"
        body="Agent called: the vendor prefers 60 days and will take 45 with a 10% deposit. Rose is fine with either; confirm with her lender before we reply. The bank has asked for the valuation report again, and the strata search is still outstanding."
        source={{ icon: <Phone />, label: "Phone call" }}
        author={{ name: "Sam Evans", initials: "SE" }}
        date="2 days ago"
        pinned={pinned}
        onPinnedChange={setPinned}
        actions={more("More actions for this note")}
      />
    </div>
  );
}
```

### Tasks section

The section head (count above 0, View all, Add), task rows in a bordered list with the last rule dropped, and the overflow link. Tick a task to mark it done. Overdue and due-today dates turn red; an unassigned task shows the person icon. A long title wraps to three lines, then clips and shows in full on hover.

```tsx
<Tasks />
```

### Section heads

No count at 0; View all only when the list can open; the action names what it adds.

```tsx
<div className="flex w-full max-w-3xl flex-col gap-2">
  <WorkspaceSectionHeader
    icon={<NotebookPen />}
    title="Notes"
    onViewAll={noop}
    action={{ label: "Add", onClick: noop }}
  />
  <WorkspaceSectionHeader
    icon={<Phone />}
    title="Interactions"
    count={12}
    onViewAll={noop}
    action={{ label: "Log", onClick: noop }}
  />
</div>
```

### Note card

160 px: the source pill, the title, two lines of the note (clipped, in full on hover), then the author, date, pin and menu. Press the pin to pin the note.

```tsx
<Note />
```

## Props

### WorkspaceSectionHeader

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `icon` (required) | `ReactNode` |  | A 16 px icon for the section, like a checked square for tasks. |
| `title` (required) | `string` |  | The section's name, like "Tasks". |
| `count` | `number` | `0` | How many there are. The count shows only above 0. |
| `onViewAll` | `() => void` |  | Opens the whole list. Shows "View all" as a small link. |
| `action` | `{ label: string; onClick: () => void; icon?: ReactNode }` |  | The section's action, as an outline button with a +, like Add, Log or Upload. |
| `headingLevel` | `"h2" \| "h3" \| "h4"` | `"h3"` | The heading level in its page. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |

### WorkspaceTaskRow

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `title` (required) | `string` |  | The task. |
| `done` | `boolean` | `false` | Whether it's done: the box is ticked and the title struck through. |
| `onDoneChange` | `(done: boolean) => void` |  | Runs when the box is ticked or cleared. |
| `priority` | `"low" \| "medium" \| "high" \| "urgent" \| "critical"` |  | Shows the priority bars when set. |
| `due` | `string` |  | When it's due, already worded, like "Due in 6 days". |
| `urgent` | `boolean` | `false` | Overdue or due today: the due date turns red. |
| `assignee` | `Person \| null` |  | Who it's assigned to. Unassigned shows the person icon. |
| `actions` | `ReactNode` |  | The row's actions, like a ⋯ menu, always visible. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |

### WorkspaceOverflowLink

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `children` (required) | `ReactNode` |  | What's hidden, like "Showing 3 of 5 tasks". |
| `onClick` (required) | `() => void` |  | Opens the whole list. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |

### WorkspaceNoteCard

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `title` (required) | `string` |  | The note's first line. |
| `body` (required) | `string` |  | The note, clipped to two lines; the rest shows on hover. |
| `source` | `{ icon: ReactNode; label: string }` |  | What the note came from, like "Phone call", as a small pill above the title. No date: the footer shows it. |
| `author` (required) | `{ name: string; initials?: string \| null; image?: string \| null; }` |  | Who wrote it: name, initials and image. |
| `date` (required) | `string` |  | When it was written, already worded, like "2 days ago". |
| `pinned` | `boolean` | `false` | Pinned notes stay at the top. |
| `onPinnedChange` | `(pinned: boolean) => void` |  | Runs when the pin is pressed. Without it the pin isn't shown. |
| `actions` | `ReactNode` |  | The note's other actions, like a ⋯ menu. |
| `className` | `string` |  | Classes added to the root element, merged with its own. Tokens only. |
