Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/editors/task-editor/min-toggle.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
Toggle to minimize display of a task (just show first part or everything)
8
*/
9
10
import { CSS, React } from "../../app-framework";
11
import { Icon } from "../../components";
12
import { TaskActions } from "./actions";
13
14
const STYLE: CSS = { fontSize: "17pt", color: "#888", float: "right" } as const;
15
16
interface Props {
17
actions?: TaskActions;
18
task_id: string;
19
hideBody?: boolean;
20
has_body: boolean;
21
}
22
23
export const MinToggle: React.FC<Props> = React.memo(
24
({ actions, task_id, hideBody, has_body }) => {
25
if (actions == null) {
26
// no support for toggling (e.g., read-only history view)
27
return <span />;
28
}
29
if (has_body) {
30
return (
31
<span
32
onClick={() => {
33
actions.toggleHideBody(task_id);
34
}}
35
style={STYLE}
36
>
37
{has_body ? (
38
<Icon name={hideBody ? "caret-right" : "caret-down"} />
39
) : (
40
<Icon name={"caret-right"} />
41
)}
42
</span>
43
);
44
} else {
45
return <span />;
46
}
47
}
48
);
49
50