Debian Codegraph @

node/@patternfly/react-core/src/components/Compass/CompassMainHeader.tsx

raw
1 import { CompassMainHeaderContent } from './CompassMainHeaderContent';
2 import { CompassMainHeaderTitle } from './CompassMainHeaderTitle';
3 import { CompassMainHeaderToolbar } from './CompassMainHeaderToolbar';
4 import { Panel, PanelMain, PanelMainBody, PanelProps } from '../Panel';
5 import styles from '@patternfly/react-styles/css/components/Compass/compass';
6 import { css } from '@patternfly/react-styles';
7
8 /** The wrapper component for header content in the main Compass area. When building out a custom implementation,
9 * you should ensure any content within the main header is rendered inside a Panel, PanelMain, PanelMainBody stack and main header content wrappers.
10 */
11
12 export interface CompassMainHeaderProps extends Omit<React.HTMLProps<HTMLDivElement>, 'title'> {
13 /** Custom main header content. To opt into a default styling, use the title and toolbar props instead. */
14 children?: React.ReactNode;
15 /** Additional classes added to the main header */
16 className?: string;
17 /** Styled title. If title or toolbar is provided, the children will be ignored. */
18 title?: React.ReactNode;
19 /** Styled toolbar. If title or toolbar is provided, the children will be ignored. */
20 toolbar?: React.ReactNode;
21 /** Additional props passed to the Panel that wraps the main header content when using the title or toolbar props. When using the
22 * children prop, you should pass your own Panel.
23 */
24 panelProps?: Omit<PanelProps, 'children'>;
25 }
26
27 export const CompassMainHeader: React.FunctionComponent<CompassMainHeaderProps> = ({
28 className,
29 title,
30 toolbar,
31 children,
32 panelProps,
33 ...props
34 }: CompassMainHeaderProps) => {
35 const _content =
36 title !== undefined || toolbar !== undefined ? (
37 <Panel {...panelProps}>
38 <PanelMain>
39 <PanelMainBody>
40 <CompassMainHeaderContent>
41 {title && <CompassMainHeaderTitle>{title}</CompassMainHeaderTitle>}
42 {toolbar && <CompassMainHeaderToolbar>{toolbar}</CompassMainHeaderToolbar>}
43 </CompassMainHeaderContent>
44 </PanelMainBody>
45 </PanelMain>
46 </Panel>
47 ) : (
48 children
49 );
50
51 return (
52 <div className={css(`${styles.compass}__main-header`, className)} {...props}>
53 {_content}
54 </div>
55 );
56 };
57
58 CompassMainHeader.displayName = 'CompassMainHeader';