On this page

chatty-cart-notice

API chuẩn của element chatty-cart-notice, sinh từ custom-elements.json của prototype trong guide.

Copy page as MarkdownRead Markdown ↗

Key rules

  • chatty-cart-notice khai 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.js là define chatty-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.g. Sold out.
action View-cart action, usually a plain chatty-button; only for an added notice.

Parts

Name Description
base Notice section.
icon Icon wrapper.
label Heading line.

CSS custom properties

Name Default Description
--chatty-cart-notice-radius – Corner radius.
--chatty-cart-notice-background – 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ộ.

Standard
LightDarkDesktopMobile

Default: trạng thái mặc định và nội dung mẫu của element.

Show code
chatty-cart-notice.element.jsWrap code linesCopy
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ả.

Standard
LightDarkDesktopMobile

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-notice.element.jsWrap code linesCopy
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-ui/custom-elements.json
2 CSS part icon chatty-ui/custom-elements.json
3 CSS part label chatty-ui/custom-elements.json

Keyboard

No element-specific keys.

Source

  • chatty-ui/custom-elements.json