Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/editors/task-editor/drag.tsx
1691 views
1
/*
2
* This file is part of CoCalc: Copyright © 2020 Sagemath, Inc.
3
* License: MS-RSL – see LICENSE.md for details
4
*/
5
6
/*
7
Drag tasks handle (and other support)
8
*/
9
10
import { Icon, Tip } from "../../components";
11
import { DragHandle as SortableDragHandle } from "@cocalc/frontend/components/sortable-list";
12
13
interface Props {
14
id: string;
15
}
16
17
function EnabledDragHandle({ id }: Props) {
18
return (
19
<SortableDragHandle id={id}>
20
<Icon name="bars" />
21
</SortableDragHandle>
22
);
23
}
24
25
function DisabledDragHandle({}: Props) {
26
return (
27
<Tip
28
title={"Select Custom Order to enable dragging tasks."}
29
delayShow={700}
30
>
31
<Icon style={{ cursor: "pointer" }} name="bars" />
32
</Tip>
33
);
34
}
35
36
interface Props {
37
sortable?: boolean;
38
}
39
40
export const DragHandle: React.FC<Props> = ({ id, sortable }) => {
41
let color, Handle;
42
if (sortable) {
43
color = "#888";
44
Handle = EnabledDragHandle;
45
} else {
46
color = "#eee";
47
Handle = DisabledDragHandle;
48
}
49
return (
50
<span style={{ fontSize: "17pt", color, marginLeft: "15px" }}>
51
<Handle id={id} />
52
</span>
53
);
54
};
55
56