| 1 |
import styles from '@patternfly/react-styles/css/components/Masthead/masthead'; |
| 2 |
import { css } from '@patternfly/react-styles'; |
| 3 |
|
| 4 |
export interface MastheadLogoProps extends React.DetailedHTMLProps< |
| 5 |
React.HTMLProps<HTMLAnchorElement>, |
| 6 |
HTMLAnchorElement |
| 7 |
> { |
| 8 |
/** Content rendered inside of the masthead logo. */ |
| 9 |
children?: React.ReactNode; |
| 10 |
/** Additional classes added to the masthead logo. */ |
| 11 |
className?: string; |
| 12 |
/** Component type of the masthead logo. */ |
| 13 |
component?: React.ElementType<any> | React.ComponentType<any>; |
| 14 |
/** @beta Flag indicating the logo is a compact variant. Used in docked layouts. */ |
| 15 |
isCompact?: boolean; |
| 16 |
} |
| 17 |
|
| 18 |
export const MastheadLogo: React.FunctionComponent<MastheadLogoProps> = ({ |
| 19 |
children, |
| 20 |
className, |
| 21 |
component, |
| 22 |
isCompact = false, |
| 23 |
...props |
| 24 |
}: MastheadLogoProps) => { |
| 25 |
let Component = component as any; |
| 26 |
if (!component) { |
| 27 |
if (props?.href !== undefined) { |
| 28 |
Component = 'a'; |
| 29 |
} else { |
| 30 |
Component = 'span'; |
| 31 |
} |
| 32 |
} |
| 33 |
return ( |
| 34 |
<Component |
| 35 |
className={css(styles.mastheadLogo, isCompact && styles.modifiers.compact, className)} |
| 36 |
{...(Component === 'a' && { tabIndex: 0 })} |
| 37 |
{...props} |
| 38 |
> |
| 39 |
{children} |
| 40 |
</Component> |
| 41 |
); |
| 42 |
}; |
| 43 |
MastheadLogo.displayName = 'MastheadLogo'; |