56 lines
1.3 KiB
JavaScript
56 lines
1.3 KiB
JavaScript
|
import React, { Component } from 'react';
|
||
|
import Header from './components/Header';
|
||
|
import {
|
||
|
BrowserRouter as Router, Route,
|
||
|
Switch,
|
||
|
} from 'react-router-dom';
|
||
|
import Map from './components/Map';
|
||
|
import Vegetables from './components/Vegetables';
|
||
|
|
||
|
import './App.css';
|
||
|
|
||
|
class App extends Component {
|
||
|
constructor(props) {
|
||
|
super(props)
|
||
|
|
||
|
this.state = {
|
||
|
background: 1
|
||
|
}
|
||
|
|
||
|
this.changeBackground.bind = this.changeBackground();
|
||
|
}
|
||
|
|
||
|
changeBackground = () => {
|
||
|
setInterval(() => {
|
||
|
let currentBackground = this.state.background;
|
||
|
document.body.style.background = `url('/background/${currentBackground}.jpg') no-repeat fixed`;
|
||
|
document.body.style.backgroundSize = 'cover';
|
||
|
document.body.style.backgroundPosition = 'center center';
|
||
|
|
||
|
if (currentBackground === 4) {
|
||
|
currentBackground = 0
|
||
|
}
|
||
|
this.setState({
|
||
|
background: currentBackground + 1
|
||
|
})
|
||
|
}, 10000);
|
||
|
}
|
||
|
|
||
|
render() {
|
||
|
return (
|
||
|
<div className="App">
|
||
|
<Header></Header>
|
||
|
<Router>
|
||
|
<Switch>
|
||
|
<Route exact path="/" component={Map} />
|
||
|
<Route exact path="/vegetaux" component={Vegetables} />
|
||
|
<Route exact path="/vegetaux/:id-:slug" component={Vegetables} />
|
||
|
</Switch>
|
||
|
</Router>
|
||
|
</div>
|
||
|
);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default App;
|