chatty-survey khai báo 6 attribute, 1 property không có attribute, 2 event, 4 slot, 5 part và 2 CSS custom property.
Import 1 module @avada/chatty-ui/elements/survey.js là define chatty-survey; 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
Satisfaction survey: star rating, optional comment, Submit and Skip. The host owns persistence; it sets busy while saving and submitted once accepted. Class ChattySurvey.
Attributes
Name
Property
Type
Default
Description
value
value
number
0
Chosen star rating; 0 means none, which keeps Submit disabled.
comment
comment
string
''
Optional comment, up to 250 characters.
busy
busy
'' | 'submit' | 'skip'
''
Which action is saving; blocks both actions and shows a spinner on that one.
error
error
boolean
false
Shows the generic error (role alert) above the actions.
submitted
submitted
boolean
false
Shows the thank-you line and the read-only rating.
readonly
readonly
boolean
false
Shows the rating read-only without the form (history).
Properties
Attributes also expose the properties listed in the Property column above.
<chatty-survey>
<span slot="heading">How was your chat?</span>
</chatty-survey>
<chatty-survey value="4" comment="Quick answer about sizes.">
<span slot="heading">How was your chat?</span>
</chatty-survey>
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 codechatty-survey.element.jsWrap code linesCopy
<chatty-survey>
<span slot="heading">How was your chat?</span>
</chatty-survey>
<chatty-survey value="4" comment="Quick answer about sizes.">
<span slot="heading">How was your chat?</span>
</chatty-survey>
Standard
LightDarkDesktopMobile
Các variant hoặc state chính đặt cạnh nhau trong cùng ví dụ.
Show codechatty-survey.element.jsWrap code linesCopy
import '@avada/chatty-ui/tokens/tokens.css';
import {IconCheck, IconAlertCircle} from '@avada/chatty-ui/elements/icon-glyphs.js';
// Standard: the chatty-survey prototype chatty-ui ports from (chatty-ui/src/elements/survey.js).
import {html} from 'lit';
import '@avada/chatty-ui/elements/survey.js';
export function States() {
return html`
<chatty-survey value="5" busy="submit">
<span slot="heading">How was your chat?</span>
</chatty-survey>
<chatty-survey value="2" error>
<span slot="heading">How was your chat?</span>
${IconAlertCircle({size: 16, slot: 'error-icon'})}
</chatty-survey>
<chatty-survey value="5" submitted>
${IconCheck({slot: 'icon'})}
<span slot="thanks">Thanks for your feedback!</span>
</chatty-survey>
`;
}
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 codechatty-survey.element.jsWrap code linesCopy
<chatty-survey>
<span slot="heading">How was your chat?</span>
</chatty-survey>
<chatty-survey value="4" comment="Quick answer about sizes.">
<span slot="heading">How was your chat?</span>
</chatty-survey>