Key rules
chatty-cart-noticekhai báo 2 attribute, 0 property không có attribute, 0 event, 4 slot, 3 part và 2 CSS custom property.- Import 1 module
@avada/chatty-ui/elements/cart-notice.jslà definechatty-cart-notice; 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
Cart outcome without a readable quantity or price: added, or could not add with a reason. Class ChattyCartNotice.
Attributes
| Name | Property | Type | Default | Description |
|---|---|---|---|---|
tone |
tone |
'success' | 'critical' |
'success' |
success = added, critical = could not add |
heading |
heading |
string |
'' |
Heading; empty uses Added to cart or Could not add to cart by tone. |
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. |
icon |
20px status icon (check when added, alert when failed). |
detail |
Failure reason, e.Sold out. |
action |
View-chatty-; only for an added notice. |
Parts
| Name | Description |
|---|---|
base |
Notice section. |
icon |
Icon wrapper. |
label |
Heading line. |
CSS custom properties
| Name | Default | Description |
|---|---|---|
- |
– | Corner radius. |
- |
– | Background. |
Usage
import '@avada/chatty-ui/tokens/tokens.css';
import {IconAlertCircle, IconCheck} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-cart-notice prototype chatty-ui ports from (chatty-ui/src/elements/cart-notice.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/cart-notice.js';
import '@avada/chatty-ui/elements/button.js';
export function Standard() {
return html`
<chatty-cart-notice>
${IconCheck({slot: 'icon'})} Cotton shirt
<chatty-button slot="action" variant="plain">View cart</chatty-button>
</chatty-cart-notice>
<chatty-cart-notice tone="critical">
${IconAlertCircle({slot: 'icon'})} Cotton shirt
<span slot="detail">Sold out</span>
</chatty-cart-notice>
`;
}
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 {IconAlertCircle, IconCheck} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-cart-notice prototype chatty-ui ports from (chatty-ui/src/elements/cart-notice.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/cart-notice.js';
import '@avada/chatty-ui/elements/button.js';
export function Standard() {
return html`
<chatty-cart-notice>
${IconCheck({slot: 'icon'})} Cotton shirt
<chatty-button slot="action" variant="plain">View cart</chatty-button>
</chatty-cart-notice>
<chatty-cart-notice tone="critical">
${IconAlertCircle({slot: 'icon'})} Cotton shirt
<span slot="detail">Sold out</span>
</chatty-cart-notice>
`;
}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 {IconAlertCircle, IconCheck} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-cart-notice prototype chatty-ui ports from (chatty-ui/src/elements/cart-notice.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/cart-notice.js';
import '@avada/chatty-ui/elements/button.js';
export function Standard() {
return html`
<chatty-cart-notice>
${IconCheck({slot: 'icon'})} Cotton shirt
<chatty-button slot="action" variant="plain">View cart</chatty-button>
</chatty-cart-notice>
<chatty-cart-notice tone="critical">
${IconAlertCircle({slot: 'icon'})} Cotton shirt
<span slot="detail">Sold out</span>
</chatty-cart-notice>
`;
}| Part | Element | Source |
|---|---|---|
| 1 | CSS part base |
chatty- |
| 2 | CSS part icon |
chatty- |
| 3 | CSS part label |
chatty- |
Keyboard
No element-specific keys.
Source
- chatty-ui/custom-elements.json