Key rules
chatty-block-productskhai báo 1 attribute, 1 property không có attribute, 1 event, 0 slot, 1 part và 0 CSS custom property.- Import 1 module
@avada/chatty-ui/elements/chatty-block-products.jslà definechatty-block-products; 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
React products block adapted to the house carousel and card action slot. Class ChattyBlockProducts.
Attributes
| Name | Property | Type | Default | Description |
|---|---|---|---|---|
block |
block |
object |
{ |
Canonical data. |
Properties
Attributes also expose the properties listed in the Property column above.
| Name | Type | Default | Description |
|---|---|---|---|
strings |
object |
{ |
Translated carousel and action labels. |
Events
| Name | Detail type | Description |
|---|---|---|
chatty- |
CustomEvent<{ |
Host- |
Slots
Not declared in the manifest.
Parts
| Name | Description |
|---|---|
base |
Full- |
CSS custom properties
Not declared in the manifest.
Usage
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/chatty-block-products.js';
export function Standard() {
return html`<div
@chatty-add-to-cart=${(event) => {
event.currentTarget.querySelector('[role=status]').textContent =
`Added: ${event.detail.product.title}`;
}}
>
<chatty-block-products
block='{"type":"products","data":{"messageId":"products-1","products":[{"id":"p1","title":"Canvas tote","price":"$24"},{"id":"p2","title":"Travel tote","price":"$32"}]}}'
></chatty-block-products>
<p role="status"></p>
</div>`;
}
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: trạng thái mặc định và nội dung mẫu của element.
Show code
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/chatty-block-products.js';
export function Standard() {
return html`<div
@chatty-add-to-cart=${(event) => {
event.currentTarget.querySelector('[role=status]').textContent =
`Added: ${event.detail.product.title}`;
}}
>
<chatty-block-products
block='{"type":"products","data":{"messageId":"products-1","products":[{"id":"p1","title":"Canvas tote","price":"$24"},{"id":"p2","title":"Travel tote","price":"$32"}]}}'
></chatty-block-products>
<p role="status"></p>
</div>`;
}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
import '@avada/chatty-ui/tokens/tokens.css';
import {html} from 'lit';
import '@avada/chatty-ui/elements/chatty-block-products.js';
export function Standard() {
return html`<div
@chatty-add-to-cart=${(event) => {
event.currentTarget.querySelector('[role=status]').textContent =
`Added: ${event.detail.product.title}`;
}}
>
<chatty-block-products
block='{"type":"products","data":{"messageId":"products-1","products":[{"id":"p1","title":"Canvas tote","price":"$24"},{"id":"p2","title":"Travel tote","price":"$32"}]}}'
></chatty-block-products>
<p role="status"></p>
</div>`;
}| Part | Element | Source |
|---|---|---|
| 1 | CSS part base |
chatty- |
Keyboard
No element-specific keys.
Source
- chatty-ui/custom-elements.json