pull/5370/head
Edson Alcala 4 years ago committed by Joseph Izang
parent 59fdd06139
commit d288233bed
  1. 17
      src/App.tsx
  2. 2
      src/AppContext.tsx
  3. 5
      src/views/HomeView.tsx

@ -38,7 +38,7 @@ const App = () => {
clientInstanceRef.current = clientInstance; clientInstanceRef.current = clientInstance;
const contractsRef = useRef(contracts); const contractsRef = useRef(contracts);
contractsRef.current = contracts; contractsRef.current = contracts;
const [themeType, setThemeType] = useState<string>("dark") const [themeType, setThemeType] = useState<string>("dark");
useEffect(() => { useEffect(() => {
console.log("Remix EthDoc loading..."); console.log("Remix EthDoc loading...");
@ -78,16 +78,15 @@ const App = () => {
} }
); );
const currentTheme = await client.call("theme", "currentTheme") const currentTheme = await client.call("theme", "currentTheme");
console.log("Current theme", currentTheme) console.log("Current theme", currentTheme);
setThemeType(currentTheme.brightness || currentTheme.quality) setThemeType(currentTheme.brightness || currentTheme.quality);
client.on("theme", "themeChanged", (theme: any) => { client.on("theme", "themeChanged", (theme: any) => {
console.log("themeChanged") console.log("themeChanged");
setThemeType(theme.quality) setThemeType(theme.quality);
}) });
}; };
loadClient(); loadClient();
@ -101,7 +100,7 @@ const App = () => {
setContracts, setContracts,
sites, sites,
setSites, setSites,
themeType themeType,
}} }}
> >
<Routes /> <Routes />

@ -16,5 +16,5 @@ export const AppContext = React.createContext({
setSites: (sites: PublishedSite[]) => { setSites: (sites: PublishedSite[]) => {
console.log("Calling Set Sites"); console.log("Calling Set Sites");
}, },
themeType: "dark" themeType: "dark",
}); });

@ -64,7 +64,10 @@ export const HomeView: React.FC = () => {
return ( return (
<AppContext.Consumer> <AppContext.Consumer>
{({ clientInstance, contracts, setContracts, themeType }) => ( {({ clientInstance, contracts, setContracts, themeType }) => (
<div id="ethdoc" style={{ color: themeType === "dark" ? "white" : "black" }}> <div
id="ethdoc"
style={{ color: themeType === "dark" ? "white" : "black" }}
>
{[...contracts.keys()].length === 0 && ( {[...contracts.keys()].length === 0 && (
<p>Compile a contract with Solidity Compiler</p> <p>Compile a contract with Solidity Compiler</p>
)} )}

Loading…
Cancel
Save