| name | ui-analysis-component-mapping |
| description | null |
Component Mapping
Category: ui-analysis · Status: 🟢 Active
When to use
Khi chuyển một design thành cây component code.
Steps
- Tách design thành cây component theo phân cấp visual và trách nhiệm.
- Ưu tiên tái sử dụng component sẵn có; chỉ tạo mới khi không có sẵn.
- Map variant trong design (size/state/intent) thành props/variant của code.
- Tách phần lặp lại thành component con nhận data qua props.
- Phân biệt presentational (UI thuần) và container (logic/data).
- Đặt tên component theo vai trò nghiệp vụ, không theo hình thức.
Template
## Mapping: <màn hình>
| Design block | Component code | Reuse? | Props/variant |
|--------------|----------------|--------|---------------|
| Nút primary | `Button` | reuse | variant="primary", size |
| Thẻ sản phẩm | `ProductCard` | new | product, onSelect |
<ProductList>
{items.map((p) => <ProductCard key={p.id} product={p} />)}
</ProductList>
Example
Good: Dùng Button có sẵn với variant, tách ProductCard nhận props, đặt tên theo nghiệp vụ.
Avoid: Tạo BlueBox mới trùng Card sẵn có, nhồi mọi thứ vào 1 component.
Checklist