Alune 组件

OrbButton

图标位于尾部圆点的主操作;等待时圆点显示月相加载并忽略点击。

使用方式

圆点按钮由宿主传入状态和回调,适合在不同应用和文档中复用。先完成快速开始中的 Provider 与样式配置。

import { OrbButton } from '@alune/ui';

接入要求见快速开始,选择依据见 交互与无障碍规范。

运行示例

运行与复制源码来自同一 TSX 文件。浮层、状态和主题独立于文档;所有回调只更新本地模拟数据。

真实示例 TSX 独立预览 ↗
查看运行源码
源码文件
import { useState } from 'react';
import {
  Button,
  DialogBadge,
  DialogBadges,
  DialogCard,
  DialogField,
  DialogFieldRow,
  DialogIcon,
  DialogList,
  DialogListItem,
  DialogPath,
  Input,
  OrbButton,
  Select,
} from '@alune/ui';

export default function Example() {
  const [name, setName] = useState('feature/example');
  const [opened, setOpened] = useState(false);
  const [busy, setBusy] = useState(false);
  const taken = name.trim() === 'main';
  return (
    <div className="example">
      <section className="example-group">
        <h2 className="example-title">字段</h2>
        <div className="example-stack">
          <DialogField
            label="分支名称"
            mono
            status={!name.trim() || taken ? 'error' : 'ok'}
            hint={!name.trim() ? '请输入分支名称' : taken ? '已存在同名分支' : '名称可用'}
          >
            <Input
              prefix={<DialogIcon name="branch" />}
              value={name}
              status={!name.trim() || taken ? 'error' : undefined}
              onChange={(event) => setName(event.target.value)}
            />
          </DialogField>
          <DialogFieldRow end>
            <DialogField label="主机" extra="必填" mono>
              <Input defaultValue="example.local" />
            </DialogField>
            <DialogField label="端口" mono>
              <Input defaultValue="22" />
            </DialogField>
          </DialogFieldRow>
          <DialogField label="标签类型" labelId="example-tag-type">
            <Select
              aria-labelledby="example-tag-type"
              defaultValue="annotated"
              options={[
                { value: 'lightweight', label: '轻量标签' },
                { value: 'annotated', label: '附注标签' },
              ]}
            />
          </DialogField>
        </div>
      </section>
      <section className="example-group">
        <h2 className="example-title">标签与列表</h2>
        <div className="example-stack">
          <DialogBadges>
            <DialogBadge>新建</DialogBadge>
            <DialogBadge tone="success" icon="check">
              可合并
            </DialogBadge>
            <DialogBadge tone="warning" icon="clock">
              暂不可合并
            </DialogBadge>
            <DialogBadge mono tone="success">
              +12
            </DialogBadge>
            <DialogBadge mono tone="danger">
              −3
            </DialogBadge>
          </DialogBadges>
          <DialogCard>
            <DialogList>
              <DialogListItem
                icon="folder"
                title="example-app"
                detail={<DialogPath path="/work/example-app" />}
              >
                <DialogBadge tone="success" icon="check">
                  已添加
                </DialogBadge>
              </DialogListItem>
              <DialogListItem
                icon="folder"
                title="example-docs"
                detail="子模块 · 有独立的 Git 状态"
              >
                <Button size="small">打开仓库</Button>
              </DialogListItem>
            </DialogList>
          </DialogCard>
        </div>
      </section>
      <section className="example-group">
        <h2 className="example-title">带图标圆点的主操作</h2>
        <div className="example-row">
          <OrbButton
            icon="arrow-up-right"
            loading={busy}
            onClick={() => {
              setBusy(true);
              window.setTimeout(() => {
                setBusy(false);
                setOpened(true);
              }, 1200);
            }}
          >
            打开仓库
          </OrbButton>
          <span className="example-status" role="status">
            {busy ? '正在打开…' : opened ? '已打开示例仓库' : ''}
          </span>
        </div>
      </section>
    </div>
  );
}

API

OrbButton

OrbButton 是通用组合成员,具体属性见关联 Props 表,运行效果见上方示例。

查看 OrbButton 实现 ↗

OrbButtonProps

属性 / 方法 类型 默认值 必填 说明
icon "warning" | "info" | "x" | "arrow-right" | "arrow-up-right" | "check" | "caret" | "trash" | "lock" | "key" | "server" | "folder" | "folder-open" | "branch" | "merge" | "pr" | "archive" | "cloud-up" | "cloud-down" | "globe" | "user" | "mail" | "terminal" | "laptop" | "search" | "bell" | "copy" | "eye" | "eye-off" | "link" | "sparkle" | "sliders" | "columns" | "download" | "moon" | "sun" | "wave" | "file" | "file-plus" | "refresh" | "plus" | "pencil" | "swap" | "shield" | "plug" | "tree" | "commit" | "chat" | "dots" | "clock" | "undo" — 是 图标内容或图标名。
loading boolean — 否 参见类型定义及对应实现。

查看 OrbButtonProps 实现 ↗

交互与使用限制

为每个操作提供可访问名称,为输入关联 label;使用语义化组件和清晰焦点。不要只靠颜色传达状态,禁用与等待时避免重复执行。

宿主负责状态、业务操作、错误处理与真实内容。组件不读取业务 store、路由或 Electron。示例中的反馈和等待均为本地模拟。

键盘、焦点、风险确认与通知策略的完整约定见交互规范。