Prototype (cùng launcher.styles.js) là chuẩn: chatty-ui port 1:1, và chatty-ui/custom-elements.json sinh từ chính prototype. Trigger mở panel và nút giỏ là hai button anh em (React lồng button trong role button). Icon trợ lý, icon giỏ và câu mời đi qua slot. Chưa surface nào dùng element thật; mục AI Mode bên dưới mô tả React đang chạy.
Element
Element
Module
chatty-launcher
@avada/chatty-ui/elements/launcher.js
API
Kind
Name
Type
Default
Description
attribute
label
string
''
Tên truy cập của trigger, ví dụ Open Chatty.
attribute
bag
boolean
false
Hiện nút giỏ; giỏ xác nhận rỗng thì bỏ.
attribute
count
number
0
Số món trong giỏ; badge hiện khi lớn hơn 0 và có trần hiển thị.
attribute
bag-label
string
'Shopping bag'
Tên nút giỏ khi count bằng 0.
attribute
count-label
string
'{count} items in cart'
Tên nút giỏ khi count lớn hơn 0; {count} được thay.
attribute
live
boolean
false
Chấm online trên orb.
event
chatty-open
CustomEvent<{target: 'panel' , 'bag'}>
–
Trigger (target panel) hoặc nút giỏ (target bag) được kích hoạt.
event
chatty-preload
CustomEvent<{}>
–
Lần đầu rê chuột vào hoặc focus; host tải panel trước.
event
click
MouseEvent
–
Kích hoạt native của trigger hoặc nút giỏ.
slot
default
–
–
Câu mời, ví dụ Ask a question.
slot
icon
–
–
Icon trợ lý trong orb.
slot
bag-icon
–
–
Icon giỏ.
part
base
–
–
Khung pill.
part
trigger
–
–
Button mở panel; vùng bấm phủ cả pill trừ nút giỏ.
part
orb
–
–
Orb trợ lý.
part
bag
–
–
Nút giỏ.
part
count
–
–
Badge số món.
css-property
--chatty-launcher-width
–
–
Bề rộng pill.
css-property
--chatty-launcher-background
–
–
Nền pill.
AI Mode
Standard
LightDarkDesktopMobile
Pill resting có chấm online, và pill có nút giỏ với badge số món.
Show codechatty-launcher.element.jsWrap code linesCopy
import React from 'react';
import {LauncherChrome} from '@scripttag/v2/components/LauncherChrome.jsx';
import {ButtonIcon} from '@scripttag/v2/icons/buttonIcon.jsx';
import IconBag from '@scripttag/v2/icons/IconBag.jsx';
import {SearchPlaceholder} from '@scripttag/v2/components/SearchBar/SearchPlaceholder.jsx';
import '@scripttag/v2/styles/glass.scss';
import '@scripttag/v2/components/SearchBar/SearchBar.scss';
// The resting skin hangs off `.chatty-ai-mode.state-resting` (and the bag off `.has-bag`), which
// AIModeWidgetRoot sets on the widget root; the frame root has neither, so the story adds them.
const resting = node => node?.closest('[data-surface]')?.classList.add('state-resting', 'has-bag');
export function Resting() {
return <div ref={resting}>
<LauncherChrome assistantName="Chatty" invitePhrases={['Ask a question']} actions={{loadPanel: () => {}, openPanel: () => {}}} bagCount={0} Icon={ButtonIcon} BagIcon={IconBag} Placeholder={SearchPlaceholder} />
</div>;
}
Import / element
Component / element
Import / file
Scope root
LauncherChrome
@scripttag/v2/components/LauncherChrome.jsx
.chatty-ai-mode
Anatomy
Part
Element
1
Trigger, icon, placeholder và nút giỏ.
Placement / order
Context
Order
Caller
Theo thứ tự markup của component.
Props
Prop
Type
Values
Default
Notes
assistantName
string
Tên trợ lý
Caller
Dùng trong nhãn mở panel.
preview
boolean
true, false
false
Bản xem tĩnh cho preview preset ở admin: trigger không role, nhãn, handler; giỏ là span.
Sizes
Size
Height
Padding
Gap
Radius
Font role (px/rem)
Hit target
Breakpoint / mechanism
Component
Theo caller
Theo caller
Theo caller
Theo caller
Theo caller
Nút native và trigger
Style từ SearchBar
Tokens
Part
Token
Light
Dark
Nền
Theo scope
Theo scope
Theo scope
States
State
Trigger
Visual change (values)
ARIA/attribute
Giỏ có hàng
bagCount lớn hơn 0
Hiện badge số lượng.
aria-label theo số lượng
Behaviour
Interaction
Result
Mở panel
Click trigger gọi action; click nút giỏ truyền bag.
Cold takeover
Khi full app đã sẵn sàng, chuyển lại biến và focus cho panel tương ứng.
Cold icon
Icon upload dùng ảnh; nếu không thì dùng Glyph do caller truyền.
Copy
String
i18n key
Where
Shopping bag
Shopping bag
Nhãn giỏ rỗng
Source
File
Evidence
Public API
Markup
Caller
Do / Don't
Accessibility
Surface
Role / name
Keyboard / focus
Live region
Contrast pair / ratio
AI Mode
Trigger role button có tên; nút giỏ có aria-label
Caller xử lý phím cho trigger; giỏ là nút native, trừ bản preview