# CountUpNode

<!-- schema:start — tự sinh từ count-up.schema.ts, không sửa tay -->

Số đếm tăng dần từ giá trị đầu đến giá trị cuối, có thể kèm tiền tố và hậu tố.

## Resolved name

`count-up`

## Configurable props

### Props

| Prop | Giá trị | Responsive | Mô tả |
| --- | --- | --- | --- |
| `from` | `số ≥ 0` | không | Giá trị bắt đầu (tối đa 2 chữ số thập phân) |
| `to` | `số ≥ 0` | không | Giá trị kết thúc (tối đa 2 chữ số thập phân) |
| `duration` | `số ≥ 0` | không | Thời gian chạy, đơn vị giây (tối đa 1 chữ số thập phân) |
| `prefix` | `chuỗi` | không | Text hiển thị trước số |
| `suffix` | `chuỗi` | không | Text hiển thị sau số |
| `sizeVariant` | `'xs' · 'sm' · 'base' · 'lg' · 'xl' · '2xl' · '3xl' · '4xl' · '5xl' · '6xl'` | có | Cỡ chữ theo thang typography |

### `sx`

| Key | Giá trị | Breakpoint |
| --- | --- | --- |
| `color` | `color` | mọi breakpoint |
| `fontWeight` | `200 · 300 · 400 · 500 · 600 · 700 · 800` | mọi breakpoint |
| `fontStyle` | `'italic'` | mọi breakpoint |
| `textDecorationLine` | `'underline'` | mọi breakpoint |
| `textTransform` | `'uppercase' · 'capitalize' · 'lowercase'` | chỉ mobile (xs) |
| `textAlign` | `'left' · 'center' · 'right' · 'justify'` | mọi breakpoint |
| `borderStyle` | `'solid' · 'dashed' · 'dotted'` | mọi breakpoint |
| `borderTopWidth` | `px` | mọi breakpoint |
| `borderRightWidth` | `px` | mọi breakpoint |
| `borderBottomWidth` | `px` | mọi breakpoint |
| `borderLeftWidth` | `px` | mọi breakpoint |
| `borderColor` | `color` | mọi breakpoint |
| `borderTopLeftRadius` | `px 0..9999` | mọi breakpoint |
| `borderTopRightRadius` | `px 0..9999` | mọi breakpoint |
| `borderBottomRightRadius` | `px 0..9999` | mọi breakpoint |
| `borderBottomLeftRadius` | `px 0..9999` | mọi breakpoint |
| `backgroundColor` | `color` | mọi breakpoint |
| `backgroundImage` | `url(https://…)` | mọi breakpoint |
| `backgroundSize` | `'cover' · 'contain' · 'auto'` | mọi breakpoint |
| `backgroundPosition` | `'left top' · 'top' · 'right top' · 'left' · 'center' · 'right' · 'left bottom' · 'bottom' · 'right bottom'` | mọi breakpoint |
| `backgroundRepeat` | `'no-repeat' · 'repeat-x' · 'repeat-y' · 'repeat'` | mọi breakpoint |
| `backgroundAttachment` | `'scroll' · 'fixed' · 'local'` | mọi breakpoint |

`color` = `var(--color-{primary\|secondary\|red\|orange\|yellow\|green\|blue\|violet\|neutral}-{100..800\|contrast}) · var(--color-background-{subtle\|default\|emphasis}) · var(--color-border-default) · var(--color-surface-default) · var(--color-common-{black\|white}) · #rgb · #rrggbb`

## Rules

- **Nội dung**: không chứa node con.
- **Cha hợp lệ**: bất kỳ.
- props.to là bắt buộc: CountUp không có giá trị mặc định cho `to`.

<!-- schema:end -->

## Cấu trúc

```text
count-up/
├── count-up.node/       # CraftJS node bọc quanh <CountUp />
│   ├── count-up.node.tsx
│   ├── types.ts         # CountUpNodeProps
│   └── helpers.ts       # useCountUpNodeProps (transform = getCountUpProps)
└── count-up.inspector/  # Panel chỉnh sửa trong editor
```

`CountUpNode` lo phần CraftJS (connectors, data attributes) rồi delegate xuống `CountUp` của `@janbox/storefront-ui`. Trong editor (`enabled`) thì `startOnView` bị tắt để số luôn hiển thị giá trị cuối; ở trang thật thì animate khi cuộn tới. Các prop không set đều lấy default qua `getCountUpProps`, riêng `to` thì bắt buộc.

## Usage

```tsx
import { CountUpNode } from '@janbox/storefront-builder';

// Cơ bản — chạy từ 0 đến 100
<CountUpNode from={0} to={100} />

// Có prefix/suffix
<CountUpNode from={0} to={1000} prefix="+" suffix="k" />

// Tùy chỉnh thời lượng + cỡ chữ responsive
<CountUpNode
  from={0}
  to={98}
  suffix="%"
  duration={3}
  sizeVariant="xl"
  md={{ sizeVariant: '3xl' }}
/>

// Style qua sx
<CountUpNode
  from={0}
  to={500}
  sx={{
    color: '#f59e0b',
    fontWeight: 700,
    textAlign: 'center',
  }}
/>
```

## Editor (Inspector)

### Tab Settings

- **Config**: From, To, Duration (s), Prefix, Suffix
- **Text style**: Size variant, Color, Style (weight/italic/underline), Text align, Text transform, Font weight

### Tab Advanced

- **Shape**: Border, Border radius
- **Background**: Background
