|
| 1 | +# Contributing to CSS Reference Guide |
| 2 | + |
| 3 | +Thank you for your interest in contributing! This document provides guidelines and instructions for contributing to the CSS Reference Guide. |
| 4 | + |
| 5 | +## 📋 Table of Contents |
| 6 | + |
| 7 | +- [Code of Conduct](#code-of-conduct) |
| 8 | +- [Getting Started](#getting-started) |
| 9 | +- [How to Contribute](#how-to-contribute) |
| 10 | +- [Development Workflow](#development-workflow) |
| 11 | +- [Adding CSS Properties](#adding-css-properties) |
| 12 | +- [Code Style](#code-style) |
| 13 | +- [Commit Messages](#commit-messages) |
| 14 | +- [Pull Request Process](#pull-request-process) |
| 15 | + |
| 16 | +## 📜 Code of Conduct |
| 17 | + |
| 18 | +By participating in this project, you agree to maintain a welcoming and inclusive environment. Please: |
| 19 | + |
| 20 | +- Be respectful and inclusive |
| 21 | +- Welcome newcomers and help them get started |
| 22 | +- Focus on constructive feedback |
| 23 | +- Accept responsibility for mistakes gracefully |
| 24 | + |
| 25 | +## 🚀 Getting Started |
| 26 | + |
| 27 | +1. **Fork the repository** on GitHub |
| 28 | + |
| 29 | +2. **Clone your fork**: |
| 30 | + ```bash |
| 31 | + git clone https://github.com/YOUR_USERNAME/css-reference-guide.git |
| 32 | + cd css-reference-guide |
| 33 | + ``` |
| 34 | + |
| 35 | +3. **Install dependencies**: |
| 36 | + ```bash |
| 37 | + npm install |
| 38 | + ``` |
| 39 | + |
| 40 | +4. **Start the development server**: |
| 41 | + ```bash |
| 42 | + npm run dev |
| 43 | + ``` |
| 44 | + |
| 45 | +5. **Create a branch** for your changes: |
| 46 | + ```bash |
| 47 | + git checkout -b feature/your-feature-name |
| 48 | + ``` |
| 49 | + |
| 50 | +## 🤝 How to Contribute |
| 51 | + |
| 52 | +### Reporting Bugs |
| 53 | + |
| 54 | +- Check if the bug has already been reported in Issues |
| 55 | +- Use the bug report template if available |
| 56 | +- Include steps to reproduce, expected behavior, and actual behavior |
| 57 | +- Add screenshots if applicable |
| 58 | + |
| 59 | +### Suggesting Features |
| 60 | + |
| 61 | +- Check the [TODO.md](TODO.md) for planned features |
| 62 | +- Open an issue to discuss the feature before implementing |
| 63 | +- Explain the use case and benefits |
| 64 | + |
| 65 | +### Adding CSS Properties |
| 66 | + |
| 67 | +This is one of the most valuable contributions! See the dedicated section below. |
| 68 | + |
| 69 | +### Improving Documentation |
| 70 | + |
| 71 | +- Fix typos and clarify explanations |
| 72 | +- Add examples and use cases |
| 73 | +- Translate documentation (open an issue first) |
| 74 | + |
| 75 | +### Code Contributions |
| 76 | + |
| 77 | +- Fix bugs |
| 78 | +- Implement features from TODO.md |
| 79 | +- Improve performance |
| 80 | +- Enhance accessibility |
| 81 | + |
| 82 | +## 💻 Development Workflow |
| 83 | + |
| 84 | +### Project Structure |
| 85 | + |
| 86 | +``` |
| 87 | +src/ |
| 88 | +├── components/ # React components |
| 89 | +├── data/ # CSS property definitions |
| 90 | +├── hooks/ # Custom React hooks |
| 91 | +├── pages/ # Route pages |
| 92 | +├── lib/ # Utilities |
| 93 | +└── index.css # Design tokens |
| 94 | +``` |
| 95 | + |
| 96 | +### Available Scripts |
| 97 | + |
| 98 | +```bash |
| 99 | +npm run dev # Start development server |
| 100 | +npm run build # Build for production |
| 101 | +npm run preview # Preview production build |
| 102 | +npm run lint # Run ESLint |
| 103 | +npm run test # Run tests |
| 104 | +``` |
| 105 | + |
| 106 | +### Design System |
| 107 | + |
| 108 | +Always use design tokens from `index.css`: |
| 109 | + |
| 110 | +```tsx |
| 111 | +// ✅ Good - uses semantic tokens |
| 112 | +<div className="bg-background text-foreground border-border" /> |
| 113 | + |
| 114 | +// ❌ Bad - hardcoded colors |
| 115 | +<div className="bg-white text-gray-900 border-gray-200" /> |
| 116 | +``` |
| 117 | + |
| 118 | +## 📚 Adding CSS Properties |
| 119 | + |
| 120 | +### Property Structure |
| 121 | + |
| 122 | +Add new properties to `src/data/cssProperties.ts`: |
| 123 | + |
| 124 | +```typescript |
| 125 | +{ |
| 126 | + name: "property-name", |
| 127 | + category: "Category", |
| 128 | + description: "Clear, concise description (1-2 sentences).", |
| 129 | + syntax: "property-name: <value>;", |
| 130 | + values: ["value1", "value2", "inherit", "initial"], |
| 131 | + example: `.example { |
| 132 | + property-name: value1; |
| 133 | + /* Additional context if helpful */ |
| 134 | +}`, |
| 135 | + browserSupport: { |
| 136 | + chrome: true, |
| 137 | + firefox: true, |
| 138 | + safari: true, |
| 139 | + edge: true |
| 140 | + } |
| 141 | +} |
| 142 | +``` |
| 143 | + |
| 144 | +### Categories |
| 145 | + |
| 146 | +Use existing categories when possible: |
| 147 | + |
| 148 | +- **Layout** - Flexbox, Grid, positioning |
| 149 | +- **Typography** - Fonts, text styling |
| 150 | +- **Colors** - Color properties and functions |
| 151 | +- **Animation** - Transitions, animations, transforms |
| 152 | +- **Spacing** - Margins, padding, gaps |
| 153 | +- **Effects** - Filters, shadows, blend modes |
| 154 | +- **Scroll** - Scroll behavior, snap |
| 155 | +- **Container Queries** - Container-based responsive design |
| 156 | +- **Functions** - CSS functions like `clamp()`, `calc()` |
| 157 | +- **Logical Properties** - Writing-mode aware properties |
| 158 | +- **Shapes & Masking** - Clip paths, masks |
| 159 | +- **At-Rules** - `@layer`, `@scope`, etc. |
| 160 | +- **Selectors & Pseudo** - Pseudo-classes and elements |
| 161 | + |
| 162 | +### Guidelines |
| 163 | + |
| 164 | +1. **Accuracy**: Verify syntax against MDN Web Docs |
| 165 | +2. **Examples**: Make examples practical and copy-paste ready |
| 166 | +3. **Browser Support**: Check caniuse.com for accuracy |
| 167 | +4. **Alphabetical Order**: Add properties alphabetically within their category |
| 168 | + |
| 169 | +### Example Contribution |
| 170 | + |
| 171 | +```typescript |
| 172 | +// Adding the 'text-wrap' property |
| 173 | +{ |
| 174 | + name: "text-wrap", |
| 175 | + category: "Typography", |
| 176 | + description: "Controls how text wraps inside an element, with options for balanced or pretty wrapping.", |
| 177 | + syntax: "text-wrap: wrap | nowrap | balance | pretty | stable;", |
| 178 | + values: ["wrap", "nowrap", "balance", "pretty", "stable"], |
| 179 | + example: `.headline { |
| 180 | + text-wrap: balance; |
| 181 | + /* Evenly distributes text across lines */ |
| 182 | +}`, |
| 183 | + browserSupport: { |
| 184 | + chrome: true, |
| 185 | + firefox: true, |
| 186 | + safari: false, |
| 187 | + edge: true |
| 188 | + } |
| 189 | +} |
| 190 | +``` |
| 191 | + |
| 192 | +## 🎨 Code Style |
| 193 | + |
| 194 | +### TypeScript |
| 195 | + |
| 196 | +- Use TypeScript for all new code |
| 197 | +- Define proper types (avoid `any`) |
| 198 | +- Use interfaces for object shapes |
| 199 | + |
| 200 | +### React |
| 201 | + |
| 202 | +- Functional components only |
| 203 | +- Use hooks for state and effects |
| 204 | +- Memoize expensive computations |
| 205 | +- Keep components focused and small |
| 206 | + |
| 207 | +### Tailwind CSS |
| 208 | + |
| 209 | +- Use design tokens, not arbitrary values |
| 210 | +- Group related classes logically |
| 211 | +- Use `cn()` utility for conditional classes |
| 212 | + |
| 213 | +```tsx |
| 214 | +import { cn } from "@/lib/utils"; |
| 215 | + |
| 216 | +<div className={cn( |
| 217 | + "base-classes", |
| 218 | + condition && "conditional-classes" |
| 219 | +)} /> |
| 220 | +``` |
| 221 | + |
| 222 | +### File Naming |
| 223 | + |
| 224 | +- Components: `PascalCase.tsx` |
| 225 | +- Hooks: `useCamelCase.ts` |
| 226 | +- Utilities: `camelCase.ts` |
| 227 | +- Types: `types.ts` or inline |
| 228 | + |
| 229 | +## 💬 Commit Messages |
| 230 | + |
| 231 | +Follow conventional commits: |
| 232 | + |
| 233 | +``` |
| 234 | +type(scope): description |
| 235 | +
|
| 236 | +[optional body] |
| 237 | +``` |
| 238 | + |
| 239 | +### Types |
| 240 | + |
| 241 | +- `feat`: New feature |
| 242 | +- `fix`: Bug fix |
| 243 | +- `docs`: Documentation |
| 244 | +- `style`: Formatting (not CSS) |
| 245 | +- `refactor`: Code restructuring |
| 246 | +- `perf`: Performance improvement |
| 247 | +- `test`: Adding tests |
| 248 | +- `chore`: Maintenance |
| 249 | + |
| 250 | +### Examples |
| 251 | + |
| 252 | +``` |
| 253 | +feat(properties): add CSS anchor positioning properties |
| 254 | +fix(search): handle special characters in search query |
| 255 | +docs(readme): update installation instructions |
| 256 | +perf(cards): implement virtual scrolling for large lists |
| 257 | +``` |
| 258 | + |
| 259 | +## 🔄 Pull Request Process |
| 260 | + |
| 261 | +1. **Update your branch** with the latest main: |
| 262 | + ```bash |
| 263 | + git fetch origin |
| 264 | + git rebase origin/main |
| 265 | + ``` |
| 266 | + |
| 267 | +2. **Run checks** before submitting: |
| 268 | + ```bash |
| 269 | + npm run lint |
| 270 | + npm run build |
| 271 | + ``` |
| 272 | + |
| 273 | +3. **Create the PR** with: |
| 274 | + - Clear title following commit conventions |
| 275 | + - Description of changes |
| 276 | + - Screenshots for UI changes |
| 277 | + - Link to related issues |
| 278 | + |
| 279 | +4. **Address feedback** promptly and push updates |
| 280 | + |
| 281 | +5. **Merge** will be done by maintainers after approval |
| 282 | + |
| 283 | +## ❓ Questions? |
| 284 | + |
| 285 | +- Open an issue for general questions |
| 286 | +- Check existing issues and discussions first |
| 287 | + |
| 288 | +--- |
| 289 | + |
| 290 | +Thank you for contributing! Every contribution, no matter how small, makes this project better. 🎉 |
0 commit comments