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

导航与渐进展开Navigation & progressive disclosure

主导航对应稳定任务目录,把搜索、收藏和站点说明安排在合适层级。Map primary navigation to stable task sections, with search, saved items, and site information at appropriate levels.

查看示例Explore exampleMarkdown ↓

01 / LIVE SPECIMEN

实际示例Working example

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

真实入口;更多菜单可通过键盘打开,Escape 关闭并恢复焦点。Real destinations. Open More with the keyboard; Escape closes it and restores focus.

02 / STRUCTURE & RULES

组成与使用规则Anatomy & usage

  1. 01品牌入口与五个任务目录构成全站主导航。The brand entry and five task sections form the global navigation.
  2. 02更多菜单承载搜索、更新记录、关于和设计规范。More contains search, update notes, about, and design guidelines.
  3. 03独立规范目录仅在规范库出现,不占用资源分类页。The documentation index appears only in the handbook, not resource sections.

必须遵守Required behavior

  • 搜索只在独立搜索页提供完整条件,目录浏览首屏先给内容。Keep full search controls on the search page and show content first in sections.
  • 折叠菜单支持 Escape 关闭并把焦点还给触发器。Escape closes the menu and returns focus to its trigger.
  • 展开更多条目后,把焦点移到第一条新内容。After revealing more entries, focus the first newly revealed item.
  • 当前位置同时用文字或下划线表达,不仅靠颜色。Use text or an underline in addition to color for the current location.

推荐做法Do

进入“学习与工作流”后立即浏览条目,需要查找时再打开搜索。Browse Learning & workflows immediately and open search when a specific goal emerges.

03 / PARAMETERS

参数与状态Parameters & states

参数Parameter取值Value用法Usage
nav.activearia-current=page当前位置不是 hover,离开鼠标后仍保留标记。The current page is not a hover state and remains marked after pointer exit.
menu.primitivedetails / summary菜单在无 JavaScript 时仍可展开。Menus remain operable without JavaScript.
list.initial24目录初始展示 24 条,再按需展开。Show 24 entries first, then reveal more on request.

当前位置Current page

保留强调与 aria-current,帮助用户定位。Keep emphasis and aria-current to indicate location.

菜单打开Menu open

目标全部可读,内容不超出手机视口。Show readable destinations within the mobile viewport.

加载更多Reveal more

按序增加内容,不跳回页首;全部显示后隐藏按钮。Append in order without returning to the top; hide the control once complete.

代码映射与 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.

<a href={withBase("learn/")} aria-current={active ? "page" : undefined}>
  <Loc zh="学习与工作流" en="Learning & workflows" />
</a>

使用的设计变量Design tokens

--lab-color-brand--lab-logo-mobile

相关规则Related rules

给 AI 的完整规则文本Full rules for AI
# 导航与渐进展开 / Navigation & progressive disclosure

ID: navigation
Version: 1.2.1

主导航对应稳定任务目录,把搜索、收藏和站点说明安排在合适层级。

Map primary navigation to stable task sections, with search, saved items, and site information at appropriate levels.

## Anatomy
- 品牌入口与五个任务目录构成全站主导航。
  The brand entry and five task sections form the global navigation.
- 更多菜单承载搜索、更新记录、关于和设计规范。
  More contains search, update notes, about, and design guidelines.
- 独立规范目录仅在规范库出现,不占用资源分类页。
  The documentation index appears only in the handbook, not resource sections.

## Parameters
- nav.active: aria-current=page
  当前位置不是 hover,离开鼠标后仍保留标记。
  The current page is not a hover state and remains marked after pointer exit.
- menu.primitive: details / summary
  菜单在无 JavaScript 时仍可展开。
  Menus remain operable without JavaScript.
- list.initial: 24
  目录初始展示 24 条,再按需展开。
  Show 24 entries first, then reveal more on request.

## Rules
- 搜索只在独立搜索页提供完整条件,目录浏览首屏先给内容。
  Keep full search controls on the search page and show content first in sections.
- 折叠菜单支持 Escape 关闭并把焦点还给触发器。
  Escape closes the menu and returns focus to its trigger.
- 展开更多条目后,把焦点移到第一条新内容。
  After revealing more entries, focus the first newly revealed item.
- 当前位置同时用文字或下划线表达,不仅靠颜色。
  Use text or an underline in addition to color for the current location.

## States
- 当前位置 / Current page: 保留强调与 aria-current,帮助用户定位。
  Keep emphasis and aria-current to indicate location.
- 菜单打开 / Menu open: 目标全部可读,内容不超出手机视口。
  Show readable destinations within the mobile viewport.
- 加载更多 / Reveal more: 按序增加内容,不跳回页首;全部显示后隐藏按钮。
  Append in order without returning to the top; hide the control once complete.

## Do / Avoid
- Do: 进入“学习与工作流”后立即浏览条目,需要查找时再打开搜索。 / Browse Learning & workflows immediately and open search when a specific goal emerges.
- Avoid: 每个分类都重复展示搜索、排序、难度和格式控件。 / Repeat search, sort, level, and format controls on every category page.

## Code mapping
- src/components/Header.astro: 全站导航与菜单 / Global navigation and menu
- src/components/DirectoryListing.astro: 渐进展开与旧链接兼容 / Progressive reveal and legacy links

## Dependencies
buttons, layout

## Acceptance
- 主导航、菜单和规范目录都能识别当前位置。
  Global, menu, and handbook navigation indicate location where relevant.
- 手机菜单不溢出,Escape 后焦点位置正确。
  Mobile menus fit and Escape restores focus.
- 旧筛选链接仍能进入对应搜索范围。
  Legacy filtered links retain their search scope.

## Implementation example
```
<a href={withBase("learn/")} aria-current={active ? "page" : undefined}>
  <Loc zh="学习与工作流" en="Learning & workflows" />
</a>
```

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

交付前检查Before delivery

  • 主导航、菜单和规范目录都能识别当前位置。Global, menu, and handbook navigation indicate location where relevant.
  • 手机菜单不溢出,Escape 后焦点位置正确。Mobile menus fit and Escape restores focus.
  • 旧筛选链接仍能进入对应搜索范围。Legacy filtered links retain their search scope.

方法参考与适用边界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 ↗