@patternfly/react-core 4.256.0 → 4.257.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@patternfly/react-core",
3
- "version": "4.256.0",
3
+ "version": "4.257.0",
4
4
  "description": "This library provides a set of common React components for use with the PatternFly reference implementation.",
5
5
  "main": "dist/js/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -70,5 +70,5 @@
70
70
  "react": "^16.8 || ^17 || ^18",
71
71
  "react-dom": "^16.8 || ^17 || ^18"
72
72
  },
73
- "gitHead": "b7e13a9702cfe902e190000f1cfe059c830cf881"
73
+ "gitHead": "1a114c6117853b688671fd37d90bfd8df69bdde5"
74
74
  }
@@ -3,16 +3,18 @@ import styles from '@patternfly/react-styles/css/components/Banner/banner';
3
3
  import { css } from '@patternfly/react-styles';
4
4
 
5
5
  export interface BannerProps extends React.HTMLProps<HTMLDivElement> {
6
- /** Content rendered inside the banner */
6
+ /** Content rendered inside the banner. */
7
7
  children?: React.ReactNode;
8
- /** Additional classes added to the banner */
8
+ /** Additional classes added to the banner. */
9
9
  className?: string;
10
- /** Variant styles for the banner */
11
- variant?: 'default' | 'info' | 'danger' | 'success' | 'warning';
12
10
  /** If set to true, the banner sticks to the top of its container */
13
11
  isSticky?: boolean;
14
- /** Text announced by screen readers to indicate the type of banner. Defaults to "${variant} banner" if this prop is not passed in */
12
+ /** Text announced by screen readers to indicate the type of banner. This prop should only
13
+ * be passed in when the banner conveys status/severity.
14
+ */
15
15
  screenReaderText?: string;
16
+ /** Variant styles for the banner. */
17
+ variant?: 'default' | 'info' | 'danger' | 'success' | 'warning';
16
18
  }
17
19
 
18
20
  export const Banner: React.FunctionComponent<BannerProps> = ({
@@ -32,8 +34,8 @@ export const Banner: React.FunctionComponent<BannerProps> = ({
32
34
  )}
33
35
  {...props}
34
36
  >
37
+ {screenReaderText && <span className="pf-u-screen-reader">{screenReaderText}</span>}
35
38
  {children}
36
- <span className="pf-u-screen-reader">{screenReaderText || `${variant} banner`}</span>
37
39
  </div>
38
40
  );
39
41
  Banner.displayName = 'Banner';
@@ -51,22 +51,12 @@ test('Renders with class name pf-m-info when "info" is passed to variant prop',
51
51
  expect(screen.getByText('Test')).toHaveClass('pf-m-info');
52
52
  });
53
53
 
54
- test('Renders pf-u-screen-reader class by default for screenReaderText', () => {
54
+ test('Does not render pf-u-screen-reader class by default', () => {
55
55
  render(<Banner>Test</Banner>);
56
- expect(screen.getByText('default banner')).toHaveClass('pf-u-screen-reader', { exact: true });
56
+ expect(screen.getByText('Test')).not.toContainHTML('<span class="pf-u-screen-reader"></span>');
57
57
  });
58
58
 
59
- test('Renders screenReaderText as "default banner" by default', () => {
60
- render(<Banner>Test</Banner>);
61
- expect(screen.getByText('default banner')).toBeInTheDocument();
62
- });
63
-
64
- test('Renders screenReaderText as "success banner" when variant="success"', () => {
65
- render(<Banner variant="success">Test</Banner>);
66
- expect(screen.getByText('success banner')).toBeInTheDocument();
67
- });
68
-
69
- test('Renders custom screenReaderText passed via prop', () => {
59
+ test('Renders screenReaderText passed via prop', () => {
70
60
  render(<Banner screenReaderText="Custom screen reader text">Test</Banner>);
71
61
  expect(screen.getByText('Custom screen reader text')).toBeInTheDocument();
72
62
  });
@@ -6,11 +6,6 @@ exports[`Matches the snapshot 1`] = `
6
6
  class="pf-c-banner"
7
7
  >
8
8
  Test
9
- <span
10
- class="pf-u-screen-reader"
11
- >
12
- default banner
13
- </span>
14
9
  </div>
15
10
  </DocumentFragment>
16
11
  `;
@@ -5,9 +5,28 @@ cssPrefix: pf-c-banner
5
5
  propComponents: ['Banner']
6
6
  ---
7
7
 
8
+ import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
9
+ import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
10
+ import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';
11
+ import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
12
+ import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
13
+
8
14
  ## Examples
9
15
 
10
16
  ### Basic
11
17
 
18
+ Banners can be styled with one of 5 different colors. A basic banner should only be used when the banner color does not represent status or severity.
19
+
12
20
  ```ts file="./BannerBasic.tsx"
21
+
22
+ ```
23
+
24
+ ### Status
25
+
26
+ When a banner is used to convey status, it is advised to pass in an icon inside the banner to convey the status in a way besides just color. The `screenReaderText` prop should also be passed in to convey the status/severity of the banner to users of certain assistive technologies such as screen readers.
27
+
28
+ In the following example, a flex layout is used inside the banner content to show one possible way to create spacing between the icons and banner text.
29
+
30
+ ```ts file="./BannerStatus.tsx"
31
+
13
32
  ```
@@ -2,17 +2,15 @@ import React from 'react';
2
2
  import { Banner } from '@patternfly/react-core';
3
3
 
4
4
  export const BannerBasic: React.FunctionComponent = () => (
5
- <React.Fragment>
6
- <Banner screenReaderText="This is a default Banner">Default banner</Banner>
5
+ <>
6
+ <Banner>Default banner</Banner>
7
7
  <br />
8
- <Banner variant="info" screenReaderText="This is an info Banner">
9
- Info banner
10
- </Banner>
8
+ <Banner variant="info">Blue banner</Banner>
11
9
  <br />
12
- <Banner variant="danger">Danger banner</Banner>
10
+ <Banner variant="danger">Red banner</Banner>
13
11
  <br />
14
- <Banner variant="success">Success banner</Banner>
12
+ <Banner variant="success">Green banner</Banner>
15
13
  <br />
16
- <Banner variant="warning">Warning banner</Banner>
17
- </React.Fragment>
14
+ <Banner variant="warning">Gold banner</Banner>
15
+ </>
18
16
  );
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+ import { Banner, Flex, FlexItem } from '@patternfly/react-core';
3
+ import CheckCircleIcon from '@patternfly/react-icons/dist/esm/icons/check-circle-icon';
4
+ import ExclamationCircleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-circle-icon';
5
+ import ExclamationTriangleIcon from '@patternfly/react-icons/dist/esm/icons/exclamation-triangle-icon';
6
+ import InfoCircleIcon from '@patternfly/react-icons/dist/esm/icons/info-circle-icon';
7
+ import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon';
8
+
9
+ export const BannerStatus: React.FunctionComponent = () => (
10
+ <>
11
+ <Banner screenReaderText="Default banner">
12
+ <Flex spaceItems={{ default: 'spaceItemsSm' }}>
13
+ <FlexItem>
14
+ <BellIcon />
15
+ </FlexItem>
16
+ <FlexItem>Default banner</FlexItem>
17
+ </Flex>
18
+ </Banner>
19
+ <br />
20
+ <Banner screenReaderText="Info banner" variant="info">
21
+ <Flex spaceItems={{ default: 'spaceItemsSm' }}>
22
+ <FlexItem>
23
+ <InfoCircleIcon />
24
+ </FlexItem>
25
+ <FlexItem>Info banner</FlexItem>
26
+ </Flex>
27
+ </Banner>
28
+ <br />
29
+ <Banner screenReaderText="Danger banner" variant="danger">
30
+ <Flex spaceItems={{ default: 'spaceItemsSm' }}>
31
+ <FlexItem>
32
+ <ExclamationCircleIcon />
33
+ </FlexItem>
34
+ <FlexItem>Danger banner</FlexItem>
35
+ </Flex>
36
+ </Banner>
37
+ <br />
38
+ <Banner screenReaderText="Success banner" variant="success">
39
+ <Flex spaceItems={{ default: 'spaceItemsSm' }}>
40
+ <FlexItem>
41
+ <CheckCircleIcon />
42
+ </FlexItem>
43
+ <FlexItem>Success banner</FlexItem>
44
+ </Flex>
45
+ </Banner>
46
+ <br />
47
+ <Banner screenReaderText="Warning banner" variant="warning">
48
+ <Flex spaceItems={{ default: 'spaceItemsSm' }}>
49
+ <FlexItem>
50
+ <ExclamationTriangleIcon />
51
+ </FlexItem>
52
+ <FlexItem>Warning banner</FlexItem>
53
+ </Flex>
54
+ </Banner>
55
+ </>
56
+ );