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 ,
34 AccordionItem ,
45 AccordionButton ,
56 Box ,
67 AccordionIcon ,
78 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 } ) => {
1825 const webviewRef = useRef ( ) ;
1926
2027 const [ collapseName , setCollapseName ] = useState ( name ) ;
2128
29+ const { closeTab } = useContext ( SearchContext ) ;
2230
23- const { closeTab} = useContext ( SearchContext ) ;
24-
25- const close = ( id ) => closeTab ( id ) ;
31+ const close = ( id : any ) => closeTab ( id ) ;
2632
27-
28- const back = ( e ) => {
33+ const back = ( e : MouseEvent < HTMLButtonElement , MouseEvent > ) => {
2934 e . preventDefault ( ) ;
30- webviewRef . current . canGoBack ( ) && webviewRef . current . goBack ( )
31- }
32-
35+ webviewRef . current . canGoBack ( ) && webviewRef . current . goBack ( ) ;
36+ } ;
3337
34- const forward = ( e ) => {
38+ const forward = ( e : MouseEvent < HTMLButtonElement , MouseEvent > ) => {
3539 e . preventDefault ( ) ;
36- webviewRef . current . canGoForward ( ) && webviewRef . current . goForward ( )
37- }
40+ webviewRef . current . canGoForward ( ) && webviewRef . current . goForward ( ) ;
41+ } ;
3842
39- const refresh = ( e ) => {
43+ const refresh = ( e : MouseEvent < HTMLButtonElement , MouseEvent > ) => {
4044 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+ } ;
4350
4451 const getTitle = ( ) => {
45- if ( webviewRef . current === undefined ) {
52+ if ( webviewRef . current === undefined ) {
4653 return name ;
47- } else {
48- return webviewRef . current . getTitle ( ) ;
4954 }
50- }
55+ return webviewRef . current . getTitle ( ) ;
56+ } ;
5157 return (
52-
53- < AccordionItem border = 'none' >
58+ < AccordionItem border = "none" >
5459 < h2 >
55- < AccordionButton _expanded = { { bg : '#03c9d7' , color : 'white' } } >
60+ < AccordionButton _expanded = { { bg : '#03c9d7' , color : 'white' } } >
5661 < 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+ />
9994
10095 < AccordionIcon />
10196 </ AccordionButton >
@@ -109,8 +104,7 @@ const BrowserCollapse = ({name, tabUrl, tabId}) => {
109104 />
110105 </ AccordionPanel >
111106 </ AccordionItem >
112- )
113- }
114-
107+ ) ;
108+ } ;
115109
116110export default BrowserCollapse ;
0 commit comments