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