Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/course/common/progress.tsx
5790 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
Progress indicator for assigning/collecting/etc. a particular assignment or handout.
8
*/
9
10
import { Space } from "antd";
11
import { Icon } from "@cocalc/frontend/components";
12
import { COLORS } from "@cocalc/util/theme";
13
14
const progress_info = {
15
color: COLORS.GRAY_D,
16
paddingLeft: "5px",
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
if (done == null || not_done == null || step == null) return <span />;
33
const style = not_done === 0 ? progress_info_done : progress_info;
34
return (
35
<Space style={style}>
36
<Icon name={not_done === 0 ? "check-circle" : "pie-chart"} />
37
{skipped ? "Skipped" : `${done} / ${not_done + done}`}
38
</Space>
39
);
40
}
41
42