plugins/ui-design/skills/ui-design-a11y/SKILL.md
无障碍设计审查与修复能力。 当用户说"无障碍"、"a11y"、"WCAG"、"键盘导航"、"屏幕阅读器"、"颜色对比度"、"ARIA"、"可访问性"、"辅助功能"、"盲人友好"时使用此技能。 基于 WCAG 2.1 标准,检测图片 Alt 文本缺失、表单 Label 关联、键盘可访问性、颜色对比度不足、ARIA 属性误用等问题。 提供修复代码示例:语义化标签、焦点管理、焦点陷阱、屏幕阅读器支持。输出合规性检查报告和修复建议。
npx skillsauth add protagonistss/ithinku-plugins ui-design-a11yInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
专注于 Web 无障碍标准 (WCAG) 的检查与修复。帮助开发者发现潜在的访问性问题并提供修复代码。
// ✅ 正确的图片无障碍实现
function AccessibleImage({ src, alt, caption }: ImageProps) {
return (
<figure>
<img
src={src}
alt={alt} // 描述性文字,装饰性图片使用 alt=""
loading="lazy"
/>
{caption && <figcaption>{caption}</figcaption>}
</figure>
);
}
// ❌ 避免
<img src="photo.jpg" /> // 缺少 alt
<img src="photo.jpg" alt="image" /> // 无意义的 alt
// ✅ 正确的表单关联
function AccessibleForm() {
return (
<form>
<div>
<label htmlFor="email">邮箱地址</label>
<input
id="email"
type="email"
aria-describedby="email-hint"
aria-required="true"
/>
<span id="email-hint">我们会向此邮箱发送验证码</span>
</div>
<div>
<label htmlFor="password">密码</label>
<input
id="password"
type="password"
aria-describedby="password-error"
aria-invalid={hasError ? 'true' : 'false'}
/>
{hasError && (
<span id="password-error" role="alert">
密码至少需要8个字符
</span>
)}
</div>
<button type="submit">登录</button>
</form>
);
}
// ✅ 可键盘操作的按钮
function AccessibleButton({ onClick, children }: ButtonProps) {
return (
<button
onClick={onClick}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
onClick();
}
}}
>
{children}
</button>
);
}
// ✅ 焦点管理样式
const focusStyles = css`
&:focus-visible {
outline: 3px solid #005fcc;
outline-offset: 2px;
}
`;
// ✅ 模态框无障碍实现
function AccessibleModal({ isOpen, onClose, title, children }: ModalProps) {
const modalRef = useRef<HTMLDivElement>(null);
const previousActiveElement = useRef<Element | null>(null);
useEffect(() => {
if (isOpen) {
previousActiveElement.current = document.activeElement;
modalRef.current?.focus();
document.body.style.overflow = 'hidden';
} else {
previousActiveElement.current?.focus();
document.body.style.overflow = '';
}
}, [isOpen]);
const handleKeyDown = (e: React.KeyboardEvent) => {
if (e.key === 'Escape') onClose();
};
if (!isOpen) return null;
return (
<div
role="dialog"
aria-modal="true"
aria-labelledby="modal-title"
ref={modalRef}
tabIndex={-1}
onKeyDown={handleKeyDown}
>
<div className="modal-backdrop" onClick={onClose} aria-hidden="true" />
<div className="modal-content">
<h2 id="modal-title">{title}</h2>
{children}
<button onClick={onClose} aria-label="关闭对话框">
<CloseIcon />
</button>
</div>
</div>
);
}
/* ✅ 符合 WCAG AA 标准的对比度 */
.text-primary {
color: #1a1a1a; /* 与白色背景对比度 > 12:1 */
}
.text-secondary {
color: #4a4a4a; /* 与白色背景对比度 > 7:1 */
}
/* ✅ 不只依赖颜色传达信息 */
.status-success {
color: #0a8754;
}
.status-success::before {
content: '✓ '; /* 同时使用图标 */
}
/* ✅ 聚焦状态清晰可见 */
:focus-visible {
outline: 3px solid #005fcc;
outline-offset: 2px;
}
// ✅ 语义化页面结构
function AccessibleLayout({ children }: { children: React.ReactNode }) {
return (
<>
<header role="banner">
<nav aria-label="主导航">
<ul>
<li><a href="/">首页</a></li>
<li><a href="/about">关于</a></li>
</ul>
</nav>
</header>
<main role="main" id="main-content">
<h1>页面标题</h1>
{children}
</main>
<aside aria-label="侧边栏">
{/* 侧边栏内容 */}
</aside>
<footer role="contentinfo">
{/* 页脚内容 */}
</footer>
</>
);
}
/ui-design 审查这段代码的无障碍问题
# 关注点:
# - 语义化标签 (nav, main, aside)
# - ARIA 属性使用
# - 键盘可访问性 (tabindex, focus)
# - 图片 Alt 文本
/ui-design 检查这个配色的对比度是否符合 WCAG AA 标准
/ui-design 修复这个表单的 Label 关联和 ARIA 描述问题
/ui-design 为这个模态框添加 Focus Trap (焦点陷阱) 功能
在提交代码前,请检查:
<img> 都有 alt 属性吗?<label> 吗?development
Vue 3 开发最佳实践指南 - Composition API、Script Setup、Pinia、TypeScript 集成及性能优化。 当用户说"Vue 3组件"、"Composition API"、"script setup"、"Pinia"、"Vue 3项目"、"ref reactive"、"defineProps defineEmits"、"Composable"、"Vue 3优化"时使用此技能。 涵盖:Script Setup 与 Composition API、响应式数据选择(ref vs reactive)、组件通信(Props/Emits/v-model/Slots)、Composables 设计模式、Pinia Setup Store、性能优化(v-memo、shallowRef、KeepAlive)。 提供 TypeScript 代码示例、反模式对照表、迁移指南和示例文件引用。
development
Vue 2 维护与开发最佳实践指南 - Options API、Vuex 及向 Vue 3 迁移准备。 当用户说"Vue 2组件"、"Options API"、"Vuex"、"Vue 2项目"、"Vue 2迁移"、"Vue mixin"、"Vue 2最佳实践"时使用此技能。 涵盖:Options API 规范(选项顺序、props 验证)、Vuex 模块化(namespaced modules)、逻辑复用(避免 mixin,使用工具函数)、迁移准备(停止使用 Filters、引入 Composition API 插件)。 提供 Vue 2 代码示例、反模式警告和迁移建议。
development
核心设计能力 - 提供配色、布局、组件样式生成及反模式检查。 当用户说"设计UI"、"生成样式"、"页面布局"、"CSS样式"、"组件设计"、"配色方案"、"设计系统"、"前端样式"、"响应式设计"、"动画效果"时使用此技能。 支持多种设计风格:Neo-Brutalism、Glassmorphism、Editorial、Cyberpunk。 提供配色方案、布局生成、组件样式、微交互动效、响应式网格。拒绝"AI廉价感",追求大胆、独特、细节丰富的设计。 重要特性:提供反模式检查,避免泛滥的渐变、无聊的阴影、默认圆角等平庸设计。
development
分析源代码并生成对应的单元测试用例。 当用户说"生成测试"、"写单元测试"、"添加测试用例"、"测试覆盖"、"单元测试"、"vitest测试"、"jest测试"、"pytest测试"、"测试代码"时使用此技能。 支持多种语言和框架:JavaScript/TypeScript (Jest, Vitest, Mocha)、Python (pytest, unittest)、Java (JUnit 5, TestNG)。 自动生成:正常流程测试、边界条件测试、异常情况测试、Mock 配置。输出遵循 AAA 模式的高质量测试代码。