# Account menu

> Who you are, whose work you are looking at, and whether your work is safe: the account panel and the workspace switcher.

Source: https://kwark.space/designSystem/components/account-menu

## Usage

### What it is
Two real pieces. The **workspace switcher** on Home (*My stories ▾*, or a production house’s logo and name) chooses whose shelf you see. The **account panel** opens from the avatar: name and email, *Display name*, *Change picture*, the cloud state in Kwark’s calm words, and *Sign out*. On a phone the avatar is the *Account* item of the floating dial (Decision 0016).

### The sync line is the important part
It tells the state first (Decision 0013): **Safe**, **Safe here, waiting to reach the cloud**, or **Safe on this device (offline by choice)**. When something is queued it offers **Retry** and **Backup**; the reason appears under it in small text, because "sync failed" gives nobody anything to act on. A 10px dot in `--k-warn` on the closed avatar says there is something to read.

### When to use
- Once per app, in the corner (desktop) or in the dial (phone).

### When not to use
- For project settings or sharing: those belong to the project (*Share*, *Edit project*).

### Writing
*Sign out*, not *Log out*. *Change picture*, *Add picture*. Never *Sync failed*; say what is safe and what to do.

## Style

### Anatomy

1. **Panel**: 288px, `--k-surface`, 1px `--k-line`, 16px padding, 16px corners in the app (`rounded-2xl`; the system’s sheet radius is 14px), `--k-shadow-pop`.
2. **Identity**: avatar 40px, name 14px Poppins 600, email 12px `--k-text-2`, Close 14px glyph.
3. **Sync block**: 12px top padding, 1px `--k-line` above, status 12px `--k-text-2` with a cloud-off glyph 14px, small actions 6px apart.
4. **Switcher**: 32px pill (44px on touch), 1px `--k-line`, 0 12px, 14px Poppins 500, 18px logo or a glyph in `--k-accent-soft`, chevron 14px.
5. **Alert dot**: 10px, 2px ring in `--k-surface`, `--k-warn`, top-right of the avatar.

### Tokens

| Token | Light | Dark |
|---|---|---|
| `--k-surface` | #ffffff | #1a1a1a |
| `--k-line` | #e2e8f0 | rgba(255, 255, 255, .1) |
| `--k-text` | #0f172a | #e3e3e3 |
| `--k-text-2` | #5b6779 | #9ca3af |
| `--k-accent-soft` | #e8b58b | #e8b58b |
| `--k-warn` | #8a5a00 | #d8a44a |
| `--k-shadow-pop` | 0 1px 2px rgba(15, 23, 42, .06), 0 12px 32px rgba(15, 23, 42, .12) | 0 2px 6px rgba(0, 0, 0, .2), 0 16px 36px rgba(0, 0, 0, .55) |
| `--k-radius-sheet` | 14px |  |
| `--k-radius-pill` | 999px |  |
| `--k-fs-body` | 14px |  |
| `--k-fs-meta` | 12px |  |

## Code

### React

In the Kwark app: `import { AccountWidget } from '@/components/account/AccountWidget'`.

```tsx
<AccountWidget />            // corner bubble on desktop
<WorkspaceSwitcher />        // the 'My stories ▾' pill on Home
```

| Prop | Type | Notes |
|---|---|---|
| `(none)` | `` | Both read the signed-in user, sync state and production houses from context. |

### HTML and CSS

Works anywhere with `kwark.css`.

```html
<div class="kw-account" role="dialog" aria-label="Your account">
  <div class="kw-account__who"><span class="kw-avatar kw-account__avatar" aria-hidden="true">MR</span><span><strong>Mira Rao</strong><small>mira@example.com</small></span><button class="kw-icon-button" type="button" aria-label="Close account panel"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12"/></svg></button></div>
  <label class="kw-field"><span class="kw-label">Display name</span><input class="kw-input" value="Mira Rao"></label>
  <button class="kw-button kw-button--sm" type="button"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3z"/><circle cx="12" cy="13" r="3"/></svg> Change picture</button>
  <div class="kw-account__sync"><span><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m2 2 20 20M5.8 5.8A7 7 0 0 0 9 19h8.5a4.5 4.5 0 0 0 1.3-.2M21.5 15.5A4.5 4.5 0 0 0 17.5 10h-1.8A7 7 0 0 0 9.9 5.1"/></svg> Safe here, waiting to reach the cloud</span><span class="kw-account__acts"><button class="kw-button kw-button--sm" type="button">Retry</button><button class="kw-button kw-button--sm kw-button--quiet" type="button">Backup</button></span></div>
  <button class="kw-button kw-button--sm kw-button--quiet" type="button"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4M16 17l5-5-5-5M21 12H9"/></svg> Sign out</button>
</div>
```

## Accessibility

### Keyboard
| Key | Does |
|---|---|
| Enter / Space on the avatar | Opens the panel; focus moves into it. |
| Escape | Closes the panel (AccountWidget listens on the document) and returns to the avatar. |
| Tab | Moves through name, picture, sync actions, Sign out. |

### ARIA
- The panel is `role="dialog" aria-label="Your account"`; the avatar button is named *Your account* and carries `aria-expanded`.
- Saved and error messages use `role="status"` and `role="alert"`.

## For agents

### Rules

- **Must** state the sync state in Decision 0013 words: Safe / Safe here, waiting to reach the cloud / Safe on this device.
- **Never** write "sync failed" or show a raw error code.
- **Always** offer Retry and Backup when changes are queued.
- **Must** live in the dial on phones, never as a second header icon (Decision 0016).

### AI readiness test

**Task:** Show an offline state in the account panel when the browser loses its connection.

**Give the agent:** This page, Decision 0013, the Sync status page.

**Constraint:** Some changes are queued.

**A reliable answer:**
- Says "Safe here, waiting to reach the cloud"
- Offers Retry and Backup
- Adds the warn dot to the closed avatar
- Never uses the word failed
