# Colour picker

> Ten project colours, each one swatch with two jobs: the colour that acts and its lighter tint that is merely lit.

Source: https://kwark.space/designSystem/components/colour-picker

## Usage

### What it is
In *New project* and *Edit project* a story can take a colour (`PRESET_COLORS`): Red, Orange, Amber, Lime, Emerald, Teal, Cyan, Blue, Violet, Pink. Each swatch is split corner to corner: the colour itself (for what acts: buttons, the current row) and its lighter tint (for what is lit: text, ticks, borders on dark). The tints keep hue and saturation and only rise in lightness, so the pair reads as one colour. **Choose later** clears it; the project then wears the app’s own brown.

### When to use
- Choosing a project’s accent. That is the only colour a person picks for the interface.

### When not to use
- For free colour (a picker with a spectrum or hex field) in the interface. A free picker cannot guarantee the contrast the pairs were chosen for.
- For writing rooms (they are designed, not picked) or story colours of characters (those are content).

### Writing
The swatches are named by their colour words. The heading is *Project colour*.

## Style

### Anatomy

1. **Swatch**: 32px circle, 2px border, transparent until chosen.
2. **Split**: the top-left half `--k-theme-*`, the bottom-right half `--k-theme-*-light`.
3. **Chosen**: the 2px border in `--k-text` (white in the app’s dark theme).
4. **Grid**: `repeat(auto-fit, minmax(2rem, 1fr))`, 12px gaps, items centred.

### Tokens

| Token | Light | Dark |
|---|---|---|
| `--k-text` | #0f172a | #e3e3e3 |
| `--k-focus` | #0f172a | #f4f4f5 |
| `--k-radius-pill` | 999px |  |
| `--k-theme-red` | #F0444B |  |
| `--k-theme-red-light` | #F68E92 |  |
| `--k-theme-orange` | #F97332 |  |
| `--k-theme-blue` | #3D7FEA |  |

## Code

### React

In the Kwark app: `import { ProjectThemePalette } from '@/shared/ProjectThemePalette'`.

```tsx
<ProjectThemePalette accentColor={accent} onSelect={theme => setAccent(theme.border)} />
```

| Prop | Type | Notes |
|---|---|---|
| `accentColor` | `string \| null` | the chosen border colour, or null for the app’s own |
| `onSelect` | `(theme) => void` | receives { label, value, border, light, text } |

### HTML and CSS

Works anywhere with `kwark.css`.

```html
<div class="kw-palette" role="group" aria-label="Project theme color">
  <button class="kw-palette__swatch" type="button" style="--kw-sw:var(--k-theme-red);--kw-sw-light:var(--k-theme-red-light)" aria-label="Red" aria-pressed="false"><i></i></button>
  <button class="kw-palette__swatch" type="button" style="--kw-sw:var(--k-theme-orange);--kw-sw-light:var(--k-theme-orange-light)" aria-label="Orange" aria-pressed="true"><i></i></button>
  <button class="kw-palette__swatch" type="button" style="--kw-sw:var(--k-theme-amber);--kw-sw-light:var(--k-theme-amber-light)" aria-label="Amber" aria-pressed="false"><i></i></button>
  <button class="kw-palette__swatch" type="button" style="--kw-sw:var(--k-theme-lime);--kw-sw-light:var(--k-theme-lime-light)" aria-label="Lime" aria-pressed="false"><i></i></button>
  <button class="kw-palette__swatch" type="button" style="--kw-sw:var(--k-theme-emerald);--kw-sw-light:var(--k-theme-emerald-light)" aria-label="Emerald" aria-pressed="false"><i></i></button>
  <button class="kw-palette__swatch" type="button" style="--kw-sw:var(--k-theme-teal);--kw-sw-light:var(--k-theme-teal-light)" aria-label="Teal" aria-pressed="false"><i></i></button>
  <button class="kw-palette__swatch" type="button" style="--kw-sw:var(--k-theme-cyan);--kw-sw-light:var(--k-theme-cyan-light)" aria-label="Cyan" aria-pressed="false"><i></i></button>
  <button class="kw-palette__swatch" type="button" style="--kw-sw:var(--k-theme-blue);--kw-sw-light:var(--k-theme-blue-light)" aria-label="Blue" aria-pressed="false"><i></i></button>
  <button class="kw-palette__swatch" type="button" style="--kw-sw:var(--k-theme-violet);--kw-sw-light:var(--k-theme-violet-light)" aria-label="Violet" aria-pressed="false"><i></i></button>
  <button class="kw-palette__swatch" type="button" style="--kw-sw:var(--k-theme-pink);--kw-sw-light:var(--k-theme-pink-light)" aria-label="Pink" aria-pressed="false"><i></i></button>
</div>
<button class="kw-button kw-button--sm kw-button--quiet" type="button">Choose later</button>
```

## Accessibility

### Keyboard
| Key | Does |
|---|---|
| Tab | Moves through the swatches. |
| Enter / Space | Chooses the colour. |

### ARIA
- `role="group" aria-label="Project theme color"`; each swatch is a button named by its colour with `aria-pressed`.
- The chosen state is the border, not the colour, so it reads without colour vision. The app scales a swatch on hover; under reduced motion it must not.

## For agents

### Rules

- **Must** offer only the ten preset pairs; never a free colour field for interface accent.
- **Always** apply the pair together: the colour for actions, the tint for lit text and ticks.
- **Must** keep *Choose later* so a project can return to the app’s own colour.
- **Never** let a project colour reach the writing rooms.

### AI readiness test

**Task:** Let a producer give each department its own colour in the budget.

**Give the agent:** This page, the Colour foundation.

**Constraint:** Departments already have tone dots in the module menu.

**A reliable answer:**
- Notes the picker is for the project accent only
- Reuses existing department tones instead of a new picker
- Asks before adding a second colour system
