2019-08-27 10:54:01 -07:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
|
|
|
*
|
|
|
|
|
* This source code is licensed under the MIT license found in the
|
|
|
|
|
* LICENSE file in the root directory of this source tree.
|
|
|
|
|
*
|
|
|
|
|
* @flow
|
|
|
|
|
*/
|
2019-02-14 13:20:24 -08:00
|
|
|
|
2020-02-21 19:45:20 -08:00
|
|
|
import * as React from 'react';
|
2019-02-14 13:20:24 -08:00
|
|
|
|
|
|
|
|
import styles from './Button.css';
|
2021-11-09 01:47:22 +05:30
|
|
|
import Tooltip from './Components/reach-ui/tooltip';
|
2019-02-14 13:20:24 -08:00
|
|
|
|
|
|
|
|
type Props = {
|
2019-04-20 15:44:24 -07:00
|
|
|
children: React$Node,
|
2019-02-14 13:20:24 -08:00
|
|
|
className?: string,
|
2021-12-21 11:58:04 -05:00
|
|
|
testName?: ?string,
|
2020-12-21 03:48:36 +01:00
|
|
|
title: React$Node,
|
2020-01-09 14:50:44 +00:00
|
|
|
...
|
2019-02-14 13:20:24 -08:00
|
|
|
};
|
|
|
|
|
|
2019-04-21 08:23:20 -07:00
|
|
|
export default function Button({
|
|
|
|
|
children,
|
|
|
|
|
className = '',
|
2021-12-21 11:58:04 -05:00
|
|
|
testName,
|
2020-12-21 03:48:36 +01:00
|
|
|
title,
|
2019-04-21 08:23:20 -07:00
|
|
|
...rest
|
|
|
|
|
}: Props) {
|
2019-04-20 14:20:48 -07:00
|
|
|
let button = (
|
2021-12-21 11:58:04 -05:00
|
|
|
<button
|
|
|
|
|
className={`${styles.Button} ${className}`}
|
|
|
|
|
data-testname={testName}
|
|
|
|
|
{...rest}>
|
2019-04-21 08:23:20 -07:00
|
|
|
<span className={`${styles.ButtonContent} ${className}`} tabIndex={-1}>
|
2019-04-20 15:44:24 -07:00
|
|
|
{children}
|
|
|
|
|
</span>
|
|
|
|
|
</button>
|
2019-04-20 14:20:48 -07:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (title) {
|
2021-11-09 01:47:22 +05:30
|
|
|
button = <Tooltip label={title}>{button}</Tooltip>;
|
2019-04-20 14:20:48 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return button;
|
2019-02-14 13:20:24 -08:00
|
|
|
}
|