Skip to content

Commit 73d28d4

Browse files
authored
feat: revamped file tree (#1302)
- removed menu icon - file tree is now horizontally scrollable when there is long file names - added indent guide in file tree
1 parent 16fbd41 commit 73d28d4

File tree

5 files changed

+381
-307
lines changed

5 files changed

+381
-307
lines changed

src/components/sidebar/style.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,10 @@ body.no-animation {
124124
width: 100%;
125125
height: 100%;
126126

127+
&.files {
128+
overflow-x: auto;
129+
}
130+
127131
> .list {
128132
width: 100%;
129133
max-width: 100%;

src/lib/openFolder.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ function openFolder(_path, opts = {}) {
7272
}
7373

7474
const $root = collapsableList(title, "folder", {
75-
tail: <Tail target={() => $root.$title} />,
7675
allCaps: true,
7776
ontoggle: () => expandList($root),
7877
});
@@ -747,7 +746,6 @@ function appendList($target, $list) {
747746
*/
748747
function createFolderTile(name, url) {
749748
const $list = collapsableList(name, "folder", {
750-
tail: <Tail target={() => $list.$title} />,
751749
ontoggle: () => expandList($list),
752750
});
753751
const { $title } = $list;
@@ -768,7 +766,6 @@ function createFileTile(name, url) {
768766
const $tile = tile({
769767
lead: <span className={helpers.getIconForFile(name)}></span>,
770768
text: name,
771-
tail: <Tail target={() => $tile} />,
772769
});
773770
$tile.dataset.url = url;
774771
$tile.dataset.name = name;
@@ -783,22 +780,22 @@ function createFileTile(name, url) {
783780
* @param {HTMLElement} param0.target
784781
* @returns {HTMLElement}
785782
*/
786-
function Tail({ target }) {
787-
return (
788-
<span
789-
className="icon more_vert"
790-
attr-action="close"
791-
onclick={(e) => {
792-
e.stopPropagation();
793-
e.preventDefault();
794-
handleItems({
795-
target: target(),
796-
type: "contextmenu",
797-
});
798-
}}
799-
></span>
800-
);
801-
}
783+
// function Tail({ target }) {
784+
// return (
785+
// <span
786+
// className="icon more_vert"
787+
// attr-action="close"
788+
// onclick={(e) => {
789+
// e.stopPropagation();
790+
// e.preventDefault();
791+
// handleItems({
792+
// target: target(),
793+
// type: "contextmenu",
794+
// });
795+
// }}
796+
// ></span>
797+
// );
798+
// }
802799

803800
/**
804801
* Add file or folder to the list if expanded

src/sidebarApps/files/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ function initApp(el) {
2222
container = el;
2323
container.classList.add("files");
2424
container.setAttribute("data-msg", strings["open folder"]);
25+
container.style.overflowX = "auto";
2526
container.addEventListener("click", clickHandler);
2627
editorManager.on(
2728
["new-file", "int-open-file-list", "remove-file"],

src/sidebarApps/files/style.scss

Lines changed: 82 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,88 @@
1212
}
1313
}
1414

15-
.list .icon.more_vert {
16-
position: sticky;
17-
right: 0;
15+
/* Make the container horizontally scrollable */
16+
overflow-x: auto !important;
17+
max-width: 100%;
18+
19+
&::-webkit-scrollbar {
20+
height: 5px;
21+
width: 5px;
22+
}
23+
24+
&::-webkit-scrollbar-thumb {
25+
background-color: rgba(0, 0, 0, 0.3);
26+
border-radius: 3px;
27+
}
28+
29+
&::-webkit-scrollbar-corner {
30+
background: transparent;
31+
}
32+
33+
scrollbar-width: thin;
34+
scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
35+
36+
.list {
37+
min-width: 100%;
38+
width: max-content;
39+
max-width: none;
40+
}
41+
42+
ul {
43+
min-width: 100%;
44+
width: max-content;
45+
overflow-x: visible !important;
46+
max-width: none;
47+
margin-left: 0;
48+
&::-webkit-scrollbar-corner {
49+
background: transparent;
50+
}
1851
}
1952

20-
.tile:not(.light) .icon.more_vert::before {
21-
background-color: rgb(153, 153, 255);
22-
background-color: var(--primary-color);
23-
color: rgb(255, 255, 255);
24-
color: var(--primary-text-color);
25-
box-shadow: 0 0 5px 0 rgb(153, 153, 255);
26-
box-shadow: 0 0 5px 0 var(--primary-color);
53+
li {
54+
min-width: 100%;
55+
width: max-content;
56+
}
57+
58+
.tile {
59+
> .text {
60+
white-space: nowrap !important;
61+
overflow: visible !important;
62+
width: max-content !important;
63+
text-overflow: clip !important;
64+
}
65+
}
66+
67+
/* Add indent guides for folders (excluding first level) */
68+
.list.collapsible > ul > .collapsible > ul {
69+
position: relative;
70+
padding-left: 24px;
71+
72+
&::before {
73+
content: "";
74+
position: absolute;
75+
left: 14px;
76+
top: 0;
77+
height: 100%;
78+
width: 1px;
79+
background: var(--border-color);
80+
z-index: 0;
81+
}
82+
83+
/* Add guides for deeper nesting */
84+
.collapsible > ul {
85+
padding-left: 24px;
86+
87+
&::before {
88+
content: "";
89+
position: absolute;
90+
left: 14px;
91+
top: 0;
92+
height: 100%;
93+
width: 1px;
94+
background: var(--border-color);
95+
z-index: 0;
96+
}
97+
}
2798
}
28-
}
99+
}

0 commit comments

Comments
 (0)