Установка
SKILL.md
Генератор каркасов компонентов
Создавайте готовые к производству каркасы компонентов с типами, вариантами, тестами и документацией.
Основной рабочий процесс
- Сбор требований: Имя компонента, фреймворк (React/Vue), необходимые пропсы
- Выбор паттерна: Определите, является ли компонент функциональным, составным или полиморфным
- Генерация компонента: Создайте основной файл компонента с типами TypeScript
- Добавление вариантов: Включите общие варианты (размер, цвет, состояние)
- Настройка стилизации: Добавьте подход к стилизации (Tailwind, CSS Modules, styled-components)
- Создание тестов: Сгенерируйте файл тестов с базовым покрытием
- Добавление истории: Создайте историю Storybook с примерами
- Документирование использования: Включите JSDoc и примеры использования
Паттерны компонентов
Базовый функциональный компонент (React)
// Button.tsx
import { forwardRef } from "react";
import { cn } from "@/lib/utils";
export interface ButtonProps
extends React.ButtonHTMLAttributes<HTMLButtonElement> {
variant?: "primary" | "secondary" | "ghost" | "destructive";
size?: "sm" | "md" | "lg";
isLoading?: boolean;
leftIcon?: React.ReactNode;
rightIcon?: React.ReactNode;
}
/**
* Button component with multiple variants and sizes
*
* @example
* ```tsx
* <Button variant="primary" size="md">
* Click me
* </Button>
* ```
*/
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
(
{
variant = "primary",
size = "md",
isLoading = false,
leftIcon,
rightIcon,
className,
children,
disabled,
...props
},
ref
) => {
return (
<button
ref={ref}
className={cn(
"inline-flex items-center justify-center rounded-md font-medium transition-colors",
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",
"disabled:pointer-events-none disabled:opacity-50",
{
// Variants
"bg-blue-600 text-white hover:bg-blue-700": variant === "primary",
"bg-gray-200 text-gray-900 hover:bg-gray-300":
variant === "secondary",
"hover:bg-gray-100": variant === "ghost",
"bg-red-600 text-white hover:bg-red-700": variant === "destructive",
// Sizes
"h-8 px-3 text-sm": size === "sm",
"h-10 px-4 text-base": size === "md",
"h-12 px-6 text-lg": size === "lg",
},
className
)}
disabled={disabled || isLoading}
{...props}
>
{isLoading && (
<svg
className="mr-2 h-4 w-4 animate-spin"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle
className="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
strokeWidth="4"
/>
<path
className="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
/>
</svg>
)}
{leftIcon && <span className="mr-2">{leftIcon}</span>}
{children}
{rightIcon && <span className="ml-2">{rightIcon}</span>}
</button>
);
}
);
Button.displayName = "Button";
Паттерн составного компонента
// Card.tsx
import { createContext, useContext } from "react";
interface CardContextValue {
variant: "default" | "outlined" | "elevated";
}
const CardContext = createContext<CardContextValue | undefined>(undefined);
export interface CardProps extends React.HTMLAttributes<HTMLDivElement> {
variant?: "default" | "outlined" | "elevated";
}
export const Card = ({
variant = "default",
className,
children,
...props
}: CardProps) => {
return (
<CardContext.Provider value={{ variant }}>
<div className={cn("rounded-lg", className)} {...props}>
{children}
</div>
</CardContext.Provider>
);
};
export const CardHeader = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div className={cn("p-6", className)} {...props} />
);
export const CardTitle = ({
className,
...props
}: React.HTMLAttributes<HTMLHeadingElement>) => (
<h3 className={cn("text-2xl font-semibold", className)} {...props} />
);
export const CardContent = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div className={cn("p-6 pt-0", className)} {...props} />
);
export const CardFooter = ({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) => (
<div className={cn("flex items-center p-6 pt-0", className)} {...props} />
);
Шаблон файла тестов
// Button.test.tsx
import { render, screen, fireEvent } from "@testing-library/react";
import { Button } from "./Button";
describe("Button", () => {
it("renders children correctly", () => {
render(<Button>Click me</Button>);
expect(
screen.getByRole("button", { name: /click me/i })
).toBeInTheDocument();
});
it("applies variant classes correctly", () => {
const { rerender } = render(<Button variant="primary">Test</Button>);
expect(screen.getByRole("button")).toHaveClass("bg-blue-600");
rerender(<Button variant="secondary">Test</Button>);
expect(screen.getByRole("button")).toHaveClass("bg-gray-200");
});
it("handles click events", () => {
const handleClick = jest.fn();
render(<Button onClick={handleClick}>Click</Button>);
fireEvent.click(screen.getByRole("button"));
expect(handleClick).toHaveBeenCalledTimes(1);
});
it("shows loading state", () => {
render(<Button isLoading>Loading</Button>);
expect(screen.getByRole("button")).toBeDisabled();
expect(screen.getByRole("button")).toContainHTML("svg");
});
it("renders with icons", () => {
render(
<Button leftIcon={<span data-testid="left">←</span>}>With Icon</Button>
);
expect(screen.getByTestId("left")).toBeInTheDocument();
});
it("forwards ref correctly", () => {
const ref = React.createRef<HTMLButtonElement>();
render(<Button ref={ref}>Test</Button>);
expect(ref.current).toBeInstanceOf(HTMLButtonElement);
});
});
Шаблон истории Storybook
// Button.stories.tsx
import type { Meta, StoryObj } from "@storybook/react";
import { Button } from "./Button";
const meta: Meta<typeof Button> = {
title: "Components/Button",
component: Button,
tags: ["autodocs"],
argTypes: {
variant: {
control: "select",
options: ["primary", "secondary", "ghost", "destructive"],
},
size: {
control: "select",
options: ["sm", "md", "lg"],
},
isLoading: {
control: "boolean",
},
},
};
export default meta;
type Story = StoryObj<typeof Button>;
export const Primary: Story = {
args: {
variant: "primary",
children: "Button",
},
};
export const Secondary: Story = {
args: {
variant: "secondary",
children: "Button",
},
};
export const WithIcons: Story = {
args: {
children: "With Icons",
leftIcon: "←",
rightIcon: "→",
},
};
export const Loading: Story = {
args: {
children: "Loading",
isLoading: true,
},
};
export const Sizes: Story = {
render: () => (
<div className="flex gap-4 items-center">
<Button size="sm">Small</Button>
<Button size="md">Medium</Button>
<Button size="lg">Large</Button>
</div>
),
};
export const Variants: Story = {
render: () => (
<div className="flex gap-4">
<Button variant="primary">Primary</Button>
<Button variant="secondary">Secondary</Button>
<Button variant="ghost">Ghost</Button>
<Button variant="destructive">Destructive</Button>
</div>
),
};
Паттерн компонента Vue
<!-- Button.vue -->
<script setup lang="ts">
import { computed } from "vue";
interface Props {
variant?: "primary" | "secondary" | "ghost" | "destructive";
size?: "sm" | "md" | "lg";
isLoading?: boolean;
disabled?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
variant: "primary",
size: "md",
isLoading: false,
disabled: false,
});
const emit = defineEmits<{
click: [event: MouseEvent];
}>();
const buttonClasses = computed(() => {
return [
"inline-flex items-center justify-center rounded-md font-medium transition-colors",
"focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2",
"disabled:pointer-events-none disabled:opacity-50",
// Variants
{
"bg-blue-600 text-white hover:bg-blue-700": props.variant === "primary",
"bg-gray-200 text-gray-900 hover:bg-gray-300":
props.variant === "secondary",
"hover:bg-gray-100": props.variant === "ghost",
"bg-red-600 text-white hover:bg-red-700": props.variant === "destructive",
},
// Sizes
{
"h-8 px-3 text-sm": props.size === "sm",
"h-10 px-4 text-base": props.size === "md",
"h-12 px-6 text-lg": props.size === "lg",
},
];
});
const handleClick = (event: MouseEvent) => {
if (!props.disabled && !props.isLoading) {
emit("click", event);
}
};
</script>
<template>
<button
:class="buttonClasses"
:disabled="disabled || isLoading"
@click="handleClick"
>
<svg
v-if="isLoading"
class="mr-2 h-4 w-4 animate-spin"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle
class="opacity-25"
cx="12"
cy="12"
r="10"
stroke="currentColor"
stroke-width="4"
/>
<path
class="opacity-75"
fill="currentColor"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"
/>
</svg>
<slot />
</button>
</template>
Индексный файл (Barrel Export)
// index.ts
export { Button } from "./Button";
export type { ButtonProps } from "./Button";
Шаблон документации по использованию
# Button Component
A flexible button component with multiple variants, sizes, and states.
## Installation
```bash
npm install @/components/ui/button
```
Использование
import { Button } from "@/components/ui/button";
function App() {
return (
<Button variant="primary" size="md" onClick={() => console.log("Clicked!")}>
Click me
</Button>
);
}
Пропсы
| Проп | Тип | По умолчанию | Описание |
|---|---|---|---|
| variant | 'primary' | 'secondary' | 'ghost' | 'destructive' | 'primary' | Вариант визуального стиля |
| size | 'sm' | 'md' | 'lg' | 'md' | Размер кнопки |
| isLoading | boolean | false | Показывает индикатор загрузки |
| leftIcon | ReactNode | - | Иконка перед текстом |
| rightIcon | ReactNode | - | Иконка после текста |
| disabled | boolean | false | Отключает кнопку |
Примеры
С иконками
<Button leftIcon={<ChevronLeft />}>Back</Button>
Состояние загрузки
<Button isLoading>Saving...</Button>
Деструктивное действие
<Button variant="destructive" onClick={handleDelete}>
Delete Account
</Button>
Доступность
- Навигация с клавиатуры
- Включены ARIA-атрибуты
- Видимый стиль фокуса
- Корректная обработка отключённого состояния
## Component Structure Template
ComponentName/ ├── ComponentName.tsx # Main component ├── ComponentName.test.tsx # Tests ├── ComponentName.stories.tsx # Storybook ├── types.ts # TypeScript types (if complex) ├── styles.module.css # CSS Modules (if used) └── index.ts # Barrel export
## Common Component Types
### UI Primitives
- Button, Input, Select, Checkbox, Radio
- Typography (Text, Heading, Label)
- Icons, Avatar, Badge
### Layout Components
- Container, Stack, Grid, Flex
- Card, Panel, Section
- Divider, Spacer
### Data Display
- Table, List, DataGrid
- Tooltip, Popover, Dropdown
- Tabs, Accordion, Collapse
### Feedback
- Alert, Toast, Modal
- Progress, Spinner, Skeleton
- EmptyState, ErrorBoundary
### Forms
- FormField, FormGroup, FormLabel
- FileUpload, DatePicker, RangePicker
- SearchInput, TagInput
## Best Practices
1. **Forward refs**: Use `forwardRef` for DOM access
2. **Type props properly**: Extend native HTML element props
3. **Use composition**: Compound components when appropriate
4. **Accessibility first**: ARIA attributes, keyboard nav
5. **Variants system**: Size, color, state variants
6. **Loading states**: Handle async operations
7. **Error states**: Validate and show errors
8. **Test coverage**: At least 80% coverage
9. **Document usage**: JSDoc and README examples
10. **Export types**: Make TypeScript types available
## Styling Approaches
### Tailwind CSS (Recommended)
- Use `cn()` utility for conditional classes
- Define variants with object syntax
- Responsive utilities built-in
### CSS Modules
- Scoped styles by default
- Type-safe with TypeScript
- Better for complex animations
### Styled Components
- CSS-in-JS with props
- Dynamic theming support
- Runtime styling
## Output Checklist
Every generated component should include:
- [ ] Main component file with TypeScript types
- [ ] Prop interface with JSDoc comments
- [ ] Multiple variants (size, color, state)
- [ ] Accessibility attributes
- [ ] Test file with key scenarios
- [ ] Storybook story with examples
- [ ] Barrel export (index.ts)
- [ ] Usage documentation
- [ ] Error handling
- [ ] Loading states (if applicable)
Вставить в README
Ссылка на карточку для вашего README — без картинок и счётчиков.
[DarkPlay: component-scaffold-generator](https://darkplay.ru/ai/skills/patricio0312rev-skills-component-scaffold-generator)
Из того же репозитория
Похожие скиллы и другие разделы каталога
Самые востребованные скиллов раздела по установкам и звёздам.
find-skillsvercel-labs · Помогает находить и устанавливать навыки агентов по запросам вроде «как сделать X»…
grill-memattpocock · Настойчивое интервью для доработки плана или дизайна.
hyperframesheygen-com · Обязательная точка входа для любых задач по видео, анимации и motion-графике в…
hyperframes-cliheygen-com · Цикл разработки HyperFrames CLI: init, add, render, preview, publish и другие команды.
agent-browservercel-labs · CLI для автоматизации браузера для ИИ-агентов: навигация по страницам, заполнение форм…
media-useheygen-com · Agent Media OS: единый навык для медиа в HyperFrames — BGM, SFX, изображения, голос, LUT.
hyperframes-registryheygen-com · Установка и подключение блоков реестра в композиции HyperFrames через add и catalog.
grill-with-docsmattpocock · Настойчивое интервью для доработки плана или дизайна, попутно создающее документацию (ADR…
improve-codebase-architecturemattpocock · Поиск в кодовой базе возможностей для углубления, визуальный HTML-отчёт о них и детальный…
tddmattpocock · Разработка через тестирование (TDD): red-green-refactor и интеграционные тесты.Соседние разделы каталога: возможно, нужный инструмент живёт там.
A11y Architectaffaan-m · Архитектор доступности, специализирующийся на соответствии WCAG 2.2 для веба и нативных…
Add Language Rulesaffaan-m · Каркас команды workflow для add-language-rules в everything-claude-code.
Database Migrationaffaan-m · Каркас команды workflow для database-migration в everything-claude-code.
Feature Developmentaffaan-m · Каркас команды workflow для feature-development в everything-claude-code.
Gan Evaluatoraffaan-m · GAN Harness — агент-оценщик: тестирует приложение через Playwright и даёт обратную связь.
Gan Generatoraffaan-m · GAN Harness — агент-генератор: реализует функции по спецификации и итерирует по отзывам.
React Build Resolveraffaan-m · Чинит сборки React в Vite, webpack, Next.js и других: JSX, гидратация, типы.
React Revieweraffaan-m · Ревьюер React/JSX: хуки, производительность, границы компонентов и безопасность.
Vue Revieweraffaan-m · Ревьюер Vue.js: Composition API, реактивность, архитектура компонентов, Pinia, Nuxt.
ruflo-dddruvnet · Каркас Domain-Driven Design: ограниченные контексты, агрегатные корни, доменные события и…Лучшие ИИ-инструменты для программирования
Подборка нейросетей и ИИ-ассистентов для разработки и автоматизации кода. Сервисы, которые ускоряют написание, ревью и отладку, экономят часы рутины и снижают порог входа в сложные
GenAPIGenapi
Notepad++ AINotepad-plus-plus
Creatium MaxCremax
Emacs AIGnu
KiteKite
Amazon Q DeveloperAmazonЛучшие ИИ-инструменты для генерации видео
Подборка нейросетей для генерации и монтажа видео. Инструменты, которые превращают текст в готовые ролики, экономят часы на съемках и постпродакшне. Подходит для SMM-специалистов,
VEED.IOVeed
MootionMootion
Sora (OpenAI)OpenAI
viralpulse.appViralpulse
Viral Maker AIViral-makerЛучшие ИИ-инструменты для генерации текста и копирайтинга
Подборка нейросетей для генерации текстов и копирайтинга. Сервисы, которые помогают создавать статьи, посты и рекламные объявления с нуля или по черновику, экономя часы рутинной ра
NeuroscribeNeuroscribe
GoGPTGogpt
НейроТекстерNeuro-texter
ChatGPTOpenAI
Cosmo ScribeCosmoscribe
Memo HelperCopilot33
LibraChatLibrachat