You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-13
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,7 @@
3
3
This repo contains a set of opinionated react component groups used to standardize functionality and look and feel across products. The components are based on PatternFly with some additional functionality.
4
4
5
5
### Branches
6
+
6
7
`main` - PatternFly 6 implementation
7
8
8
9
`v5` - PatternFly 5 implementation
@@ -14,22 +15,27 @@ This repo contains a set of opinionated react component groups used to standardi
14
15
---
15
16
16
17
### Migration from [RedHatInsights/frontend-components](https://github.com/RedHatInsights/frontend-components) to [patternfly/react-component-groups](https://github.com/patternfly/react-component-groups)
18
+
17
19
Please see the [migration guide](./migration.md)
18
20
19
21
---
22
+
20
23
## Contribution guide
21
24
22
25
### Before adding a new component:
26
+
23
27
- make sure your use case is new/complex enough to be added to this extension
24
28
- the component should bring a value value above and beyond existing PatternFly components
25
29
26
30
### To add a new component:
31
+
27
32
1. create a folder in `src/` matching its name (for example `src/MyComponent`)
28
33
2. to the new folder add a new `.tsx` file named after the component (for example `src/MyComponent/MyComponent.tsx`)
29
34
3. to the same folder include an `index.ts` which will export the component as a default and then all necessary interfaces
30
35
4. if this file structure is not met, your component won't be exposed correctly
- the API is maximally simplified and all props are provided with a description
82
92
- it is built on top of existing PatternFly types without prop omitting
83
93
- it is well documented using the PatternFly documentation (`/packages/module/patternfly-docs/content/extensions/component-groups/examples/MyComponent/MyComponent.md`) with examples of all possible use cases (`packages/module/patternfly-docs/content/extensions/component-groups/examples/MyComponent/MyComponent[...]Example.tsx`)
84
94
- do not unnecessarily use external libraries in your component - rather, delegate the necessary logic to the component's user using the component's API
85
95
86
96
#### Component API definition example:
97
+
87
98
```
99
+
100
+
import { FunctionComponent } from 'react';
101
+
88
102
// when possible, extend available PatternFly types
When adding a component for which it is advantageous to divide it into several sub-components make sure:
145
+
146
+
When adding a component for which it is advantageous to divide it into several sub-components make sure:
147
+
131
148
- component and all its sub-components are located in separate files and directories straight under the `src/` folder
132
149
- sub-components are exported and documented separately from their parent
133
150
- parent component should provide a way to pass props to all its sub-components
134
151
135
152
The aim is to enable the user of our "complex" component to use either complete or take advantage of its sub-components and manage their composition independently.
136
153
137
154
### Testing:
155
+
138
156
When adding/making changes to a component, always make sure your code is tested:
139
-
- use React Testing Library for unit testing
157
+
158
+
- use React Testing Library for unit testing
140
159
- add unit tests to a `[ComponentName].test.tsx` file to your component's directory
141
160
- make sure all the core functionality is covered using Cypress component or E2E tests
142
161
- add component tests to `cypress/component/[ComponentName].cy.tsx` file and E2E tests to `cypress/e2e/[ComponentName].spec.cy.ts`
143
162
- add `ouiaId` to the component props definition with a default value of the component name (for subcomponents, let's use `ComponentName-element-specification` naming convention e.g. `ouiaId="WarningModal-confirm-button"`)
144
163
145
164
### Styling:
165
+
146
166
- for styling always use JSS
147
167
- new classNames should be named in camelCase starting with the name of a given component and following with more details clarifying its purpose/component's subsection to which the class is applied (`actionMenu`, `actionMenuDropdown`, `actionMenuDropdownToggle`, etc.)
148
168
- do not use `pf-v6-u-XXX` classes, use CSS variables in a custom class instead (styles for the utility classes are not bundled with the standard patternfly.css - it would require the consumer to import also addons.css)
@@ -153,10 +173,12 @@ When adding/making changes to a component, always make sure your code is tested:
153
173
- run `npm run build`
154
174
155
175
## Development
176
+
156
177
- run `npm install`
157
178
- run `npm run start` to build and start the development server
158
179
159
180
## Testing and Linting
181
+
160
182
- run `npm run test` to run the unit tests
161
183
- run `npm run cypress:run:cp` to run Cypress component tests
162
184
- run `npm run cypress:run:e2e` to run Cypress E2E tests
@@ -165,4 +187,3 @@ When adding/making changes to a component, always make sure your code is tested:
165
187
## A11y testing
166
188
167
189
- run `npm run build:docs` followed by `npm run serve:docs`, then run `npm run test:a11y` in a new terminal window to run our accessibility tests for the components. Once the accessibility tests have finished running you can run `npm run serve:a11y` to locally view the generated report.
0 commit comments