Key rules
chatty-cart-confirmationkhai báo 6 attribute, 0 property không có attribute, 0 event, 6 slot, 4 part và 2 CSS custom property.- Import 1 module
@avada/chatty-ui/elements/cart-confirmation.jslà definechatty-cart-confirmation; 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
Receipt for one cart line or a group added together, with quantity pulses and an optional view-cart action. Class ChattyCartConfirmation.
Attributes
| Name | Property | Type | Default | Description |
|---|---|---|---|---|
heading |
heading |
string |
'Added to cart' |
Heading and accessible name of the receipt. |
grouped |
grouped |
boolean |
false |
One receipt for the cart- |
show- |
showAll |
boolean |
false |
Show every grouped line (admin history); storefront shows three when there are more than four. |
quantity |
quantity |
number | undefined |
undefined |
quantity now in the cart |
quantity- |
quantityLabel |
string |
'Quantity in cart' |
Label before the quantity, e.Quantity in cart. |
price |
price |
string |
'' |
Formatted line price, e.$48.00. |
Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
Events
Not declared in the manifest.
Slots
| Name | Description |
|---|---|
| default | Product title for a single- |
items |
Cart confirmation lines added together; use grouped with this slot. |
more |
Localized overflow summary when more than four lines are collapsed. |
media |
Thumbnail, 64 × 80 for a single receipt or 40 × 50 in a group; omit for text- |
detail |
Variant line, e.Size M / Blue. |
action |
View-chatty-. |
Parts
| Name | Description |
|---|---|
base |
Receipt section. |
label |
Heading line. |
media |
Thumbnail wrapper. |
line |
Quantity and price row. |
CSS custom properties
| Name | Default | Description |
|---|---|---|
- |
– | Corner radius. |
- |
– | Background. |
Usage
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/cart-confirmation.js';
import '@avada/chatty-ui/elements/button.js';
<chatty-cart-confirmation quantity="2" price="$48.00">
<img slot="media" src="/fixtures/tote.svg" alt="" />
Canvas tote bag
<span slot="detail">Natural / Large</span>
<chatty-button slot="action" variant="plain">View cart</chatty-button>
</chatty-cart-confirmation>
<chatty-cart-confirmation quantity="1" price="$18.00">Ceramic mug</chatty-cart-confirmation>
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
<chatty-cart-confirmation quantity="2" price="$48.00">
<img slot="media" src="/fixtures/tote.svg" alt="" />
Canvas tote bag
<span slot="detail">Natural / Large</span>
<chatty-button slot="action" variant="plain">View cart</chatty-button>
</chatty-cart-confirmation>
<chatty-cart-confirmation quantity="1" price="$18.00">Ceramic mug</chatty-cart-confirmation>Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.
Show code
<chatty-cart-confirmation grouped heading="Added 5 products to cart">
<chatty-cart-confirmation slot="items" quantity="2" price="$48.00"
><img slot="media" src="/fixtures/tote.svg" alt="" />Canvas tote bag<span slot="detail"
>Natural / Large</span
></chatty-cart-confirmation
>
<chatty-cart-confirmation slot="items" quantity="1" price="$18.00"
>Ceramic mug</chatty-cart-confirmation
>
<chatty-cart-confirmation slot="items" quantity="1" price="$28.00"
><img slot="media" src="/fixtures/cap.svg" alt="" />Wool cap</chatty-cart-confirmation
>
<chatty-cart-confirmation slot="items" quantity="1" price="$24.00"
>Linen scarf</chatty-cart-confirmation
>
<chatty-cart-confirmation slot="items" quantity="1" price="$18.00"
>Leather wallet</chatty-cart-confirmation
>
<span slot="more">and 2 more products — view in cart</span>
<chatty-button slot="action" variant="plain">View cart</chatty-button>
</chatty-cart-confirmation>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-cart-confirmation quantity="2" price="$48.00">
<img slot="media" src="/fixtures/tote.svg" alt="" />
Canvas tote bag
<span slot="detail">Natural / Large</span>
<chatty-button slot="action" variant="plain">View cart</chatty-button>
</chatty-cart-confirmation>
<chatty-cart-confirmation quantity="1" price="$18.00">Ceramic mug</chatty-cart-confirmation>| Part | Element | Source |
|---|---|---|
| 1 | CSS part base |
chatty- |
| 2 | CSS part label |
chatty- |
| 3 | CSS part media |
chatty- |
| 4 | CSS part line |
chatty- |
Keyboard
No element-specific keys.
Source
- chatty-ui/custom-elements.json