Debian Codegraph @

node/@patternfly/react-core/src/components/EmptyState/EmptyStateHeader.tsx

raw
1 import { css } from '@patternfly/react-styles';
2 import styles from '@patternfly/react-styles/css/components/EmptyState/empty-state';
3 import { EmptyStateIcon } from './EmptyStateIcon';
4
5 export enum EmptyStateHeadingLevel {
6 h1 = 'h1',
7 h2 = 'h2',
8 h3 = 'h3',
9 h4 = 'h4',
10 h5 = 'h5',
11 h6 = 'h6'
12 }
13
14 export interface EmptyStateHeaderProps extends React.HTMLProps<HTMLDivElement> {
15 /** Additional classes added to the empty state header */
16 className?: string;
17 /** Additional classes added to the title inside empty state header */
18 titleClassName?: string;
19 /** Text of the title inside empty state header, will be wrapped in headingLevel */
20 titleText?: React.ReactNode;
21 /** Empty state icon element to be rendered. Can also be a spinner component */
22 icon?: React.ComponentType<any>;
23 /** The heading level to use, default is h1 */
24 headingLevel?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
25 }
26
27 export const EmptyStateHeader: React.FunctionComponent<EmptyStateHeaderProps> = ({
28 className,
29 titleClassName,
30 titleText,
31 headingLevel: HeadingLevel = EmptyStateHeadingLevel.h1,
32 icon: Icon,
33 ...props
34 }: EmptyStateHeaderProps) => (
35 <div className={css(`${styles.emptyState}__header`, className)} {...props}>
36 {Icon && <EmptyStateIcon icon={Icon} />}
37 {titleText && (
38 <div className={css(`${styles.emptyState}__title`)}>
39 <HeadingLevel className={css(styles.emptyStateTitleText, titleClassName)}>{titleText}</HeadingLevel>
40 </div>
41 )}
42 </div>
43 );
44
45 EmptyStateHeader.displayName = 'EmptyStateHeader';