Fix compilation error in theme manager

pull/26/head
brogan20 2022-07-04 15:37:06 -04:00
parent 7cd1969dc3
commit 84e42afc09
2 changed files with 493 additions and 398 deletions

885
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
import React, { useState, useEffect } from "react"; import React, { useState, useEffect } from "react";
import axios from "axios"; import axios from "axios";
import Fuse from "fuse.js"; import Fuse from "fuse.js";
import { useCookies } from "react-cookie";
import queryString from "query-string"; import queryString from "query-string";
import LangFilters from "./components/LangFilters"; import LangFilters from "./components/LangFilters";
@ -68,6 +69,7 @@ function App() {
const [searchParams, setSearchParams] = useState({ searchTerm: defaultSearch, "lang.code": "" }); const [searchParams, setSearchParams] = useState({ searchTerm: defaultSearch, "lang.code": "" });
// array of all search results // array of all search results
const [searchResults, setSearchResults] = useState([]); const [searchResults, setSearchResults] = useState([]);
const [cookies, setCookie, ] = useCookies(["lightMode"]);
const [queries, setQueries] = useState({ lang: "", subject: "" }); const [queries, setQueries] = useState({ lang: "", subject: "" });
// eslint-disable-next-line // eslint-disable-next-line
@ -83,6 +85,7 @@ function App() {
// fetches data the first time the page renders // fetches data the first time the page renders
useEffect(() => { useEffect(() => {
swapMode(cookies.lightMode ? themes.lightMode : themes.darkMode);
async function fetchData() { async function fetchData() {
try { try {
setQueries(queryString.parse(document.location.search)); setQueries(queryString.parse(document.location.search));
@ -233,8 +236,7 @@ function App() {
<div className="wrapper"> <div className="wrapper">
<ThemeContext.Consumer> <ThemeContext.Consumer>
{({ changeTheme }) => { {({ changeTheme }) => {
let willBeDarkMode = (window.matchMedia && let willBeDarkMode = cookies.lightMode && cookies.lightMode.toLowerCase() !== "true"; //whether or not we are currently light mode and will become dark mode
window.matchMedia('(prefers-color-scheme: dark)').matches); //whether or not we are currently light mode and will become dark mode
changeTheme(willBeDarkMode ? themes.light : themes.dark); changeTheme(willBeDarkMode ? themes.light : themes.dark);
return ( return (
<img <img