cn-frontend-ui-engineering

Builds or improves front-end interfaces that require production-grade layout, responsive behavior, accessibility, interaction states, and refined visual quality.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "cn-frontend-ui-engineering" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-adf1607c68f8409d495a64af0c9c6fbb2fa7fe6a081bdf31ca0cf21b810981cc. Verify the upstream source and version against https://skillhub.cn/skills/user_55e286a5/cn-frontend-ui-engineering before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Builds or improves front-end interfaces that require production-grade layout, responsive behavior, accessibility, interaction states, and refined visual quality.

0 Downloads

Introduction source: third_party · user_55e286a5 · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: cn-frontend-ui-engineering
slug: cn-frontend-ui-engineering
version: 1.0.0
displayName: 生产级网页界面制作
summary: 构建或改进需要生产级布局、响应式行为、可访问性、交互状态与精致视觉质量的前端界面。
description: 在构建或修改需要生产级布局、响应式行为、可访问性、交互状态或精致视觉质量的面向用户界时使用。
tags: [frontend, ui, responsive, accessibility, components, interaction]
license: MIT
homepage: https://github.com/addyosmani/agent-skills/tree/main/skills/frontend-ui-engineering

前端界面工程

概述

构建可访问、高性能且视觉精致的生产级用户界面。目标是做出像顶级公司里具备设计意识的工程师所打造的 UI——而不是像 AI 生成的界面。这意味着要真正遵循设计系统、做好无障碍支持、采用经过深思熟虑的交互模式,并且杜绝千篇一律的「AI 美学」。

何时使用

  • 构建全新的 UI 组件或页面
  • 修改现有的面向用户的交互界面
  • 实现响应式布局
  • 添加交互行为或状态管理
  • 修复视觉或用户体验问题

组件架构

文件结构

将与某个组件相关的所有内容就近放置(colocate):

src/components/
  TaskList/
    TaskList.tsx          # Component implementation
    TaskList.test.tsx     # Tests
    TaskList.stories.tsx  # Storybook stories (if using)
    use-task-list.ts      # Custom hook (if complex state)
    types.ts              # Component-specific types (if needed)

组件模式

优先组合(composition)而非配置(configuration):

// Good: Composable
<Card>
  <CardHeader>
    <CardTitle>Tasks</CardTitle>
  </CardHeader>
  <CardBody>
    <TaskList tasks={tasks} />
  </CardBody>
</Card>

// Avoid: Over-configured
<Card
  title="Tasks"
  headerVariant="large"
  bodyPadding="md"
  content={<TaskList tasks={tasks} />}
/>

保持组件职责单一:

// Good: Does one thing
export function TaskItem({ task, onToggle, onDelete }: TaskItemProps) {
  return (
    <li className="flex items-center gap-3 p-3">
      <Checkbox checked={task.done} onChange={() => onToggle(task.id)} />
      <span className={task.done ? 'line-through text-muted' : ''}>{task.title}</span>
      <Button variant="ghost" size="sm" onClick={() => onDelete(task.id)}>
        <TrashIcon />
      </Button>
    </li>
  );
}

将数据获取与渲染展示分离:

// Container: handles data
export function TaskListContainer() {
  const { tasks, isLoading, error } = useTasks();

  if (isLoading) return <TaskListSkeleton />;
  if (error) return <ErrorState message="Failed to load tasks" retry={refetch} />;
  if (tasks.length === 0) return <EmptyState message="No tasks yet" />;

  return <TaskList tasks={tasks} />;
}

// Presentation: handles rendering
export function TaskList({ tasks }: { tasks: Task[] }) {
  return (
    <ul role="list" className="divide-y">
      {tasks.map(task => <TaskItem key={task.id} task={task} />)}
    </ul>
  );
}

状态管理

选择能用的最简方案:

Local state (useState)           → Component-specific UI state
Lifted state                     → Shared between 2-3 sibling components
Context                          → Theme, auth, locale (read-heavy, write-rare)
URL state (searchParams)         → Filters, pagination, shareable UI state
Server state (React Query, SWR)  → Remote data with caching
Global store (Zustand, Redux)    → Complex client state shared app-wide

避免属性层层透传超过 3 层。 如果你正在把 props 穿过那些自身并不使用它们的组件,就应该引入 context 或重构组件树。

设计系统遵循

避免 AI 美学

AI 生成的 UI 有可识别的规律。请避免以下所有情况:

AI 默认做法 问题所在 生产级做法
Purple/indigo everything 模型默认采用视觉上「安全」的配色,导致每个应用看起来都千篇一律 使用项目实际的调色板
Excessive gradients 渐变会增加视觉噪声,并与大多数设计系统相冲突 与设计系统一致的扁平或微妙渐变
Rounded everything (rounded-2xl) 最大圆角传达「友好」感,却忽略了真实设计中圆角的层级关系 采用设计系统一致的 border-radius
Generic hero sections 模板驱动的布局,与实际内容或用户需求毫无关联 以内容为先的布局
Lorem ipsum-style copy 占位文本会掩盖真实内容才会暴露的布局问题(长度、换行、溢出) 贴近真实的占位内容
Oversized padding everywhere 处处等量的宽松留白会破坏视觉层级,并浪费屏幕空间 一致的间距标尺
Stock card grids 整齐划一的网格是一种布局捷径,忽略了信息优先级与浏览习惯 目的驱动的布局
Shadow-heavy design 多层阴影带来的纵深感会与内容争夺注意力,并在低端设备上拖慢渲染 除非设计系统明确要求,否则采用微妙或无阴影

间距与布局

使用一致的间距标尺。不要自创数值:

/* Use the scale: 0.25rem increments (or whatever the project uses) */
/* Good */  padding: 1rem;      /* 16px */
/* Good */  gap: 0.75rem;       /* 12px */
/* Bad */   padding: 13px;      /* Not on any scale */
/* Bad */   margin-top: 2.3rem; /* Not on any scale */

排版

遵循排版层级:

h1 → Page title (one per page)
h2 → Section title
h3 → Subsection title
body → Default text
small → Secondary/helper text

不要跳过标题层级。不要用标题样式来呈现非标题内容。

颜色

  • 使用语义化颜色 token:text-primary、bg-surface、border-default——而非原始十六进制值
  • 确保足够的对比度(正文 4.5:1,大号文字 3:1)
  • 不要仅依赖颜色来传达信息(也要配合图标、文字或图案)

可访问性(WCAG 2.1 AA)

每个组件都必须达到以下标准:

键盘导航

// Every interactive element must be keyboard accessible
<button onClick={handleClick}>Click me</button>        // ✓ Focusable by default
<div onClick={handleClick}>Click me</div>               // ✗ Not focusable
<div role="button" tabIndex={0} onClick={handleClick}    // ✓ But prefer <button>
     onKeyDown={e => {
       if (e.key === 'Enter') handleClick();
       if (e.key === ' ') e.preventDefault();
     }}
     onKeyUp={e => {
       if (e.key === ' ') handleClick();
     }}>
  Click me
</div>

ARIA 标签

// Label interactive elements that lack visible text
<button aria-label="Close dialog"><XIcon /></button>

// Label form inputs
<label htmlFor="email">Email</label>
<input id="email" type="email" />

// Or use aria-label when no visible label exists
<input aria-label="Search tasks" type="search" />

焦点管理

// Move focus when content changes
function Dialog({ isOpen, onClose }: DialogProps) {
  const closeRef = useRef<HTMLButtonElement>(null);

  useEffect(() => {
    if (isOpen) closeRef.current?.focus();
  }, [isOpen]);

  // Trap focus inside dialog when open
  return (
    <dialog open={isOpen}>
      <button ref={closeRef} onClick={onClose}>Close</button>
      {/* dialog content */}
    </dialog>
  );
}

有意义的空状态与错误状态

// Don't show blank screens
function TaskList({ tasks }: { tasks: Task[] }) {
  if (tasks.length === 0) {
    return (
      <div role="status" className="text-center py-12">
        <TasksEmptyIcon className="mx-auto h-12 w-12 text-muted" />
        <h3 className="mt-2 text-sm font-medium">No tasks</h3>
        <p className="mt-1 text-sm text-muted">Get started by creating a new task.</p>
        <Button className="mt-4" onClick={onCreateTask}>Create Task</Button>
      </div>
    );
  }

  return <ul role="list">...</ul>;
}

响应式设计

以移动端优先的方式设计,再逐步扩展:

// Tailwind: mobile-first responsive
<div className="
  grid grid-cols-1      /* Mobile: single column */
  sm:grid-cols-2        /* Small: 2 columns */
  lg:grid-cols-3        /* Large: 3 columns */
  gap-4
">

在以下断点进行测试:320px、768px、1024px、1440px。

加载与过渡

// Skeleton loading (not spinners for content)
function TaskListSkeleton() {
  return (
    <div className="space-y-3" aria-busy="true" aria-label="Loading tasks">
      {Array.from({ length: 3 }).map((_, i) => (
        <div key={i} className="h-12 bg-muted animate-pulse rounded" />
      ))}
    </div>
  );
}

// Optimistic updates for perceived speed
function useToggleTask() {
  const queryClient = useQueryClient();

  return useMutation({
    mutationFn: toggleTask,
    onMutate: async (taskId) => {
      await queryClient.cancelQueries({ queryKey: ['tasks'] });
      const previous = queryClient.getQueryData(['tasks']);

      queryClient.setQueryData(['tasks'], (old: Task[]) =>
        old.map(t => t.id === taskId ? { ...t, done: !t.done } : t)
      );

      return { previous };
    },
    onError: (_err, _taskId, context) => {
      queryClient.setQueryData(['tasks'], context?.previous);
    },
  });
}

参见

关于详细的可访问性要求与测试工具,请参见 references/accessibility-checklist.md。

常见自我开脱

自我开脱 现实情况
"可访问性只是锦上添花" 在许多司法管辖区,它既是法律要求,也是工程质量标准。
"我们稍后再做响应式" 事后补救响应式设计的难度,是从一开始构建时的 3 倍。
"设计还没定稿,所以我先不写样式" 使用设计系统的默认值。未加样式的 UI 会给审查者留下糟糕的第一印象。
"这只是一个原型" 原型迟早会变成生产代码。从一开始就打好基础。
"AI 美学眼下无伤大雅" 它暴露出低质量。从一开始就使用项目真正的设计系统。

危险信号

  • 超过 200 行的组件(应当拆分)
  • 内联样式或随意的像素值
  • 缺少错误状态、加载状态或空状态
  • 没有进行键盘导航测试
  • 仅以颜色作为状态标识(红/绿但不配文字或图标)
  • 千篇一律的「AI 观感」(紫色渐变、超大卡片、模板化布局)

验证

构建 UI 之后:

  • [ ] 组件渲染无控制台报错
  • [ ] 所有交互元素均可键盘访问(用 Tab 键遍历页面)
  • [ ] 屏幕阅读器能够传达页面的内容与结构
  • [ ] 响应式:在 320px、768px、1024px、1440px 下均正常
  • [ ] 加载、错误、空状态均已处理
  • [ ] 遵循项目的设计系统(间距、颜色、排版)
  • [ ] 开发工具或 axe-core 中无可访问性警告

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value92/100

Highlights

  • 全面覆盖前端工程核心领域,包括组件架构、状态管理、设计系统、可访问性、响应式等
  • 提供生产级最佳实践,解决真实开发场景中的核心痛点
  • 内容深度与广度兼具,具备高实用价值
Trigger Precision95/100

Highlights

  • 触发描述精准完整,明确说明使用场景
  • tags 覆盖合理,边界清晰,不易误触或漏触
Structure and Standards94/100

Highlights

  • 文档结构清晰完整,包含概述、使用场景、详细章节和验证清单
  • 提供丰富的代码示例和最佳实践,便于理解与执行
  • frontmatter 完整,符合规范
Execution Reliability93/100

Areas to improve

  • 引用文件缺失 Reported severity: Minor

    SKILL.md 中引用了 references/accessibility-checklist.md 文件,但该文件未传入

    Recommendation: 请确保所有被引用的文件都包含在 Skill 包中,或移除无法提供的引用

Highlights

  • 提供了详细的组件模式、状态管理策略和可访问性实现方法
  • 覆盖主要异常场景(加载、错误、空状态),并提供解决方案
  • 工具来源明确,参数正确,具备高执行可靠性
Evidence Verifiability (mean of the first four)94/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • github.com

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.