# Feedback · Divan

> Use the lowest step that does the job: prevent, guide, note, toast with Undo, ask a second time.

Part of Divan, the DivanWorks design system. Web page: https://brand.divanworks.com/feedback · All topics: https://brand.divanworks.com/llms.txt

## Rules

- Prevent: format as people type, show limits up front, keep the main button waiting with the reason beside it.
- Guide: the hint under the field turns into the instruction (Field.Error, regular weight) and the field gets aria-invalid (a faint warm tint).
- Note: when something can’t load, keep what was there, dim it, add one <Note> with a way forward.
- Toast: confirm what just happened; for undoable actions do it at once and offer Undo.
- Answer every press: what is not ready at once shows it on what was pressed, from 150 ms on (a spinner in a Button or a side-menu row, any other link or row breathes), or with a small spinner at the top when that is out of sight. trackPresses() in the root layout does it for pages, Button for a promise its onclick returns, ConfirmButton for a promise its onconfirm returns, enhance from #lib/forms.js for forms; pending={busy} for anything else. A press made before the page’s code starts breathes at once and is made again when it is ready (the script in src/app.html).
- Ask a second time: only for what can’t easily be undone. In place with <ConfirmButton> (the first press turns the button into the question, with Cancel and the verb); from code with ask() (the same question as a dialog). The question is in the words of the action; the buttons are Cancel and the verb. Never the browser’s confirm().

## Components

### Note

A quiet status line next to what it is about, with a way forward.

```ts
import { Note } from '#lib/components/ui/note/index.js';
```

```svelte
<Note>
	Unable to update your activity.
	{#snippet action()}<Button variant="plain" size="sm">Try Again</Button>{/snippet}
</Note>
<Note tone="success">Saved. Applies to new comments.</Note>
```

### Field

Label, control, hint and guidance for one form field.

```ts
import * as Field from '#lib/components/ui/field/index.js';
```

```svelte
<Field.Field>
	<Field.Label for="handle">YouTube handle</Field.Label>
	<Input id="handle" name="handle" dir="ltr" aria-invalid={!ok} />
	{#if ok}<Field.Description>The @name under your channel title.</Field.Description>
	{:else}<Field.Error>Write your handle like @yourchannel.</Field.Error>{/if}
</Field.Field>
```

### Toaster

Confirm what just happened; Undo for undoable actions. Mount <Toaster /> once in the layout.

```ts
import { Toaster } from '#lib/components/ui/sonner/index.js';
import { toast } from 'svelte-sonner';
```

```svelte
toast('Instagram disconnected', {
	description: 'Your support stays counted.',
	action: { label: 'Undo', onClick: reconnect }
});
```

### Dialog

Only before what cannot be undone.

```ts
import * as Dialog from '#lib/components/ui/dialog/index.js';
```

```svelte
<Dialog.Root>
	<Dialog.Trigger>{#snippet child({ props })}<Button variant="secondary" {...props}>Delete Campaign…</Button>{/snippet}</Dialog.Trigger>
	<Dialog.Content showCloseButton={false}>
		<Dialog.Header>
			<Dialog.Title>Delete the Round 2 campaign?</Dialog.Title>
			<Dialog.Description>Its page and board are removed for good.</Dialog.Description>
		</Dialog.Header>
		<Dialog.Footer><Dialog.Close>Cancel</Dialog.Close><Button variant="destructive">Delete</Button></Dialog.Footer>
	</Dialog.Content>
</Dialog.Root>
```

### MediaPlayer

Every video or sound a person plays, with the browser’s own controls. When the file does not play (it never arrives, or the browser cannot read it) it says so in place with Try Again and Download, never a black box at 0:00. Any attribute of <video> passes through (autoplay, loop, preload, class); captions={{ src, label, lang }} adds a WebVTT track (a recording’s transcript).

```ts
import { MediaPlayer } from '#lib/components/ui/media/index.js';
```

```svelte
<MediaPlayer src={file.url} playsinline autoplay loop class="max-h-[70svh] max-w-full" />
<MediaPlayer kind="audio" src={sound.url} preload="none" class="w-full" />
```

### VideoFrame

A video’s first frame as a picture, for tiles, covers and previews (muted, nothing plays). When the video does not load, it shows its poster or a film icon on the same tone.

```ts
import { VideoFrame } from '#lib/components/ui/media/index.js';
```

```svelte
<VideoFrame src="{first.url}#t=0.1" poster={startFrame} class="size-full object-cover" />
```

### Picture

Every picture that comes from a file or another site (a stored picture’s thumbnail, a network’s thumbnail, a person’s photo): an <img> that, when the picture does not load or there is none, shows a quiet icon on the muted tone in the same box, never the browser’s broken-picture sign. icon= changes the sign (a person for a profile photo). Any attribute of <img> passes through. A picture written into the page (src="/logo.webp") needs none.

```ts
import { Picture } from '#lib/components/ui/media/index.js';
```

```svelte
<Picture src={thumbUrl(r.url)} loading="lazy" class="size-14 rounded-field object-cover" />
<Picture icon={UserRoundIcon} src={me.photo} alt="" class="size-16 rounded-full object-cover" />
```
