Agent Skills › videojs/video.js › create-react-component

create-react-component

GitHub

指导创建和修改 Video.js React UI 组件,涵盖状态管理、API 设计、样式钩子及测试规范,确保组件符合核心契约与渲染最佳实践。

.agents/skills/create-react-component/SKILL.md videojs/video.js

触发场景

创建新的 Video.js React 组件 修改现有 Video.js React 组件结构或逻辑

安装

npx skills add videojs/video.js --skill create-react-component -g -y
更多选项

非标准路径

npx skills add https://github.com/videojs/video.js/tree/main/.agents/skills/create-react-component -g -y

不安装直接使用

npx skills use videojs/video.js@create-react-component

指定 Agent (Claude Code)

npx skills add videojs/video.js --skill create-react-component -a claude-code -g -y

安装 repo 全部 skill

npx skills add videojs/video.js --all -g -y

预览 repo 内 skill

npx skills add videojs/video.js --list

SKILL.md

Frontmatter
{
    "name": "create-react-component",
    "description": "Create or change Video.js React UI components. Use for React component boundaries, state ownership, compound parts, render customization, styling hooks, exports, or client behavior."
}

React component implementation

Read the relevant core contract, nearest React component and tests, public exports, and UI design record before choosing a pattern. Use packages/react/src/ui/play-button/ for a simple control and packages/react/src/ui/slider/ for a compound control.

Workflow

  1. Classify the request as a reusable primitive or app/skin composition before defining its contract. Then define the state owner, semantics, APIs, optional parts, styling contract, and opt-outs.
  2. Put runtime-neutral state and actions in packages/core/src/core/ui/; put reusable DOM interaction in packages/core/src/dom/ui/; subscribe to the narrowest player state in React.
  3. Reuse createMediaButton when its contract fits. Otherwise use UIComponentProps and renderElement so DOM props, event handlers, state callbacks, and refs compose correctly.
  4. Let React own rendered DOM updates: express them through props, state, context, and render output. Reserve refs for browser imperatives such as focus or measurement; avoid mutating React-owned nodes so debugging, tests, hydration, and integrations remain authoritative.
  5. Keep render analysable by React Compiler. A component that mutates a core (setProps, setMedia, setInput) must read getState() in that same component, and every value it feeds the core must be a hook result or a prop. Never read a mutable .current or write a ref during render. When parts in other components need derived state, derive it there with a pure helper such as VolumePopoverCore.deriveState rather than sharing a mutated instance.
  6. Add a compound part only for a semantic, focusable, placeable, omittable, or replaceable node. Keep context values narrow and scoped to the owning root; do not mirror derived state through effects. If the API starts coordinating independent behavior, extract another component or hook instead of adding modes and options.
  7. Expose discrete state through mapped data-* attributes and dynamic layout values through stable CSS custom properties. Leave visual defaults to skins and CSS. Treat descendant selectors, :has(), and other complex selectors introduced by composition as a likely sign that the primitive boundary or styling hooks need improvement.
  8. Preserve the default semantic element while allowing deliberate replacement through render. Ensure omitted parts and unsupported features do not leave hidden behavior or required markup behind.
  9. Export compound APIs as tree-shakeable ESM namespaces with export * as Name from './index.parts'; keep parts as direct re-exports and do not assemble a runtime namespace object. When a compound specializes another compound, re-export unchanged base parts under the specialized namespace and create a specialized part only when its behavior or defaults differ. Avoid pulling optional dependencies into unrelated imports. Add focused tests for rendered behavior, ref/prop composition, context boundaries, and customization.

Use packages/react/src/ui/create-media-button.tsx, packages/react/src/utils/use-render.tsx, and packages/react/src/ui/slider/index.parts.ts as implementation anchors. Check packages/react/package.json and packages/react/vite.config.ts when the public or bundle boundary changes.

Example

Input: “Create the React chapter-skip control.”

Output: A scoped core contract, composable React adapter, stable styling hooks, deliberate render escape hatch, exports, and focused tests.

版本历史

  • 8a0a3d8 当前 2026-10-20 08:02

同 Skill 集合

.agents/skills/change-spf-behavior/SKILL.md
.agents/skills/commit-pr/SKILL.md
.agents/skills/configure-vite-plus/SKILL.md
.agents/skills/create-html-component/SKILL.md
.agents/skills/create-issue/SKILL.md
.agents/skills/create-skill/SKILL.md
.agents/skills/create-spf-behavior/SKILL.md
.agents/skills/design-api/SKILL.md
.agents/skills/document-spf-feature/SKILL.md
.agents/skills/document-spf-use-case/SKILL.md
.agents/skills/implement-accessible-ui/SKILL.md
.agents/skills/implement-spf-feature/SKILL.md
.agents/skills/implement-spf-use-case/SKILL.md
.agents/skills/implement-ui-transition/SKILL.md
.agents/skills/investigate-issue/SKILL.md
.agents/skills/maintain-agent-docs/SKILL.md
.agents/skills/maintain-tests/SKILL.md
.agents/skills/maintain-vjsc-skin-gaps/SKILL.md
.agents/skills/review-accessibility/SKILL.md
.agents/skills/review-api/SKILL.md
.agents/skills/review-branch/SKILL.md
.agents/skills/review-docs/SKILL.md
.agents/skills/review-html-component-design/SKILL.md
.agents/skills/review-html-component/SKILL.md
.agents/skills/review-react-component-design/SKILL.md
.agents/skills/review-react-component/SKILL.md
.agents/skills/write-api-reference/SKILL.md
.agents/skills/write-design-doc/SKILL.md
.agents/skills/write-docs/SKILL.md
.agents/skills/write-html-component-design/SKILL.md
.agents/skills/write-locale-translations/SKILL.md
.agents/skills/write-react-component-design/SKILL.md
.agents/skills/write-rfc/SKILL.md
.agents/skills/create-rolldown-plugin/SKILL.md
.agents/skills/create-vite-plugin/SKILL.md
.agents/skills/create-vjsc-component/SKILL.md
.agents/skills/transform-rolldown-code/SKILL.md

元信息

文件数
0
版本
8a0a3d8
Hash
156c8f0d
收录时间
2026-10-20 08:02

首页 - Wiki
Copyright © 2011-2026 iteam. Current version is 2.155.2. UTC+08:00, 2026-11-03 15:41
浙ICP备14020137号-1