forked from opensumi/core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrop-area.tsx
40 lines (31 loc) · 1003 Bytes
/
drop-area.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
import React from 'react';
import { localize, useInjectable } from '@opensumi/ide-core-browser';
import { IMainLayoutService } from '../../common';
import styles from './styles.module.less';
interface IDropAreaProps {
location: string;
}
const DropArea: React.FC<IDropAreaProps> = (props) => {
const { location } = props;
const layoutService = useInjectable<IMainLayoutService>(IMainLayoutService);
const handleDrop = React.useCallback(
(e: React.DragEvent) => {
const containerId = e.dataTransfer?.getData('containerId');
layoutService.moveContainerTo(containerId, location);
},
[layoutService, location],
);
return (
<div
className={styles.drop_area}
onDrop={handleDrop}
onDragOver={(e) => {
e.preventDefault();
}}
>
{localize('main-layout.drop-area.tip')}
</div>
);
};
export const RightDropArea = () => <DropArea location='right' />;
export const BottomDropArea = () => <DropArea location='bottom' />;