-
Notifications
You must be signed in to change notification settings - Fork 730
/
Copy pathTooltip.tsx
43 lines (40 loc) · 888 Bytes
/
Tooltip.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
import React from 'react';
import cx from 'classnames';
export type TooltipProps = {
left?: number;
top?: number;
className?: string;
style?: React.CSSProperties;
children?: React.ReactNode;
unstyled?: boolean;
};
export const defaultStyles: React.CSSProperties = {
position: 'absolute',
backgroundColor: 'white',
color: '#666666',
padding: '.3rem .5rem',
borderRadius: '3px',
fontSize: '14px',
boxShadow: '0 1px 2px rgba(33,33,33,0.2)',
lineHeight: '1em',
pointerEvents: 'none',
};
export default function Tooltip({
className,
top,
left,
style = defaultStyles,
children,
unstyled = false,
...restProps
}: TooltipProps & JSX.IntrinsicElements['div']) {
return (
<div
className={cx('vx-tooltip-portal', className)}
style={{ top, left, ...(!unstyled && style) }}
{...restProps}
>
{children}
</div>
);
}