UNPKG

3.9 kBMarkdownView Raw
1---
2id: Contributing
3section: root
4hideTOC: true
5---
6
7# Contributing to @patternfly/react-core
8
9## Adding a new component
10
111. Check for open issues that are not assigned to anyone, and assign yourself. If you do not see an issue for the component you want to contribute open an issue and assign yourself. Assigning yourself will ensure that others do not begin working on the component you currently have in progress.
122. Generate the component scaffolding by running `yarn generate`. This will generate a structure that resembles the following
13 ```text
14 packages/react-core/src/[type]/[ComponentName]/
15 index.js - Barrel File exporting public exports
16 ComponentName.js - Component Implementation
17 ComponentName.test.js - Component Tests
18 ComponentName.md - Component Docs
19 examples/ - dir for all examples
20 SimpleComponentName.js - Simple Example
21 ```
223. Write the component implementation in `[Component].js`.
234. Add jest tests to `[Component].test.js`. All new components must be tested.
245. Add any additional public exports to `index.js`
256. Update the generated `[ComponentName].md.` See how to create [component docs.](../react-core/README.md)
267. Add integration tests to the demo-app found [here](../react-integration)
27
28## Code contribution guidelines
29
30Adhering to the following process is the best way to get your work included in the project:
31
321. [Fork](https://help.github.com/fork-a-repo/) the project, clone your fork, and configure the remotes:
33
34```bash
35# Clone your fork of the repo into the current directory
36git clone https://github.com/<your-username>/patternfly-react.git
37# Navigate to the newly cloned directory
38cd patternfly-react
39# Assign the original repo to a remote called "upstream"
40git remote add upstream https://github.com/patternfly/patternfly-react.git
41```
42
432. Create a branch:
44
45```text
46$ git checkout -b my-branch -t upstream/main
47```
48
493. Generate your component
50
51```bash
52# Run the tool to Generate the component scaffolding
53 yarn generate
54```
55
56- When you select the option to generate a PatternFly 4 component, a structure resembling the following is generated
57 ```text
58 packages/react-core/src/[type]/[ComponentName]/
59 index.js - Barrel File exporting public exports
60 ComponentName.js - Component Implementation
61 ComponentName.test.js - Component Tests
62 ComponentName.md - Component Docs
63 ```
64
654. Develop your component. After development is complete, ensure tests and lint standards pass.
66
67```text
68$ yarn test
69```
70
71Ensure no lint errors are introduced in `yarn-error.log` after running this command.
72
735. Add a commit using `yarn commit`:
74
75This project uses [`lerna`](https://lernajs.io/) to do automatic releases and generate a changelog based on the commit history. So we follow [a convention][3] for commit messages. Please follow this convention for your commit messages.
76
77You can use `commitizen` to help you to follow [the convention][3].
78
79Once you are ready to commit the changes, please use the below commands:
80
81```text
82$ git add <files to be committed>
83$ yarn commit
84```
85
86... and follow the instruction of the interactive prompt.
87
886. Rebase
89
90Use `git rebase` (not `git merge`) to sync your work from time to time. Ensure all commits related to a single issue have been [squashed](https://github.com/ginatrapani/todo.txt-android/wiki/Squash-All-Commits-Related-to-a-Single-Issue-into-a-Single-Commit).
91
92```text
93$ git fetch upstream
94$ git rebase upstream/main
95```
96
977. Push
98
99```text
100$ git push origin my-branch
101```
102
1038. Create a pull request
104
105 - A link to the PatternFly 4 demo documentation will be automatically generated and posted as a comment after the pull request build is complete.
106
107## Additional information
108
109See the PatternFly React Guide for full details on [Code Contribution Guidelines](https://github.com/patternfly/patternfly-react/blob/main/CONTRIBUTING.md#code-contribution-guidelines)