AI UP LAB / 组件规范Components / v1.2.1

加载、空白与错误反馈Loading, empty & error feedback

让用户理解发生了什么、哪些内容仍可用,以及下一步能做什么。Explain what happened, what remains usable, and what the user can do next.

查看示例Explore exampleMarkdown ↓

01 / LIVE SPECIMEN

实际示例Working example

示例 / 可操作的状态标有按钮EXAMPLE / Interactive states have controls

02 / STRUCTURE & RULES

组成与使用规则Anatomy & usage

  1. 01状态标题说明当前情况。A state heading explains the current situation.
  2. 02短说明给出原因或限制,只写已知事实。A short explanation gives a known cause or constraint.
  3. 03恢复动作具体可执行,例如重试或查看全部。A concrete recovery action offers retry or a broader view.

必须遵守Required behavior

  • 加载骨架预留内容尺寸,不能把“没有内容”当成“仍在加载”。Reserve content dimensions with skeletons and distinguish no content from still loading.
  • 局部失败只影响对应模块,保留导航、已有内容和退出方式。Contain failures to the affected module while retaining navigation and usable content.
  • 空状态给出可操作的下一步,避免只留一个空白盒。Empty states offer a next step instead of an unexplained blank box.
  • 错误状态不能只有红色;写清可确认的原因和重试方式。Errors require words as well as red, with a known reason and a retry path.

推荐做法Do

“未能复制,可选中文字或下载文件”,仍保留文档。Copy failed; select the text or download the file, while keeping the document accessible.

03 / PARAMETERS

参数与状态Parameters & states

参数Parameter取值Value用法Usage
loadingaria-busy=true仅标记正在更新的区域,不封锁无关内容。Mark the updating region without blocking unrelated content.
statusrole=status / polite复制完成、收藏变更等非阻断结果。Non-blocking results such as copied text or saved state.
feedback.duration4.5s短暂操作提示可自动消失;错误原因留在原区域。Transient confirmations may clear automatically; persistent errors remain in context.

加载中Loading

展示稳定占位;完成后替换为内容并结束 busy 状态。Show a stable placeholder, then replace it with content and clear busy state.

无匹配No matches

说明当前没有匹配项,提供清除条件或浏览入口。Explain the lack of matches and offer reset or browsing.

失败Failure

保留上下文,重试只作用于失败模块。Keep context and retry the affected module only.

完成Complete

即时反馈并保留可继续操作的状态。Announce completion while keeping the interface usable.

代码映射与 AI 使用Code mapping & AI use

先读取本项规则,再通过下列映射找到已有实现。调整共用组件时,同步检查依赖项。Read these rules, then locate the existing implementation below. Check dependencies when changing shared components.

实现片段Implementation fragment

组件片段需放入相应 Astro 文件上下文,按代码映射补齐导入。Place component fragments in the corresponding Astro context and complete imports from the code mappings.

<section aria-busy="true" aria-label="资源列表">
  <!-- Keep the layout stable while loading. -->
</section>
<p role="status" aria-live="polite"></p>

使用的设计变量Design tokens

--lab-color-success--lab-color-warning--lab-color-error--lab-color-soft

相关规则Related rules

给 AI 的完整规则文本Full rules for AI
# 加载、空白与错误反馈 / Loading, empty & error feedback

ID: feedback
Version: 1.2.1

让用户理解发生了什么、哪些内容仍可用,以及下一步能做什么。

Explain what happened, what remains usable, and what the user can do next.

## Anatomy
- 状态标题说明当前情况。
  A state heading explains the current situation.
- 短说明给出原因或限制,只写已知事实。
  A short explanation gives a known cause or constraint.
- 恢复动作具体可执行,例如重试或查看全部。
  A concrete recovery action offers retry or a broader view.

## Parameters
- loading: aria-busy=true
  仅标记正在更新的区域,不封锁无关内容。
  Mark the updating region without blocking unrelated content.
- status: role=status / polite
  复制完成、收藏变更等非阻断结果。
  Non-blocking results such as copied text or saved state.
- feedback.duration: 4.5s
  短暂操作提示可自动消失;错误原因留在原区域。
  Transient confirmations may clear automatically; persistent errors remain in context.

## Rules
- 加载骨架预留内容尺寸,不能把“没有内容”当成“仍在加载”。
  Reserve content dimensions with skeletons and distinguish no content from still loading.
- 局部失败只影响对应模块,保留导航、已有内容和退出方式。
  Contain failures to the affected module while retaining navigation and usable content.
- 空状态给出可操作的下一步,避免只留一个空白盒。
  Empty states offer a next step instead of an unexplained blank box.
- 错误状态不能只有红色;写清可确认的原因和重试方式。
  Errors require words as well as red, with a known reason and a retry path.

## States
- 加载中 / Loading: 展示稳定占位;完成后替换为内容并结束 busy 状态。
  Show a stable placeholder, then replace it with content and clear busy state.
- 无匹配 / No matches: 说明当前没有匹配项,提供清除条件或浏览入口。
  Explain the lack of matches and offer reset or browsing.
- 失败 / Failure: 保留上下文,重试只作用于失败模块。
  Keep context and retry the affected module only.
- 完成 / Complete: 即时反馈并保留可继续操作的状态。
  Announce completion while keeping the interface usable.

## Do / Avoid
- Do: “未能复制,可选中文字或下载文件”,仍保留文档。 / Copy failed; select the text or download the file, while keeping the document accessible.
- Avoid: 仅弹出“错误”,或因一张预览失败让整页不可点击。 / Show only Error, or block the whole page because one preview failed.

## Code mapping
- src/components/DirectoryExplorer.astro: 真实搜索空状态 / Real search empty state
- src/components/BrandSpecDemo.astro: 状态转换与恢复演示 / State transitions and recovery examples

## Dependencies
buttons, assets-motion

## Acceptance
- 加载、无匹配和失败状态可以分别触发与恢复。
  Loading, no-match, and failure states can each be triggered and recovered.
- 反馈通过可读文本表达,读屏能收到结果。
  Readable text and live status expose the result.
- 恢复后焦点仍在有意义的位置。
  Recovery leaves focus in a meaningful place.

## Implementation example
```
<section aria-busy="true" aria-label="资源列表">
  <!-- Keep the layout stable while loading. -->
</section>
<p role="status" aria-live="polite"></p>
```

## Reference
Method reference: https://tmall-design.com/#case/feed
Rules, parameters, examples, and branding in this file are specific to AI UP LAB.
按任务整理 AI 工作说明 →Assemble a task-specific brief →

交付前检查Before delivery

  • 加载、无匹配和失败状态可以分别触发与恢复。Loading, no-match, and failure states can each be triggered and recovered.
  • 反馈通过可读文本表达,读屏能收到结果。Readable text and live status expose the result.
  • 恢复后焦点仍在有意义的位置。Recovery leaves focus in a meaningful place.

方法参考与适用边界Reference & scope

参考 Tmall Design 将规则、映射与代码关联的组织方法。本页参数、示例和品牌资产为 AI UP LAB 自身规范。Inspired by Tmall Design’s organization of rules, mappings, and code. Parameters, examples, and brand assets here are specific to AI UP LAB.

Tmall Design ↗