# Upload resolve

An image attachment that resolves as it uploads: coarse blocks of its own colours sharpen in steps, with a trace round the thumbnail.

Also called: upload animation, pixelated upload.

> chatcn Pro: needs a Pro license (https://chatcn.dev/pro). Install from the `@chatcn-pro` registry with your license token; setup at https://chatcn.dev/docs/chatcn-pro.

Example: Pictures that resolve. Three photos upload into the composer: each sharpens in steps from coarse blocks as its bytes arrive, one fails and retries. Preview: https://chatcn.dev/preview/upload-resolve-demo

The picture is the progress bar. The thumbnail starts as a few coarse blocks of its own colours and sharpens in five steps as the bytes arrive, with a hairline tracing the thumbnail's edge for the exact amount. When it lands the trace closes and lets go and the percent becomes the file's size. A failed upload drains to gray and offers a retry in place.

## Installation

```bash
npx shadcn@latest add @chatcn-pro/upload-resolve
```

## Usage

```tsx
import { UploadResolve } from "@/components/ui/chatcn/pro/upload-resolve"

<UploadResolve
  src={URL.createObjectURL(file)}
  name={file.name}
  bytes={file.size}
  progress={upload.progress}
  status={upload.status}
  onRemove={() => remove(file)}
  onRetry={() => retry(file)}
/>
```

## Examples

### States

Example: Uploading, done, failed. Three photos in each state: resolving at 38 percent, sharp and done, and stopped with a retry. Preview: https://chatcn.dev/preview/upload-resolve-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `src` | `string` | The picked image; an object URL works |
| `name` | `string` | Truncates with a title for the full name |
| `bytes` | `number` | Shown once the upload lands |
| `progress` | `number` | 0 to 1 |
| `status` | `"uploading" | "done" | "error"` |  |
| `onRemove` / `onRetry` | `() => void` | Each shows its button when passed |

## Accessibility

- Remove and retry are named with the file: Remove falls-at-dawn.webp.
- The percent, the size or the failure is a polite live region.

## Motion

- The canvas redraws only when the block size changes (20, 10, 5, 3, 2, sharp), never per frame.
- Reduced motion: two states only, coarse until it lands, then sharp.

Source: https://chatcn.dev/docs/components/upload-resolve