Debian Codegraph @

node/@patternfly/react-core/src/components/Masthead/Masthead.tsx

raw
1 import { useContext } from 'react';
2 import styles from '@patternfly/react-styles/css/components/Masthead/masthead';
3 import { css } from '@patternfly/react-styles';
4 import { formatBreakpointMods } from '../../helpers/util';
5 import { PageContext } from '../Page/PageContext';
6
7 export interface MastheadProps extends React.DetailedHTMLProps<React.HTMLProps<HTMLDivElement>, HTMLDivElement> {
8 /** Content rendered inside of the masthead */
9 children?: React.ReactNode;
10 /** Additional classes added to the masthead */
11 className?: string;
12 /** Display type at various breakpoints */
13 display?: {
14 default?: 'inline' | 'stack';
15 sm?: 'inline' | 'stack';
16 md?: 'inline' | 'stack';
17 lg?: 'inline' | 'stack';
18 xl?: 'inline' | 'stack';
19 '2xl'?: 'inline' | 'stack';
20 };
21 /** Insets at various breakpoints */
22 inset?: {
23 default?: 'insetNone' | 'insetXs' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl' | 'inset3xl';
24 sm?: 'insetNone' | 'insetXs' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl' | 'inset3xl';
25 md?: 'insetNone' | 'insetXs' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl' | 'inset3xl';
26 lg?: 'insetNone' | 'insetXs' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl' | 'inset3xl';
27 xl?: 'insetNone' | 'insetXs' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl' | 'inset3xl';
28 '2xl'?: 'insetNone' | 'insetXs' | 'insetSm' | 'insetMd' | 'insetLg' | 'insetXl' | 'inset2xl' | 'inset3xl';
29 };
30 /** @beta Indicates the variant of the masthead */
31 variant?: 'default' | 'docked';
32 }
33
34 export const Masthead: React.FunctionComponent<MastheadProps> = ({
35 children,
36 className,
37 display = {
38 md: 'inline'
39 },
40 inset,
41 variant = 'default',
42 ...props
43 }: MastheadProps) => {
44 const { width, getBreakpoint } = useContext(PageContext);
45 return (
46 <header
47 className={css(
48 styles.masthead,
49 variant === 'docked' && styles.modifiers.docked,
50 formatBreakpointMods(display, styles, 'display-', getBreakpoint(width)),
51 formatBreakpointMods(inset, styles, '', getBreakpoint(width)),
52 className
53 )}
54 {...props}
55 >
56 {children}
57 </header>
58 );
59 };
60 Masthead.displayName = 'Masthead';