CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
sagemathinc

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/course/common/progress.tsx
Views: 687
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
Progress indicator for assigning/collecting/etc. a particular assignment or handout.
8
*/
9
10
import { Icon, Gap } from "@cocalc/frontend/components";
11
import { COLORS } from "@cocalc/util/theme";
12
13
const progress_info = {
14
color: COLORS.GRAY_D,
15
marginLeft: "10px",
16
whiteSpace: "normal",
17
} as const;
18
19
const progress_info_done = {
20
...progress_info,
21
color: COLORS.BS_GREEN_DD,
22
} as const;
23
24
interface ProgressProps {
25
done: number;
26
not_done: number;
27
step: string;
28
skipped?: boolean;
29
}
30
31
export function Progress({ done, not_done, step, skipped }: ProgressProps) {
32
function render_checkbox() {
33
if (not_done === 0) {
34
return (
35
<span style={{ fontSize: "12pt" }}>
36
<Icon name="check-circle" />
37
<Gap />
38
</span>
39
);
40
}
41
}
42
43
function render_status() {
44
if (!skipped) {
45
return (
46
<>
47
({done} / {not_done + done} {step})
48
</>
49
);
50
} else {
51
return <>Skipped</>;
52
}
53
}
54
55
function style() {
56
if (not_done === 0) {
57
return progress_info_done;
58
} else {
59
return progress_info;
60
}
61
}
62
63
if (done == null || not_done == null || step == null) {
64
return <span />;
65
} else {
66
return (
67
<div style={style()}>
68
{render_checkbox()}
69
{render_status()}
70
</div>
71
);
72
}
73
}
74
75