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
+39-14Lines changed: 39 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,9 @@
1
1
# PatternFly React Component Groups
2
-
2
+
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,31 @@ 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
25
+
### AI-assisted development guidelines
26
+
27
+
Please reference [PatternFly's AI-assisted development guidelines](https://github.com/patternfly/.github/blob/main/CONTRIBUTING.md) if you'd like to contribute code generated using AI.
28
+
22
29
### Before adding a new component:
30
+
23
31
- make sure your use case is new/complex enough to be added to this extension
24
32
- the component should bring a value value above and beyond existing PatternFly components
25
33
26
34
### To add a new component:
35
+
27
36
1. create a folder in `src/` matching its name (for example `src/MyComponent`)
28
37
2. to the new folder add a new `.tsx` file named after the component (for example `src/MyComponent/MyComponent.tsx`)
29
38
3. to the same folder include an `index.ts` which will export the component as a default and then all necessary interfaces
30
39
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
96
- it is built on top of existing PatternFly types without prop omitting
83
97
- 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
98
- 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
99
86
100
#### Component API definition example:
101
+
87
102
```
103
+
104
+
import { FunctionComponent } from 'react';
105
+
88
106
// when possible, extend available PatternFly types
When adding a component for which it is advantageous to divide it into several sub-components make sure:
149
+
150
+
When adding a component for which it is advantageous to divide it into several sub-components make sure:
151
+
131
152
- component and all its sub-components are located in separate files and directories straight under the `src/` folder
132
153
- sub-components are exported and documented separately from their parent
133
154
- parent component should provide a way to pass props to all its sub-components
134
155
135
156
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
157
137
158
### Testing:
159
+
138
160
When adding/making changes to a component, always make sure your code is tested:
139
-
- use React Testing Library for unit testing
161
+
162
+
- use React Testing Library for unit testing
140
163
- add unit tests to a `[ComponentName].test.tsx` file to your component's directory
141
164
- make sure all the core functionality is covered using Cypress component or E2E tests
142
165
- add component tests to `cypress/component/[ComponentName].cy.tsx` file and E2E tests to `cypress/e2e/[ComponentName].spec.cy.ts`
143
166
- 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
167
145
168
### Styling:
169
+
146
170
- for styling always use JSS
147
171
- 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
172
- 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 +177,12 @@ When adding/making changes to a component, always make sure your code is tested:
153
177
- run `npm run build`
154
178
155
179
## Development
180
+
156
181
- run `npm install`
157
182
- run `npm run start` to build and start the development server
158
183
159
184
## Testing and Linting
185
+
160
186
- run `npm run test` to run the unit tests
161
187
- run `npm run cypress:run:cp` to run Cypress component tests
162
188
- run `npm run cypress:run:e2e` to run Cypress E2E tests
@@ -165,4 +191,3 @@ When adding/making changes to a component, always make sure your code is tested:
165
191
## A11y testing
166
192
167
193
- 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