Debian Codegraph @

node/@patternfly/react-core/src/components/Breadcrumb/BreadcrumbHeading.tsx

raw
1 import { Fragment } from 'react';
2 import RhMicronsCaretRightIcon from '@patternfly/react-icons/dist/esm/icons/rh-microns-caret-right-icon';
3 import styles from '@patternfly/react-styles/css/components/Breadcrumb/breadcrumb';
4 import { css } from '@patternfly/react-styles';
5
6 export interface BreadcrumbHeadingProps extends React.HTMLProps<HTMLLIElement> {
7 /** Content rendered inside the breadcrumb title. */
8 children?: React.ReactNode;
9 /** Additional classes added to the breadcrumb item. */
10 className?: string;
11 /** HREF for breadcrumb link. */
12 to?: string;
13 /** Target for breadcrumb link. */
14 target?: string;
15 /** Sets the base component to render. Defaults to <a> */
16 component?: React.ReactNode;
17 /** Internal prop set by Breadcrumb on all but the first crumb */
18 showDivider?: boolean;
19 }
20
21 export const BreadcrumbHeading: React.FunctionComponent<BreadcrumbHeadingProps> = ({
22 children = null,
23 className = '',
24 to = undefined,
25 target = undefined,
26 component = 'a',
27 showDivider,
28 ...props
29 }: BreadcrumbHeadingProps) => {
30 const Component = component as any;
31 return (
32 <li {...props} className={css(styles.breadcrumbItem, className)}>
33 {showDivider && (
34 <span className={styles.breadcrumbItemDivider}>
35 <RhMicronsCaretRightIcon />
36 </span>
37 )}
38 <h1 className={styles.breadcrumbHeading}>
39 {!to && component === 'button' && (
40 <button className={css(styles.breadcrumbLink, styles.modifiers.current)} aria-current type="button">
41 {children}
42 </button>
43 )}
44 {to && (
45 <Component
46 href={to}
47 target={target}
48 className={css(styles.breadcrumbLink, styles.modifiers.current)}
49 aria-current="page"
50 >
51 {children}
52 </Component>
53 )}
54 {!to && component !== 'button' && <Fragment>{children}</Fragment>}
55 </h1>
56 </li>
57 );
58 };
59 BreadcrumbHeading.displayName = 'BreadcrumbHeading';