Key rules
chatty-ad-referralkhai báo 5 attribute, 0 property không có attribute, 2 event, 3 slot, 6 part và 2 CSS custom property.- Import 1 module
@avada/chatty-ui/elements/ad-referral.jslà definechatty-ad-referral; 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
The ad a customer came from, as a preview card above their first bubble in the inbox. The caption clamps to two lines; the chevron expands the caption and the details (media, product). Class ChattyAdReferral.
Attributes
| Name | Property | Type | Default | Description |
|---|---|---|---|---|
heading |
heading |
string |
'' |
Channel label, e.Facebook ad, Instagram ad, Clicked your ad. |
href |
href |
string |
'' |
Public post URL; http(s) only, otherwise the link is hidden. |
link- |
linkLabel |
string |
'View post' |
Text of the view- |
toggle- |
toggleLabel |
string |
'Ad details' |
Accessible name of the chevron. |
expanded |
expanded |
boolean |
false |
Shows the full caption and the details; hides the thumbnail. |
Properties
Attributes also expose the properties listed in the Property column above.
Not declared in the manifest.
Events
| Name | Detail type | Description |
|---|---|---|
toggle |
Event |
expanded changed from the chevron. |
click |
MouseEvent |
Native activation of the toggle. |
Slots
| Name | Description |
|---|---|
| default | Caption: ad title and body. |
thumb |
48px thumbnail, hidden while expanded. |
details |
Media and product shown while expanded. |
Parts
| Name | Description |
|---|---|
base |
Card container. |
label |
Channel label, e.Facebook ad. |
link |
View- |
caption |
Clamped caption. |
toggle |
Expand button. |
details |
Expanded details wrapper. |
CSS custom properties
| Name | Default | Description |
|---|---|---|
- |
– | Corner radius. |
- |
– | Background. |
Usage
import '@avada/chatty-ui/tokens/tokens.css';
import '@avada/chatty-ui/elements/ad-referral.js';
<chatty-ad-referral heading="Facebook ad"
>Summer collection<br />Explore our collection</chatty-ad-referral
>
<chatty-ad-referral heading="WhatsApp ad" href="https://example.com/post">
<img slot="thumb" src="/fixtures/tote.svg" alt="" />
Canvas tote bag<br />Carry everything, every day.
<img
slot="details"
src="/fixtures/tote.svg"
alt="Canvas tote bag"
style="max-width: 100%; max-height: 240px; border-radius: 8px"
/>
</chatty-ad-referral>
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-ad-referral heading="Facebook ad"
>Summer collection<br />Explore our collection</chatty-ad-referral
>
<chatty-ad-referral heading="WhatsApp ad" href="https://example.com/post">
<img slot="thumb" src="/fixtures/tote.svg" alt="" />
Canvas tote bag<br />Carry everything, every day.
<img
slot="details"
src="/fixtures/tote.svg"
alt="Canvas tote bag"
style="max-width: 100%; max-height: 240px; border-radius: 8px"
/>
</chatty-ad-referral>Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.
Show code
<chatty-ad-referral heading="Instagram ad" expanded>
Canvas tote bag<br />Carry everything, every day.
<img
slot="details"
src="/fixtures/tote.svg"
alt="Canvas tote bag"
style="width: 160px; border-radius: 8px"
/>
</chatty-ad-referral>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-ad-referral heading="Facebook ad"
>Summer collection<br />Explore our collection</chatty-ad-referral
>
<chatty-ad-referral heading="WhatsApp ad" href="https://example.com/post">
<img slot="thumb" src="/fixtures/tote.svg" alt="" />
Canvas tote bag<br />Carry everything, every day.
<img
slot="details"
src="/fixtures/tote.svg"
alt="Canvas tote bag"
style="max-width: 100%; max-height: 240px; border-radius: 8px"
/>
</chatty-ad-referral>| Part | Element | Source |
|---|---|---|
| 1 | CSS part base |
chatty- |
| 2 | CSS part label |
chatty- |
| 3 | CSS part link |
chatty- |
| 4 | CSS part caption |
chatty- |
| 5 | CSS part toggle |
chatty- |
| 6 | CSS part details |
chatty- |
Keyboard
| Key | Action |
|---|---|
| Enter / Space | Toggle details; Enter follows the link. |
Source
- chatty-ui/custom-elements.json