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-04-23 08:41:52 -07:00
|
|
|
import Tooltip from '@reach/tooltip';
|
2019-02-14 13:20:24 -08:00
|
|
|
|
|
|
|
|
import styles from './Button.css';
|
2019-04-23 08:41:52 -07:00
|
|
|
import tooltipStyles from './Tooltip.css';
|
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,
|
2019-05-01 10:43:40 -07:00
|
|
|
title?: string,
|
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 = '',
|
2019-05-01 10:43:40 -07:00
|
|
|
title = '',
|
2019-04-21 08:23:20 -07:00
|
|
|
...rest
|
|
|
|
|
}: Props) {
|
2019-04-20 14:20:48 -07:00
|
|
|
let button = (
|
2019-04-23 08:41:52 -07:00
|
|
|
<button className={`${styles.Button} ${className}`} {...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) {
|
|
|
|
|
button = (
|
|
|
|
|
<Tooltip className={tooltipStyles.Tooltip} label={title}>
|
|
|
|
|
{button}
|
|
|
|
|
</Tooltip>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return button;
|
2019-02-14 13:20:24 -08:00
|
|
|
}
|