1
- import { makeStyles } from "@mui/styles" ;
2
1
import ChevronRightIcon from "@mui/icons-material/ChevronRight" ;
3
2
import ExpandMoreIcon from "@mui/icons-material/ExpandMore" ;
4
3
import TreeView from "@mui/lab/TreeView" ;
5
4
import TreeItem from "@mui/lab/TreeItem" ;
6
5
import Menu from "@mui/material/Menu" ;
7
6
import MenuItem from "@mui/material/MenuItem" ;
8
- import { CSSProperties , FC , useState } from "react" ;
7
+ import { type CSSProperties , type FC , useState } from "react" ;
8
+ import { css } from "@emotion/react" ;
9
9
import { FileTree } from "utils/filetree" ;
10
10
import { DockerIcon } from "components/Icons/DockerIcon" ;
11
11
import { colors } from "theme/colors" ;
@@ -35,7 +35,6 @@ export const FileTreeView: FC<{
35
35
fileTree : FileTree ;
36
36
activePath ?: string ;
37
37
} > = ( { fileTree, activePath, onDelete, onRename, onSelect } ) => {
38
- const styles = useStyles ( ) ;
39
38
const [ contextMenu , setContextMenu ] = useState < ContextMenu | undefined > ( ) ;
40
39
41
40
const buildTreeItems = (
@@ -60,9 +59,54 @@ export const FileTreeView: FC<{
60
59
nodeId = { currentPath }
61
60
key = { currentPath }
62
61
label = { filename }
63
- className = { `${ styles . fileTreeItem } ${
64
- currentPath === activePath ? "active" : ""
65
- } `}
62
+ css = { ( theme ) => css `
63
+ overflow : hidden;
64
+ user-select : none;
65
+
66
+ & : focus : not (.active ) > .MuiTreeItem-content {
67
+ background : ${ theme . palette . action . hover } ;
68
+ color : ${ theme . palette . text . primary } ;
69
+ }
70
+
71
+ & : not (: focus ): not (.active ) > .MuiTreeItem-content : hover {
72
+ background : ${ theme . palette . action . hover } ;
73
+ color : ${ theme . palette . text . primary } ;
74
+ }
75
+
76
+ & > .MuiTreeItem-content {
77
+ padding : ${ theme . spacing ( 0.25 , 2 ) } ;
78
+ color : ${ theme . palette . text . secondary } ;
79
+
80
+ & svg {
81
+ width : 16px ;
82
+ height : 16px ;
83
+ }
84
+
85
+ & > .muitreeitem-label {
86
+ margin-left : 4px ;
87
+ font-size : 13px ;
88
+ color : inherit;
89
+ }
90
+ }
91
+
92
+ & .active {
93
+ & > .MuiTreeItem-content {
94
+ color : ${ theme . palette . text . primary } ;
95
+ background : ${ colors . gray [ 13 ] } ;
96
+ pointer-events : none;
97
+ }
98
+ }
99
+
100
+ & .MuiTreeItem-group {
101
+ margin-left : 0 ;
102
+
103
+ // We need to find a better way to recursive padding here
104
+ & .MuiTreeItem-content {
105
+ padding-left : calc (var (--level ) * ${ theme . spacing ( 5 ) } );
106
+ }
107
+ }
108
+ ` }
109
+ className = { currentPath === activePath ? "active" : "" }
66
110
onClick = { ( ) => {
67
111
onSelect ( currentPath ) ;
68
112
} }
@@ -161,60 +205,6 @@ export const FileTreeView: FC<{
161
205
) ;
162
206
} ;
163
207
164
- const useStyles = makeStyles ( ( theme ) => ( {
165
- fileTreeItem : {
166
- overflow : "hidden" ,
167
- userSelect : "none" ,
168
-
169
- "&:focus:not(.active) > .MuiTreeItem-content" : {
170
- background : theme . palette . action . hover ,
171
- color : theme . palette . text . primary ,
172
- } ,
173
-
174
- "&:not(:focus):not(.active) > .MuiTreeItem-content:hover" : {
175
- background : theme . palette . action . hover ,
176
- color : theme . palette . text . primary ,
177
- } ,
178
-
179
- "& > .MuiTreeItem-content" : {
180
- padding : theme . spacing ( 0.25 , 2 ) ,
181
- color : theme . palette . text . secondary ,
182
-
183
- "& svg" : {
184
- width : 16 ,
185
- height : 16 ,
186
- } ,
187
-
188
- "& > .MuiTreeItem-label" : {
189
- marginLeft : 4 ,
190
- fontSize : 13 ,
191
- color : "inherit" ,
192
- } ,
193
- } ,
194
-
195
- "&.active" : {
196
- "& > .MuiTreeItem-content" : {
197
- color : theme . palette . text . primary ,
198
- background : colors . gray [ 13 ] ,
199
- pointerEvents : "none" ,
200
- } ,
201
- } ,
202
-
203
- "& .MuiTreeItem-group" : {
204
- marginLeft : 0 ,
205
-
206
- // We need to find a better way to recursive padding here
207
- "& .MuiTreeItem-content" : {
208
- paddingLeft : `calc(var(--level) * ${ theme . spacing ( 5 ) } )` ,
209
- } ,
210
- } ,
211
- } ,
212
- editor : {
213
- flex : 1 ,
214
- } ,
215
- preview : { } ,
216
- } ) ) ;
217
-
218
208
const FileTypeTerraform = ( ) => (
219
209
< svg xmlns = "http://www.w3.org/2000/svg" viewBox = "0 0 32 32" fill = "#813cf3" >
220
210
< title > file_type_terraform</ title >
0 commit comments