|
| 1 | +# Contributing to Toast |
| 2 | + |
| 3 | +Thank you for your interest in contributing to Toast! This guide will help you get started with contributing to the project. |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +- [Development Setup](#development-setup) |
| 8 | +- [Development Workflow](#development-workflow) |
| 9 | +- [Testing](#testing) |
| 10 | +- [Code Style](#code-style) |
| 11 | +- [Submitting Changes](#submitting-changes) |
| 12 | +- [Reporting Issues](#reporting-issues) |
| 13 | +- [Feature Requests](#feature-requests) |
| 14 | + |
| 15 | +## Development Setup |
| 16 | + |
| 17 | +1. **Fork and clone the repository** |
| 18 | + ```bash |
| 19 | + git clone https://github.com/YOUR_USERNAME/toast.git |
| 20 | + cd toast |
| 21 | + ``` |
| 22 | + |
| 23 | +2. **Install dependencies** |
| 24 | + ```bash |
| 25 | + mix deps.get |
| 26 | + ``` |
| 27 | + |
| 28 | +3. **Set up the demo application** |
| 29 | + ```bash |
| 30 | + cd demo |
| 31 | + mix setup |
| 32 | + ``` |
| 33 | + |
| 34 | +## Development Workflow |
| 35 | + |
| 36 | +Toast includes a demo application in the `demo/` directory that makes development easier. We've created Mix tasks to streamline the development process: |
| 37 | + |
| 38 | +### Working with Local Changes |
| 39 | + |
| 40 | +1. **Switch to local development mode** |
| 41 | + ```bash |
| 42 | + cd demo |
| 43 | + mix mode.local |
| 44 | + ``` |
| 45 | + This creates a symlink from `demo/deps/toast` to your local toast project, allowing you to see changes immediately. |
| 46 | + |
| 47 | +2. **Check current mode** |
| 48 | + ```bash |
| 49 | + mix mode |
| 50 | + ``` |
| 51 | + This shows whether you're using the local version or the published Hex package. |
| 52 | + |
| 53 | +3. **Switch to published mode** |
| 54 | + ```bash |
| 55 | + mix mode.published |
| 56 | + ``` |
| 57 | + This uses the published Hex package, useful for testing the actual release. |
| 58 | + |
| 59 | +### Running the Demo |
| 60 | + |
| 61 | +```bash |
| 62 | +cd demo |
| 63 | +mix phx.server |
| 64 | +``` |
| 65 | + |
| 66 | +Visit [`localhost:4000`](http://localhost:4000) to see the demo application with live examples of toast notifications. |
| 67 | + |
| 68 | +## Testing |
| 69 | + |
| 70 | +### Running Tests |
| 71 | + |
| 72 | +```bash |
| 73 | +# Run tests in the main project |
| 74 | +mix test |
| 75 | + |
| 76 | +# Run tests in the demo |
| 77 | +cd demo && mix test |
| 78 | +``` |
| 79 | + |
| 80 | +### Testing Your Changes |
| 81 | + |
| 82 | +1. Make your changes to the toast library |
| 83 | +2. Ensure you're in local mode (`mix mode.local` in the demo directory) |
| 84 | +3. Test your changes in the demo application |
| 85 | +4. Write or update tests as needed |
| 86 | + |
| 87 | +## Code Style |
| 88 | + |
| 89 | +- Follow standard Elixir conventions |
| 90 | +- Run the formatter before committing: `mix format` |
| 91 | +- Write descriptive commit messages |
| 92 | + |
| 93 | +### JavaScript Code |
| 94 | + |
| 95 | +- The JavaScript hook is in `assets/js/toast.js` |
| 96 | +- Follow existing code patterns and style |
| 97 | + |
| 98 | +### CSS Styles |
| 99 | + |
| 100 | +- Styles are in `assets/css/toast.css` |
| 101 | + |
| 102 | +## Submitting Changes |
| 103 | + |
| 104 | +1. **Create a feature branch from `dev`** |
| 105 | + ```bash |
| 106 | + git checkout dev |
| 107 | + git pull origin dev |
| 108 | + git checkout -b feature/your-feature-name |
| 109 | + ``` |
| 110 | + |
| 111 | +2. **Make your changes** |
| 112 | + - Write clear, focused commits |
| 113 | + - Include tests for new functionality |
| 114 | + - Update documentation as needed |
| 115 | + |
| 116 | +3. **Ensure all tests pass** |
| 117 | + ```bash |
| 118 | + mix test |
| 119 | + mix format --check-formatted |
| 120 | + ``` |
| 121 | + |
| 122 | +4. **Push your branch and create a pull request** |
| 123 | + - **IMPORTANT: Target the `dev` branch, not `main`** |
| 124 | + - Provide a clear description of your changes |
| 125 | + - Reference any related issues |
| 126 | + - Include screenshots for UI changes |
| 127 | + |
| 128 | +### Pull Request Guidelines |
| 129 | + |
| 130 | +- **Target Branch**: All PRs should target the `dev` branch |
| 131 | +- **Title**: Use a clear, descriptive title |
| 132 | +- **Description**: Explain what changes you made and why |
| 133 | +- **Testing**: Describe how you tested your changes |
| 134 | +- **Breaking Changes**: Clearly note any breaking changes |
| 135 | + |
| 136 | +## Reporting Issues |
| 137 | + |
| 138 | +When reporting issues, please include: |
| 139 | + |
| 140 | +- Elixir/Erlang versions (`elixir --version`) |
| 141 | +- Phoenix version |
| 142 | +- LiveView version |
| 143 | +- Steps to reproduce the issue |
| 144 | +- Expected behavior |
| 145 | +- Actual behavior |
| 146 | +- Any error messages or logs |
| 147 | + |
| 148 | +## Feature Requests |
| 149 | + |
| 150 | +We welcome feature requests! Please: |
| 151 | + |
| 152 | +- Check existing issues to avoid duplicates |
| 153 | +- Provide a clear use case |
| 154 | +- Explain why the feature would be valuable |
| 155 | +- If possible, suggest an implementation approach |
| 156 | + |
| 157 | +## Publishing (Maintainers Only) |
| 158 | + |
| 159 | +When ready to publish a new version: |
| 160 | + |
| 161 | +1. Update the version in `mix.exs` |
| 162 | +2. Update the CHANGELOG.md |
| 163 | +3. From the demo directory, run: |
| 164 | + ```bash |
| 165 | + cd demo |
| 166 | + mix toast_publish |
| 167 | + ``` |
| 168 | + This automatically switches the demo to use the published version before publishing. |
| 169 | + |
| 170 | +## Questions? |
| 171 | + |
| 172 | +Feel free to open an issue for any questions about contributing. We're here to help! |
| 173 | + |
| 174 | +Thank you for contributing to Toast! 🍞 |
0 commit comments