fix the dark mode so it shows up on popups
This commit is contained in:
parent
283bd5f8fb
commit
884f600d3e
18
src/App.js
18
src/App.js
@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useCallback} from 'react';
|
import React, { useState, useCallback, useEffect } from 'react';
|
||||||
import { Router, Switch, Route, Redirect } from 'react-router-dom';
|
import { Router, Switch, Route, Redirect } from 'react-router-dom';
|
||||||
import * as BS from 'react-bootstrap'
|
import * as BS from 'react-bootstrap'
|
||||||
|
|
||||||
@ -24,8 +24,20 @@ export default function App() {
|
|||||||
const [, updateState] = useState();
|
const [, updateState] = useState();
|
||||||
const forceUpdate = useCallback(() => updateState({}), []);
|
const forceUpdate = useCallback(() => updateState({}), []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (localStorage.getItem("pk-darkmode")) {
|
||||||
|
localStorage.removeItem("pk-darkmode");
|
||||||
|
document.body.classList.add('dark-mode')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
localStorage.setItem("pk-darkmode", "true");
|
||||||
|
document.body.classList.remove('dark-mode')
|
||||||
|
}
|
||||||
|
forceUpdate();
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={ `contents ${localStorage.getItem('opendyslexic') ? "opendyslexic" : ""} ${localStorage.getItem("pk-darkmode") ? "dark-mode" : ""}`}>
|
<div className={ `contents ${localStorage.getItem('opendyslexic') ? "opendyslexic" : ""}`}>
|
||||||
<Router history={history}>
|
<Router history={history}>
|
||||||
<Navbar forceUpdate={forceUpdate} setIsSubmit={setIsSubmit} />
|
<Navbar forceUpdate={forceUpdate} setIsSubmit={setIsSubmit} />
|
||||||
<div className="content">
|
<div className="content">
|
||||||
@ -36,7 +48,7 @@ export default function App() {
|
|||||||
}
|
}
|
||||||
</Route>
|
</Route>
|
||||||
<Route exact path="/">
|
<Route exact path="/">
|
||||||
<Home isLoading={isLoading} setIsLoading={setIsLoading} isSubmit={isSubmit} setIsSubmit={setIsSubmit} isInvalid={isInvalid} setIsInvalid={setIsInvalid}/>
|
<Home forceUpdate={forceUpdate} isLoading={isLoading} setIsLoading={setIsLoading} isSubmit={isSubmit} setIsSubmit={setIsSubmit} isInvalid={isInvalid} setIsInvalid={setIsInvalid}/>
|
||||||
</Route>
|
</Route>
|
||||||
<Route path="/profile">
|
<Route path="/profile">
|
||||||
<Public />
|
<Public />
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
|
|
||||||
import * as BS from 'react-bootstrap'
|
import * as BS from 'react-bootstrap'
|
||||||
import Toggle from 'react-toggle'
|
import Toggle from 'react-toggle'
|
||||||
@ -9,9 +9,14 @@ import history from "../History.js";
|
|||||||
const Navbar = ({ setIsSubmit, forceUpdate}) => {
|
const Navbar = ({ setIsSubmit, forceUpdate}) => {
|
||||||
|
|
||||||
function toggleDarkMode() {
|
function toggleDarkMode() {
|
||||||
if (localStorage.getItem("pk-darkmode"))
|
if (localStorage.getItem("pk-darkmode")) {
|
||||||
localStorage.removeItem("pk-darkmode");
|
localStorage.removeItem("pk-darkmode");
|
||||||
else localStorage.setItem("pk-darkmode", "true");
|
document.body.classList.add('dark-mode')
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
localStorage.setItem("pk-darkmode", "true");
|
||||||
|
document.body.classList.remove('dark-mode')
|
||||||
|
}
|
||||||
forceUpdate();
|
forceUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -29,7 +29,6 @@ html, body {
|
|||||||
|
|
||||||
.dark-mode {
|
.dark-mode {
|
||||||
background-color: $gray-800;
|
background-color: $gray-800;
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-header {
|
.card-header {
|
||||||
@ -50,13 +49,11 @@ html, body {
|
|||||||
.dark-mode .card-body {
|
.dark-mode .card-body {
|
||||||
color: $white;
|
color: $white;
|
||||||
background-color: $gray-800;
|
background-color: $gray-800;
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark-mode .card-header {
|
.dark-mode .card-header {
|
||||||
color: $gray-100 !important;
|
color: $gray-100 !important;
|
||||||
background-color: $gray-900 !important;
|
background-color: $gray-900 !important;
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.navbar {
|
.navbar {
|
||||||
@ -68,7 +65,6 @@ html, body {
|
|||||||
.dark-mode .navbar {
|
.dark-mode .navbar {
|
||||||
color: $gray-100;
|
color: $gray-100;
|
||||||
background-color: $gray-900;
|
background-color: $gray-900;
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark-mode .navbar-brand {
|
.dark-mode .navbar-brand {
|
||||||
@ -83,14 +79,12 @@ html, body {
|
|||||||
color: $gray-200;
|
color: $gray-200;
|
||||||
border-color: #191c1f;
|
border-color: #191c1f;
|
||||||
background-color: $gray-900;
|
background-color: $gray-900;
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark-mode .form-control:disabled {
|
.dark-mode .form-control:disabled {
|
||||||
color: $gray-600;
|
color: $gray-600;
|
||||||
border-color: #191c1f;
|
border-color: #191c1f;
|
||||||
background-color: $gray-900;
|
background-color: $gray-900;
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark-mode .form-control:focus {
|
.dark-mode .form-control:focus {
|
||||||
@ -148,21 +142,18 @@ html, body {
|
|||||||
color: $white;
|
color: $white;
|
||||||
background-color: $danger;
|
background-color: $danger;
|
||||||
border: $gray-900;
|
border: $gray-900;
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark-mode .alert-primary {
|
.dark-mode .alert-primary {
|
||||||
color: $white;
|
color: $white;
|
||||||
background-color: $primary;
|
background-color: $primary;
|
||||||
border: $gray-900;
|
border: $gray-900;
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dark-mode .alert-light {
|
.dark-mode .alert-light {
|
||||||
color: $white;
|
color: $white;
|
||||||
background-color: $gray-900;
|
background-color: $gray-900;
|
||||||
border: #191c1f;
|
border: #191c1f;
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
code {
|
code {
|
||||||
@ -177,7 +168,6 @@ code {
|
|||||||
.dark-mode code {
|
.dark-mode code {
|
||||||
color: white !important;
|
color: white !important;
|
||||||
background-color: $gray-900;
|
background-color: $gray-900;
|
||||||
transition: background-color 0.3s ease;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pre {
|
pre {
|
||||||
|
Loading…
Reference in New Issue
Block a user