# CountdownTimerNode

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

Đồng hồ đếm ngược đến một thời điểm, hiển thị các đơn vị thời gian kèm nhãn.

## Resolved name

`countdown-timer`

## Configurable props

### Props

| Prop | Giá trị | Responsive | Mô tả |
| --- | --- | --- | --- |
| `date` | `chuỗi` | không | Thời điểm kết thúc, dạng ISO (ví dụ 2030-01-01T00:00) |
| `units` | `mảng object` | không | Các đơn vị cần hiển thị, theo thứ tự |
| `units[].value` | `'months' · 'weeks' · 'days' · 'hours' · 'minutes' · 'seconds'` | không | Đơn vị thời gian |
| `units[].caption` | `chuỗi` | không | Nhãn hiển thị dưới số |
| `hideAfterExpired` | `true · false` | không | Ẩn đồng hồ khi đã hết giờ |
| `timeProps` | `object` | không | Kiểu chữ của con số |
| `timeProps.sizeVariant` | `'xs' · 'sm' · 'base' · 'lg' · 'xl' · '2xl' · '3xl' · '4xl' · '5xl' · '6xl'` | có | Cỡ chữ theo thang typography |
| `timeProps.sx.color` | `color` | không |  |
| `timeProps.sx.fontWeight` | `200 · 300 · 400 · 500 · 600 · 700 · 800` | không |  |
| `timeProps.sx.fontStyle` | `'italic'` | không |  |
| `timeProps.sx.textDecorationLine` | `'underline'` | không |  |
| `captionProps` | `object` | không | Kiểu chữ của nhãn |
| `captionProps.sizeVariant` | `'xs' · 'sm' · 'base' · 'lg' · 'xl' · '2xl' · '3xl' · '4xl' · '5xl' · '6xl'` | có | Cỡ chữ theo thang typography |
| `captionProps.sx.color` | `color` | không |  |
| `captionProps.sx.fontWeight` | `200 · 300 · 400 · 500 · 600 · 700 · 800` | không |  |
| `captionProps.sx.fontStyle` | `'italic'` | không |  |
| `captionProps.sx.textDecorationLine` | `'underline'` | không |  |
| `captionProps.sx.textTransform` | `'uppercase' · 'capitalize' · 'lowercase'` | không |  |
| `unitItemProps` | `object` | không | Kiểu của từng ô đơn vị |
| `unitItemProps.sx.width` | `px · 'N%' · 'auto'` | có |  |
| `unitItemProps.sx.paddingTop` | `px` | có |  |
| `unitItemProps.sx.paddingRight` | `px` | có |  |
| `unitItemProps.sx.paddingBottom` | `px` | có |  |
| `unitItemProps.sx.paddingLeft` | `px` | có |  |
| `unitItemProps.sx.borderTopLeftRadius` | `px 0..9999` | có |  |
| `unitItemProps.sx.borderTopRightRadius` | `px 0..9999` | có |  |
| `unitItemProps.sx.borderBottomRightRadius` | `px 0..9999` | có |  |
| `unitItemProps.sx.borderBottomLeftRadius` | `px 0..9999` | có |  |
| `unitItemProps.sx.rowGap` | `px` | có |  |
| `unitItemProps.sx.backgroundColor` | `color` | không |  |

### `sx`

| Key | Giá trị | Breakpoint |
| --- | --- | --- |
| `width` | `px · 'N%' · 'auto' · 'fit-content'` | mọi breakpoint |
| `marginTop` | `px · 'auto'` | mọi breakpoint |
| `marginRight` | `px · 'auto'` | mọi breakpoint |
| `marginBottom` | `px · 'auto'` | mọi breakpoint |
| `marginLeft` | `px · 'auto'` | mọi breakpoint |
| `paddingTop` | `px` | mọi breakpoint |
| `paddingRight` | `px` | mọi breakpoint |
| `paddingBottom` | `px` | mọi breakpoint |
| `paddingLeft` | `px` | 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 |
| `flexWrap` | `'wrap'` | mọi breakpoint |
| `justifyContent` | `'flex-start' · 'center' · 'flex-end' · 'space-between'` | mọi breakpoint |
| `columnGap` | `px` | mọi breakpoint |
| `rowGap` | `px` | 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.date là bắt buộc: countdown-timer cần thời điểm kết thúc để đếm ngược.
- props.units là bắt buộc: countdown-timer không có giá trị mặc định cho `units`.

<!-- schema:end -->

## Notes

- `unitItemProps` style từng ô đơn vị (box bao quanh số và nhãn); `rowGap` ở đó là khoảng cách giữa số và nhãn.
- `timeProps` chỉ style con số, `captionProps` chỉ style nhãn bên dưới. Cả hai nhận `sizeVariant` responsive (`sizeVariant`, `sm`/`md`/`lg`) cùng một vài key `sx` về chữ.
- `sx` ngoài cùng style container chứa tất cả các ô (khoảng cách `columnGap`/`rowGap`, `justifyContent`, `flexWrap`, nền, viền, margin, padding); `sx` này responsive bằng key `sm`/`md`/`lg` lồng bên trong.
- Khi editor đang bật, component hiển thị placeholder nếu `units` rỗng hoặc đã hết giờ với `hideAfterExpired: true`.

## Usage

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

// Đếm ngược đến ngày sale
<CountdownTimerNode
  date="2026-12-31T23:59:59"
  units={[
    { value: 'days',    caption: 'Days' },
    { value: 'hours',   caption: 'Hours' },
    { value: 'minutes', caption: 'Mins' },
    { value: 'seconds', caption: 'Secs' },
  ]}
  hideAfterExpired={false}
  sx={{ columnGap: 8 }}
  unitItemProps={{
    sx: {
      width: 64,
      paddingTop: 8,
      paddingBottom: 8,
      backgroundColor: '#fa8c16',
      borderTopLeftRadius: 8,
      borderTopRightRadius: 8,
      borderBottomLeftRadius: 8,
      borderBottomRightRadius: 8,
    },
  }}
  timeProps={{
    sizeVariant: '2xl',
    sx: { color: '#ffffff', fontWeight: 700 },
  }}
  captionProps={{
    sizeVariant: 'xs',
    sx: { color: '#ffffff', textTransform: 'uppercase' },
  }}
/>
```
