-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathSimpleButton.tsx
64 lines (55 loc) · 1.43 KB
/
SimpleButton.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import * as React from 'react';
import { Button, Tooltip } from 'antd';
import { ButtonProps } from 'antd/lib/button';
import { AbstractTooltipProps, TooltipPlacement } from 'antd/lib/tooltip';
import { CSS_PREFIX } from '../../constants';
export interface OwnProps {
/**
* Additional [antd tooltip](https://ant.design/components/tooltip/)
* properties to pass to the tooltip component. Note: The props `title`
* and `placement` will override the props `tooltip` and `tooltipPlacement`
* of this component!
*/
tooltipProps?: AbstractTooltipProps;
/**
* The tooltip to be shown on hover.
*/
tooltip?: string;
/**
* The position of the tooltip.
*/
tooltipPlacement?: TooltipPlacement;
}
export type SimpleButtonProps = OwnProps & ButtonProps;
const defaultClassName = `${CSS_PREFIX}simplebutton`;
const SimpleButton: React.FC<SimpleButtonProps> = ({
className,
type = 'primary',
tooltip,
tooltipPlacement,
tooltipProps = {
mouseEnterDelay: 1.5
},
children,
...passThroughProps
}) => {
const finalClassName = className
? `${className} ${defaultClassName}`
: `${defaultClassName}`;
return (
<Tooltip
title={tooltip}
placement={tooltipPlacement}
{...tooltipProps}
>
<Button
className={finalClassName}
type={type}
{...passThroughProps}
>
{children}
</Button>
</Tooltip>
);
};
export default SimpleButton;