# chatty-icon

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

## Key rules

- `chatty-icon` khai báo 2 attribute, 0 property không có attribute, 0 event, 1 slot, 1 part và 2 CSS custom property.
- Import 1 module `@avada/chatty-ui/elements/icon.js` là define `chatty-icon`; 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

A sized glyph box for an SVG passed through the slot; decorative unless it has a label. Class `ChattyIcon`.

### Attributes

| Name | Property | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `size` | `size` | `'sm' \| 'md' \| 'lg'` | `'md'` | Glyph box size: 16, 20 or 24px. |
| `label` | `label` | `string` | `''` | Accessible name; empty keeps the icon decorative (aria-hidden). |

### Properties

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

Not declared in the manifest.

### Events

Not declared in the manifest.

### Slots

| Name | Description |
| --- | --- |
| default | The SVG glyph; it fills the box and paints with currentColor. |

### Parts

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

### CSS custom properties

| Name | Default | Description |
| --- | --- | --- |
| `--chatty-icon-size` | – | Box width and height; overrides size. |
| `--chatty-icon-color` | – | Glyph colour; defaults to the inherited text colour. |

## Usage

```js
import '@avada/chatty-ui/tokens/tokens.css';
import {ArrowUpIcon, IconClose} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-icon prototype chatty-ui ports from (chatty-ui/src/elements/icon.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/icon.js';

export function Standard() {
  return html`
    <chatty-icon size="sm">${IconClose({size: 20})}</chatty-icon>
    <chatty-icon>${IconClose({size: 20})}</chatty-icon>
    <chatty-icon size="lg">${IconClose({size: 20})}</chatty-icon>
    <chatty-icon size="lg" label="Send">${ArrowUpIcon({size: 20})}</chatty-icon>
  `;
}
```

## 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.

```js
import '@avada/chatty-ui/tokens/tokens.css';
import {ArrowUpIcon, IconClose} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-icon prototype chatty-ui ports from (chatty-ui/src/elements/icon.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/icon.js';

export function Standard() {
  return html`
    <chatty-icon size="sm">${IconClose({size: 20})}</chatty-icon>
    <chatty-icon>${IconClose({size: 20})}</chatty-icon>
    <chatty-icon size="lg">${IconClose({size: 20})}</chatty-icon>
    <chatty-icon size="lg" label="Send">${ArrowUpIcon({size: 20})}</chatty-icon>
  `;
}
```

## 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ố.

```js
import '@avada/chatty-ui/tokens/tokens.css';
import {ArrowUpIcon, IconClose} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-icon prototype chatty-ui ports from (chatty-ui/src/elements/icon.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/icon.js';

export function Standard() {
  return html`
    <chatty-icon size="sm">${IconClose({size: 20})}</chatty-icon>
    <chatty-icon>${IconClose({size: 20})}</chatty-icon>
    <chatty-icon size="lg">${IconClose({size: 20})}</chatty-icon>
    <chatty-icon size="lg" label="Send">${ArrowUpIcon({size: 20})}</chatty-icon>
  `;
}
```

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

## Keyboard

No element-specific keys.

### Source

- chatty-ui/custom-elements.json
