Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sagemathinc
GitHub Repository: sagemathinc/cocalc
Path: blob/master/src/packages/frontend/editors/stopwatch/button-bar.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
Some buttons
8
*/
9
import { HistoryOutlined, RedoOutlined, UndoOutlined } from "@ant-design/icons";
10
import { Button } from "antd";
11
import { useIntl } from "react-intl";
12
13
import { Rendered } from "@cocalc/frontend/app-framework";
14
import { Gap } from "@cocalc/frontend/components/gap";
15
import { labels } from "@cocalc/frontend/i18n";
16
import { TimeActions } from "./actions";
17
18
export function ButtonBar({ actions }: { actions: TimeActions }): React.JSX.Element {
19
return (
20
<div style={{ margin: "1px" }}>
21
{timeTravelButton(actions)}
22
<Gap />
23
{undoRedoGroup(actions)}
24
</div>
25
);
26
}
27
28
function timeTravelButton(actions: TimeActions): Rendered {
29
const intl = useIntl();
30
31
return (
32
<Button
33
key={"time-travel"}
34
onClick={() => actions.time_travel()}
35
icon={<HistoryOutlined />}
36
>
37
{intl.formatMessage(labels.timetravel)}
38
</Button>
39
);
40
}
41
42
function undoRedoGroup(actions: TimeActions): Rendered {
43
return (
44
<Button.Group key={"undo-group"}>
45
<Button
46
key={"undo"}
47
title={"Undo last thing you did"}
48
onClick={() => actions.undo()}
49
icon={<UndoOutlined />}
50
>
51
Undo
52
</Button>
53
<Button
54
key={"redo"}
55
title={"Redo last thing you did"}
56
onClick={() => actions.redo()}
57
icon={<RedoOutlined />}
58
>
59
Redo
60
</Button>
61
</Button.Group>
62
);
63
}
64
65