Key rules
chatty-product-rowkhai báo 2 attribute, 1 property không có attribute, 1 event, 1 slot, 3 part và 0 CSS custom property.- Import 1 module
@avada/chatty-ui/elements/product-card.jslà definechatty-product-row; 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.
On this page
Overview
A scroll-snap product row with desktop edge arrows and touch position dots. Class ChattyProductRow.
Attributes
| Name | Property | Type | Default | Description |
|---|---|---|---|---|
label |
label |
string |
'Products' |
Accessible name of the scroll region. |
surface |
surface |
'ai- |
'ai- |
Widget layout and arrow geometry. |
Properties
Attributes also expose the properties listed in the Property column above.
| Name | Type | Default | Description |
|---|---|---|---|
strings |
object |
{ |
Localized names for arrow controls. |
Events
| Name | Detail type | Description |
|---|---|---|
click |
MouseEvent |
Native arrow activation. |
Slots
| Name | Description |
|---|---|
| default | Product cards in reading order. |
Parts
| Name | Description |
|---|---|
base |
Focusable horizontal scroll region. |
previous |
Previous- |
next |
Next- |
CSS custom properties
Not declared in the manifest.
Usage
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/product-card.js';
import '@avada/chatty-ui/elements/image.js';
import '@avada/chatty-ui/elements/button.js';
<chatty-product-row label="Recommended products">
<chatty-product-card price="$24" label="View Canvas tote bag">
<chatty-image
slot="media"
src="/fixtures/tote.svg"
alt=""
ratio="4 / 5"
fit="contain"
></chatty-image>
Canvas tote bag
<chatty-button slot="action" size="sm">Add to cart</chatty-button>
</chatty-product-card>
<chatty-product-card price="$18" label="View Ceramic mug">
<chatty-image
slot="media"
src="/fixtures/mug.svg"
alt=""
ratio="4 / 5"
fit="contain"
></chatty-image>
Ceramic mug
<chatty-button slot="action" size="sm">Add to cart</chatty-button>
</chatty-product-card>
</chatty-product-row>
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ộ.
Default: ví dụ giữ context cha cần thiết từ story có sẵn.
Show code
<chatty-product-row label="Recommended products">
<chatty-product-card price="$24" label="View Canvas tote bag">
<chatty-image
slot="media"
src="/fixtures/tote.svg"
alt=""
ratio="4 / 5"
fit="contain"
></chatty-image>
Canvas tote bag
<chatty-button slot="action" size="sm">Add to cart</chatty-button>
</chatty-product-card>
<chatty-product-card price="$18" label="View Ceramic mug">
<chatty-image
slot="media"
src="/fixtures/mug.svg"
alt=""
ratio="4 / 5"
fit="contain"
></chatty-image>
Ceramic mug
<chatty-button slot="action" size="sm">Add to cart</chatty-button>
</chatty-product-card>
</chatty-product-row>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ả.
Anatomy: một instance mặc định riêng, có khoảng trống quanh các phần được đánh số.
Show code
<chatty-product-row label="Recommended products">
<chatty-product-card price="$24" label="View Canvas tote bag">
<chatty-image
slot="media"
src="/fixtures/tote.svg"
alt=""
ratio="4 / 5"
fit="contain"
></chatty-image>
Canvas tote bag
<chatty-button slot="action" size="sm">Add to cart</chatty-button>
</chatty-product-card>
<chatty-product-card price="$18" label="View Ceramic mug">
<chatty-image
slot="media"
src="/fixtures/mug.svg"
alt=""
ratio="4 / 5"
fit="contain"
></chatty-image>
Ceramic mug
<chatty-button slot="action" size="sm">Add to cart</chatty-button>
</chatty-product-card>
</chatty-product-row>| Part | Element | Source |
|---|---|---|
| 1 | CSS part base |
chatty- |
| 2 | CSS part previous |
chatty- |
| 3 | CSS part next |
chatty- |
Keyboard
| Key | Action |
|---|---|
| ArrowLeft / ArrowRight | Scroll the row one viewport left or right. |
| Home / End | Scroll to the first / last product. |
Source
- chatty-ui/custom-elements.json