Skip to content

Commit 59ae4e6

Browse files
committed
course: handout -- make button ui consistent with modern antd standards
1 parent 93b50fd commit 59ae4e6

File tree

3 files changed

+54
-78
lines changed

3 files changed

+54
-78
lines changed

src/packages/frontend/course/handouts/handout.tsx

Lines changed: 37 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@ import {
1111
CSS,
1212
} from "@cocalc/frontend/app-framework";
1313
import { capitalize, trunc_middle } from "@cocalc/util/misc";
14-
import { Alert, Card, Col, Row } from "antd";
15-
import {
16-
Button,
17-
ButtonGroup,
18-
FormControl,
19-
FormGroup,
20-
} from "../../antd-bootstrap";
14+
import { Alert, Button, Input, Card, Col, Row, Space } from "antd";
2115
import { Icon, MarkdownInput, Tip } from "../../components";
2216
import { UserMap } from "../../todo-types";
2317
import { CourseActions } from "../actions";
@@ -251,26 +245,23 @@ export const Handout: React.FC<HandoutProps> = React.memo(
251245
<div style={{ marginTop: "15px" }}>
252246
Type in "OVERWRITE" if you are certain to replace the handout files of
253247
all students.
254-
<FormGroup>
255-
<FormControl
256-
autoFocus
257-
type="text"
258-
onChange={(e) =>
259-
set_copy_handout_confirm_overwrite_text((e.target as any).value)
260-
}
261-
style={{ marginTop: "1ex" }}
262-
/>
263-
</FormGroup>
264-
<ButtonGroup style={{ textAlign: "center", marginTop: "15px" }}>
248+
<Input
249+
autoFocus
250+
onChange={(e) =>
251+
set_copy_handout_confirm_overwrite_text(e.target.value)
252+
}
253+
style={{ marginTop: "1ex" }}
254+
/>
255+
<Space style={{ textAlign: "center", marginTop: "15px" }}>
256+
{render_copy_cancel()}
265257
<Button
266258
disabled={copy_handout_confirm_overwrite_text !== "OVERWRITE"}
267-
bsStyle="danger"
259+
danger
268260
onClick={do_it}
269261
>
270262
<Icon name="exclamation-triangle" /> Confirm replacing files
271263
</Button>
272-
{render_copy_cancel()}
273-
</ButtonGroup>
264+
</Space>
274265
</div>
275266
);
276267
}
@@ -307,16 +298,16 @@ export const Handout: React.FC<HandoutProps> = React.memo(
307298
{step_direction(step)} the {n} student{n > 1 ? "s" : ""}
308299
{step_ready(step)}?
309300
</div>
310-
<ButtonGroup>
301+
<Space>
302+
{render_copy_cancel()}
311303
<Button
312304
key="yes"
313-
bsStyle="primary"
305+
type="primary"
314306
onClick={() => copy_handout(step, false)}
315307
>
316308
Yes
317309
</Button>
318-
{render_copy_cancel()}
319-
</ButtonGroup>
310+
</Space>
320311
</div>
321312
}
322313
/>
@@ -340,23 +331,19 @@ export const Handout: React.FC<HandoutProps> = React.memo(
340331
<div style={{ marginBottom: "15px" }}>
341332
{copy_confirm_all_caution(step)}
342333
</div>
343-
<ButtonGroup>
344-
<Button
345-
key="all"
346-
bsStyle="warning"
347-
onClick={() => copy_handout(step, false)}
348-
>
334+
<Space>
335+
{render_copy_cancel()}
336+
<Button key="all" onClick={() => copy_handout(step, false)}>
349337
Yes, do it
350338
</Button>
351339
<Button
352340
key="all-overwrite"
353-
bsStyle="danger"
341+
danger
354342
onClick={() => set_copy_handout_confirm_overwrite(true)}
355343
>
356344
Replace student files!
357345
</Button>
358-
{render_copy_cancel()}
359-
</ButtonGroup>
346+
</Space>
360347
{render_copy_handout_confirm_overwrite(step)}
361348
</div>
362349
);
@@ -377,10 +364,11 @@ export const Handout: React.FC<HandoutProps> = React.memo(
377364
{step_direction(step)}
378365
...
379366
</div>
380-
<ButtonGroup>
367+
<Space>
368+
{render_copy_cancel()}
381369
<Button
382370
key="all"
383-
bsStyle="danger"
371+
danger
384372
onClick={() => {
385373
set_copy_confirm_all_handout(true);
386374
set_copy_confirm(true);
@@ -394,15 +382,14 @@ export const Handout: React.FC<HandoutProps> = React.memo(
394382
{n ? (
395383
<Button
396384
key="new"
397-
bsStyle="primary"
385+
type="primary"
398386
onClick={() => copy_handout(step, true)}
399387
>
400388
The {n} student{n > 1 ? "s" : ""} not already{" "}
401389
{past_tense(step_verb(step))} {step_direction(step)}
402390
</Button>
403391
) : undefined}
404-
{render_copy_cancel()}
405-
</ButtonGroup>
392+
</Space>
406393
{copy_confirm_all_handout
407394
? render_copy_confirm_overwrite_all(step)
408395
: undefined}
@@ -413,22 +400,11 @@ export const Handout: React.FC<HandoutProps> = React.memo(
413400
}
414401

415402
function render_handout_button(status): Rendered {
416-
let bsStyle;
417403
const handout_count = status.handout;
418-
const { not_handout } = status;
419-
if (handout_count === 0) {
420-
bsStyle = "primary";
421-
} else {
422-
if (not_handout === 0) {
423-
bsStyle = "success";
424-
} else {
425-
bsStyle = "warning";
426-
}
427-
}
428404
return (
429405
<Button
430406
key="handout"
431-
bsStyle={bsStyle}
407+
type={handout_count === 0 ? "primary" : undefined}
432408
onClick={() => {
433409
set_copy_confirm_handout(true);
434410
set_copy_confirm(true);
@@ -469,14 +445,14 @@ export const Handout: React.FC<HandoutProps> = React.memo(
469445
<div>
470446
Are you sure you want to delete this handout?
471447
<br /> <br />
472-
<ButtonGroup>
473-
<Button key="yes" onClick={delete_handout} bsStyle="danger">
474-
<Icon name="trash" /> Delete
475-
</Button>
448+
<Space>
476449
<Button key="no" onClick={() => set_confirm_delete(false)}>
477450
Cancel
478451
</Button>
479-
</ButtonGroup>
452+
<Button key="yes" onClick={delete_handout} danger>
453+
<Icon name="trash" /> Delete
454+
</Button>
455+
</Space>
480456
</div>
481457
}
482458
/>
@@ -590,13 +566,15 @@ export const Handout: React.FC<HandoutProps> = React.memo(
590566
}
591567
return (
592568
<Row key="summary" style={{ backgroundColor: backgroundColor }}>
593-
<Col md={4} style={{ paddingRight: "0px" }}>
569+
<Col md={8} style={{ paddingRight: "0px" }}>
594570
{render_handout_name()}
595571
</Col>
596-
<Col md={12}>
572+
<Col md={8}>
597573
<Row style={{ marginLeft: "8px" }}>
598574
{render_handout_button(status)}
599-
<span style={{ color: "#666", marginLeft: "5px" }}>
575+
<span
576+
style={{ color: "#666", marginLeft: "5px", marginTop: "10px" }}
577+
>
600578
({status.handout}/{status.handout + status.not_handout}{" "}
601579
transferred)
602580
</span>

src/packages/frontend/course/handouts/handouts-info-panel.tsx

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
// React Libraries
88
import { React, useState } from "@cocalc/frontend/app-framework";
99
import { to_json } from "@cocalc/util/misc";
10-
import { Col, Row } from "antd";
11-
import { Button, ButtonGroup } from "../../antd-bootstrap";
10+
import { Button, Space, Col, Row } from "antd";
1211
import { ErrorDisplay, Icon, Tip } from "../../components";
1312
import { CourseActions } from "../actions";
1413
import { BigTime } from "../common";
@@ -50,10 +49,15 @@ export const StudentHandoutInfo: React.FC<StudentHandoutInfoProps> = (
5049
function render_open_recopy_confirm(name, copy, copy_tip) {
5150
if (recopy) {
5251
const v: any[] = [];
52+
v.push(
53+
<Button key="copy_cancel" onClick={() => setRecopy(false)}>
54+
Cancel
55+
</Button>,
56+
);
5357
v.push(
5458
<Button
5559
key="copy_confirm"
56-
bsStyle="danger"
60+
danger
5761
onClick={() => {
5862
setRecopy(false);
5963
return copy();
@@ -62,15 +66,10 @@ export const StudentHandoutInfo: React.FC<StudentHandoutInfoProps> = (
6266
<Icon name="share-square" /> Yes, {name.toLowerCase()} again
6367
</Button>,
6468
);
65-
v.push(
66-
<Button key="copy_cancel" onClick={() => setRecopy(false)}>
67-
Cancel
68-
</Button>,
69-
);
70-
return v;
69+
return <Space>{v}</Space>;
7170
} else {
7271
return (
73-
<Button key="copy" bsStyle="warning" onClick={() => setRecopy(true)}>
72+
<Button key="copy" onClick={() => setRecopy(true)}>
7473
<Tip title={name} tip={<span>{copy_tip}</span>}>
7574
<Icon name="share-square" /> {name}...
7675
</Tip>
@@ -81,37 +80,37 @@ export const StudentHandoutInfo: React.FC<StudentHandoutInfoProps> = (
8180

8281
function render_open_recopy(name, open, copy, copy_tip, open_tip) {
8382
return (
84-
<ButtonGroup key="open_recopy">
83+
<Space key="open_recopy">
8584
{render_open_recopy_confirm(name, copy, copy_tip)}
8685
<Button key="open" onClick={open}>
8786
<Tip title="Open Folder" tip={open_tip}>
8887
<Icon name="folder-open" /> Open directory...
8988
</Tip>
9089
</Button>
91-
</ButtonGroup>
90+
</Space>
9291
);
9392
}
9493

9594
function render_open_copying(open, stop) {
9695
return (
97-
<ButtonGroup key="open_copying">
98-
<Button key="copy" bsStyle="success" disabled={true}>
96+
<Space key="open_copying">
97+
<Button key="copy" type="primary" disabled={true}>
9998
<Icon name="cocalc-ring" spin /> Working...
10099
</Button>
101-
<Button key="stop" bsStyle="danger" onClick={stop}>
100+
<Button key="stop" danger onClick={stop}>
102101
<Icon name="times" />
103102
</Button>
104103
<Button key="open" onClick={open}>
105104
<Icon name="folder-open" /> Open
106105
</Button>
107-
</ButtonGroup>
106+
</Space>
108107
);
109108
}
110109

111110
function render_copy(name, copy, copy_tip) {
112111
return (
113112
<Tip key="copy" title={name} tip={copy_tip}>
114-
<Button onClick={copy} bsStyle={"primary"}>
113+
<Button onClick={copy} type="primary">
115114
<Icon name="share-square" /> {name}
116115
</Button>
117116
</Tip>

src/packages/frontend/course/handouts/handouts-panel.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ import {
1313
} from "@cocalc/frontend/app-framework";
1414
import ScrollableList from "@cocalc/frontend/components/scrollable-list";
1515
import { cmp } from "@cocalc/util/misc";
16-
import { Alert } from "antd";
16+
import { Alert, Button } from "antd";
1717
import { Set } from "immutable";
18-
import { Button } from "../../antd-bootstrap";
1918
import { Icon, Tip } from "../../components";
2019
import { UserMap } from "../../todo-types";
2120
import { CourseActions } from "../actions";

0 commit comments

Comments
 (0)