Debian Codegraph @

node/@patternfly/react-core/src/components/Wizard/WizardHeader.tsx

raw
1 import styles from '@patternfly/react-styles/css/components/Wizard/wizard';
2 import { css } from '@patternfly/react-styles';
3 import { Button } from '../Button';
4 import RhMicronsCloseIcon from '@patternfly/react-icons/dist/esm/icons/rh-microns-close-icon';
5
6 export interface WizardHeaderProps extends React.HTMLProps<HTMLDivElement> {
7 /** Callback function called when the X (Close) button is clicked */
8 onClose?: (event: React.MouseEvent<HTMLButtonElement>) => void;
9 /** Title of the wizard */
10 title: string;
11 /** Description of the wizard */
12 description?: React.ReactNode;
13 /** Component type of the description */
14 descriptionComponent?: 'div' | 'p';
15 /** Flag indicating whether the close button should be in the header */
16 isCloseHidden?: boolean;
17 /** Aria-label applied to the X (Close) button */
18 closeButtonAriaLabel?: string;
19 /** id for the title */
20 titleId?: string;
21 /** id for the description */
22 descriptionId?: string;
23 /** Additional classes spread to the wizard header */
24 className?: string;
25 }
26
27 export const WizardHeader: React.FunctionComponent<WizardHeaderProps> = ({
28 onClose = () => undefined,
29 title,
30 description,
31 isCloseHidden,
32 closeButtonAriaLabel,
33 titleId,
34 descriptionComponent: Component = 'div',
35 descriptionId,
36 className,
37 ...props
38 }: WizardHeaderProps) => (
39 <div className={css(styles.wizardHeader, className)} {...props}>
40 {!isCloseHidden && (
41 <div className={css(styles.wizardClose)}>
42 <Button variant="plain" aria-label={closeButtonAriaLabel} onClick={onClose} icon={<RhMicronsCloseIcon />} />
43 </div>
44 )}
45 <div className={css(styles.wizardTitle)}>
46 <h2 className={css(styles.wizardTitleText)} id={titleId}>
47 {title || <>&nbsp;</>}
48 </h2>
49 </div>
50
51 {description && (
52 <Component className={css(styles.wizardDescription)} id={descriptionId}>
53 {description}
54 </Component>
55 )}
56 </div>
57 );
58
59 WizardHeader.displayName = 'WizardHeader';