forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBanner.tsx
More file actions
41 lines (39 loc) · 1.27 KB
/
Banner.tsx
File metadata and controls
41 lines (39 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import * as React from 'react';
import styles from '@patternfly/react-styles/css/components/Banner/banner';
import { css } from '@patternfly/react-styles';
export interface BannerProps extends React.HTMLProps<HTMLDivElement> {
/** Content rendered inside the banner. */
children?: React.ReactNode;
/** Additional classes added to the banner. */
className?: string;
/** If set to true, the banner sticks to the top of its container */
isSticky?: boolean;
/** Text announced by screen readers to indicate the type of banner. This prop should only
* be passed in when the banner conveys status/severity.
*/
screenReaderText?: string;
/** Variant styles for the banner. */
variant?: 'default' | 'info' | 'danger' | 'success' | 'warning';
}
export const Banner: React.FunctionComponent<BannerProps> = ({
children,
className,
variant = 'default',
screenReaderText,
isSticky = false,
...props
}: BannerProps) => (
<div
className={css(
styles.banner,
styles.modifiers[variant as 'success' | 'danger' | 'warning' | 'info'],
isSticky && styles.modifiers.sticky,
className
)}
{...props}
>
{screenReaderText && <span className="pf-u-screen-reader">{screenReaderText}</span>}
{children}
</div>
);
Banner.displayName = 'Banner';