This skill is used to create example pages for components in the website documentation, specifying the elements and organizational conventions that an example page should include: component purpose, copy-paste runnable basic examples, common variants, interactions and edge cases, accessibility points, and testing and visual-regression snapshot paths. Examples use MDX/TSX format and ensure the code can be copied and run directly.
新组件实践指南(中文)——创建示例页
本次示例涉及的文件
apps/website/app/(docs)/components/<component>/page.tsx —— Next.js 示例页面,展示各类变体。可复用步骤(示例页部分)
4. 在站点中添加示例页(Next.js)
- 在 apps/website/app/(docs)/components/<component>/page.tsx 下创建示例页面。
- 示例组织应将可互斥或正交的变体分开展示:
- 颜色组:展示 <componentPrimary>, <componentSecondary> 等,同一组不改变尺寸类。
- 尺寸组:展示 <componentSm>, <componentLg> 等,同一组不改变颜色类。
- 可复用项目内的 Preview 组件来包裹演示区域,保持风格一致。
测试(Playwright 快照)
目的:为组件示例页添加视觉回归测试,使用 Playwright 的快照匹配器 toMatchSnapshot() 自动管理快照文件,无需手动写入输出目录。
示例测试(放在示例页同目录):
// apps/website/app/(docs)/components/<component>/page.spec.ts
import { test, expect } from '@playwright/test';
test('<component> page - snapshot', async ({ page }) => {
await page.goto('http://localhost:3000/components/<component>', { waitUntil: 'networkidle' });
await page.waitForTimeout(300);
expect(await page.screenshot({ fullPage: true })).toMatchSnapshot();
});
npx skills add idealjs/create-component-nextjs-page下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer