Skip to content

Commit

Permalink
forecast page finished
Browse files Browse the repository at this point in the history
  • Loading branch information
bdhsu committed Jan 14, 2019
1 parent b5a36ad commit 903f9f3
Show file tree
Hide file tree
Showing 23 changed files with 605 additions and 8 deletions.
35 changes: 34 additions & 1 deletion src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@ html {
body {
box-sizing: border-box;
font-size: 1.6rem;
font-family: -apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen-Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif;

}

.App {
background: linear-gradient(to left, #f2fcfe, #1c92d2);
/* background: linear-gradient(to left, #f2fcfe, #1c92d2); */
/* background: yellow; */
min-height: 100vh;
}
/* HEADER */
Expand Down Expand Up @@ -92,3 +95,33 @@ header {
color: white;
/* margin: 0 auto; */
}

/* Forecast */
/* Forecast */
/* Forecast */

.day-container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: space-around;
}

.day-item {
flex-direction: column;
padding: 50px;
justify-content: center;
align-items: center;
}

.day-pic {
display: block;
margin: 0 auto;
height: 100px;
}

.day-title {
display: flex;
font-size: 28px;
font-weight: 300;
}
11 changes: 11 additions & 0 deletions src/Day.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React, {Component} from 'react';

class Day extends Component {
render() {
return (

)
}
}

export default Day;
46 changes: 41 additions & 5 deletions src/Forecast.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import React, { Component } from 'react';
import queryString from 'query-string';
// components
import api from './utils/api';
import api from './utils/api';
import dateHelper from './utils/dateHelper';

const Day = (props) => {
var date = props.day.dt;
var pic = props.day.weather["0"].icon;
return (
<div className="day-item">
<img className="day-pic" src={require("./img/weather-icons/" + pic + ".svg")} alt="" />
<p className="day-title">{dateHelper.convertTimestamp(date)}</p>
</div>
)
}

class Forecast extends Component {
constructor(props) {
Expand Down Expand Up @@ -31,12 +43,22 @@ class Forecast extends Component {
return {
error: null,
location: location["city"],
weather: results.list["0"],
weather: results.list,
loading: false,
}
});
}.bind(this));
}

// handleClick(location) {
// console.log(JSON.stringify(location));
//
// this.props.history.push({
// pathname: 'forecast',
// search: '?city=' + location,
// });
// }

render() {
var error = this.state.error;
var location = this.state.location;
Expand All @@ -56,10 +78,24 @@ class Forecast extends Component {
}

return (


<div className="container">
{JSON.stringify(weather)}
{JSON.stringify(weather["0"])}
{/* {JSON.stringify(weather["0"])} */}
{/* {JSON.stringify(dateHelper.convertTimestamp(weather[0].dt))}
{JSON.stringify(dateHelper.convertTimestamp(weather[1].dt))}
{JSON.stringify(dateHelper.convertTimestamp(weather[2].dt))}
{JSON.stringify(dateHelper.convertTimestamp(weather[3].dt))}
{JSON.stringify(dateHelper.convertTimestamp(weather[4].dt))}
{JSON.stringify(dateHelper.convertTimestamp(weather[5].dt))}
{JSON.stringify(dateHelper.convertTimestamp(weather[6].dt))}
{JSON.stringify(dateHelper.convertTimestamp(weather[7].dt))}
{JSON.stringify(dateHelper.convertTimestamp(weather[8].dt))} */}
<div className="day-container">
{weather.map(function(day) {
return <Day day={day}/>
}, this)}
</div>

</div>
)
}
Expand Down
28 changes: 28 additions & 0 deletions src/img/weather-icons/01d.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions src/img/weather-icons/01n.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions src/img/weather-icons/02d.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions src/img/weather-icons/02n.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions src/img/weather-icons/03d.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/img/weather-icons/03n.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/img/weather-icons/04d.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions src/img/weather-icons/04n.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions src/img/weather-icons/09d.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 903f9f3

Please sign in to comment.