2018-11-18 15:47:54 +01:00
|
|
|
import React, { Component } from 'react';
|
2018-11-18 19:03:01 +01:00
|
|
|
import Header from './Header';
|
2018-11-18 15:47:54 +01:00
|
|
|
import {
|
|
|
|
BrowserRouter as Router, Route,
|
|
|
|
Switch,
|
|
|
|
} from 'react-router-dom';
|
2018-11-18 19:53:29 +01:00
|
|
|
import Map from '../Routes/Map';
|
|
|
|
import Home from '../Routes/Home';
|
|
|
|
import Vegetables from '../Routes/Vegetables';
|
2018-11-18 15:47:54 +01:00
|
|
|
|
|
|
|
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>
|
2018-11-18 19:03:01 +01:00
|
|
|
<Route exact path="/" component={Home} />
|
|
|
|
<Route exact path="/carte" component={Map} />
|
2018-11-18 19:53:29 +01:00
|
|
|
<Route exact path="/vegetaux/:typeId-:typeSlug" component={Vegetables} />
|
2018-11-18 15:47:54 +01:00
|
|
|
</Switch>
|
|
|
|
</Router>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default App;
|