-
-
Notifications
You must be signed in to change notification settings - Fork 26
docs: create react.md #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
digiwand
wants to merge
11
commits into
main
Choose a base branch
from
doc-react-components
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5a29256
doc: add react.md
digiwand 6ab3a39
docs: update "Contributing to React Components"
digiwand cccda45
Merge branch 'main' into doc-react-components
HowardBraham 9168601
docs: update "Contributing to React Components" -> "React Guidelines"
digiwand 589657f
doc: React Guidelines - "Please refer to the respective repository"
digiwand b7fd763
doc: add React Guidelines to README.md
digiwand 86a92d6
doc: React Guidelines add "Avoid unnecessary rerenders" examples
digiwand b279ef6
fix:lint: react.md EOL / line updates
digiwand d5910c9
fix:lint: yarn fix:lint - react.md bulletpoint /s
digiwand bc41f20
react.md: add design-tokens w/ link
digiwand a269d93
react.md: update Storybook guide
digiwand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# React Guidelines | ||
|
||
## Purpose | ||
|
||
This document provides guidelines for contributing new components or updating existing components in our React codebases. | ||
|
||
## Guidelines for React Components | ||
|
||
The following guidelines are not strictly required, but are considered best practices that contribute to higher quality components. Not all guidelines will be applicable depending on the specific React repository's support. Please refer to the respective repository for additional guidelines and further details. | ||
|
||
If certain requirements cannot be met due to time constraints, legacy code, or other factors, contributors should use their best judgement on which requirements are most important or feasible to implement. | ||
|
||
### Component Structure | ||
|
||
- Follow consistent file structure | ||
- Use functional components with hooks instead of class components | ||
- Separate container and presentational components when appropriate | ||
- Avoid large, complex components - break into reusable pieces | ||
|
||
### Component User Interface Features (If applicable) | ||
|
||
- Accessibility (A11y) | ||
- Dark-mode | ||
- Dynamic text length | ||
- Internationalization (i18n) translations including right-to-left languages | ||
- Responsive UI/UX (support mobile, fullscreen, and pop-up views) | ||
- Use of [design tokens](https://github.com/MetaMask/design-tokens) for color and typography to ensure brand consistency and uphold accessibility standards | ||
|
||
### Code Quality | ||
|
||
- Prefer TypeScript for static typing | ||
- Follow linting rules and formatting guidelines | ||
- Name props and state values descriptively | ||
- Extract reusable logic into custom hooks | ||
- Avoid unnecessary rerenders | ||
- Examples: | ||
- Blog: [5 Ways to Optimize Your Functional React Components | ||
](https://javascript.plainenglish.io/5-ways-to-optimize-your-functional-react-components-cb3cf6c7bd68) | ||
- React Doc: https://react.dev/learn/render-and-commit#optimizing-performance | ||
|
||
### Testing | ||
|
||
- Strive for full test coverage | ||
- Write unit tests | ||
- Write e2e tests (If applicable) | ||
|
||
### Documentation | ||
|
||
- Implement Storybook for interactive documentation of UI components (If applicable). Storybook serves as a powerful tool for showcasing components in isolation, allowing developers and designers to interact with, test, and explore components in various states. This interactive environment not only enhances understanding and collaboration but also significantly streamlines future UI iterations. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.