Debian Codegraph @

node/@patternfly/react-core/src/components/Compass/CompassNavHome.tsx

raw
1 import { useRef } from 'react';
2 import styles from '@patternfly/react-styles/css/components/Compass/compass';
3 import { css } from '@patternfly/react-styles';
4 import { Button } from '../Button';
5 import { Tooltip } from '../Tooltip';
6
7 const CompassHomeIcon = () => (
8 <svg
9 width="1em"
10 height="1em"
11 className="pf-v6-svg"
12 viewBox="0 0 20 20"
13 fill="none"
14 xmlns="http://www.w3.org/2000/svg"
15 aria-hidden="true"
16 >
17 <path
18 d="M8.33268 13.334H11.666"
19 stroke="currentcolor"
20 strokeWidth="1.5"
21 strokeLinecap="round"
22 strokeLinejoin="round"
23 />
24 <path
25 d="M1.66602 6.66602L9.73102 2.63351C9.89994 2.54905 10.0988 2.54905 10.2677 2.63351L18.3327 6.66602"
26 stroke="currentcolor"
27 strokeWidth="1.5"
28 strokeLinecap="round"
29 strokeLinejoin="round"
30 />
31 <path
32 d="M16.6673 9.16602V15.4993C16.6673 16.6039 15.7719 17.4993 14.6673 17.4993H5.33398C4.22941 17.4993 3.33398 16.6039 3.33398 15.4993V9.16602"
33 stroke="currentcolor"
34 strokeWidth="1.5"
35 strokeLinecap="round"
36 strokeLinejoin="round"
37 />
38 </svg>
39 );
40
41 export interface CompassNavHomeProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onClick'> {
42 /** Content to display in the tooltip. Defaults to "Home". */
43 tooltipContent?: React.ReactNode;
44 /** Click handler for the home button. */
45 onClick?: React.MouseEventHandler<HTMLButtonElement>;
46 /** Additional classes added to the nav home wrapper. */
47 className?: string;
48 /** Accessible label for the nav home. */
49 'aria-label'?: string;
50 }
51
52 export const CompassNavHome: React.FunctionComponent<CompassNavHomeProps> = ({
53 'aria-label': ariaLabel = 'Home',
54 tooltipContent = 'Home',
55 className,
56 onClick,
57 ...props
58 }: CompassNavHomeProps) => {
59 const buttonRef = useRef<HTMLButtonElement>(null);
60
61 return (
62 <div className={css(styles.compassNav + '-home', className)} {...props}>
63 <Tooltip content={tooltipContent} position="left" aria="none" aria-live="off" triggerRef={buttonRef}>
64 <Button
65 isCircle
66 variant="plain"
67 icon={<CompassHomeIcon />}
68 aria-label={ariaLabel}
69 onClick={onClick}
70 ref={buttonRef}
71 />
72 </Tooltip>
73 </div>
74 );
75 };
76
77 CompassNavHome.displayName = 'CompassNavHome';