-
Notifications
You must be signed in to change notification settings - Fork 30
feat(severity): Convert Battery to Severity Component #365
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
Merged
Merged
Changes from all commits
Commits
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,27 @@ | ||
| import React from 'react'; | ||
| import Severity, { SeverityType } from '../../packages/module/dist/dynamic/Severity'; | ||
|
|
||
| const severities = [ | ||
| { type: SeverityType.critical, label: 'Critical severity', ouiaId: 'Severity-critical' }, | ||
| { type: SeverityType.important, label: 'Important severity', ouiaId: 'Severity-important' }, | ||
| { type: SeverityType.moderate, label: 'Moderate severity', ouiaId: 'Severity-moderate' }, | ||
| { type: SeverityType.minor, label: 'Minor severity', ouiaId: 'Severity-minor' }, | ||
| { type: SeverityType.none, label: 'No severity', ouiaId: 'Severity-none' }, | ||
| { type: SeverityType.undefined, label: 'Undefined severity', ouiaId: 'Severity-undefined' } | ||
| ]; | ||
|
|
||
| describe('Severity', () => { | ||
| severities.map(({ type, label, ouiaId }) => { | ||
| it(`renders Severity with ${type} severity`, () => { | ||
| cy.mount(<Severity severity={type} label={label} ouiaId={ouiaId} />); | ||
| cy.get(`[data-ouia-component-id="${ouiaId}"]`).should('exist'); | ||
| cy.get(`[data-ouia-component-id="${ouiaId}"]`).should('have.attr', 'title', label); | ||
| cy.get('span').contains(label); | ||
| }); | ||
| }); | ||
|
|
||
| it('hides label when labelHidden is true', () => { | ||
| cy.mount(<Severity severity={SeverityType.important} label="Important severity" labelHidden />); | ||
| cy.contains('Important severity').should('not.exist'); | ||
| }); | ||
| }); |
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
72 changes: 0 additions & 72 deletions
72
...patternfly-docs/content/extensions/component-groups/examples/Battery/Battery.md
This file was deleted.
Oops, something went wrong.
8 changes: 0 additions & 8 deletions
8
...nfly-docs/content/extensions/component-groups/examples/Battery/BatteryCriticalExample.tsx
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...rnfly-docs/content/extensions/component-groups/examples/Battery/BatteryDefaultExample.tsx
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
...tternfly-docs/content/extensions/component-groups/examples/Battery/BatteryHighExample.tsx
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...atternfly-docs/content/extensions/component-groups/examples/Battery/BatteryLowExample.tsx
This file was deleted.
Oops, something went wrong.
4 changes: 0 additions & 4 deletions
4
...ernfly-docs/content/extensions/component-groups/examples/Battery/BatteryMediumExample.tsx
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
...tternfly-docs/content/extensions/component-groups/examples/Severity/Severity.md
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,79 @@ | ||
| --- | ||
| # Sidenav top-level section | ||
| # should be the same for all markdown files | ||
| section: Component groups | ||
| subsection: Status and state indicators | ||
| # Sidenav secondary level section | ||
| # should be the same for all markdown files | ||
| id: Severity | ||
| # Tab (react | react-demos | html | html-demos | design-guidelines | accessibility) | ||
| source: react | ||
| # If you use typescript, the name of the interface to display props for | ||
| # These are found through the sourceProps function provided in patternfly-docs.source.js | ||
| propComponents: ['Severity'] | ||
| sourceLink: https://github.com/patternfly/react-component-groups/blob/main/packages/module/patternfly-docs/content/extensions/component-groups/examples/Severity/Severity.md | ||
| --- | ||
|
|
||
| import Severity, { SeverityType } from '@patternfly/react-component-groups/dist/dynamic/Severity'; | ||
|
|
||
| The **severity** component generates an icon with an optional label, which corresponds to a level `minor`, `moderate`, `important` or `critical`. Each level corresponds with a severity level and respective color: | ||
|
|
||
| | Severity level | Meaning | Style | | ||
| | --- | --- | --- | | ||
| | Level 1 | Minor severity (best case scenario) | Dark grey icon | | ||
| | Level 2 | Moderate severity | Yellow icon | | ||
| | Level 3 | Important severity | Orange icon | | ||
| | Level 4 | Critical severity (worst case scenario) | Red icon | | ||
|
|
||
| To specify the severity risk level, you can pass a predefined enum or text value into the `severity` property that corresponds to the appropriate severity level. | ||
|
|
||
| To add an optional label, add the `label` property to the `<Severity>` component. | ||
|
|
||
| ## Examples | ||
|
|
||
| ### Undefined variant | ||
|
|
||
| The default style for the severity component appears when any value besides "none", "low", "medium", "high", or "critical" is passed to `Severity`. | ||
|
|
||
| ```js file="./SeverityUndefinedExample.tsx" | ||
|
|
||
| ``` | ||
| ### None severity | ||
|
|
||
| To style no severity, pass "none" or `SeverityType.none` to `severity`. | ||
|
|
||
| ```js file="./SeverityNoneExample.tsx" | ||
|
|
||
| ``` | ||
|
|
||
| ### Minor severity | ||
|
|
||
| To style a minor severity, pass "minor" or `SeverityType.minor` to `severity`. | ||
|
|
||
| ```js file="./SeverityMinorExample.tsx" | ||
|
|
||
| ``` | ||
|
|
||
| ### Moderate severity | ||
|
|
||
| To style a moderate severity, pass "moderate", or `SeverityType.moderate` to `severity`. | ||
|
|
||
| ```js file="./SeverityModerateExample.tsx" | ||
|
|
||
| ``` | ||
|
|
||
| ### Important severity | ||
|
|
||
| To style an important severity, pass "important", or `SeverityType.important` to `severity`. | ||
|
|
||
| ```js file="./SeverityImportantExample.tsx" | ||
|
|
||
| ``` | ||
|
|
||
| ### Critical severity | ||
|
|
||
| To style a critical severity, pass "critical" or `SeverityType.critical` to `severity`. | ||
|
|
||
| ```js file="./SeverityCriticalExample.tsx" | ||
|
|
||
| ``` |
8 changes: 8 additions & 0 deletions
8
...ly-docs/content/extensions/component-groups/examples/Severity/SeverityCriticalExample.tsx
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,8 @@ | ||
| import React from 'react'; | ||
| import Severity, { SeverityType } from '@patternfly/react-component-groups/dist/dynamic/Severity'; | ||
|
|
||
| export const BasicExample: React.FunctionComponent = () => ( | ||
|
|
||
| <Severity severity={SeverityType.critical} label="Critical" /> | ||
|
|
||
| ); | ||
6 changes: 6 additions & 0 deletions
6
...y-docs/content/extensions/component-groups/examples/Severity/SeverityImportantExample.tsx
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,6 @@ | ||
| import React from 'react'; | ||
| import Severity, { SeverityType } from '@patternfly/react-component-groups/dist/dynamic/Severity'; | ||
|
|
||
| export const BasicExample: React.FunctionComponent = () => ( | ||
| <Severity severity={SeverityType.important} label="Important" /> | ||
| ); |
4 changes: 4 additions & 0 deletions
4
...rnfly-docs/content/extensions/component-groups/examples/Severity/SeverityMinorExample.tsx
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,4 @@ | ||
| import React from 'react'; | ||
| import Severity, { SeverityType } from '@patternfly/react-component-groups/dist/dynamic/Severity'; | ||
|
|
||
| export const BasicExample: React.FunctionComponent = () => <Severity severity={SeverityType.minor} label="Minor" />; |
4 changes: 4 additions & 0 deletions
4
...ly-docs/content/extensions/component-groups/examples/Severity/SeverityModerateExample.tsx
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,4 @@ | ||
| import React from 'react'; | ||
| import Severity, { SeverityType } from '@patternfly/react-component-groups/dist/dynamic/Severity'; | ||
|
|
||
| export const BasicExample: React.FunctionComponent = () => <Severity severity={SeverityType.moderate} label="Moderate" />; |
4 changes: 4 additions & 0 deletions
4
...ernfly-docs/content/extensions/component-groups/examples/Severity/SeverityNoneExample.tsx
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,4 @@ | ||
| import React from 'react'; | ||
| import Severity, { SeverityType } from '@patternfly/react-component-groups/dist/dynamic/Severity'; | ||
|
|
||
| export const BasicExample: React.FunctionComponent = () => <Severity severity={SeverityType.none} label="None" />; |
5 changes: 5 additions & 0 deletions
5
...y-docs/content/extensions/component-groups/examples/Severity/SeverityUndefinedExample.tsx
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,5 @@ | ||
| import React from 'react'; | ||
| import Severity from '@patternfly/react-component-groups/dist/dynamic/Severity'; | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| export const BasicExample: React.FunctionComponent = () => <Severity label="Undefined" severity={'an unknown value' as any} /> |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
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.