fix: improving theme jank
This commit is contained in:
@@ -4,21 +4,21 @@ import { compose } from "recompose"
|
|||||||
import styled from "@emotion/styled"
|
import styled from "@emotion/styled"
|
||||||
import { withTheme } from "emotion-theming"
|
import { withTheme } from "emotion-theming"
|
||||||
|
|
||||||
import { SIZES } from "./styles/constants"
|
import { SIZES } from "styles/constants"
|
||||||
|
|
||||||
// import theme from "./styles/theme"
|
// import theme from "./styles/theme"
|
||||||
import Navbar from "./components/Navbar"
|
|
||||||
import Day from "routes/Day"
|
import Day from "routes/Day"
|
||||||
import Month from "routes/Month"
|
import Month from "routes/Month"
|
||||||
import Year from "routes/Year"
|
import Year from "routes/Year"
|
||||||
import User from "routes/User"
|
import User from "routes/User"
|
||||||
import Search from "routes/Search"
|
import Search from "routes/Search"
|
||||||
import Welcome from "routes/Welcome"
|
import Welcome from "routes/Welcome"
|
||||||
import PrivateRoute from "./components/PrivateRoute"
|
|
||||||
|
|
||||||
import { OnlineContext } from "./components/context/online"
|
import Navbar from "components/Navbar"
|
||||||
import { withAuthentication } from "./components/session"
|
import PrivateRoute from "components/PrivateRoute"
|
||||||
import { withFirebase } from "./components/firebase"
|
import { OnlineContext } from "components/context/online"
|
||||||
|
import { withAuthentication } from "components/session"
|
||||||
|
import { withFirebase } from "components/firebase"
|
||||||
import ThemeTogglerContext from "components/context/theme"
|
import ThemeTogglerContext from "components/context/theme"
|
||||||
|
|
||||||
const FullscreenBgColor = styled.div`
|
const FullscreenBgColor = styled.div`
|
||||||
@@ -32,7 +32,6 @@ const RouteLayout = styled.div`
|
|||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
max-width: ${SIZES.maxWidth};
|
max-width: ${SIZES.maxWidth};
|
||||||
min-height: calc(100vh - 60px);
|
min-height: calc(100vh - 60px);
|
||||||
background-color: transparent;
|
|
||||||
`
|
`
|
||||||
|
|
||||||
class App extends Component {
|
class App extends Component {
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ const Container = styled.div`
|
|||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
max-width: ${SIZES.maxWidth};
|
max-width: ${SIZES.maxWidth};
|
||||||
min-height: calc(100vh - 60px);
|
min-height: calc(100vh - 60px);
|
||||||
background-color: ${props => props.theme.colors.bodyBackground};
|
|
||||||
`
|
`
|
||||||
|
|
||||||
export default Container
|
export default Container
|
||||||
|
|||||||
@@ -17,11 +17,21 @@ class ThemeToggler extends React.Component {
|
|||||||
: "DARK",
|
: "DARK",
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle = () => {
|
componentDidMount() {
|
||||||
|
// set the body style property on mount so routes don't flash between transitions
|
||||||
|
const { themeName } = this.state
|
||||||
|
this.toggle(themeName)
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle = newThemeName => {
|
||||||
const { themeName } = this.state
|
const { themeName } = this.state
|
||||||
const body = document.body
|
const body = document.body
|
||||||
let newTheme
|
let newTheme
|
||||||
|
if (newThemeName) {
|
||||||
|
newTheme = newThemeName
|
||||||
|
} else {
|
||||||
newTheme = themeName === "LIGHT" ? "DARK" : "LIGHT"
|
newTheme = themeName === "LIGHT" ? "DARK" : "LIGHT"
|
||||||
|
}
|
||||||
body.style.setProperty(
|
body.style.setProperty(
|
||||||
"background-color",
|
"background-color",
|
||||||
theme[newTheme].colors.bodyBackground
|
theme[newTheme].colors.bodyBackground
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
|
|
||||||
import App from "../App"
|
import App from "components/App"
|
||||||
import Layout from "components/Layout"
|
import Layout from "components/Layout"
|
||||||
|
|
||||||
/* similar to create-react-app, the App.js is like the
|
/* similar to create-react-app, the App.js is like the
|
||||||
|
|||||||
Reference in New Issue
Block a user