Skip to content

Commit f43f09a

Browse files
committed
add icon hover component
1 parent 5988c71 commit f43f09a

File tree

1 file changed

+100
-0
lines changed

1 file changed

+100
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
import React, { useState } from 'react'
2+
import { CustomTooltip } from '@remix-ui/helper'
3+
import { FormattedMessage } from 'react-intl'
4+
import { ROOT_PATH } from '../utils/constants'
5+
6+
export type FileHoverIconsProps = {
7+
hover: boolean
8+
isEditable: boolean
9+
file: any
10+
handleNewFolderOp: any
11+
handleNewFileOp: any
12+
renamePathOp: any
13+
deletePathOp: any
14+
}
15+
16+
export function FileHoverIcons(props: FileHoverIconsProps) {
17+
18+
return (
19+
<>
20+
{(props.hover && !props.isEditable) && <div className={`d-flex flex-row align-items-center`} style={{ marginLeft: '6rem' }}>
21+
{
22+
props.file.isDirectory ? (
23+
<>
24+
<CustomTooltip
25+
placement="right-start"
26+
delay={{show: 1000, hide: 0}}
27+
tooltipText={<FormattedMessage id="filePanel.edit" />}
28+
tooltipId={`filePanel.edit.${props.file.path}`}
29+
tooltipClasses="text-nowrap"
30+
>
31+
<span
32+
className="far fa-folder fa-1x remixui_icons_space remixui_icons"
33+
onClick={async (e) => {
34+
e.stopPropagation()
35+
console.log(props)
36+
await props.handleNewFolderOp(props.file.path)
37+
console.log('clicked on folder icon')
38+
}}
39+
></span>
40+
</CustomTooltip>
41+
<CustomTooltip
42+
placement="right-start"
43+
delay={{show: 1000, hide: 0}}
44+
tooltipText={<FormattedMessage id="fileExplorer.edit" />}
45+
tooltipId={`fileExplorer.edit.${props.file.path}`}
46+
tooltipClasses="text-nowrap"
47+
>
48+
<span
49+
className="far fa-file fa-1x remixui_icons remixui_icons_space"
50+
onClick={async (e) => {
51+
e.stopPropagation()
52+
await props.handleNewFileOp(props.file.path)
53+
console.log('clicked on file icon')
54+
}}
55+
></span>
56+
</CustomTooltip>
57+
</>
58+
) : null
59+
}
60+
<CustomTooltip
61+
placement="right-start"
62+
delay={{show: 1000, hide: 0}}
63+
tooltipText={<FormattedMessage id="fileExplorer.edit" />}
64+
tooltipId={`fileExplorer.edit.${props.file.path}`}
65+
tooltipClasses="text-nowrap"
66+
>
67+
<span
68+
className="far fa-pen fa-1x remixui_icons remixui_icons_space"
69+
onClick={async (e) => {
70+
e.stopPropagation()
71+
console.log(props)
72+
console.log(e)
73+
await props.renamePathOp(props.file.path, props.file.type)
74+
console.log('clicked on edit icon')
75+
}}
76+
></span>
77+
</CustomTooltip>
78+
<CustomTooltip
79+
placement="right-start"
80+
delay={{show: 1000, hide: 0}}
81+
tooltipText={<FormattedMessage id="fileExplorer.edit" />}
82+
tooltipId={`fileExplorer.edit.${props.file.path}`}
83+
tooltipClasses="text-nowrap"
84+
>
85+
<span
86+
className="far fa-trash fa-1x remixui_icons remixui_icons_space"
87+
onClick={async (e) => {
88+
e.stopPropagation()
89+
console.log(props)
90+
console.log(e)
91+
console.log('clicked on trash icon')
92+
await props.deletePathOp(props.file.path)
93+
}}
94+
></span>
95+
</CustomTooltip>
96+
</div>
97+
}
98+
</>
99+
)
100+
}

0 commit comments

Comments
 (0)