• 简体中文
  • CharacterMarkMirror

    把已经在运行的角色再画一遍,画到别处。

    source
    mirror
    mirror
    mirror
    mirror
    import { CharacterMark, CharacterMarkMirror } from '@aora-bot/react';
    
    export default function Demo() {
      return (
        <div className="site-demo">
          <div className="site-demo__cell">
            <CharacterMark sourceId="demo-source" shape="hex" color="blue" state="orbit" sizePx={92} />
            <span className="site-demo__label">source</span>
          </div>
          {(['red', 'green', 'violet', 'orange'] as const).map((color) => (
            <div className="site-demo__cell" key={color}>
              <CharacterMarkMirror sourceId="demo-source" color={color} sizePx={92} />
              <span className="site-demo__label">mirror</span>
            </div>
          ))}
        </div>
      );
    }

    一个引擎,五个角色,五种墨色。镜像是指向源根分组的 <use href> 元素。

    换墨色不必再跑一份动画

    墨色是可继承的 CSS 自定义属性,所以它在 <use> 所在处解析,而不是在源的定义处。每个镜像设置自己的 --aora-fg,共享几何会捡起来。

    尺寸同理——它设在外层,而不是 SVG 内部。

    一页里 id 必须唯一

    sourceId 会变成 DOM id,<use href="#id"> 解析到文档里的第一个匹配。同一页上两个相同 id 的源,意味着每个镜像都指向第一个。

    优先使用 MarkStageProvider,它用 useId 推导 id,不会碰撞——即使一页上有好几个 Provider,而这正是带多个示例的文档站点会产生的情况。

    API

    属性类型默认值说明
    sourceId*string—Id of a mounted `CharacterMark`'s root group.
    childrenstring | number | bigint | boolean | ReactElement<unknown, string | JSXElementConstructor<any>> | Iterable<ReactNode> | ReactPortal | Promise<AwaitedReactNode> | null——
    classNamestring——
    color"black" | "brown" | "red" | "orange" | "yellow" | "green" | "cyan" | "blue" | "violet" | "magenta" | "pink" | "gray"'black'—
    eyeColorstring——
    face"cute" | "eyes" | "line"—Face style of the source, echoed as `data-face`. The geometry itself comes from the source.
    lineWeightnumber—Stroke weight of the source, echoed as `data-line-weight`.
    nose"slant" | "angular" | "hook" | "long" | "curve" | "bow" | null—Nose of the source, echoed as `data-nose`. `null` means the source draws none.
    sizeCssstring | number——
    sizePxnumber——
    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"'idle'—
    styleCSSProperties——
    styleIdStyleId—Style series of the source, echoed as `data-style`.
    styleOptionsRecord<string, unknown>—Style parameters of the source, echoed as `data-style-options`.
    variantStyleVariant—Variant of the source, echoed as `data-variant`.

    接下来