forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
BreadcrumbHeading.tsx
44 lines (42 loc) · 1.32 KB
/
BreadcrumbHeading.tsx
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
44
import * as React from 'react';
import styles from '@patternfly/patternfly/components/Breadcrumb/breadcrumb.css';
import { css } from '@patternfly/react-styles';
export interface BreadcrumbHeadingProps extends React.HTMLProps<HTMLLIElement> {
/** Content rendered inside the breadcrumb title. */
children?: React.ReactNode;
/** Additional classes added to the breadcrumb item. */
className?: string;
/** HREF for breadcrumb link. */
to?: string;
/** Target for breadcrumb link. */
target?: string;
/** Sets the base component to render. Defaults to <a> */
component?: React.ReactNode;
}
export const BreadcrumbHeading: React.FunctionComponent<BreadcrumbHeadingProps> = ({
children = null,
className = '',
to = null,
target = null,
component = 'a',
...props
}: BreadcrumbHeadingProps) => {
const Component = component as any;
return (
<li {...props} className={css(styles.breadcrumbItem, className)}>
<h1 className={css(styles.breadcrumbHeading)}>
{to && (
<Component
href={to}
target={target}
className={css(styles.breadcrumbLink, styles.modifiers.current)}
aria-current="page"
>
{children}
</Component>
)}
{!to && <React.Fragment>{children}</React.Fragment>}
</h1>
</li>
);
}