# chatty-spinner

API chuẩn của element chatty-spinner, sinh từ custom-elements.json của prototype trong guide.

## Key rules

- `chatty-spinner` khai báo 2 attribute, 0 property không có attribute, 0 event, 0 slot, 1 part và 2 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/spinner.js` là define `chatty-spinner`; chunk chỉ import element nó dùng. Prototype chuẩn:  trong guide.
- Đổi tên attribute, event, slot, part hay CSS custom property là đổi API: diff của custom-elements.json phải có trong 1 MR.

## Overview

An indeterminate loading ring; decorative unless it has a label. Class `ChattySpinner`.

### Attributes

| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `size` | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Ring size: 16, 24 or 32px. |
| `label` | `label` | `string` | `''` | Accessible name; set it to expose role progressbar, empty keeps it decorative. |

### Properties

Attributes also expose the properties listed in the Property column above.

Not declared in the manifest.

### Events

Not declared in the manifest.

### Slots

Not declared in the manifest.

### Parts

| Name | Description |
| --- | --- |
| `base` | Ring box. |

### CSS custom properties

| Name | Default | Description |
| --- | --- | --- |
| `--chatty-spinner-size` | – | Ring width and height; overrides size. |
| `--chatty-spinner-color` | – | Ring colour; defaults to the accent. |

## Usage

```js
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/spinner.js';
```

```html
<chatty-spinner size="sm"></chatty-spinner>
<chatty-spinner></chatty-spinner>
<chatty-spinner size="lg" label="Loading orders"></chatty-spinner>
```

## Live preview

Component thật dùng cùng story với trang component; dữ liệu mẫu nằm trong frame cục bộ.

Example (Standard) — Default: trạng thái mặc định và nội dung mẫu của element.

```html
<chatty-spinner size="sm"></chatty-spinner>
<chatty-spinner></chatty-spinner>
<chatty-spinner size="lg" label="Loading orders"></chatty-spinner>
```

## Anatomy

Số trong hình khớp bảng bên dưới. Phần chỉ hiện ở state khác được ghi Not shown; ví dụ không thêm phần tử giả.

Example (Standard) — Anatomy: một instance mặc định riêng, có khoảng trống quanh các phần được đánh số.

```html
<chatty-spinner size="sm"></chatty-spinner>
<chatty-spinner></chatty-spinner>
<chatty-spinner size="lg" label="Loading orders"></chatty-spinner>
```

| Part | Element | Source |
| --- | --- | --- |
| 1 | CSS part `base` | chatty-ui/custom-elements.json |

## Keyboard

No element-specific keys.

### Source

- chatty-ui/custom-elements.json
