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
5977 views
1
/*
2
* This file is part of CoCalc: Copyright © 2020-2026 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({
19
actions,
20
}: {
21
actions: TimeActions;
22
}): React.JSX.Element {
23
const intl = useIntl();
24
return (
25
<div style={{ margin: "1px" }}>
26
{timeTravelButton(actions, intl)}
27
<Gap />
28
{undoRedoGroup(actions)}
29
</div>
30
);
31
}
32
33
function timeTravelButton(actions: TimeActions, intl): Rendered {
34
return (
35
<Button
36
key={"time-travel"}
37
onClick={() => actions.time_travel()}
38
icon={<HistoryOutlined />}
39
>
40
{intl.formatMessage(labels.timetravel)}
41
</Button>
42
);
43
}
44
45
function undoRedoGroup(actions: TimeActions): Rendered {
46
return (
47
<Button.Group key={"undo-group"}>
48
<Button
49
key={"undo"}
50
title={"Undo last thing you did"}
51
onClick={() => actions.undo()}
52
icon={<UndoOutlined />}
53
>
54
Undo
55
</Button>
56
<Button
57
key={"redo"}
58
title={"Redo last thing you did"}
59
onClick={() => actions.redo()}
60
icon={<RedoOutlined />}
61
>
62
Redo
63
</Button>
64
</Button.Group>
65
);
66
}
67
68