Contributing to Hikari
Thank you for your interest in contributing to Hikari! This document provides guidelines and instructions for contributing to the project.
Table of Contents
- Code of Conduct
- Getting Started
- Development Setup
- Code Style Guidelines
- Git Workflow
- Testing Guidelines
- Documentation Standards
- Pull Request Process
- Community Guidelines
Code of Conduct
Our Pledge
We are committed to providing a welcoming and inclusive environment for all contributors. Please be respectful, constructive, and professional in all interactions.
Standards
- Use welcoming and inclusive language
- Be respectful of differing viewpoints and experiences
- Gracefully accept constructive criticism
- Focus on what is best for the community
- Show empathy towards other community members
Getting Started
Prerequisites
Before contributing, ensure you have:
- Rust 1.82+: Install from rustup.rs
- Python 3.11+: For development tooling
- Just: Install with cargo install just
- Git: For version control
Fork and Clone
- 1Fork the repository on GitHub
- 2Clone your fork locally:
- 1Add upstream remote:
Development Setup
Install Dependencies
# Install Rust toolchain
# Install Just
# Install Python dependencies (for tooling)
Build the Project
# Build all packages
# Or use cargo directly
Run Examples
# Run the website
# Run SSR demo
Development Mode
# Start development server (if configured)
Code Style Guidelines
Rust Code Style
We follow standard Rust conventions:
- 1Formatting: Use rustfmt
# or
- 1Linting: Use clippy
# or
- 1Naming Conventions:
- Structs/Enums: PascalCase
- Functions/Variables: snake_case
- Constants: SCREAMING_SNAKE_CASE
- Chinese Constants: Use Chinese characters (e.g., 石青)
// PascalCase
// snake_case
pub const MAX_SIZE: usize = 100; // SCREAMING_SNAKE_CASE
pub const 石青: Color = Color ; // Chinese (for palette)
Tairitsu Component Style
Components should follow these patterns:
// Always use component attribute
SCSS Style
Follow SCSS best practices:
// Use variables for all values
.my-component {
background-color: var(--hi-color-surface);
padding: var(--hi-spacing-md);
border-radius: var(--hi-radius-lg);
}
// Use nesting for related styles
.my-component {
&.modifier {
// Modifier styles
}
&:hover {
// Hover styles
}
.child-element {
// Child styles
}
}
Documentation Style
All public items must be documented:
/// Button component with multiple variants.
///
/// # Examples
///
/// ```rust
/// use hikari_components::Button;
///
/// rsx! {
/// Button { variant: ButtonVariant::Primary, "Click Me" }
/// }
/// ```
///
/// # Props
///
/// - `variant`: Button style variant
/// - `size`: Button size (Small, Medium, Large)
/// - `disabled`: Whether the button is disabled
/// - `loading`: Show loading spinner
Git Workflow
Branch Naming
Use descriptive branch names:
- feature/add-table-component
- fix/button-loading-state
- docs/update-readme
- refactor/theme-system
Commit Messages
Follow the emoji + one-liner format (as defined in PLAN.md):
emoji one-sentence english description
Examples:
- feat: Add table component with pagination
- fix: Resolve button disabled state bug
- docs: Update installation instructions
- refactor: Improve theme provider performance
Common emojis:
- feat - New feature
- fix - Bug fix
- docs - Documentation changes
- style - Code style changes (formatting)
- refactor - Code refactoring
- test - Adding or updating tests
- chore - Maintenance tasks
Commit Workflow
- 1Create a feature branch:
- 1Make changes and commit:
- 1Push to your fork:
- 1Create Pull Request: Go to GitHub and create a PR
Keeping Your Fork Updated
Testing Guidelines
Write Tests
All new features must include tests:
Run Tests
# Run all tests
# or
# Run tests for specific package
# Run tests with output
Test Coverage
- Aim for >80% code coverage
- Test edge cases and error conditions
- Test component props and state
- Test async code properly
Documentation Standards
Code Documentation
- All public items must have doc comments
- Include examples for complex APIs
- Document panics, errors, and safety considerations
- Use proper Markdown formatting
README Documentation
Each package should have a README with:
- 1Overview: What the package does
- 2Installation: How to add as dependency
- 3Quick Start: Basic usage example
- 4API Reference: Detailed API docs
- 5Examples: Advanced usage patterns
Example Applications
Examples should be:
- Complete: Fully functional applications
- Documented: Well-commented code
- Idiomatic: Follow best practices
- Independent: Can run standalone
Pull Request Process
Before Submitting
- 1Code Quality:
- Run just fmt to format code
- Run just lint to check for issues
- Run just test to ensure tests pass
- Update documentation if needed
- 1Commits:
- Squash related commits
- Ensure commit messages follow guidelines
- Remove outdated or debug commits
- 1Documentation:
- Update relevant README files
- Add/update code documentation
- Update CHANGELOG if applicable
Creating a Pull Request
- 1Go to the Hikari repository on GitHub
- 2Click "New Pull Request"
- 3Select your feature branch
- 4Fill in the PR template:
- ---
- -
- --Review Process
- 1Automated Checks: CI will run tests and linters
- 2Code Review: Maintainers will review your code
- 3Feedback: Address review comments
- 4Approval: Once approved, your PR will be merged
After Merge
- Delete your feature branch
- Update your local master branch
- Celebrate! Thank you for your contribution
Project Structure Guidelines
Adding a New Component
When adding a new component:
- 1Location: Place in appropriate module (basic, feedback, navigation, data)
- 2File Structure:
packages/hikari-components/src/
├── category/
│ ├── mod.rs # Export the component
│ └── component.rs # Component implementation
- 1Exports: Add to mod.rs and lib.rs
- 1Documentation: Document in package README
- 1Example: Add to website or create dedicated example
Adding a New Package
When adding a new package:
- 1Update Workspace: Add to Cargo.toml
- 2Create Structure: Follow existing package structure
- 3Documentation: Create comprehensive README
- 4Examples: Provide usage examples
- 5Tests: Include thorough tests
Community Guidelines
Communication Channels
- GitHub Issues: Bug reports and feature requests
- GitHub Discussions: General questions and ideas
- Pull Requests: Code contributions
Getting Help
- 1Check existing documentation
- 2Search existing issues
- 3Ask in GitHub Discussions
- 4Join community chat (if available)
Reporting Issues
When reporting bugs:
- 1Use Issue Template: Fill out all required fields
- 2Minimal Reproduction: Provide code that reproduces the issue
- 3Environment: Include Rust version, OS, etc.
- 4Expected vs Actual: Describe what you expected vs what happened
Feature Requests
When requesting features:
- 1Use Case: Describe the problem you're solving
- 2Proposed Solution: How you envision it working
- 3Alternatives: Other approaches you considered
- 4Willingness to Contribute: Indicate if you can implement it
Recognition
Contributors will be:
- Listed in CONTRIBUTORS.md
- Mentioned in release notes
- Credited in relevant documentation
- Invited to become maintainers (for consistent contributors)
License
By contributing, you agree that your contributions will be licensed under the Synthetic Source License (SySL), Version 1.0.
Questions?
If you have questions:
- 1Check this document
- 2Review existing issues and PRs
- 3Start a GitHub Discussion
- 4Contact maintainers
Thank you for contributing to Hikari! Your contributions help make Hikari better for everyone.