AgentAvatar
真正丢进列表里的那个头像。
Ada
Grace
Alan
它在什么之间选择
按顺序:
- 照片,如果设置了
pictureUrl - 群组簇,如果
members非空 - 角色,从
id推导
也就是说应用可以把手里有的东西传进去,得到一个说得通的结果,而不必在每个调用点分支。
不必存储的身份
未显式给出时,形状和墨色从 id 哈希而来,所以每个用户都有固定角色,而你不存储任何东西。两个客户端、两次会话和一次服务端渲染都会达成一致。
在 agent 上传入 shape 或 color 可以分别覆盖其中一项。
脸型
在 agent 上加 face: 'line' 即可使用线条脸。鼻子和形状、墨色一样从 id 哈希而来,所以同样稳定;设置 nose 可以指定一种,null 则不画。
阵容 preset 也可以带脸型和鼻子;agent 上的显式值优先于预设,预设优先于哈希。
尺寸
xs, 16px
sm, 22px
md, 28px
lg, 36px
xl, 72px
静止与光晕
still 渲染图片而不是动画——长列表里的正确选择。halo 加上一层从角色自身色相推导的柔软色洗。
填充
fillPx 设定圆内角色的大小。圆保持自己的尺寸,变的只是里面画的东西:比圆小就留出边距,比圆大就被裁掉。默认正好填满圆。它是一个自定义属性而不是子元素的宽度,因为三个分支里有两个的子元素是 img,样式表已经给它们定了尺寸。
fillPx 44
fillPx 64
fillPx 80
形状正在改变时
isMorphingShape 表示形状此刻正在角色底下被换掉——编辑器开着,有人在网格里一格格点。它为真时,头像在落定窗口(SETTLE_MS,经由 useMarkSettle)内保持上一次落定的状态,于是一次变形是一次变化而不是两次。同一帧里同时换形状和表情的身体,读起来不是同一个角色换了轮廓,而是另一个角色出现了。
无障碍
头像是 aria-hidden 的,除非它有带名字的照片。当头像单独站着、旁边没有文字时,请自己给它一个名字——见无障碍。
API
| 属性 | 类型 | 默认值 | 说明 |
|---|---|---|---|
agent* | AgentLike | — | — |
className | string | — | — |
emotionId | string | — | Protocol id, for hosts that speak the wire format. Ignored when `state` is given. |
face | "cute" | "eyes" | "line" | — | Face style, overriding whatever the agent identity resolves to. |
fillPx | number | — | Size of the character inside the circle. Smaller than the circle leaves a margin; larger crops it. Defaults to filling the circle exactly. |
halo | boolean | false | Soft colour wash behind the character. |
isMorphingShape | boolean | false | The shape is being changed under the character right now. Holds the last settled state for the settle window, so a morph is one change rather than two. A body that changes shape and expression in the same frame does not read as the same character having a new outline; it reads as a different character appearing. |
lineWeight | number | — | Stroke width multiplier. Not part of an identity, so always explicit. |
nose | "slant" | "angular" | "hook" | "long" | "curve" | "bow" | null | — | Nose, overriding the identity. `null` draws no nose. |
size | "xs" | "sm" | "md" | "lg" | "xl" | 'md' | — |
sizePx | number | — | Exact pixel size, overriding `size`. |
state | "idle" | "sleeping" | "drowsy" | "bored" | "waking" | "powering-down" | "listening" | "thinking" | "searching" | "reading" | "writing" | "working" | "loading" | "progress" | "radar" | "orbit" | "dictating" | "uploading" | "sending" | "receiving" | "messaging" | "waiting" | "spawning" | "composing" | "dragging" | "happy" | "excited" | "laughing" | "playful" | "proud" | "celebrate" | "bouncing" | "shy" | "sad" | "angry" | "confused" | "suspicious" | "surprised" | "scared" | "curious" | "humming" | "alerting" | "notifying" | "refusing" | — | — |
still | boolean | false | Render a still image instead of an animation. |
style | CSSProperties | — | — |
接下来
- AvatarStack——重叠的群组头像
- 徽标与状态——未读数与状态点
- 智能体名册——侧边栏里的二十张脸