1
- import { CloseIcon , ArrowLeftIcon , RepeatIcon } from "@chakra-ui/icons" ;
2
- import { Accordion ,
1
+ import { CloseIcon , ArrowLeftIcon , RepeatIcon } from '@chakra-ui/icons' ;
2
+ import {
3
+ Accordion ,
3
4
AccordionItem ,
4
5
AccordionButton ,
5
6
Box ,
6
7
AccordionIcon ,
7
8
AccordionPanel ,
8
- IconButton
9
- } from "@chakra-ui/react" ;
10
- import { useContext , useEffect , useRef , useState } from "react" ;
11
- import { SearchContext } from "renderer/context/SearchContext" ;
12
- import Webview from "./Webview" ;
13
- import { AiOutlineLeft , AiOutlineRight , AiOutlineClose } from 'react-icons/ai' ;
14
-
15
-
16
- const BrowserCollapse = ( { name, tabUrl, tabId} ) => {
17
-
9
+ IconButton ,
10
+ } from '@chakra-ui/react' ;
11
+ import {
12
+ MouseEvent ,
13
+ MouseEvent ,
14
+ MouseEvent ,
15
+ useContext ,
16
+ useEffect ,
17
+ useRef ,
18
+ useState ,
19
+ } from 'react' ;
20
+ import { SearchContext } from 'renderer/context/SearchContext' ;
21
+ import { AiOutlineLeft , AiOutlineRight , AiOutlineClose } from 'react-icons/ai' ;
22
+ import Webview from './Webview' ;
23
+
24
+ const BrowserCollapse = ( { name, tabUrl, tabId } ) => {
18
25
const webviewRef = useRef ( ) ;
19
26
20
27
const [ collapseName , setCollapseName ] = useState ( name ) ;
21
28
29
+ const { closeTab } = useContext ( SearchContext ) ;
22
30
23
- const { closeTab} = useContext ( SearchContext ) ;
24
-
25
- const close = ( id ) => closeTab ( id ) ;
31
+ const close = ( id : any ) => closeTab ( id ) ;
26
32
27
-
28
- const back = ( e ) => {
33
+ const back = ( e : MouseEvent < HTMLButtonElement , MouseEvent > ) => {
29
34
e . preventDefault ( ) ;
30
- webviewRef . current . canGoBack ( ) && webviewRef . current . goBack ( )
31
- }
32
-
35
+ webviewRef . current . canGoBack ( ) && webviewRef . current . goBack ( ) ;
36
+ } ;
33
37
34
- const forward = ( e ) => {
38
+ const forward = ( e : MouseEvent < HTMLButtonElement , MouseEvent > ) => {
35
39
e . preventDefault ( ) ;
36
- webviewRef . current . canGoForward ( ) && webviewRef . current . goForward ( )
37
- }
40
+ webviewRef . current . canGoForward ( ) && webviewRef . current . goForward ( ) ;
41
+ } ;
38
42
39
- const refresh = ( e ) => {
43
+ const refresh = ( e : MouseEvent < HTMLButtonElement , MouseEvent > ) => {
40
44
e . preventDefault ( ) ;
41
- webviewRef . current . isLoading ( ) ? webviewRef . current . stop ( ) : webviewRef . current . reload ( ) ;
42
- }
45
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
46
+ webviewRef . current . isLoading ( )
47
+ ? webviewRef . current . stop ( )
48
+ : webviewRef . current . reload ( ) ;
49
+ } ;
43
50
44
51
const getTitle = ( ) => {
45
- if ( webviewRef . current === undefined ) {
52
+ if ( webviewRef . current === undefined ) {
46
53
return name ;
47
- } else {
48
- return webviewRef . current . getTitle ( ) ;
49
54
}
50
- }
55
+ return webviewRef . current . getTitle ( ) ;
56
+ } ;
51
57
return (
52
-
53
- < AccordionItem border = 'none' >
58
+ < AccordionItem border = "none" >
54
59
< h2 >
55
- < AccordionButton _expanded = { { bg : '#03c9d7' , color : 'white' } } >
60
+ < AccordionButton _expanded = { { bg : '#03c9d7' , color : 'white' } } >
56
61
< IconButton
57
- backgroundColor = '#32363e'
58
- _hover = { { bg : '#32363e' } }
59
- size = 'xs'
60
- onClick = { ( e ) => back ( e ) }
61
- icon = { < AiOutlineLeft _hover = { { color :'red' } } /> }
62
- />
63
- < Box flex = '1' textAlign = 'left' marginLeft = '5px' marginRight = '5px' >
64
- < p style = { { textAlign :'center' } } > { getTitle ( ) } </ p >
65
- </ Box >
66
- < IconButton
67
- backgroundColor = '#32363e'
68
- marginRight = '10px'
69
- _hover = { { bg : '#32363e' } }
70
- size = 'xs'
71
- onClick = { ( e ) => forward ( e ) }
72
- icon = { < AiOutlineRight _hover = { { color :'red' } } /> }
73
- />
74
- < IconButton
75
- backgroundColor = "#32363e"
76
- marginRight = '10px'
77
- _hover = { { bg : '#32363e' } }
78
- size = 'xs'
79
- onClick = { ( e ) => refresh ( e ) }
80
- icon = {
81
- < RepeatIcon
82
- _hover = { { color : 'yellow' } }
83
-
84
- />
85
- }
86
- />
87
- < IconButton
88
- backgroundColor = "#32363e"
89
- _hover = { { bg : '#32363e' } }
90
- size = 'xs'
91
- onClick = { ( ) => close ( tabId ) }
92
- icon = {
93
- < AiOutlineClose
94
- _hover = { { color : 'red' } }
95
-
96
- />
97
- }
98
- />
62
+ backgroundColor = "#32363e"
63
+ _hover = { { bg : '#32363e' } }
64
+ size = "xs"
65
+ onClick = { ( e ) => back ( e ) }
66
+ icon = { < AiOutlineLeft _hover = { { color : 'red' } } /> }
67
+ />
68
+ < Box flex = "1" textAlign = "left" marginLeft = "5px" marginRight = "5px" >
69
+ < p style = { { textAlign : 'center' } } > { getTitle ( ) } </ p >
70
+ </ Box >
71
+ < IconButton
72
+ backgroundColor = "#32363e"
73
+ marginRight = "10px"
74
+ _hover = { { bg : '#32363e' } }
75
+ size = "xs"
76
+ onClick = { ( e ) => forward ( e ) }
77
+ icon = { < AiOutlineRight _hover = { { color : 'red' } } /> }
78
+ />
79
+ < IconButton
80
+ backgroundColor = "#32363e"
81
+ marginRight = "10px"
82
+ _hover = { { bg : '#32363e' } }
83
+ size = "xs"
84
+ onClick = { ( e ) => refresh ( e ) }
85
+ icon = { < RepeatIcon _hover = { { color : 'yellow' } } /> }
86
+ />
87
+ < IconButton
88
+ backgroundColor = "#32363e"
89
+ _hover = { { bg : '#32363e' } }
90
+ size = "xs"
91
+ onClick = { ( ) => close ( tabId ) }
92
+ icon = { < AiOutlineClose _hover = { { color : 'red' } } /> }
93
+ />
99
94
100
95
< AccordionIcon />
101
96
</ AccordionButton >
@@ -109,8 +104,7 @@ const BrowserCollapse = ({name, tabUrl, tabId}) => {
109
104
/>
110
105
</ AccordionPanel >
111
106
</ AccordionItem >
112
- )
113
- }
114
-
107
+ ) ;
108
+ } ;
115
109
116
110
export default BrowserCollapse ;
0 commit comments