Skip to content

Commit

Permalink
dark mode enhanced
Browse files Browse the repository at this point in the history
  • Loading branch information
Rajesh-Royal committed Jun 20, 2021
1 parent 4e40666 commit a689029
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 6 additions & 2 deletions client/src/Components/common/DarkModeToggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const DarkModeToggle = () => {
useEffect(() => {
if (
localStorage.emp_theme === "dark" ||
(!("bid_Theme" in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches)
(!("emp_Theme" in localStorage) && window.matchMedia("(prefers-color-scheme: dark)").matches)
) {
document.documentElement.classList.add("dark");
setDark(true);
Expand All @@ -21,13 +21,17 @@ const DarkModeToggle = () => {
? document.documentElement.classList.add("dark")
: document.documentElement.classList.remove("dark");
};

useEffect(() => {
dark ? (localStorage.emp_theme = "dark") : (localStorage.emp_theme = "light");
}, [dark]);

return (
<button
type="button"
className="focus:outline-none"
onClick={() => {
setDark(!dark);
dark ? (localStorage.emp_theme = "dark") : (localStorage.emp_theme = "light");
setDarkMode();
}}
aria-label="Toggle color mode">
Expand Down
7 changes: 3 additions & 4 deletions client/src/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { ApolloClient, ApolloProvider, InMemoryCache } from "@apollo/client";
import React from "react";
import ReactDOM from "react-dom";
import { ApolloClient, InMemoryCache, ApolloProvider } from "@apollo/client";

import "./assets/global-css/tailwind.css";
import App from "./App";
import "./assets/global-css/tailwind.css";
import { projectData } from "./Data/data";

const client = new ApolloClient({
uri: projectData.graphqlServerLive,
uri: projectData.graphqlServerLocal,
cache: new InMemoryCache(),
});

Expand Down

0 comments on commit a689029

Please sign in to comment.