You've already forked gpui-component
mirror of
https://github.com/librekeys/gpui-component.git
synced 2026-04-14 08:46:29 -07:00
79 lines
2.9 KiB
Markdown
79 lines
2.9 KiB
Markdown
# Contributing Guide
|
|
|
|
Contributions are welcome, if you find some bugs or have some ideas, please open an issue or submit a pull request.
|
|
|
|
Please ensure that you are using clean code, following the coding style and code organization in existing code, and make sure all the tests pass.
|
|
|
|
Please submit **one PR that does one thing**, this is important, and helps us to review your code more easily and push to merge fast.
|
|
|
|
## AI Assistance
|
|
|
|
> 🤖 When you submit PR, please point out which parts are generated by AI, if any.
|
|
|
|
All code generated by AI must be reviewed and tested by humans, and should follow the same coding style and code organization as existing code.
|
|
|
|
The AI generated code without refactoring will be rejected.
|
|
|
|
## Code Style
|
|
|
|
Before you start to write code, please read the existing code to follow the same coding style and code organization.
|
|
|
|
- Inspired by existing code or refer to macOS/Windows controls API design to name your functions, properties, structs etc.
|
|
|
|
## Development and Testing
|
|
|
|
There are a lot of UI test cases in the `crates/story` folder, if you change the existing features you can run the tests to make sure they are working.
|
|
|
|
### Run story
|
|
|
|
Use `cargo run` to run the complete story examples to display them all in a gallery of GPUI components.
|
|
|
|
```bash
|
|
cargo run
|
|
```
|
|
|
|
### Run single example
|
|
|
|
There is also available some split examples, run `cargo run --example` to see the available examples.
|
|
|
|
```bash
|
|
cargo run --example table
|
|
```
|
|
|
|
## UI Guides
|
|
|
|
GPUI Component is inspired by macOS and Windows controls, combined with shadcn/ui design for a modern experience.
|
|
|
|
So please refer to the following UI guides when you design or change the UI components:
|
|
|
|
- [Apple Human Interface Guidelines](https://developer.apple.com/design/human-interface-guidelines/)
|
|
- [Microsoft Fluent Design System](https://learn.microsoft.com/en-us/windows/apps/design/)
|
|
- [shadcn/ui](https://ui.shadcn.com/)
|
|
|
|
### Rules
|
|
|
|
- Use `default` mouse cursor not `pointer` for buttons, unless it's a link button, we are building desktop apps, not web apps.
|
|
- Use `md` size for most cases and as the default.
|
|
|
|
## Profile the performance
|
|
|
|
When you change the rendering code, please profile the performance to make sure the FPS is still good.
|
|
|
|
You can use `MTL_HUD_ENABLED=1` environment variable to enable the Metal HUD to see the FPS and other performance metrics.
|
|
|
|
```bash
|
|
MTL_HUD_ENABLED=1 cargo run
|
|
```
|
|
|
|
> NOTE: Only available on macOS with Metal backend, and the FPS is up **limited your monitor refresh rate**, usually 60 or 120.
|
|
|
|
### Use Samply to profile the the performance
|
|
|
|
You can use [Samply](https://github.com/mstange/samply) to profile the performance of the application to get more detailed information.
|
|
|
|
```bash
|
|
samply record cargo run
|
|
```
|
|
|
|
Use `samply record` command to start rust development, and do some operations in the app that you want to profile, then stop the terminal with `ctrl-c`, then samply will open the browser to show the profile results.
|