Commit 44f40f51 authored by ioedeveloper's avatar ioedeveloper Committed by GitHub

Highlight files on hover

parent fa1188e9
...@@ -55,7 +55,8 @@ export const FileExplorer = (props: FileExplorerProps) => { ...@@ -55,7 +55,8 @@ export const FileExplorer = (props: FileExplorerProps) => {
handleHide: null handleHide: null
}, },
modals: [], modals: [],
toasterMsg: '' toasterMsg: '',
mouseOverElement: null
}) })
const editRef = useRef(null) const editRef = useRef(null)
...@@ -858,6 +859,18 @@ export const FileExplorer = (props: FileExplorerProps) => { ...@@ -858,6 +859,18 @@ export const FileExplorer = (props: FileExplorerProps) => {
} }
} }
const handleMouseOver = (path: string) => {
setState(prevState => {
return { ...prevState, mouseOverElement: path }
})
}
const handleMouseOut = () => {
setState(prevState => {
return { ...prevState, mouseOverElement: null }
})
}
const label = (file: File) => { const label = (file: File) => {
return ( return (
<div <div
...@@ -901,9 +914,17 @@ export const FileExplorer = (props: FileExplorerProps) => { ...@@ -901,9 +914,17 @@ export const FileExplorer = (props: FileExplorerProps) => {
e.stopPropagation() e.stopPropagation()
handleContextMenuFolder(e.pageX, e.pageY, file.path, e.target.textContent) handleContextMenuFolder(e.pageX, e.pageY, file.path, e.target.textContent)
}} }}
labelClass={ state.focusEdit.element === file.path ? 'bg-light' : state.focusElement.findIndex(item => item.key === file.path) !== -1 ? 'bg-secondary' : '' } labelClass={ state.focusEdit.element === file.path ? 'bg-light' : state.focusElement.findIndex(item => item.key === file.path) !== -1 ? 'bg-secondary' : state.mouseOverElement === file.path ? 'bg-secondary' : (state.focusContext.element === file.path) && (state.focusEdit.element !== file.path) ? 'bg-secondary' : '' }
controlBehaviour={ state.ctrlKey } controlBehaviour={ state.ctrlKey }
expand={state.expandPath.includes(file.path)} expand={state.expandPath.includes(file.path)}
onMouseOver={(e) => {
e.stopPropagation()
handleMouseOver(file.path)
}}
onMouseOut={(e) => {
e.stopPropagation()
if (state.mouseOverElement === file.path) handleMouseOut()
}}
> >
{ {
file.child ? <TreeView id={`treeView${file.path}`} key={index}>{ file.child ? <TreeView id={`treeView${file.path}`} key={index}>{
...@@ -928,6 +949,10 @@ export const FileExplorer = (props: FileExplorerProps) => { ...@@ -928,6 +949,10 @@ export const FileExplorer = (props: FileExplorerProps) => {
pageY={state.focusContext.y} pageY={state.focusContext.y}
path={file.path} path={file.path}
type='folder' type='folder'
onMouseOver={(e) => {
e.stopPropagation()
handleMouseOver(file.path)
}}
/> />
} }
</div> </div>
...@@ -949,7 +974,15 @@ export const FileExplorer = (props: FileExplorerProps) => { ...@@ -949,7 +974,15 @@ export const FileExplorer = (props: FileExplorerProps) => {
handleContextMenuFile(e.pageX, e.pageY, file.path, e.target.textContent) handleContextMenuFile(e.pageX, e.pageY, file.path, e.target.textContent)
}} }}
icon='far fa-file' icon='far fa-file'
labelClass={ state.focusEdit.element === file.path ? 'bg-light' : state.focusElement.findIndex(item => item.key === file.path) !== -1 ? 'bg-secondary' : '' } labelClass={ state.focusEdit.element === file.path ? 'bg-light' : state.focusElement.findIndex(item => item.key === file.path) !== -1 ? 'bg-secondary' : state.mouseOverElement === file.path ? 'bg-secondary' : (state.focusContext.element === file.path) && (state.focusEdit.element !== file.path) ? 'bg-secondary' : '' }
onMouseOver={(e) => {
e.stopPropagation()
handleMouseOver(file.path)
}}
onMouseOut={(e) => {
e.stopPropagation()
if (state.mouseOverElement === file.path) handleMouseOut()
}}
/> />
{ ((state.focusContext.element === file.path) && (state.focusEdit.element !== file.path)) && { ((state.focusContext.element === file.path) && (state.focusEdit.element !== file.path)) &&
<FileExplorerContextMenu <FileExplorerContextMenu
...@@ -965,6 +998,10 @@ export const FileExplorer = (props: FileExplorerProps) => { ...@@ -965,6 +998,10 @@ export const FileExplorer = (props: FileExplorerProps) => {
pageY={state.focusContext.y} pageY={state.focusContext.y}
path={file.path} path={file.path}
type='file' type='file'
onMouseOver={(e) => {
e.stopPropagation()
handleMouseOver(file.path)
}}
/> />
} }
</div> </div>
......
...@@ -41,5 +41,6 @@ export interface FileExplorerContextMenuProps { ...@@ -41,5 +41,6 @@ export interface FileExplorerContextMenuProps {
pageX: number, pageX: number,
pageY: number, pageY: number,
path: string, path: string,
type: string type: string,
onMouseOver?: (...args) => void
} }
...@@ -10,6 +10,8 @@ export interface TreeViewItemProps { ...@@ -10,6 +10,8 @@ export interface TreeViewItemProps {
expand?: boolean, expand?: boolean,
onClick?: (...args: any) => void, onClick?: (...args: any) => void,
onInput?: (...args: any) => void, onInput?: (...args: any) => void,
onMouseOver?: (...args) => void,
onMouseOut?: (...args) => void,
className?: string, className?: string,
iconX?: string, iconX?: string,
iconY?: string, iconY?: string,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment