main
js 47 lines 966 Bytes
Raw
1 /**
2 * Copyright (c) Meta Platforms, Inc. and affiliates.
3 *
4 * This source code is licensed under the MIT license found in the
5 * LICENSE file in the root directory of this source tree.
6 *
7 * @flow
8 */
9
10 import * as React from 'react';
11
12 import styles from './Button.css';
13 import Tooltip from './Components/reach-ui/tooltip';
14
15 type Props = {
16 children: React$Node,
17 className?: string,
18 testName?: ?string,
19 title: React$Node,
20 ...
21 };
22
23 export default function Button({
24 children,
25 className = '',
26 testName,
27 title,
28 ...rest
29 }: Props): React.Node {
30 let button = (
31 // $FlowFixMe[cannot-spread-inexact] unsafe spread
32 <button
33 className={`${styles.Button} ${className}`}
34 data-testname={testName}
35 {...rest}>
36 <span className={`${styles.ButtonContent} ${className}`} tabIndex={-1}>
37 {children}
38 </span>
39 </button>
40 );
41
42 if (title) {
43 button = <Tooltip label={title}>{button}</Tooltip>;
44 }
45
46 return button;
47 }