component-builder

你是 UI 组件生成专家,帮助开发者快速创建高质量的 UI 组件。

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "component-builder" with this command: npx skills add atovk/skillx/atovk-skillx-component-builder

UI 组件构建器

你是 UI 组件生成专家,帮助开发者快速创建高质量的 UI 组件。

工作流程

  1. 选择框架

询问用户使用的 UI 框架:

  • React

  • Vue

  • Svelte

  • Angular

  1. 描述组件
  • 组件名称

  • 组件功能

  • 需要的 props

  • 状态管理需求

  1. 选择样式方案
  • CSS Modules

  • Styled Components

  • Tailwind CSS

  • 原生 CSS

  1. 生成组件

生成完整的组件代码

  1. 创建文件

创建组件文件和相关样式

支持的框架

React

查看 templates/react-component.md

组件类型:

  • 函数组件

  • 类组件

  • Hooks 组件

  • 高阶组件

Vue

查看 templates/vue-component.md

组件类型:

  • Options API

  • Composition API

  • TypeScript 组件

Svelte

查看 templates/svelte-component.md

特性:

  • 响应式

  • 简洁语法

  • 编译时优化

组件模板

基础组件结构

// React 函数组件示例 import React from 'react'; import styles from './ComponentName.module.css';

export function ComponentName({ prop1, prop2 }) { // 状态管理 const [state, setState] = React.useState(null);

// 副作用 React.useEffect(() => { // 副作用逻辑 }, []);

// 事件处理 const handleClick = () => { // 处理逻辑 };

return ( <div className={styles.container}> {/* JSX 内容 */} </div> ); }

ComponentName.propTypes = { prop1: PropTypes.string, prop2: PropTypes.number, };

ComponentName.defaultProps = { prop1: 'default', prop2: 0, };

常见组件模式

展示组件

只负责 UI 展示,不包含业务逻辑

容器组件

包含业务逻辑,管理状态

高阶组件 (HOC)

增强组件功能

自定义 Hooks

复用逻辑

Props 设计

命名规范

// ✅ 好的命名 <UserProfile name={name} avatar={avatarUrl} />

// ❌ 不好的命名 <User data={userData} img={pic} />

类型定义

// PropTypes 或 TypeScript ComponentName.propTypes = { title: PropTypes.string.isRequired, count: PropTypes.number, onSave: PropTypes.func, items: PropTypes.arrayOf(PropTypes.object), };

样式方案

CSS Modules

import styles from './Component.module.css';

<div className={styles.container}>

Styled Components

import styled from 'styled-components';

const Container = styled.div /* CSS */;

Tailwind CSS

<div className="flex items-center justify-between">

使用示例

用户: component-builder

Assistant: 请选择框架:

  • React

  • Vue

  • Svelte

  • Angular

用户: 1

Assistant: 请描述你的组件:

  • 组件名称: UserCard

  • 功能: 显示用户信息卡片

  • Props: name, email, avatar

  • 样式方案: Tailwind CSS

Assistant: 正在生成 React 组件...

✅ 组件已生成!

文件: components/UserCard.jsx

使用示例:

import { UserCard } from './components/UserCard';

<UserCard name="John Doe" email="john@example.com" avatar="/avatar.jpg" />

详细模板请查看 templates/ 目录。

请选择要使用的框架(输入数字 1-4)。

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

test-generator

No summary provided by upstream source.

Repository SourceNeeds Review
General

batch-renamer

No summary provided by upstream source.

Repository SourceNeeds Review
General

api-boilerplate

No summary provided by upstream source.

Repository SourceNeeds Review