# Contributing to Uniface Element

Thank you for your interest in contributing to Uniface Element! We welcome contributions from the community.

## Table of Contents

- [Code of Conduct](#code-of-conduct)
- [How Can I Contribute?](#how-can-i-contribute)
- [Development Setup](#development-setup)
- [Coding Standards](#coding-standards)
- [Commit Guidelines](#commit-guidelines)
- [Pull Request Process](#pull-request-process)

## Code of Conduct

- Be respectful and inclusive
- Provide constructive feedback
- Focus on what is best for the community
- Show empathy towards other community members

## How Can I Contribute?

### Reporting Bugs

Before creating bug reports, please check existing issues to avoid duplicates. When creating a bug report, include:

- **Title**: Clear and descriptive
- **Description**: Detailed explanation of the issue
- **Reproduction**: Steps to reproduce the behavior
- **Expected behavior**: What you expected to happen
- **Environment**: OS, browser, Node.js version, package version
- **Screenshots**: If applicable, add screenshots

### Suggesting Enhancements

Enhancement suggestions are welcome! Please include:

- **Use case**: What problem would this solve?
- **Proposed solution**: How should it work?
- **Alternatives**: What alternatives have you considered?
- **Impact**: Who would benefit from this feature?

### Pull Requests

Pull requests are the best way to propose changes. Here's how to submit one:

1. Fork the repository
2. Create a branch for your feature or bugfix
3. Make your changes following our coding standards
4. Write tests for your changes (if applicable)
5. Ensure all tests pass
6. Commit your changes with clear messages
7. Push to your fork and submit a pull request

## Development Setup

### Prerequisites

- Node.js >= 18.0.0
- npm >= 8.0.0

### Installation

```bash
# Clone your fork
git clone https://github.com/your-username/uniface-element.git
cd uniface-element

# Install dependencies
npm install

# Start development server
npm run dev
```

### Build and Test

```bash
# Type check
npm run check

# Build the library
npm run build

# Run linting
npm run lint

# Format code
npm run format

# Run security audit
npm run audit
```

## Coding Standards

### TypeScript

- Use TypeScript for all new code
- Avoid using `any` type
- Provide proper type definitions for props and events
- Use interfaces for object shapes

### Svelte Components

- Follow Svelte best practices
- Use `<script lang="ts">` for TypeScript
- Organize component structure: script → template → styles
- Use meaningful component and variable names

### Code Style

We use ESLint and Prettier for code formatting:

```bash
# Auto-fix linting issues
npm run lint:fix

# Format all files
npm run format
```

### Documentation

- Update README.md if you change user-facing behavior
- Add JSDoc comments for public APIs
- Update relevant documentation files
- Include usage examples for new features

## Commit Guidelines

We follow [Conventional Commits](https://www.conventionalcommits.org/) specification:

### Commit Message Format

```
<type>(<scope>): <subject>

<body>

<footer>
```

### Types

- **feat**: A new feature
- **fix**: A bug fix
- **docs**: Documentation only changes
- **style**: Changes that don't affect code meaning (formatting, etc.)
- **refactor**: Code change that neither fixes a bug nor adds a feature
- **perf**: Performance improvement
- **test**: Adding or updating tests
- **chore**: Changes to build process or auxiliary tools
- **ci**: CI/CD changes

### Examples

```
feat(button): add loading state support

feat(dialog): add backdrop blur option

fix(datatable): correct column width calculation

docs(readme): update installation instructions

refactor(utils): extract common validation logic
```

## Pull Request Process

### Before Submitting

1. **Test your changes**: Ensure all existing tests pass
2. **Add tests**: Write tests for new features or bug fixes
3. **Update docs**: Update documentation as needed
4. **Check formatting**: Run `npm run format` and `npm run lint:fix`
5. **Rebase**: Make sure your branch is up to date with main

### PR Title

Use the same format as commit messages:

```
feat(component): brief description of changes
```

### PR Description

Include:

- **Summary**: What changes were made and why
- **Type**: What type of change is this? (feature, bugfix, refactor, etc.)
- **Testing**: How did you test these changes?
- **Screenshots**: Add screenshots for UI changes
- **Break changes**: List any breaking changes

### Review Process

1. Automated checks (CI/CD) will run
2. Maintainers will review your code
3. Address review comments
4. Once approved, your PR will be merged

## Getting Help

- **Documentation**: Check `/docs` directory for detailed documentation
- **Issues**: Search existing issues or create a new one
- **Discussions**: Use GitHub Discussions for questions

## License

By contributing, you agree that your contributions will be licensed under the [MIT License](LICENSE).

## Thank You!

Thank you for contributing to Uniface Element! Your contributions help make this project better for everyone.