1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-22 17:23:22 +01:00

fix build

This commit is contained in:
Matthias Kretschmann 2018-06-24 20:53:15 +02:00
parent c9369dfa09
commit b881b297c4
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 24 additions and 15 deletions

View File

@ -17,12 +17,24 @@ class ThemeSwitch extends PureComponent {
constructor(props) {
super(props)
if (localStorage.getItem('dark') === 'true') {
this.state = { dark: true }
} else if (localStorage.getItem('dark') === 'false') {
this.state = { dark: null }
this.state = { dark: null }
}
isDark = () => this.state.dark === true
darkLocalStorageMode = darkLocalStorage => {
if (darkLocalStorage === 'true') {
this.setState({ dark: true })
} else {
this.state = { dark: null }
this.setState({ dark: false })
}
}
darkMode = now => {
if (!this.isDark() && (now >= 19 || now <= 7)) {
this.setState({ dark: true })
} else {
this.setState({ dark: null })
}
}
@ -30,18 +42,16 @@ class ThemeSwitch extends PureComponent {
const now = new Date().getHours()
const darkLocalStorage = localStorage.getItem('dark')
if (darkLocalStorage) return
if (now >= 19 || now <= 7) {
this.setState({ dark: true })
if (darkLocalStorage) {
this.darkLocalStorageMode(darkLocalStorage)
} else {
this.darkMode(now)
}
}
isDark = () => this.state.dark === true
handleChange = () => {
this.setState({ dark: !this.isDark() })
localStorage.setItem('dark', !this.isDark())
handleChange = event => {
this.setState({ dark: event.target.checked })
localStorage.setItem('dark', event.target.checked)
}
render() {

View File

@ -10,7 +10,6 @@ html,
body {
margin: 0;
padding: 0;
height: 100%;
}
html {