mirror of
https://github.com/kremalicious/portfolio.git
synced 2024-12-23 01:29:41 +01:00
fix build
This commit is contained in:
parent
c9369dfa09
commit
b881b297c4
@ -17,12 +17,24 @@ class ThemeSwitch extends PureComponent {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(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 {
|
} 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 now = new Date().getHours()
|
||||||
const darkLocalStorage = localStorage.getItem('dark')
|
const darkLocalStorage = localStorage.getItem('dark')
|
||||||
|
|
||||||
if (darkLocalStorage) return
|
if (darkLocalStorage) {
|
||||||
|
this.darkLocalStorageMode(darkLocalStorage)
|
||||||
if (now >= 19 || now <= 7) {
|
} else {
|
||||||
this.setState({ dark: true })
|
this.darkMode(now)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isDark = () => this.state.dark === true
|
handleChange = event => {
|
||||||
|
this.setState({ dark: event.target.checked })
|
||||||
handleChange = () => {
|
localStorage.setItem('dark', event.target.checked)
|
||||||
this.setState({ dark: !this.isDark() })
|
|
||||||
localStorage.setItem('dark', !this.isDark())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -10,7 +10,6 @@ html,
|
|||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
height: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
html {
|
html {
|
||||||
|
Loading…
Reference in New Issue
Block a user