Skip to content

Commit 7b7f4f4

Browse files
committed
add hover bug. add behaviour to click actions
1 parent 891556c commit 7b7f4f4

File tree

5 files changed

+34
-27
lines changed

5 files changed

+34
-27
lines changed

libs/remix-ui/workspace/src/lib/components/file-explorer-hovericons.tsx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ export type FileHoverIconsProps = {
88
file: any
99
handleNewFolderOp?: any
1010
handleNewFileOp?: any
11-
renamePathOp?: any
12-
deletePathOp?: any
11+
renamePathOp?: (path: string, newName: string) => void | Promise<void>
12+
deletePathOp?: (path: string | string[]) => void | Promise<void>
1313
}
1414

1515
export function FileHoverIcons(props: FileHoverIconsProps) {
@@ -31,9 +31,7 @@ export function FileHoverIcons(props: FileHoverIconsProps) {
3131
className="far fa-folder fa-1x remixui_icons_space remixui_icons"
3232
onClick={async (e) => {
3333
e.stopPropagation()
34-
console.log(props)
3534
await props.handleNewFolderOp(props.file.path)
36-
console.log('clicked on folder icon')
3735
}}
3836
></span>
3937
{/* </CustomTooltip> */}
@@ -49,7 +47,6 @@ export function FileHoverIcons(props: FileHoverIconsProps) {
4947
onClick={async (e) => {
5048
e.stopPropagation()
5149
await props.handleNewFileOp(props.file.path)
52-
console.log('clicked on file icon')
5350
}}
5451
></span>
5552
{/* </CustomTooltip> */}
@@ -67,10 +64,7 @@ export function FileHoverIcons(props: FileHoverIconsProps) {
6764
className="far fa-pen fa-1x remixui_icons remixui_icons_space"
6865
onClick={async (e) => {
6966
e.stopPropagation()
70-
console.log(props)
71-
console.log(e)
7267
await props.renamePathOp(props.file.path, props.file.type)
73-
console.log('clicked on edit icon')
7468
}}
7569
></span>
7670
{/* </CustomTooltip> */}
@@ -85,9 +79,6 @@ export function FileHoverIcons(props: FileHoverIconsProps) {
8579
className="far fa-trash fa-1x remixui_icons remixui_icons_space"
8680
onClick={async (e) => {
8781
e.stopPropagation()
88-
console.log(props)
89-
console.log(e)
90-
console.log('clicked on trash icon')
9182
await props.deletePathOp(props.file.path)
9283
}}
9384
></span>

libs/remix-ui/workspace/src/lib/components/file-explorer.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,11 @@ export const FileExplorer = (props: FileExplorerProps) => {
405405
moveFile={handleFileMove}
406406
moveFolder={handleFolderMove}
407407
handleClickFolder={handleClickFolder}
408-
createNewFile={handleNewFileInput}
409-
createNewFolder={handleNewFolderInput}
408+
createNewFile={props.createNewFile}
409+
createNewFolder={props.createNewFolder}
410+
deletePath={deletePath}
411+
renamePath={renamePath}
412+
editModeOn={props.editModeOn}
410413
/>
411414
</div>
412415
</div>

libs/remix-ui/workspace/src/lib/components/flat-tree.tsx

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ interface FlatTreeProps {
4141
createNewFile?: any
4242
createNewFolder?: any
4343
deletePath?: (path: string | string[]) => void | Promise<void>
44-
renamePath?: (path: string, newName: string) => void | Promise<void>
44+
renamePath?: (path: string, type: string, isNew?: boolean) => void
45+
editModeOn?: (path: string, type: string, isNew?: boolean) => void
4546
}
4647

4748
let mouseTimer: any = {
@@ -184,7 +185,19 @@ export const FlatTree = (props: FlatTreeProps) => {
184185
}
185186
}, [focusEdit])
186187

187-
const [onMouseEnter, setOnMouseEnter] = useState(false)
188+
const showIcons = (file: FileType) =>
189+
file.path === hover ? (
190+
<div>
191+
<FileHoverIcons
192+
file={file}
193+
isEditable={true}
194+
renamePathOp={props.editModeOn}
195+
deletePathOp={deletePath}
196+
handleNewFileOp={props.createNewFile}
197+
handleNewFolderOp={props.createNewFolder}
198+
/>
199+
</div>
200+
) : null
188201

189202
const Row = (index: number) => {
190203
const node = Object.keys(flatTree)[index]
@@ -193,17 +206,14 @@ export const FlatTree = (props: FlatTreeProps) => {
193206
<li
194207
className={`${labelClass(file)} li_tv`}
195208
onMouseOver={(e) => {
196-
console.log(e)
197209
setHover(file.path)
198210
}}
199211
onMouseOut={() => {
200-
setHover(file.path)
212+
setHover('')
201213
}}
202214
data-type={file.isDirectory ? 'folder' : 'file'}
203215
data-path={`${file.path}`}
204216
data-id={`treeViewLitreeViewItem${file.path}`}
205-
onMouseEnter={() => setOnMouseEnter(true)}
206-
onMouseLeave={() => setOnMouseEnter(false)}
207217
>
208218
<div data-id={`treeViewDivtreeViewItem${file.path}`} className={`d-flex flex-row align-items-center`}>
209219
{getIndentLevelDiv(file.path)}
@@ -222,16 +232,9 @@ export const FlatTree = (props: FlatTreeProps) => {
222232
data-label-path={`${file.path}`}
223233
key={index}>
224234
{file.name}
225-
226235
</div>
227236
<div className="d-flex flex-row align-items-center">
228-
{!onMouseEnter && (
229-
<div>
230-
<FileHoverIcons
231-
file={file}
232-
isEditable={true}
233-
/>
234-
</div>)}
237+
{showIcons(file)}
235238
{getFileStateIcons(file)}
236239
</div>
237240
</>

libs/remix-ui/workspace/src/lib/remix-ui-workspace.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,6 +1129,10 @@ export function Workspace() {
11291129
handleNewFileInput={handleNewFileInput}
11301130
handleNewFolderInput={handleNewFolderInput}
11311131
dragStatus={dragStatus}
1132+
createNewFile={handleNewFileInput}
1133+
createNewFolder={handleNewFolderInput}
1134+
deletePath={deletePath}
1135+
renamePath={editModeOn}
11321136
/>
11331137

11341138
)}
@@ -1188,7 +1192,10 @@ export function Workspace() {
11881192
editModeOn={editModeOn}
11891193
handleNewFileInput={handleNewFileInput}
11901194
handleNewFolderInput={handleNewFolderInput}
1195+
createNewFile={handleNewFileInput}
1196+
createNewFolder={handleNewFolderInput}
11911197
deletePath={deletePath}
1198+
renamePath={editModeOn}
11921199
dragStatus={dragStatus}
11931200
/>
11941201
)}

libs/remix-ui/workspace/src/lib/types/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ export interface FileExplorerProps {
131131
handleNewFileInput: (parentFolder?: string) => Promise<void>
132132
handleNewFolderInput: (parentFolder?: string) => Promise<void>
133133
deletePath?: (path: string[]) => Promise<void>
134+
createNewFile:(parentFolder?: string) => Promise<void>
135+
createNewFolder:(parentFolder?: string) => Promise<void>
136+
renamePath:(path: string, type: string, isNew?: boolean) => void
134137
dragStatus: (status: boolean) => void
135138
}
136139

0 commit comments

Comments
 (0)