On this page

chatty-email-continue

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

Copy page as MarkdownRead Markdown ↗

Key rules

  • chatty-email-continue khai báo 5 attribute, 1 property không có attribute, 1 event, 1 slot, 4 part và 2 CSS custom property.
  • Import 1 module @avada/chatty-ui/elements/email-continue.js là define chatty-email-continue; 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

In-chat card that emails the conversation so the shopper can continue by replying. A known email is shown as text; otherwise the card asks for one and validates it before sending. The host sends the email; it sets loading while sending, then sent-to or failed. Class ChattyEmailContinue.

Attributes

Name Property Type Default Description
email email string '' Email already on the conversation; shown as text instead of the input.
value value string '' Prefilled input value.
loading loading boolean false Sending: the button shows a spinner and repeat sends are blocked.
failed failed boolean false Shows the send-failure message (role alert).
sent-to sentTo string '' Recipient once sent; replaces the card with the receipt.

Properties

Attributes also expose the properties listed in the Property column above.

Name Type Default Description
strings Partial<Record<'title' | 'lead' | 'label' | 'invalid' | 'failed' | 'send' | 'sent', string>> {} Translated labels with English defaults; supported keys are listed in the type.

Events

Name Detail type Description
chatty-submit CustomEvent<{email: string}> Send with a valid email.

Slots

Name Description
icon Check icon of the sent receipt.

Parts

Name Description
base Card, or the sent receipt.
title Card heading.
input Email input.
error Validation or failure message.

CSS custom properties

Name Default Description
--chatty-email-continue-radius – Card corner radius.
--chatty-email-continue-background – Card background.

Usage

import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/email-continue.js';
<chatty-email-continue email="guest@example.com"></chatty-email-continue>
<chatty-email-continue value="guest@example"></chatty-email-continue>

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-email-continue.element.jsWrap code linesCopy
<chatty-email-continue email="guest@example.com"></chatty-email-continue>
<chatty-email-continue value="guest@example"></chatty-email-continue>
Standard
LightDarkDesktopMobile

Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.

Show code
chatty-email-continue.element.jsWrap code linesCopy
import '@avada/chatty-ui/tokens/tokens.css';
import {IconCheck} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-email-continue prototype chatty-ui ports from (chatty-ui/src/elements/email-continue.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/email-continue.js';

export function States() {
  return html`
    <chatty-email-continue email="guest@example.com" loading></chatty-email-continue>
    <chatty-email-continue email="guest@example.com" failed></chatty-email-continue>
    <chatty-email-continue sent-to="guest@example.com">
      ${IconCheck({slot: 'icon'})}
    </chatty-email-continue>
  `;
}

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-email-continue.element.jsWrap code linesCopy
<chatty-email-continue email="guest@example.com"></chatty-email-continue>
<chatty-email-continue value="guest@example"></chatty-email-continue>
Part Element Source
1 CSS part base chatty-ui/custom-elements.json
2 CSS part title chatty-ui/custom-elements.json
3 CSS part input chatty-ui/custom-elements.json
4 CSS part error chatty-ui/custom-elements.json

Keyboard

Key Action
Enter Submit the email form.

Source

  • chatty-ui/custom-elements.json