|
| 1 | +# Contributing to @dev-ahmed-mahmoud/react-custom-scrollbars |
| 2 | + |
| 3 | +Thank you for your interest in contributing! This project is a modern TypeScript/React 19 implementation of the original react-custom-scrollbars by [Malte Wessel](https://github.com/malte-wessel). |
| 4 | + |
| 5 | +## 📋 Table of Contents |
| 6 | + |
| 7 | +- [Code of Conduct](#code-of-conduct) |
| 8 | +- [How Can I Contribute?](#how-can-i-contribute) |
| 9 | +- [Development Setup](#development-setup) |
| 10 | +- [Pull Request Process](#pull-request-process) |
| 11 | +- [Coding Standards](#coding-standards) |
| 12 | + |
| 13 | +## Code of Conduct |
| 14 | + |
| 15 | +This project follows a [Code of Conduct](CODE_OF_CONDUCT.md) that we expect all contributors to adhere to. |
| 16 | + |
| 17 | +## How Can I Contribute? |
| 18 | + |
| 19 | +### 🐛 Reporting Bugs |
| 20 | +- Use the [bug report template](.github/ISSUE_TEMPLATE/bug_report.yml) |
| 21 | +- Include a clear description and reproduction steps |
| 22 | +- Provide environment details (React/Node.js versions, browser, OS) |
| 23 | +- Include a minimal code example demonstrating the issue |
| 24 | + |
| 25 | +### 💡 Suggesting Features |
| 26 | +- Use the [feature request template](.github/ISSUE_TEMPLATE/feature_request.yml) |
| 27 | +- Explain the use case and expected behavior |
| 28 | +- Consider TypeScript implications |
| 29 | + |
| 30 | +### 🔧 Contributing Code |
| 31 | +- Fix bugs or implement new features |
| 32 | +- Improve documentation |
| 33 | +- Add tests for new functionality |
| 34 | +- Optimize performance |
| 35 | + |
| 36 | +## Development Setup |
| 37 | + |
| 38 | +### Prerequisites |
| 39 | +- **Node.js**: 20.0.0 or higher |
| 40 | +- **npm**: Latest version |
| 41 | +- **TypeScript**: 5.8+ knowledge helpful |
| 42 | + |
| 43 | +### Setup Instructions |
| 44 | + |
| 45 | +1. **Fork and Clone** |
| 46 | + ```bash |
| 47 | + git clone https://github.com/YOUR-USERNAME/react-custom-scrollbars.git |
| 48 | + cd react-custom-scrollbars |
| 49 | + ``` |
| 50 | + |
| 51 | +2. **Install Dependencies** |
| 52 | + ```bash |
| 53 | + npm install |
| 54 | + ``` |
| 55 | + |
| 56 | +3. **Development Commands** |
| 57 | + ```bash |
| 58 | + # Run tests |
| 59 | + npm test |
| 60 | + |
| 61 | + # Run tests with coverage |
| 62 | + npm run test:coverage |
| 63 | + |
| 64 | + # Type checking |
| 65 | + npm run typecheck |
| 66 | + |
| 67 | + # Linting |
| 68 | + npm run lint |
| 69 | + npm run lint:fix |
| 70 | + |
| 71 | + # Build |
| 72 | + npm run build |
| 73 | + |
| 74 | + # Run all checks |
| 75 | + npm run prepublishOnly |
| 76 | + ``` |
| 77 | + |
| 78 | +## Pull Request Process |
| 79 | + |
| 80 | +### 1. Create a Branch |
| 81 | +```bash |
| 82 | +git checkout -b feature/your-feature-name |
| 83 | +# or |
| 84 | +git checkout -b fix/your-bug-fix |
| 85 | +``` |
| 86 | + |
| 87 | +### 2. Make Your Changes |
| 88 | +- Write clear, concise commit messages following [Conventional Commits](https://conventionalcommits.org/) |
| 89 | +- Add tests for new functionality |
| 90 | +- Update documentation if needed |
| 91 | +- Ensure TypeScript types are accurate |
| 92 | + |
| 93 | +### 3. Test Your Changes |
| 94 | +```bash |
| 95 | +# Run all checks |
| 96 | +npm run prepublishOnly |
| 97 | + |
| 98 | +# Ensure all tests pass |
| 99 | +npm test |
| 100 | + |
| 101 | +# Check TypeScript compilation |
| 102 | +npm run typecheck |
| 103 | + |
| 104 | +# Verify linting |
| 105 | +npm run lint |
| 106 | +``` |
| 107 | + |
| 108 | +### 4. Commit and Push |
| 109 | +```bash |
| 110 | +git commit -m "feat: add new scrollbar customization option" |
| 111 | +git push origin feature/your-feature-name |
| 112 | +``` |
| 113 | + |
| 114 | +### 5. Create Pull Request |
| 115 | +- Use a clear, descriptive title |
| 116 | +- Reference any related issues |
| 117 | +- Include a detailed description of changes |
| 118 | +- Add screenshots for visual changes |
| 119 | + |
| 120 | +## Coding Standards |
| 121 | + |
| 122 | +### TypeScript Guidelines |
| 123 | +```typescript |
| 124 | +// ✅ Good: Proper typing |
| 125 | +interface MyComponentProps { |
| 126 | + children: ReactNode |
| 127 | + className?: string |
| 128 | +} |
| 129 | + |
| 130 | +// ✅ Good: Use meaningful names |
| 131 | +const handleScrollStart = useCallback(() => { |
| 132 | + // implementation |
| 133 | +}, []) |
| 134 | + |
| 135 | +// ❌ Avoid: Any types |
| 136 | +const handleEvent = (event: any) => { } |
| 137 | +``` |
| 138 | + |
| 139 | +### React Patterns |
| 140 | +```typescript |
| 141 | +// ✅ Good: Use hooks appropriately |
| 142 | +const MyComponent = forwardRef<ScrollbarsRef, MyComponentProps>((props, ref) => { |
| 143 | + const scrollbarsRef = useRef<ScrollbarsRef>(null) |
| 144 | + |
| 145 | + useImperativeHandle(ref, () => ({ |
| 146 | + scrollToTop: () => scrollbarsRef.current?.scrollToTop(), |
| 147 | + })) |
| 148 | + |
| 149 | + return <Scrollbars ref={scrollbarsRef} {...props} /> |
| 150 | +}) |
| 151 | +``` |
| 152 | +
|
| 153 | +### Testing Requirements |
| 154 | +- **Unit Tests**: For all new features and bug fixes |
| 155 | +- **TypeScript Tests**: Ensure types are properly tested |
| 156 | +- **Integration Tests**: For component interactions |
| 157 | +
|
| 158 | +```typescript |
| 159 | +// Example test |
| 160 | +describe('Scrollbars', () => { |
| 161 | + it('should call onScrollStart when scrolling begins', async () => { |
| 162 | + const onScrollStart = vi.fn() |
| 163 | + |
| 164 | + render( |
| 165 | + <Scrollbars onScrollStart={onScrollStart}> |
| 166 | + <div>Content</div> |
| 167 | + </Scrollbars> |
| 168 | + ) |
| 169 | + |
| 170 | + // Test implementation |
| 171 | + }) |
| 172 | +}) |
| 173 | +``` |
| 174 | +
|
| 175 | +## 📚 Documentation |
| 176 | +
|
| 177 | +### Code Documentation |
| 178 | +- Use TypeScript for self-documenting code |
| 179 | +- Add JSDoc comments for complex functions |
| 180 | +- Include examples in documentation |
| 181 | +
|
| 182 | +### README Updates |
| 183 | +- Update README.md for new features |
| 184 | +- Add TypeScript examples |
| 185 | +- Update API documentation |
| 186 | +
|
| 187 | +## 🔍 Code Review Process |
| 188 | +
|
| 189 | +1. **Automated Checks**: All PRs must pass CI checks |
| 190 | +2. **Manual Review**: Code will be reviewed for: |
| 191 | + - Functionality and correctness |
| 192 | + - TypeScript best practices |
| 193 | + - Performance implications |
| 194 | + - Test coverage |
| 195 | + - Documentation completeness |
| 196 | +
|
| 197 | +## 🙏 Recognition |
| 198 | +
|
| 199 | +Contributors will be: |
| 200 | +- Added to the contributors list |
| 201 | +- Credited in release notes |
| 202 | +- Mentioned in the README |
| 203 | +
|
| 204 | +## ❓ Questions? |
| 205 | +
|
| 206 | +- Open an issue for questions |
| 207 | +- Check existing issues and PRs |
| 208 | +- Review the [API documentation](docs/API.md) |
| 209 | +
|
| 210 | +## 📝 License |
| 211 | +
|
| 212 | +By contributing, you agree that your contributions will be licensed under the MIT License. |
| 213 | +
|
| 214 | +--- |
| 215 | +
|
| 216 | +**Credits:** |
| 217 | +- Original library by [Malte Wessel](https://github.com/malte-wessel) |
| 218 | +- v5.0 modernization maintained by [Ahmed Mahmoud](https://github.com/dev-ahmedmahmoud) |
0 commit comments