-
Notifications
You must be signed in to change notification settings - Fork 67
/
Splitter.tsx
70 lines (66 loc) 路 1.71 KB
/
Splitter.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
65
66
67
68
69
70
import {DoubleLeftOutlined, DoubleRightOutlined} from '@ant-design/icons';
import {Tooltip, TooltipProps} from 'antd';
import * as S from './ResizablePanels.styled';
interface IProps {
isOpen: boolean;
onClick(): void;
id?: string;
className?: string;
name: string;
isToolTipVisible?: boolean;
tooltip?: string;
tooltipPlacement?: TooltipProps['placement'];
onMouseDown(e: React.MouseEvent<HTMLElement, MouseEvent>): void;
onTouchStart(e: React.TouchEvent<HTMLElement>): void;
dataTour?: string;
}
const Splitter = ({
isOpen,
name,
onClick,
id,
className,
onMouseDown,
onTouchStart,
tooltip,
tooltipPlacement = 'right',
isToolTipVisible = false,
dataTour,
}: IProps) => {
const button = (
<S.SplitterButton
$isPulsing={isToolTipVisible}
data-cy={`toggle-drawer-${name}`}
icon={isOpen ? <DoubleLeftOutlined /> : <DoubleRightOutlined />}
onClick={event => {
event.stopPropagation();
onClick();
}}
onMouseDown={event => event.stopPropagation()}
shape="circle"
type="primary"
data-tour={dataTour}
/>
);
return (
<S.SplitterContainer id={id} key={id} className={className} onMouseDown={onMouseDown} onTouchStart={onTouchStart}>
<S.ButtonContainer>
{isToolTipVisible ? (
<Tooltip
title={tooltip}
visible
trigger={[]}
placement={tooltipPlacement}
overlayClassName="splitter"
getPopupContainer={node => node.parentElement ?? document.body}
>
{button}
</Tooltip>
) : (
button
)}
</S.ButtonContainer>
</S.SplitterContainer>
);
};
export default Splitter;