Debian Codegraph @

node/@patternfly/react-core/src/components/Compass/CompassNavSearch.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 CompassSearchIcon = () => (
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="M14.166 14.166L17.4993 17.4993"
19 stroke="currentcolor"
20 strokeWidth="1.5"
21 strokeLinecap="round"
22 strokeLinejoin="round"
23 />
24 <path
25 d="M2.5 9.16667C2.5 12.8486 5.48477 15.8333 9.16667 15.8333C11.0108 15.8333 12.6801 15.0846 13.887 13.8744C15.0897 12.6685 15.8333 11.0044 15.8333 9.16667C15.8333 5.48477 12.8486 2.5 9.16667 2.5C5.48477 2.5 2.5 5.48477 2.5 9.16667Z"
26 stroke="currentcolor"
27 strokeWidth="1.5"
28 strokeLinecap="round"
29 strokeLinejoin="round"
30 />
31 </svg>
32 );
33
34 export interface CompassNavSearchProps extends Omit<React.HTMLProps<HTMLDivElement>, 'onClick'> {
35 /** Content to display in the tooltip. Defaults to "Search". */
36 tooltipContent?: React.ReactNode;
37 /** Click handler for the search button. */
38 onClick?: React.MouseEventHandler<HTMLButtonElement>;
39 /** Additional classes added to the nav search wrapper. */
40 className?: string;
41 /** Accessible label for the nav search. */
42 'aria-label'?: string;
43 }
44
45 export const CompassNavSearch: React.FunctionComponent<CompassNavSearchProps> = ({
46 'aria-label': ariaLabel = 'Search',
47 tooltipContent = 'Search',
48 className,
49 onClick,
50 ...props
51 }: CompassNavSearchProps) => {
52 const buttonRef = useRef<HTMLButtonElement>(null);
53
54 return (
55 <div className={css(styles.compassNav + '-search', className)} {...props}>
56 <Tooltip content={tooltipContent} aria="none" aria-live="off" triggerRef={buttonRef}>
57 <Button
58 isCircle
59 variant="plain"
60 icon={<CompassSearchIcon />}
61 aria-label={ariaLabel}
62 onClick={onClick}
63 ref={buttonRef}
64 />
65 </Tooltip>
66 </div>
67 );
68 };
69
70 CompassNavSearch.displayName = 'CompassNavSearch';