On this page

Ad referral

Thẻ nguồn quảng cáo của tin nhắn trong inbox.

Copy page as MarkdownRead Markdown ↗

Key rules

  • Thẻ chỉ render khi có dữ liệu quảng cáo.
  • Element chatty-ad-referral ở mục Standard là chuẩn chatty-ui port theo; các mục theo surface mô tả component React đang chạy.
On this page

Use when / Avoid

Hiển thị ngữ cảnh quảng cáo của hội thoại.

Use instead

Component Use when
AdReferralBlock Hiển thị ngữ cảnh quảng cáo của hội thoại.
button Caller sở hữu tương tác liên quan.

Live preview

Standard

Standard
LightDarkDesktopMobile

Card chỉ có caption, và card có thumbnail, link bài đăng và chi tiết thu gọn.

Show code
chatty-ad-referral.element.jsWrap code linesCopy
<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>

Prototype (cùng ad-referral.styles.js) là chuẩn: chatty-ui port 1:1, và chatty-ui/custom-elements.json sinh từ chính prototype. Caption, thumbnail và phần chi tiết (media, sản phẩm) đi qua slot. Chưa inbox dùng element thật; mục Admin bên dưới mô tả React đang chạy.

Element

Element Module
chatty-ad-referral @avada/chatty-ui/elements/ad-referral.js

API

Kind Name Type Default Description
attribute heading string '' Nhãn kênh, ví dụ Facebook ad, Instagram ad, Clicked your ad.
attribute href string '' URL bài đăng; chỉ http(s), URL khác thì ẩn link.
attribute link-label string 'View post' Chữ của link bài đăng.
attribute toggle-label string 'Ad details' Tên truy cập của nút mở rộng.
attribute expanded boolean false Mở caption đầy đủ và phần chi tiết; ẩn thumbnail.
event toggle Event – expanded đổi từ nút mở rộng.
event click MouseEvent – Kích hoạt native của nút mở rộng.
slot default – – Caption: tiêu đề và nội dung quảng cáo.
slot thumb – – Thumbnail, ẩn khi mở rộng.
slot details – – Media và sản phẩm, hiện khi mở rộng.
part base – – Khung card.
part label – – Nhãn kênh.
part link – – Link bài đăng.
part caption – – Caption bị kẹp khi thu gọn.
part toggle – – Nút mở rộng; chỉ hiện khi có chi tiết hoặc caption bị kẹp.
part details – – Vùng chi tiết.
css-property --chatty-ad-referral-radius – – Bo góc.
css-property --chatty-ad-referral-background – – Nền.

Admin

Standard
LightDarkDesktopMobile

Card chỉ có caption, và card có thumbnail, link bài đăng và chi tiết thu gọn.

Show code
chatty-ad-referral.element.jsWrap code linesCopy
<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>
Standard
LightDarkDesktopMobile

Card đã mở rộng: caption đầy đủ và ảnh chi tiết.

Show code
chatty-ad-referral.element.jsWrap code linesCopy
<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>
Current (React), being replaced
LightDarkDesktopMobile

Thẻ thật với dữ liệu cục bộ, không có media ngoài.

Show code
ad-referral.jsxWrap code linesCopy
import React from 'react';
import {AdReferralBlock} from '@assets/pages/InboxManagement/v2/blocks/AdReferralBlock.jsx';
import '@assets/pages/InboxManagement/v2/styles.scss';

export function Card() {
  return <AdReferralBlock block={{adReferral: {platform: 'facebook', title: 'Summer collection', body: 'Explore our collection'}, i18n: text => text}} />;
}

Import / element

Component / element Import / file Scope root
AdReferralBlock @assets/pages/InboxManagement/v2/blocks/AdReferralBlock.jsx .inbox-v2

Anatomy

Part Element
1 Thumbnail tùy chọn, nhãn, nội dung, nút mở rộng và media.

Placement / order

Context Order
Caller Theo thứ tự markup của component.

Props

Prop Type Values Default Notes
block object adReferral và i18n Caller Không có adReferral thì trả null.

Sizes

Size Height Padding Gap Radius Font role (px/rem) Hit target Breakpoint / mechanism
Component Theo nội dung 8px 8px Theo token body-small Nút native Grid fit-content

Tokens

Part Token Light Dark
Nền Theo style inbox Theo style inbox No Dark skin

States

State Trigger Visual change (values) ARIA/attribute
Mở rộng Có media hoặc caption bị cắt Hiện chi tiết khi nhấn. aria-expanded

Behaviour

Interaction Result
Toggle Đổi expanded và dừng sự kiện hàng.

Copy

String i18n key Where
Ad details Ad details Nhãn nút mở rộng

Source

File Evidence
Public API
Markup
Caller

Do / Don't

Accessibility

Surface Role / name Keyboard / focus Live region Contrast pair / ratio
Admin Nút có tên Ad details và aria-expanded Nút native nhận Tab, Enter, Space Không có live region Theo style inbox

Target