fix: style flashes, app start_url, and quotes

This commit is contained in:
Kyle Gill
2019-05-29 22:36:24 -06:00
parent 4ebe1ec1de
commit 5d46b17eef
3 changed files with 22 additions and 3 deletions

View File

@@ -17,10 +17,21 @@ class ThemeToggler extends React.Component {
: "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 body = document.body
const newTheme = themeName === "LIGHT" ? "DARK" : "LIGHT"
let newTheme
if (newThemeName) {
newTheme = newThemeName
} else {
newTheme = themeName === "LIGHT" ? "DARK" : "LIGHT"
}
body.style.setProperty(
"background-color",
theme[newTheme].colors.bodyBackground