1
- import React , { useState , useEffect } from "react" ;
1
+ import React , { useState , useEffect , useContext } from "react" ;
2
2
import { TabIdentifierClient } from "chrome-tab-identifier" ;
3
3
4
4
import SVG from "../SVG" ;
5
5
import TreeList from "../../containers/TreeList/TreeList" ;
6
6
import Resizer from "../../containers/Resizer" ;
7
+ import { OptionsContext } from "../../contexts/OptionsContext" ;
7
8
import { fetchURLDetails } from "../../utils/url" ;
8
9
import { switchTheme } from "../../utils/themeList" ;
9
10
import getHeaderBackgroundColor from "../../utils/backgroundColor" ;
@@ -22,7 +23,11 @@ function Pane({
22
23
reloading,
23
24
setReloading,
24
25
} ) {
26
+ const { options } = useContext ( OptionsContext ) ;
25
27
const [ tabId , setTabId ] = useState ( ) ;
28
+ const [ headerStyle , setHeaderStyle ] = useState (
29
+ getHeaderBackgroundColor ( options ) ,
30
+ ) ;
26
31
27
32
useEffect ( ( ) => {
28
33
tabIdClient . getTabId ( ) . then ( ( tab ) => {
@@ -45,10 +50,7 @@ function Pane({
45
50
return (
46
51
< div className = "spantree-tree-pane" style = { { width : width + "px" } } >
47
52
< div className = "spantree-pane-main" >
48
- < div
49
- className = "spantree-pane-header"
50
- style = { getHeaderBackgroundColor ( ) }
51
- >
53
+ < div className = "spantree-pane-header" style = { headerStyle } >
52
54
< div className = "spantree-spread" >
53
55
< div className = "spantree-pane-details" >
54
56
< SVG
@@ -59,7 +61,15 @@ function Pane({
59
61
{ URLDetails . dirFormatted }
60
62
</ div >
61
63
< div className = "spantree-pane-icons" >
62
- < span onClick = { switchTheme } className = "spantree-close-button" >
64
+ < span
65
+ onClick = { ( ) => {
66
+ switchTheme ( ) ;
67
+ setTimeout ( ( ) => {
68
+ setHeaderStyle ( getHeaderBackgroundColor ( options ) ) ;
69
+ } , 100 ) ;
70
+ } }
71
+ className = "spantree-close-button"
72
+ >
63
73
< SVG icon = "half" height = "9" />
64
74
</ span >
65
75
< span onClick = { toggleOpened } className = "spantree-close-button" >
0 commit comments