• 简体中文
  • CompactCharacterPicker

    裁到刚好能放在注册表单旁边的选择器。

    形状
    配色
    import { useState } from 'react';
    import { AgentAvatar, CompactCharacterPicker, type ColorId, type ShapeId } from '@aora-bot/react';
    
    export default function Demo() {
      const [shape, setShape] = useState<ShapeId>('blob');
      const [color, setColor] = useState<ColorId>('blue');
      return (
        <div className="site-demo site-demo--column">
          <AgentAvatar agent={{ id: 'first', shape, color }} size="xl" />
          <CompactCharacterPicker shape={shape} color={color} onSelectShape={setShape} onSelectColor={setColor} />
        </div>
      );
    }

    选项少是有意的

    只给一小撮墨色和形状,而不是整本目录。形状是 AUTO_SHAPE_POOL——在 16px 下仍然读得出是个角色的形状;少掉的那种墨色是 black,它被保留为默认墨色,没人会把它当成一个选择(ASSIGNABLE_COLOR_IDS)。一个人决定自己第一个智能体长什么样时,想要的是几个显而易见的选项,而不是整本目录;完整网格属于他们稍后可以打开的编辑器。

    组件和普通选择器一样是受控的,两组选项排在同一行。

    API

    属性类型默认值说明
    color*"black" | "brown" | "red" | "orange" | "yellow" | "green" | "cyan" | "blue" | "violet" | "magenta" | "pink" | "gray"——
    shape*"mochi" | "circle" | "blob" | "pebble" | "egg" | "bun" | "tofu" | "pill" | "hex" | "onigiri" | "gem" | "cloud" | "drop" | "leaf" | "flower" | "clover" | "sprout" | "mushroom" | "acorn" | "cactus" | "pear" | "apple" | "strawberry" | "cherry" | "star" | "heart" | "flame" | "bell" | "ghost" | "bot" | "crescent" | "boba" | "fish" | "octopus" | "cat" | "bunny" | "bear" | "chick" | "penguin" | "pig" | "fox" | "bob" | "topknot" | "spiky" | "curly" | "twinbuns"——
    classNamestring——
    face"cute" | "eyes" | "line"—Face style. Passing it adds the face toggle, and the nose row when the line face is chosen — the same behaviour as the full picker.
    lineWeightnumber——
    nose"slant" | "angular" | "hook" | "long" | "curve" | "bow" | null—Nose for the line face. Defaults to the first nose while `face` is `line`.
    onSelectColor((color: "black" | "brown" | "red" | "orange" | "yellow" | "green" | "cyan" | "blue" | "violet" | "magenta" | "pink" | "gray") => void)——
    onSelectFace((face: "cute" | "eyes" | "line") => void)——
    onSelectNose((nose: "slant" | "angular" | "hook" | "long" | "curve" | "bow") => void)——
    onSelectShape((shape: "mochi" | "circle" | "blob" | "pebble" | "egg" | "bun" | "tofu" | "pill" | "hex" | "onigiri" | "gem" | "cloud" | "drop" | "leaf" | "flower" | "clover" | "sprout" | "mushroom" | "acorn" | "cactus" | "pear" | "apple" | "strawberry" | "cherry" | "star" | "heart" | "flame" | "bell" | "ghost" | "bot" | "crescent" | "boba" | "fish" | "octopus" | "cat" | "bunny" | "bear" | "chick" | "penguin" | "pig" | "fox" | "bob" | "topknot" | "spiky" | "curly" | "twinbuns") => void)——
    sizePxnumber—Size of each preview. Defaults to `PICKER_MARK_PX`.
    styleCSSProperties——

    接下来