Key rules
- Classic: inset đang active là
--chatty-layout-inset, lấy bản desktop và đổi sang bản mobile khi class mobile bật. - AI Mode: chuyển mobile khi viewport ≤899px; card carousel giữ 184px ở mọi breakpoint.
- AI Mode: giữa tin trong một cụm là
var(--chatty-space-050); giữa các cụm tin làvar(--chatty-space-400). - Admin: cột giữa inbox có
min-width480px và bỏ mốc này khi container còn 1080px trở xuống (trừ mixed inbox ticket/table). - Giá trị trong body là code hiện tại; đề xuất sửa nằm ở Target.
On this page
Where tokens live
| Surface | File | Scope root | Theme switch |
|---|---|---|---|
| Classic | _ |
.Avada- |
Không đổi theo theme |
| AI Mode | _ |
.chatty- |
Không đổi theo theme; mixin gọi ở cả Dark và Light |
| Admin | _ |
.inbox- |
Chỉ một theme; không có alias inset active |
How to apply
| Surface | API / class | Example |
|---|---|---|
| Classic | Padding theo inset active | padding- |
| AI Mode | Padding theo inset active | padding: var(- |
| Admin | Sass mixin của chatty- |
@include foundations. |
Element map
| Element | Surface | Role/Token | Light | Dark |
|---|---|---|---|---|
| Popup desktop | Classic | width | 400px | Same value |
| Popup radius | Classic | radius.$card | 20px | Same value |
| Composer padding | Classic | .Avada- |
12px | Same value |
| Home card gutter | Classic | - |
14px | Same value |
| Mobile sheet top | Classic | .mobile | 12px | Same value |
| Header panel | AI Mode | .aimode- |
52px | Same value |
| Mobile panel top | AI Mode | .is- |
12px | Same value |
| Card carousel | AI Mode | .chatty- |
184px | Same value |
| Tin cùng cụm | AI Mode | .chatty- |
var( |
Same value |
| Giữa các cụm tin | AI Mode | margin- |
var( |
Same value |
| Cột giữa inbox | Admin | Desktop- |
480px | No Dark skin |
| Business Brain fields | Admin | fieldset reset | padding 0, margin 0 | No Dark skin |
Tokens
Classic
Spacing
| Token | Value | Use |
|---|---|---|
| - |
0 | Storefront phát ra đơn vị px |
| - |
1 | Storefront phát ra đơn vị px |
| - |
2 | Storefront phát ra đơn vị px |
| - |
4 | Storefront phát ra đơn vị px |
| - |
6 | Storefront phát ra đơn vị px |
| - |
8 | Storefront phát ra đơn vị px |
| - |
10 | Storefront phát ra đơn vị px |
| - |
12 | Storefront phát ra đơn vị px |
| - |
16 | Storefront phát ra đơn vị px |
| - |
20 | Storefront phát ra đơn vị px |
| - |
24 | Storefront phát ra đơn vị px |
| - |
28 | Storefront phát ra đơn vị px |
| - |
32 | Storefront phát ra đơn vị px |
| - |
40 | Storefront phát ra đơn vị px |
| - |
48 | Storefront phát ra đơn vị px |
| - |
64 | Storefront phát ra đơn vị px |
| - |
80 | Storefront phát ra đơn vị px |
Radius
| Token | Value | Use |
|---|---|---|
$xs |
6px | Scale SCSS dùng chung |
$sm |
10px | Scale SCSS dùng chung |
$md |
14px | Scale SCSS dùng chung |
$lg |
18px | Scale SCSS dùng chung |
$card |
20px | Scale SCSS dùng chung |
$panel |
28px | Scale SCSS dùng chung |
$pill |
999px | Scale SCSS dùng chung |
| - |
6px | Token CSS cũ của chatty- |
| - |
8px | Token CSS cũ của chatty- |
| - |
12px | Token CSS cũ của chatty- |
| - |
9999px | Token CSS cũ của chatty- |
Breakpoints
| Name | Expression | Mechanism |
|---|---|---|
| Classic mobile | 899px | JS mobileMaxWidth config; class mobile |
| Classic input | (max- |
Role input- |
Variables
| Part | Token | Light | Dark |
|---|---|---|---|
| Inset mobile | - |
var( |
Same value |
| Inset desktop | - |
var( |
Same value |
| Panel chat | - |
820px | Same value |
| Panel classic | - |
400px | Same value |
| Panel sidebar | - |
430px | Same value |
| Header | - |
52px | Same value |
| Breakpoint mobile | - |
899px | Same value |
| Inset active desktop | - |
var( |
Same value |
| Inset active mobile | - |
var( |
Same value |
AI Mode
Spacing
| Token | Value | Use |
|---|---|---|
| - |
0 | Storefront phát ra đơn vị px |
| - |
1 | Storefront phát ra đơn vị px |
| - |
2 | Storefront phát ra đơn vị px |
| - |
4 | Storefront phát ra đơn vị px |
| - |
6 | Storefront phát ra đơn vị px |
| - |
8 | Storefront phát ra đơn vị px |
| - |
10 | Storefront phát ra đơn vị px |
| - |
12 | Storefront phát ra đơn vị px |
| - |
16 | Storefront phát ra đơn vị px |
| - |
20 | Storefront phát ra đơn vị px |
| - |
24 | Storefront phát ra đơn vị px |
| - |
28 | Storefront phát ra đơn vị px |
| - |
32 | Storefront phát ra đơn vị px |
| - |
40 | Storefront phát ra đơn vị px |
| - |
48 | Storefront phát ra đơn vị px |
| - |
64 | Storefront phát ra đơn vị px |
| - |
80 | Storefront phát ra đơn vị px |
Radius
| Token | Value | Use |
|---|---|---|
| - |
30px | Biến radius của AI Mode |
| - |
28px | Biến radius của AI Mode |
| - |
20px | Biến radius của AI Mode |
| - |
18px | Biến radius của AI Mode |
| - |
14px | Biến radius của AI Mode |
| - |
10px | Biến radius của AI Mode |
| - |
6px | Biến radius của AI Mode |
Breakpoints
| Name | Expression | Mechanism |
|---|---|---|
| AI Mode mobile | (max- |
Hook so sánh viewport ≤899 và class is- |
| AI Mode light desktop | (min- |
Media query của fill Light |
Variables
| Part | Token | Light | Dark |
|---|---|---|---|
| Inset mobile | - |
var( |
Same value |
| Inset desktop | - |
var( |
Same value |
| Panel chat | - |
820px | Same value |
| Panel classic | - |
400px | Same value |
| Panel sidebar | - |
430px | Same value |
| Header | - |
52px | Same value |
| Breakpoint mobile | - |
899px | Same value |
| Inset active desktop | - |
var( |
Same value |
| Inset active mobile | - |
var( |
Same value |
Admin
Spacing
| Token | Value | Use |
|---|---|---|
| - |
0 | Giá trị chia 16 thành rem; đọc - |
| - |
1 | Giá trị chia 16 thành rem; đọc - |
| - |
2 | Giá trị chia 16 thành rem; đọc - |
| - |
4 | Giá trị chia 16 thành rem; đọc - |
| - |
6 | Giá trị chia 16 thành rem; đọc - |
| - |
8 | Giá trị chia 16 thành rem; đọc - |
| - |
10 | Giá trị chia 16 thành rem; đọc - |
| - |
12 | Giá trị chia 16 thành rem; đọc - |
| - |
16 | Giá trị chia 16 thành rem; đọc - |
| - |
20 | Giá trị chia 16 thành rem; đọc - |
| - |
24 | Giá trị chia 16 thành rem; đọc - |
| - |
28 | Giá trị chia 16 thành rem; đọc - |
| - |
32 | Giá trị chia 16 thành rem; đọc - |
| - |
40 | Giá trị chia 16 thành rem; đọc - |
| - |
48 | Giá trị chia 16 thành rem; đọc - |
| - |
64 | Giá trị chia 16 thành rem; đọc - |
| - |
80 | Giá trị chia 16 thành rem; đọc - |
Radius
| Token | Value | Use |
|---|---|---|
| - |
6px | Token CSS cũ của chatty- |
| - |
8px | Token CSS cũ của chatty- |
| - |
12px | Token CSS cũ của chatty- |
| - |
9999px | Token CSS cũ của chatty- |
Breakpoints
| Name | Expression | Mechanism |
|---|---|---|
| Admin mobile type | (max- |
Biến type.$admin- |
| Inbox thu gọn center | 1080px | Container query của inbox, bỏ min- |
| Inbox profile drawer | 900px | Container query của inbox, profile mở thành drawer trên chat, list giữ min- |
Variables
| Part | Token | Light | Dark |
|---|---|---|---|
| Inset mobile | - |
var( |
No Dark skin |
| Inset desktop | - |
var( |
No Dark skin |
| Panel chat | - |
820px | No Dark skin |
| Panel classic | - |
400px | No Dark skin |
| Panel sidebar | - |
430px | No Dark skin |
| Header | - |
52px | No Dark skin |
| Breakpoint mobile | - |
899px | No Dark skin |
Composed values
| Element | Surface | Light | Dark | Fallback |
|---|---|---|---|---|
| Mobile sheet | Classic | top 12px; height và max- |
Same value | Không khai báo |
| Chiều cao desktop | Classic | min(700px, chiều cao viewport trừ 101px) | Same value | Không khai báo |
| Chiều cao panel mobile | AI Mode | - |
Same value | 100svh |
| Padding dưới của composer mobile | AI Mode | - |
Same value | 0px |
| Grid inbox khi container ≤1080px | Admin | minmax(260px, 1fr) 6px minmax(0, 3fr) 6px fit- |
No Dark skin | Không khai báo |
Box thật trên Classic dùng inset active và token spacing.
Show code
import React from 'react';
import {Box} from '@avada/chatty-ui/components/box.js';
export function Inset() {
return (
<Box data-inset style={{paddingInline: 'var(--chatty-layout-inset)', display: 'grid', gap: 'var(--chatty-space-400)', borderInlineStart: '1px solid var(--chatty-color-border-strong)'}}>
<Box className="chatty-type-heading-medium">One content inset</Box>
<Box className="chatty-type-body-medium">The transparent child adds no horizontal padding.</Box>
<Box className="chatty-type-body-small">16px mobile / 24px desktop</Box>
</Box>
);
}Copy-paste export
Classic
.Avada-Faqs_Popup {
--chatty-space-0: 0px;
--chatty-space-025: 1px;
--chatty-space-050: 2px;
--chatty-space-100: 4px;
--chatty-space-150: 6px;
--chatty-space-200: 8px;
--chatty-space-250: 10px;
--chatty-space-300: 12px;
--chatty-space-400: 16px;
--chatty-space-500: 20px;
--chatty-space-600: 24px;
--chatty-space-700: 28px;
--chatty-space-800: 32px;
--chatty-space-1000: 40px;
--chatty-space-1200: 48px;
--chatty-space-1600: 64px;
--chatty-space-2000: 80px;
--chatty-layout-inset-mobile: var(--chatty-space-400);
--chatty-layout-inset-desktop: var(--chatty-space-600);
--chatty-layout-panel-chat: 820px;
--chatty-layout-panel-classic: 400px;
--chatty-layout-panel-sidebar: 430px;
--chatty-layout-header: 52px;
--chatty-breakpoint-mobile: 899px;
}
.Avada-Faqs_Popup {
--chatty-layout-inset: var(--chatty-layout-inset-desktop);
}
.Avada-Faqs_Popup.mobile {
--chatty-layout-inset: var(--chatty-layout-inset-mobile);
}
AI Mode
.chatty-ai-mode {
--chatty-space-0: 0px;
--chatty-space-025: 1px;
--chatty-space-050: 2px;
--chatty-space-100: 4px;
--chatty-space-150: 6px;
--chatty-space-200: 8px;
--chatty-space-250: 10px;
--chatty-space-300: 12px;
--chatty-space-400: 16px;
--chatty-space-500: 20px;
--chatty-space-600: 24px;
--chatty-space-700: 28px;
--chatty-space-800: 32px;
--chatty-space-1000: 40px;
--chatty-space-1200: 48px;
--chatty-space-1600: 64px;
--chatty-space-2000: 80px;
--chatty-layout-inset-mobile: var(--chatty-space-400);
--chatty-layout-inset-desktop: var(--chatty-space-600);
--chatty-layout-panel-chat: 820px;
--chatty-layout-panel-classic: 400px;
--chatty-layout-panel-sidebar: 430px;
--chatty-layout-header: 52px;
--chatty-breakpoint-mobile: 899px;
}
.chatty-ai-mode {
--chatty-layout-inset: var(--chatty-layout-inset-desktop);
--radius-pill: 30px;
--radius-panel: 28px;
--radius-card: 20px;
--radius-lg: 18px;
--radius-md: 14px;
--radius-sm: 10px;
--radius-xs: 6px;
}
Admin
.inbox-v2 {
--chatty-space-0: var(--p-space-0, 0rem);
--chatty-space-025: var(--p-space-025, 0.0625rem);
--chatty-space-050: var(--p-space-050, 0.125rem);
--chatty-space-100: var(--p-space-100, 0.25rem);
--chatty-space-150: var(--p-space-150, 0.375rem);
--chatty-space-200: var(--p-space-200, 0.5rem);
--chatty-space-250: var(--p-space-250, 0.625rem);
--chatty-space-300: var(--p-space-300, 0.75rem);
--chatty-space-400: var(--p-space-400, 1rem);
--chatty-space-500: var(--p-space-500, 1.25rem);
--chatty-space-600: var(--p-space-600, 1.5rem);
--chatty-space-700: var(--p-space-700, 1.75rem);
--chatty-space-800: var(--p-space-800, 2rem);
--chatty-space-1000: var(--p-space-1000, 2.5rem);
--chatty-space-1200: var(--p-space-1200, 3rem);
--chatty-space-1600: var(--p-space-1600, 4rem);
--chatty-space-2000: var(--p-space-2000, 5rem);
--chatty-layout-inset-mobile: var(--chatty-space-400);
--chatty-layout-inset-desktop: var(--chatty-space-600);
--chatty-layout-panel-chat: 820px;
--chatty-layout-panel-classic: 400px;
--chatty-layout-panel-sidebar: 430px;
--chatty-layout-header: 52px;
--chatty-breakpoint-mobile: 899px;
}
Contrast matrix
| Surface | Pair | Light ratio | Dark ratio |
|---|---|---|---|
| Classic | Không áp dụng: token spacing không đặt màu | Not available | Not available |
| AI Mode | Không áp dụng: token spacing không đặt màu | Not available | Not available |
| Admin | Không áp dụng: token spacing không đặt màu | Not available | No Dark skin |
Target
Header phóng to: pseudo-element trong grid flow đẩy icon xuống, absolute giữ icon ở tâm.
Show code
import React, {useEffect, useRef, useState} from 'react';
import {readMotionDuration} from '@avada/chatty-ui/primitives/surfaceMorph.js';
import {IconBag} from '@avada/chatty-ui/icons/chatIcons.jsx';
function Diagram({id, children}) {
return <figure data-rule-visual={id} style={{margin: 0, color: 'var(--vib-1, #25252a)', fontFamily: 'inherit'}}>
<style>{`
[data-rule-visual] * { box-sizing: border-box; }
[data-rule-visual] .rule-columns { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1fr); gap:16px; }
[data-rule-visual] .rule-stage { position:relative; height:230px; overflow:hidden; border:1px solid #85858b; border-radius:12px; background:var(--bg-deep, #fff); margin-top:10px; }
[data-rule-visual] .rule-store { padding:14px; font-size:12px; line-height:1.5; }
[data-rule-visual] .rule-product { display:flex; gap:8px; margin-top:12px; align-items:center; }
[data-rule-visual] .rule-image { width:36px; height:36px; flex:none; background:#d9d5ce; border-radius:4px; }
[data-rule-visual] .rule-panel { position:absolute; left:12px; bottom:12px; background:#4759a8; border:1px solid #c2c9ef; border-radius:16px; color:white; overflow:hidden; }
[data-rule-visual] .rule-panel span { display:block; width:130px; padding:10px; font-size:12px; }
[data-rule-visual] .rule-controls { display:flex; align-items:center; flex-wrap:wrap; gap:12px; margin-bottom:14px; }
[data-rule-visual] .rule-replay { font:inherit; color:inherit; background:transparent; padding:6px 14px; border:1px solid currentColor; border-radius:8px; cursor:pointer; }
[data-rule-visual] .rule-replay:focus-visible { outline:3px solid #657fdf; outline-offset:3px; }
[data-rule-visual] figcaption, [data-rule-visual] .rule-note { font-size:12px; line-height:1.55; margin-top:12px; }
[data-rule-visual] .rule-header-view { position:relative; height:150px; display:grid; place-items:center; border:1px solid #85858b; border-radius:12px; overflow:hidden; margin-top:12px; }
[data-rule-visual] .rule-header { position:relative; width:150px; height:72px; border:1px solid #85858b; border-radius:10px; display:flex; justify-content:center; align-items:center; }
[data-rule-visual] .rule-header:after { content:''; position:absolute; left:0; right:0; top:50%; border-top:1px dashed #b55c42; pointer-events:none; }
[data-rule-visual] .rule-header-control { position:relative; padding:0; border:0; background:transparent; color:inherit; width:48px; height:48px; display:grid; grid-auto-rows:min-content; align-content:center; justify-items:center; transform:scale(2); }
[data-rule-visual] .rule-header-control::before { content:''; height:6px; width:100%; }
[data-rule-visual] .rule-header-control[data-fixed]::before { position:absolute; inset:0; }
[data-rule-visual] .rule-header-control svg { display:block; width:22px; height:22px; }
[data-rule-visual] .rule-timeline { display:grid; grid-template-columns:100px minmax(0,1fr); gap:12px; align-items:start; margin:16px 0; font-size:12px; }
[data-rule-visual] .rule-track { display:flex; flex-wrap:wrap; gap:6px; align-items:center; }
[data-rule-visual] .rule-task { padding:8px; border:1px solid #85858b; border-radius:4px; }
[data-rule-visual] .rule-cost { display:block; height:16px; border-radius:3px; margin-top:8px; }
[data-rule-visual] .rule-resize-axis { position:relative; height:90px; margin-top:14px; font-size:12px; }
[data-rule-visual] .rule-resize-axis::before { content:''; position:absolute; top:32px; left:0; right:0; border-top:1px solid #85858b; }
[data-rule-visual] .rule-time-mark { position:absolute; top:24px; height:20px; border-left:1px dashed currentColor; }
[data-rule-visual] .rule-time-mark span { position:absolute; top:-19px; transform:translateX(-50%); }
[data-rule-visual] .rule-time-bar { position:absolute; top:34px; left:0; height:10px; border-radius:3px; }
[data-rule-visual] .rule-time-label { position:absolute; top:54px; left:0; right:0; line-height:1.4; }
[data-rule-visual] .rule-chart { display:grid; gap:8px; margin-top:14px; }
[data-rule-visual] .rule-metric-columns { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; font-size:12px; text-align:center; }
[data-rule-visual] .rule-bar-track { height:110px; display:flex; align-items:end; justify-content:center; border-bottom:1px solid #85858b; }
[data-rule-visual] .rule-bar { width:70%; min-height:2px; background:#4759a8; border-radius:3px 3px 0 0; }
[data-rule-visual] .rule-bar-value { min-height:36px; display:flex; align-items:end; justify-content:center; }
@media(max-width:380px) { [data-rule-visual] .rule-columns { gap:8px; } [data-rule-visual] .rule-stage { height:240px; } }
@media(prefers-reduced-motion:reduce) { [data-rule-visual], [data-rule-visual] * { animation:none !important; transition:none !important; } }
`}</style>
{children}
</figure>;
}
function SurfaceComparison({resize = false}) {
const root = useRef(null);
const [run, setRun] = useState(0);
const played = useRef(0);
const [state, setState] = useState('Ready');
const [reduced, setReduced] = useState(false);
useEffect(() => {
const media = matchMedia('(prefers-reduced-motion: reduce)');
const update = () => setReduced(media.matches);
update();
media.addEventListener('change', update);
return () => media.removeEventListener('change', update);
}, []);
useEffect(() => {
if (!run) return;
if (played.current === run) {
setState('Ready');
return;
}
played.current = run;
const element = root.current;
const stages = [...element.querySelectorAll('.rule-stage')];
const panels = stages.map(stage => stage.querySelector('.rule-panel'));
const store = stages[0].querySelector('.rule-store');
const style = getComputedStyle(element);
const open = readMotionDuration({style, token: resize ? '--chatty-motion-duration-350' : '--chatty-motion-duration-400', fallback: resize ? 350 : 400});
const targetDuration = resize ? 280 : open;
const tailDelay = resize ? 206 : 0;
const close = readMotionDuration({style, token: '--chatty-motion-duration-350', fallback: 350});
const easing = style.getPropertyValue('--chatty-motion-ease-surface').trim() || 'cubic-bezier(0.2, 0, 0, 1)';
const startWidth = resize ? 94 : 54;
const startHeight = resize ? 102 : 38;
const widths = stages.map(stage => stage.clientWidth - 24);
const animations = [];
let cancelled = false;
let hold;
let releaseHold;
const pause = () => new Promise(resolve => { releaseHold = resolve; hold = setTimeout(resolve, 500); });
const animate = (node, frames, duration, delay = 0) => {
const animation = node.animate(frames, {duration, delay, easing, fill: 'forwards'});
animations.push(animation);
return animation.finished;
};
const show = expanded => {
panels.forEach((panel, index) => Object.assign(panel.style, {
width: `${expanded ? widths[index] : startWidth}px`, height: `${expanded ? 150 : startHeight}px`, clipPath: 'none'
}));
};
const play = async () => {
setState('Opening');
if (reduced) {
show(true);
await pause();
if (cancelled) return;
show(false);
setState('Done');
return;
}
const geometry = [{width: `${startWidth}px`, height: `${startHeight}px`}, {width: `${widths[0]}px`, height: '150px'}];
Object.assign(panels[1].style, {width: `${widths[1]}px`, height: '150px'});
const clips = [
{clipPath: `inset(${150 - startHeight}px ${Math.max(0, widths[1] - startWidth)}px 0 0 round 16px)`},
{clipPath: 'inset(0px 0px 0px 0px round 16px)'}
];
await Promise.all([
animate(panels[0], geometry, open, tailDelay),
animate(panels[1], clips, targetDuration),
animate(store, [{transform: 'translateY(0px)'}, {transform: 'translateY(14px)'}], open, tailDelay)
]);
if (cancelled) return;
setState('Open');
await pause();
if (cancelled) return;
setState('Closing');
await Promise.all([
animate(panels[0], [...geometry].reverse(), close, tailDelay),
animate(panels[1], [...clips].reverse(), resize ? targetDuration : close),
animate(store, [{transform: 'translateY(14px)'}, {transform: 'translateY(0px)'}], close, tailDelay)
]);
if (!cancelled) setState('Done');
};
play().catch(error => { if (!cancelled) throw error; });
return () => {
cancelled = true;
clearTimeout(hold);
releaseHold?.();
animations.forEach(animation => animation.cancel());
store.style.transform = '';
show(false);
};
}, [run, reduced, resize]);
return <div ref={root} data-comparison={resize ? 'resize' : 'overlay'} data-run={run} data-state={state} data-reduced={reduced}>
<div className="rule-controls">
<button className="rule-replay" type="button" onClick={() => setRun(value => value + 1)}>Replay</button>
<span role="status">{state}{reduced ? ' · Reduced motion · static endpoints' : resize ? ' · Current tail 556 ms / Target 280 ms' : ' · 400 / 350 ms'}</span>
</div>
<div className="rule-columns">
{['width/height', 'clip-path'].map((label, index) => <div key={label}>
<strong>{resize ? index ? 'Target' : 'Current code' : label}</strong>
{resize && <div className="rule-note">{label}</div>}
<div className="rule-stage">
<div className="rule-store"><strong>Store</strong><p>Everyday essentials</p>{[0, 1].map(item => <div className="rule-product" key={item}><span className="rule-image" /><span>Ceramic collection<br />View product</span></div>)}</div>
<div className="rule-panel" style={{width: resize ? 94 : 54, height: resize ? 102 : 38}}><span>Chat</span></div>
</div>
{resize ? <>
<div className="rule-note">Time after input (ms), 0–600</div>
<div className="rule-resize-axis" aria-label="Time after input, milliseconds">
<span className="rule-time-mark" data-target-deadline="300" style={{left: '50%'}}><span>300</span></span>
<span className="rule-time-mark" data-input-window="500" style={{left: '83.333%'}}><span>500</span></span>
<span className="rule-time-bar" style={{width: index ? '46.667%' : '92.667%', background: index ? '#39765c' : '#a55740'}} />
<span className="rule-time-label">{index ? 'Target: 280 ms' : 'Observed end: 345–556 ms'}</span>
</div>
<div className="rule-note">{index ? 'Đích ≤300 ms kể cả đuôi; chưa phải code hiện tại.' : 'Layout shift: AI Mode bag 0.29–0.44; Classic Expand/Collapse 0.073–0.080.'}</div>
</> : <div className="rule-note">{index ? 'CLS 0.000–0.003' : 'CLS 0.67–0.74'}</div>}
</div>)}
</div>
<p className="rule-note">Mô phỏng phóng đại dịch chuyển để nhìn rõ hai cách đổi bounds; không phải phép đo CLS của preview. {resize ? 'Current code còn đổi width từng frame. CLS báo 0 không có nghĩa là không dịch: 23/24 lần bị loại do cửa sổ 500 ms sau input; một frame tại 556 ms đã bị tính vào CLS (0.0013). Preview minh họa biên kết thúc chậm nhất bằng clock 350 ms cộng khoảng chờ 206 ms, không phải trace frame gốc. Target 280 ms là mô phỏng đích ≤300 ms kể cả đuôi, không phải số đo production. Mobile không có resize morph; product detail chưa kiểm.' : 'CLS lấy từ số đo bàn giao trên store thật; hình chỉ minh họa cơ chế. Màu và nội dung panel được đơn giản hóa.'}</p>
</div>;
}
function Metric({title, values, unit, maximum}) {
return <section className="rule-chart" aria-label={title}>
<strong>{title}</strong>
<div className="rule-metric-columns">{values.map((value, index) => <div key={index}>
<span className="rule-bar-value">{value === null ? 'Not measured' : `${value}${unit}`}</span>
<div className="rule-bar-track">{value !== null && <div className="rule-bar" data-value={value} style={{height: `${value / maximum * 100}%`, background: ['#a55740', '#4759a8', '#39765c'][index]}} />}</div>
<span>{['A', 'B', 'C'][index]}</span>
</div>)}</div>
</section>;
}
export function PseudoElement() {
return <Diagram id="pseudo-element">
<div className="rule-columns">
{[false, true].map(fixed => <div key={String(fixed)}>
<strong>{fixed ? 'Absolute pseudo-element' : 'Grid item pseudo-element'}</strong>
<div className="rule-header-view"><div className="rule-header">
<button type="button" className="rule-header-control" data-fixed={fixed || undefined} aria-label="Bag"><IconBag size={22} /></button>
</div></div>
<p className="rule-note">{fixed ? 'Offset 0 px' : 'Offset +3 px'} · Zoom ×2</p>
</div>)}
</div>
<figcaption>Vạch đứt là tâm header. Bên trái, ::before còn trong grid flow nên đẩy tâm icon xuống 3px; bên phải position:absolute đưa phần trang trí ra khỏi flow. Phóng to gấp đôi để thấy chênh lệch.</figcaption>
</Diagram>;
}Target: mẫu giá trị Inbox được duyệt; không phải implementation production.
Show code
import React from 'react';
const radii = {"container": "20px", "dialog": "20px", "popover": "12px", "control": "10px", "element": "8px", "tag": "6px", "checkbox": "4px", "avatar": "clamp(6px, 30%, 12px)", "action": "9999px", "chat-control": ".5rem", "option-item": ".5rem", "kbd": ".25rem"};
const themes = {"light": {"--chatty-color-bg": "#fff", "--chatty-color-bg-fill-caution-secondary": "oklch(.9167 .1785 98.00)", "--chatty-color-bg-fill-critical": "oklch(.9470 .0300 20.50)", "--chatty-color-bg-fill-info-secondary": "oklch(.8637 .1018 216.95)", "--chatty-color-bg-fill-inverse": "#1b1b1b", "--chatty-color-bg-fill-secondary": "#ebebeb", "--chatty-color-bg-fill-success": "oklch(.9672 .0599 131.73)", "--chatty-color-bg-fill-success-secondary": "oklch(.9053 .1942 133.49)", "--chatty-color-bg-fill-tertiary": "#ddd", "--chatty-color-bg-fill-tertiary-hover": "#d0d0d0", "--chatty-color-bg-surface": "#fff", "--chatty-color-bg-surface-critical": "oklch(.9470 .0300 20.50)", "--chatty-color-bg-surface-secondary": "#f7f7f7", "--chatty-color-bg-surface-secondary-selected": "#ebebeb", "--chatty-color-bg-surface-success": "oklch(.9672 .0599 131.73)", "--chatty-color-bg-surface-tertiary": "#f2f2f2", "--chatty-color-bg-surface-warning": "oklch(.9557 .0350 67.45)", "--chatty-color-border": "rgba(221,221,221,1)", "--chatty-color-border-secondary": "rgba(242,242,242,1)", "--chatty-color-border-tertiary": "rgba(192,192,192,1)", "--chatty-color-border-warning": "oklch(.9316 .0545 67.18)", "--chatty-color-icon-secondary": "#606060", "--chatty-color-text": "#101010", "--chatty-color-text-brand-on-accent": "#fff", "--chatty-color-text-caution": "oklch(.2708 .0638 90.28)", "--chatty-color-text-critical": "oklch(.2121 .0942 30.90)", "--chatty-color-text-info": "oklch(.2715 .0576 221.37)", "--chatty-color-text-link": "oklch(.4840 .2413 262.80)", "--chatty-color-text-link-inverse": "oklch(.7340 .1449 264.63)", "--chatty-color-text-on-accent": "#fff", "--chatty-color-text-secondary": "rgba(74,74,74,1)", "--chatty-color-text-success": "oklch(.2334 .0796 134.14)", "--chatty-color-text-warning": "oklch(.2475 .0726 51.49)"}, "dark": {"--chatty-color-bg": "#121212", "--chatty-color-bg-fill-caution-secondary": "#4f4700", "--chatty-color-bg-fill-critical": "#2f040b", "--chatty-color-bg-fill-info-secondary": "#003a5a", "--chatty-color-bg-fill-inverse": "#303030", "--chatty-color-bg-fill-secondary": "#373737", "--chatty-color-bg-fill-success": "#014b40", "--chatty-color-bg-fill-success-secondary": "#014b40", "--chatty-color-bg-fill-tertiary": "#414141", "--chatty-color-bg-fill-tertiary-hover": "#585858", "--chatty-color-bg-surface": "#1a1a1a", "--chatty-color-bg-surface-critical": "#5f0716", "--chatty-color-bg-surface-secondary": "#282828", "--chatty-color-bg-surface-secondary-selected": "#373737", "--chatty-color-bg-surface-success": "#073630", "--chatty-color-bg-surface-tertiary": "#2f2f2f", "--chatty-color-bg-surface-warning": "#412d00", "--chatty-color-border": "#ffffff17", "--chatty-color-border-secondary": "#ffffff0f", "--chatty-color-border-tertiary": "#ffffff2e", "--chatty-color-border-warning": "#956f00", "--chatty-color-icon-secondary": "#aaa", "--chatty-color-text": "#eee", "--chatty-color-text-brand-on-accent": "#121212", "--chatty-color-text-caution": "#ffeb78", "--chatty-color-text-critical": "#f78086", "--chatty-color-text-info": "#a8d8ff", "--chatty-color-text-link": "#c5d0ff", "--chatty-color-text-link-inverse": "#c5d0ff", "--chatty-color-text-on-accent": "#121212", "--chatty-color-text-secondary": "#aaa", "--chatty-color-text-success": "#2ced83", "--chatty-color-text-warning": "#ffc879"}};
const frameStyle = {
...themes.light,
...Object.fromEntries(Object.entries(radii).map(([role,value])=>['--chatty-radius-'+role,value])),
'--chatty-type-family':'ShopifyInter, ui-sans-serif, system-ui, sans-serif',
'--chatty-type-weight-regular':400,'--chatty-type-weight-medium':500,'--chatty-type-weight-semibold':600,
'--chatty-type-body-medium-size':'13px','--chatty-type-body-medium-line':'20px',
'--chatty-type-button-label-size':'12px','--chatty-type-button-label-line':'16px',
'--chatty-type-badge-label-size':'12px','--chatty-type-badge-label-line':'18px',
fontFamily:'var(--chatty-type-family)',fontSize:'var(--chatty-type-body-medium-size)',lineHeight:'var(--chatty-type-body-medium-line)',fontWeight:'var(--chatty-type-weight-regular)',
color:'var(--chatty-color-text)',background:'var(--chatty-color-bg-surface)',padding:16
};
const box = {border:'1px solid #888',background:'#f7f7f7',padding:12,color:'#101010',font:'inherit'};
function Target({children}) { return <div data-inbox-target style={frameStyle}><link rel="stylesheet" href="https://cdn.shopify.com/static/fonts/shopifyinter/v0/styles.css"/><p style={{marginTop:0}}>Target · design fixture · phase 1b chưa ship</p>{children}</div>; }
function RadiusSample({role,value}) {
const style={...box,borderRadius:`var(--chatty-radius-${role})`};
if(role==='checkbox')return <input aria-label="Checkbox radius sample" type="checkbox" style={{...style,appearance:'none',width:24,height:24,padding:0}}/>;
if(role==='avatar')return <span role="img" aria-label="Avatar initials" style={{...style,width:36,height:36,padding:0,display:'grid',placeItems:'center'}}>AB</span>;
if(role==='tag')return <span style={{...style,padding:'0 8px',display:'inline-block'}}>Status</span>;
if(role==='kbd')return <kbd style={{...style,padding:'0 6px'}}>A</kbd>;
if(['action','control','chat-control','option-item'].includes(role))return <button type="button" style={style}>Action</button>;
if(role==='dialog')return <dialog open aria-label="Dialog radius sample" style={{...style,position:'static',margin:0}}>Dialog</dialog>;
return <section aria-label={`${role} radius sample`} style={style}>{role}</section>;
}
export function Radius() {
return <Target><div style={{display:'grid',gridTemplateColumns:'repeat(auto-fit,minmax(140px,1fr))',gap:16}}>{Object.entries(radii).map(([role,value])=><figure key={role} data-radius-role={role} style={{margin:0,[`--chatty-radius-${role}`]:value}}><RadiusSample role={role} value={value}/><figcaption>{role} · {value}{role==='kbd'?' · đề xuất':''}</figcaption></figure>)}</div></Target>;
}