Skip to main content

Welcome

Thank you for considering contributing to Component Library! This guide will help you get started.

Getting Started

Fork and Clone

# Fork the repository on GitHub
# Then clone your fork
git clone https://github.com/YOUR_USERNAME/component-library.git
cd component-library

Install Dependencies

npm install

Development Workflow

# Start Storybook for development
npm run storybook

# Build library
npm run build

# Build everything
npm run build:all

Project Structure

component-library/
├── src/
│   ├── components/     # Component source files
│   │   ├── Button/
│   │   └── Input/
│   └── styles/         # Global styles
├── stories/            # Storybook stories
├── docs/               # Mintlify documentation
└── .storybook/         # Storybook configuration

Adding a New Component

1. Create Component Files

mkdir src/components/NewComponent
Create the following files:
NewComponent/
├── NewComponent.tsx
├── NewComponent.css
└── index.ts

2. Component Template

// NewComponent.tsx
import React from 'react';
import './NewComponent.css';

export interface NewComponentProps {
  // Define props
}

export const NewComponent = React.forwardRef<HTMLElement, NewComponentProps>(
  (props, ref) => {
    return (
      // Component JSX
    );
  }
);

NewComponent.displayName = 'NewComponent';

3. Add Styles

/* NewComponent.css */
.new-component {
  /* Component styles using CSS variables */
}

4. Export Component

// index.ts
export { NewComponent } from './NewComponent';
export type { NewComponentProps } from './NewComponent';

5. Add to Main Export

// src/components/index.ts
export * from './NewComponent';

6. Create Storybook Story

// stories/NewComponent.stories.tsx
import type { Meta, StoryObj } from '@storybook/react';
import { NewComponent } from '../src/components/NewComponent';

const meta: Meta<typeof NewComponent> = {
  title: 'Components/NewComponent',
  component: NewComponent,
  tags: ['autodocs'],
};

export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
  args: {},
};

7. Create Documentation

<!-- docs/components/new-component.mdx -->
---
title: NewComponent
description: 'Component description'
---

## Overview

Component overview and usage.

Code Standards

TypeScript

  • Use TypeScript for all components
  • Export prop interfaces
  • Extend HTML element props when appropriate
interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
  variant?: 'primary' | 'secondary';
}

Accessibility

  • Include proper ARIA attributes
  • Support keyboard navigation
  • Provide accessible labels
  • Test with screen readers
<button
  aria-label="Close"
  aria-describedby="description"
>
  ×
</button>

CSS

  • Use CSS custom properties
  • Follow BEM naming convention
  • Keep specificity low
.component {
  color: var(--primary-color);
}

.component--variant {
  /* Variant styles */
}

Testing

  • Test all component variants
  • Test accessibility
  • Test keyboard navigation
  • Test with different props

Pull Request Process

1. Create a Branch

git checkout -b feature/new-component

2. Make Changes

  • Write code following standards
  • Add tests if applicable
  • Update documentation

3. Commit Changes

Use conventional commits:
git commit -m "feat: add NewComponent"
git commit -m "fix: resolve button focus issue"
git commit -m "docs: update installation guide"
Commit types:
  • feat: New feature
  • fix: Bug fix
  • docs: Documentation
  • style: Code style changes
  • refactor: Code refactoring
  • test: Tests
  • chore: Maintenance

4. Push and Create PR

git push origin feature/new-component
Create a pull request on GitHub with:
  • Clear description
  • Screenshots (if UI changes)
  • Link to related issues

Review Process

  1. Automated checks run (build, lint)
  2. Maintainers review code
  3. Address feedback
  4. Merge when approved

Documentation

Component Documentation

Update these files:
  • Component MDX in docs/components/
  • API reference in docs/api/
  • Storybook stories

Code Comments

/**
 * Button component with multiple variants
 * @param variant - Visual style variant
 * @param size - Button size
 */
export const Button = ({ variant, size }: ButtonProps) => {
  // Implementation
};

Release Process

Maintainers handle releases:
  1. Update version in package.json
  2. Update CHANGELOG.md
  3. Create git tag
  4. Publish to NPM
  5. Deploy documentation

Questions?

  • Open an issue on GitHub
  • Check existing documentation
  • Review closed PRs for examples

Code of Conduct

  • Be respectful and inclusive
  • Provide constructive feedback
  • Help others learn and grow

License

By contributing, you agree that your contributions will be licensed under the MIT License.

Thank You!

Your contributions make this library better for everyone. Thank you for your time and effort!