Skip to content

Commit 89c5e3e

Browse files
committed
Dark Theme autocolor Correction
1 parent 01f2b4e commit 89c5e3e

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

content/src/scripts/components/Pane/Pane.jsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import React, { useState, useEffect } from "react";
1+
import React, { useState, useEffect, useContext } from "react";
22
import { TabIdentifierClient } from "chrome-tab-identifier";
33

44
import SVG from "../SVG";
55
import TreeList from "../../containers/TreeList/TreeList";
66
import Resizer from "../../containers/Resizer";
7+
import { OptionsContext } from "../../contexts/OptionsContext";
78
import { fetchURLDetails } from "../../utils/url";
89
import { switchTheme } from "../../utils/themeList";
910
import getHeaderBackgroundColor from "../../utils/backgroundColor";
@@ -22,7 +23,11 @@ function Pane({
2223
reloading,
2324
setReloading,
2425
}) {
26+
const { options } = useContext(OptionsContext);
2527
const [tabId, setTabId] = useState();
28+
const [headerStyle, setHeaderStyle] = useState(
29+
getHeaderBackgroundColor(options),
30+
);
2631

2732
useEffect(() => {
2833
tabIdClient.getTabId().then((tab) => {
@@ -45,10 +50,7 @@ function Pane({
4550
return (
4651
<div className="spantree-tree-pane" style={{ width: width + "px" }}>
4752
<div className="spantree-pane-main">
48-
<div
49-
className="spantree-pane-header"
50-
style={getHeaderBackgroundColor()}
51-
>
53+
<div className="spantree-pane-header" style={headerStyle}>
5254
<div className="spantree-spread">
5355
<div className="spantree-pane-details">
5456
<SVG
@@ -59,7 +61,15 @@ function Pane({
5961
{URLDetails.dirFormatted}
6062
</div>
6163
<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+
>
6373
<SVG icon="half" height="9" />
6474
</span>
6575
<span onClick={toggleOpened} className="spantree-close-button">

content/src/scripts/utils/backgroundColor.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
1-
import { useContext } from "react";
2-
3-
import { OptionsContext } from "../contexts/OptionsContext";
4-
5-
const getHeaderBackgroundColor = () => {
6-
const { options } = useContext(OptionsContext);
7-
1+
const getHeaderBackgroundColor = (options) => {
82
if ("auto-theme" in options && options["auto-theme"]) {
93
const fetchedValue = window
104
.getComputedStyle(document.querySelector("header"))

0 commit comments

Comments
 (0)