-
Notifications
You must be signed in to change notification settings - Fork 0
/
Results.js
53 lines (47 loc) 路 1.63 KB
/
Results.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import React, { Component } from "react";
import { Link } from "react-router-dom";
import "./css/Results.css";
class Results extends Component {
render() {
console.log(this.props);
if (this.props.weatherInfo !== "") {
var weather = this.props.weatherInfo;
var city = weather.name;
var temp = Math.round(weather.main.temp);
var minTemp = Math.round(weather.main.temp_min);
var maxTemp = Math.round(weather.main.temp_max);
var status = weather.weather[0].main;
var description = weather.weather[0].description;
var backgroundColor = "";
if (temp > 70) {
backgroundColor = "hot"
} else if (temp < 50) {
backgroundColor = "cold"
} else {
backgroundColor = "warm"
}
return (
<div className={"results " + backgroundColor}>
<div className="resultsContainer">
<h1 className="temp">{temp}掳</h1>
<p className="status">{status}</p>
<p className="longText">In <span className="info">{city}</span> currently,
you will see <span className="info">{description}</span> if you happen to
look outside. The temperature will range between a low
of <span className="info">{minTemp}掳</span> and a
high of <span className="info">{maxTemp}掳</span>.</p>
</div>
<Link to="/">go back</Link>
</div>
);
} else {
return (
<div className="results error hot">
<h1>Something went wrong somewhere!</h1>
<Link to="/">go back</Link>
</div>
);
}
}
}
export default Results;