|
| 1 | +# Contributing to Calendar Heatmap Card |
| 2 | + |
| 3 | +Thank you for your interest in contributing to the Calendar Heatmap Card! This document provides guidelines and instructions for contributing. |
| 4 | + |
| 5 | +## Code Architecture |
| 6 | + |
| 7 | +The Calendar Heatmap Card uses a fully LitElement-based architecture: |
| 8 | + |
| 9 | +1. **Main Component**: `CalendarHeatmapCard` - Manages the overall card lifecycle and data fetching |
| 10 | +2. **UI Components**: |
| 11 | + - `HeatmapGrid` - Renders the heatmap grid cells |
| 12 | + - `DayLabels` - Renders the day labels |
| 13 | + - `MonthHeader` - Renders the month header |
| 14 | + - `DetailView` - Renders the detail view |
| 15 | + |
| 16 | +All components use LitElement for consistent reactivity and templating. |
| 17 | + |
| 18 | +## Development Setup |
| 19 | + |
| 20 | +1. Clone the repository: |
| 21 | + ```bash |
| 22 | + git clone https://github.com/MagicMicky/lovelace-calendar-heatmap-card.git |
| 23 | + cd lovelace-calendar-heatmap-card |
| 24 | + ``` |
| 25 | + |
| 26 | +2. Install dependencies: |
| 27 | + ```bash |
| 28 | + npm install |
| 29 | + ``` |
| 30 | + |
| 31 | +3. Start development server: |
| 32 | + ```bash |
| 33 | + npm run build:watch |
| 34 | + ``` |
| 35 | + |
| 36 | +4. Link the development version to your Home Assistant instance for testing. |
| 37 | + |
| 38 | +## Dependency Management |
| 39 | + |
| 40 | +- **lit**: Used for all components (LitElement) |
| 41 | + |
| 42 | +When adding new dependencies, please consider: |
| 43 | +- Is it necessary? |
| 44 | +- Could it be implemented without the dependency? |
| 45 | +- What's the impact on bundle size? |
| 46 | + |
| 47 | +## Code Style |
| 48 | + |
| 49 | +We use ESLint and Prettier to maintain code quality and consistency: |
| 50 | + |
| 51 | +```bash |
| 52 | +# Run linting |
| 53 | +npm run lint |
| 54 | + |
| 55 | +# Fix linting issues |
| 56 | +npm run lint:fix |
| 57 | +``` |
| 58 | + |
| 59 | +## Pull Request Process |
| 60 | + |
| 61 | +1. Fork the repository and create a feature branch |
| 62 | +2. Make your changes |
| 63 | +3. Ensure your code passes linting |
| 64 | +4. Update documentation if necessary |
| 65 | +5. Submit a pull request |
| 66 | + |
| 67 | +## Component Guidelines |
| 68 | + |
| 69 | +### LitElement Components |
| 70 | + |
| 71 | +- Use LitElement's reactive properties system |
| 72 | +- Use lit-html for templating in the render method |
| 73 | +- Follow the established component pattern |
| 74 | +- Document properties and methods |
| 75 | +- Use CSS custom properties for theming |
| 76 | + |
| 77 | +### Event Handling |
| 78 | + |
| 79 | +- Use custom events for component communication |
| 80 | +- Document event details |
| 81 | +- Ensure events bubble and compose correctly |
| 82 | + |
| 83 | +### Services |
| 84 | + |
| 85 | +- Document the API interactions |
| 86 | +- Handle errors gracefully |
| 87 | +- Provide meaningful console messages for debugging |
| 88 | + |
| 89 | +## Testing |
| 90 | + |
| 91 | +We use Jest for testing: |
| 92 | + |
| 93 | +```bash |
| 94 | +npm test |
| 95 | +``` |
| 96 | + |
| 97 | +Please add tests for new features when possible. |
| 98 | + |
| 99 | +## Documentation |
| 100 | + |
| 101 | +Update the README.md file if you add new features or configuration options. |
| 102 | + |
| 103 | +## License |
| 104 | + |
| 105 | +By contributing, you agree that your contributions will be licensed under the project's MIT License. |
0 commit comments