# RatingNode

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

Hàng ngôi sao đánh giá, hỗ trợ số lẻ (ví dụ 4.5 trên 5 sao).

## Resolved name

`rating`

## Configurable props

### Props

| Prop | Giá trị | Responsive | Mô tả |
| --- | --- | --- | --- |
| `rating` | `số ≥ 0` | không | Điểm hiện tại (tối đa 1 chữ số thập phân) |
| `count` | `số nguyên 1..10` | không | Số ngôi sao hiển thị (tối đa 10) |
| `color` | `color` | không | Màu của các ngôi sao |
| `size` | `px` | có | Kích thước mỗi ngôi sao, đơn vị px |

### `sx`

| Key | Giá trị | 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 |
| `columnGap` | `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ỳ.

<!-- schema:end -->

## Cấu trúc

```text
rating/
├── rating/            # Component thuần túy (không phụ thuộc CraftJS)
│   ├── rating.tsx     # <Rating /> — render Primitive + danh sách StarRating
│   ├── types.ts       # RatingProps
│   └── helpers.ts     # defaultProps + getRatingProps (merge default)
├── rating.node/       # CraftJS node bọc quanh <Rating />
│   ├── rating.node.tsx
│   ├── types.ts       # RatingNodeProps = RatingProps
│   └── helpers.ts     # useRatingNodeProps (transform = getRatingProps)
└── rating.inspector/  # Panel chỉnh sửa trong editor
```

`RatingNode` chỉ lo phần CraftJS (connectors, data attributes) rồi delegate xuống component `Rating`. `rating` là prop bắt buộc; các prop còn lại có default qua `getRatingProps`.

## Usage

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

// Cơ bản — 5 sao, rating 4.5
<RatingNode rating={4.5} />

// Tùy chỉnh số sao, kích thước, màu
<RatingNode rating={3} count={5} size={28} color="#f59e0b" />

// Size responsive
<RatingNode rating={4} size={20} md={{ size: 32 }} />

// Điều chỉnh khoảng cách giữa các sao + spacing ngoài
<RatingNode
  rating={4.5}
  sx={{
    columnGap: 8,
    marginTop: 12,
    marginBottom: 12,
  }}
/>
```

## Editor (Inspector)

### Tab Settings

- **Config**: Rating, Count, Size (responsive), Color (color picker), Column gap
- **Spacing (px)**: Margin, Padding (responsive)

### Tab Advanced

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