# Canvas design panel

Design mode's controls for the elements chosen on a frame: layout, spacing, type, surface and words, with the edits counted, undone and handed over.

Live variants: https://design.arcadia.is/components/canvas-design-panel

```tsx
import { CanvasDesignPanel } from "@arcadia/ui";
```

A Save button's values as its page reported them. Change one, undo it, then Finish or Discard.

```tsx
import { useState } from "react";
import { CanvasPanel, CanvasDesignPanel, Facts } from "@arcadia/ui";

function Editing() {
  const { edits, setEdits, edit } = useDesign([SAVE]);
  const [tool, setTool] = useState<CanvasTool>("design");
  const [handed, setHanded] = useState("Nothing yet");
  return (
    <div {...stylex.props(styles.stack)}>
      <div {...stylex.props(styles.stage, styles.editingStage)}>
        <CanvasPanel
          label="Tools"
          defaultPlace={{ side: "left", anchor: "top" }}
          tools={["select", "design"]}
          tool={tool}
          onToolChange={setTool}
          toolBodies={{
            design: (
              <CanvasDesignPanel
                selection={[SAVE]}
                session={edits}
                onEdit={edit}
                onUndo={() => setEdits(undoEdits(edits))}
                onRedo={() => setEdits(redoEdits(edits))}
                onDiscard={() => setEdits(discardAll(edits))}
                onFinish={() => { setHanded(toCommentPayload(edits).words); setEdits(discardAll(edits)); }}
              />
            ),
          }}
        >
          <Facts items={[{ label: "Handed over", value: handed }]} />
        </CanvasPanel>
      </div>
      <p {...stylex.props(styles.preview)}>{previewLine(edits)}</p>
    </div>
  );
}
```

## Accessibility

The panel is a region named Design. Each group has a heading, each field is named by its row's label, and the token a value is stands as text beside that label. The count of edits is a polite live line, so an undo is heard, and a reason for a failure is an alert. Undo, Redo, Discard and Finish are buttons, and Finish is busy while the edits are applied.

- Tab: Moves through the fields, then the bar
- Command Z, Shift Command Z: On a plane in Design mode with the focus on the plane, undoes and redoes the edits

## API reference

### CanvasDesignPanel

- `selection` (`readonly CanvasDesignAnchor[]`, required): The elements the controls read and change: the first answers, and a change reaches every one of them.
- `session` (`CanvasDesignSession`, required)
- `status` (`CanvasDesignStatus`, default `"idle"`): Applying holds Finish busy; failed shows why under the bar.
- `problem` (`string`)
- `label` (`string`, default `"Design"`): Its name for assistive technology, in the words of the product ("Design").
- `onEdit` (`(target: CanvasDesignTarget, value: string | null) => void`): A change of one property: null returns it to the value of the document.
- `onUndo` (`() => void`)
- `onRedo` (`() => void`)
- `onDiscard` (`() => void`): Every pending edit dropped. The host asks first where the work is worth a question; the part only names the act.
- `onFinish` (`() => void`)
- `rootStyle` (`RootStyle`): A component's typed override prop: `Layout` and its documented knobs, each the references it takes or another kit knob of its kind; anything else is a type error at the call site (STYLEX.md).
