Skip to content

Commit 065b79d

Browse files
committed
file listing: more work eliminating react-bootstrap
1 parent 06a6680 commit 065b79d

File tree

2 files changed

+63
-43
lines changed

2 files changed

+63
-43
lines changed

src/packages/frontend/project/explorer/file-listing/file-row.tsx

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

6-
import { Button, Popover } from "antd";
6+
import { Button, Popover, Col, Row } from "antd";
77
import memoizeOne from "memoize-one";
8-
// tricky to convert to antd due to use of smPull and smPush
9-
import { Col, Row } from "react-bootstrap";
108
import { CSS, React, useState } from "@cocalc/frontend/app-framework";
11-
import { Icon, IconName, TimeAgo, Tip } from "@cocalc/frontend/components";
9+
import {
10+
Icon,
11+
IconName,
12+
TimeAgo,
13+
Tip,
14+
VisibleXS,
15+
} from "@cocalc/frontend/components";
1216
import { useStudentProjectFunctionality } from "@cocalc/frontend/course";
1317
import { file_options } from "@cocalc/frontend/editor-tmp";
1418
import { should_open_in_foreground } from "@cocalc/frontend/lib/should-open-in-foreground";
@@ -202,7 +206,7 @@ export const FileRow: React.FC<Props> = React.memo((props) => {
202206
props.actions.open_file({
203207
path,
204208
foreground,
205-
explicit:true,
209+
explicit: true,
206210
});
207211
if (foreground) {
208212
props.actions.set_file_search("");
@@ -339,7 +343,7 @@ export const FileRow: React.FC<Props> = React.memo((props) => {
339343
onMouseDown={handle_mouse_down}
340344
className={props.no_select ? "noselect" : undefined}
341345
>
342-
<Col sm={1} xs={1} style={{ textAlign: "center" }}>
346+
<Col sm={2} xs={6} style={{ textAlign: "center" }}>
343347
{!student_project_functionality.disableActions && (
344348
<FileCheckbox
345349
name={props.name}
@@ -350,13 +354,22 @@ export const FileRow: React.FC<Props> = React.memo((props) => {
350354
/>
351355
)}
352356
</Col>
353-
<Col sm={1} xs={1} style={{ textAlign: "center" }}>
357+
<Col sm={2} xs={6} style={{ textAlign: "center" }}>
354358
{render_public_file_info()}
355359
</Col>
356-
<Col sm={1} xs={3} onClick={handle_click}>
360+
<Col sm={2} xs={12} onClick={handle_click}>
357361
{render_icon()}
358362
</Col>
359-
<Col sm={4} smPush={5} xs={6}>
363+
<Col sm={10} xs={24} onClick={handle_click}>
364+
<VisibleXS>
365+
<span style={{ marginLeft: "16px" }} />
366+
</VisibleXS>
367+
{render_name()}
368+
</Col>
369+
<Col sm={8} xs={24}>
370+
<VisibleXS>
371+
<span style={{ marginLeft: "16px" }} />
372+
</VisibleXS>
360373
{render_timestamp()}
361374
{props.isdir ? (
362375
<>
@@ -369,9 +382,6 @@ export const FileRow: React.FC<Props> = React.memo((props) => {
369382
</span>
370383
)}
371384
</Col>
372-
<Col sm={5} smPull={4} xs={12} onClick={handle_click}>
373-
{render_name()}
374-
</Col>
375385
</Row>
376386
);
377387
});

src/packages/frontend/project/explorer/file-listing/listing-header.tsx

Lines changed: 41 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@
55

66
import React from "react";
77
import { TypedMap } from "@cocalc/frontend/app-framework";
8-
import { Icon, Gap } from "@cocalc/frontend/components";
9-
// tricky to convert to antd due to use of smPull and smPush
10-
import { Col, Row } from "react-bootstrap";
8+
import { Icon, Gap, VisibleMDLG } from "@cocalc/frontend/components";
9+
import { Col, Row } from "antd";
1110

1211
// TODO: Flatten active_file_sort for easy PureComponent use
1312
interface Props {
@@ -30,45 +29,56 @@ const inner_icon_style = { marginRight: "10px" };
3029
export const ListingHeader: React.FC<Props> = (props: Props) => {
3130
const { active_file_sort, sort_by } = props;
3231

33-
function render_sort_link(column_name: string, display_name: string) {
32+
function render_sort_link(
33+
column_name: string,
34+
display_name: string,
35+
marginLeft?,
36+
) {
3437
return (
35-
<a
36-
href=""
37-
onClick={(e) => {
38-
e.preventDefault();
39-
return sort_by(column_name);
40-
}}
41-
style={{ color: "#428bca", fontWeight: "bold" }}
42-
>
43-
{display_name}
44-
<Gap />
45-
{active_file_sort.get("column_name") === column_name ? (
46-
<Icon
47-
style={inner_icon_style}
48-
name={
49-
active_file_sort.get("is_descending") ? "caret-up" : "caret-down"
50-
}
51-
/>
52-
) : undefined}
53-
</a>
38+
<span>
39+
<VisibleMDLG>
40+
<span style={{ marginLeft }} />
41+
</VisibleMDLG>
42+
<a
43+
href=""
44+
onClick={(e) => {
45+
e.preventDefault();
46+
return sort_by(column_name);
47+
}}
48+
style={{ color: "#428bca", fontWeight: "bold" }}
49+
>
50+
{display_name}
51+
<Gap />
52+
{active_file_sort.get("column_name") === column_name ? (
53+
<Icon
54+
style={inner_icon_style}
55+
name={
56+
active_file_sort.get("is_descending")
57+
? "caret-up"
58+
: "caret-down"
59+
}
60+
/>
61+
) : undefined}
62+
</a>
63+
</span>
5464
);
5565
}
5666

5767
return (
5868
<Row style={row_style}>
59-
<Col sm={2} xs={3} />
60-
<Col sm={1} xs={3}>
61-
{render_sort_link("type", "Type")}
69+
<Col sm={4} xs={6} />
70+
<Col sm={2} xs={6}>
71+
{render_sort_link("type", "Type", "-4px")}
6272
</Col>
63-
<Col sm={4} smPush={5} xs={6}>
64-
{render_sort_link("time", "Date Modified")}
73+
<Col sm={10} xs={24}>
74+
{render_sort_link("name", "Name", "-4px")}
75+
</Col>
76+
<Col sm={8} xs={12}>
77+
{render_sort_link("time", "Date Modified", "2px")}
6578
<span className="pull-right">
6679
{render_sort_link("size", "Size/Download/View")}
6780
</span>
6881
</Col>
69-
<Col sm={5} smPull={4} xs={12}>
70-
{render_sort_link("name", "Name")}
71-
</Col>
7282
</Row>
7383
);
7484
};

0 commit comments

Comments
 (0)