-
Notifications
You must be signed in to change notification settings - Fork 0
Master #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: compare
Are you sure you want to change the base?
Master #1
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,12 @@ | ||
| .App { | ||
| text-align: center; | ||
| background-color: #282c34; | ||
| font-size: calc(10px + 2vmin); | ||
| color: white; | ||
| min-height: 100vh; | ||
|
|
||
|
|
||
|
|
||
|
Comment on lines
+7
to
+9
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove those extra lines
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there an extension called prettier, try to use |
||
| } | ||
|
|
||
| .App-logo { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,23 +1,15 @@ | ||
| import logo from './logo.svg'; | ||
| import './App.css'; | ||
|
|
||
| import Inputcity from './component/Inputcity'; | ||
| // import Weather from './component/Weather'; | ||
| //import Weatherrr from './component/Weatherrr'; | ||
| // import Wether from './component/Wether'; | ||
|
Comment on lines
+3
to
+5
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. don't leave commented code in your prod
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. here and everywhere in your code |
||
| function App() { | ||
| return ( | ||
| <div className="App"> | ||
| <header className="App-header"> | ||
| <img src={logo} className="App-logo" alt="logo" /> | ||
| <p> | ||
| Edit <code>src/App.js</code> and save to reload. | ||
| </p> | ||
| <a | ||
| className="App-link" | ||
| href="https://reactjs.org" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| > | ||
| Learn React | ||
| </a> | ||
| </header> | ||
| {/* <Wether /> */} | ||
| {/* <Weather /> */} | ||
| {/* <Weatherrr latt='29' long='44' /> */} | ||
| <Inputcity /> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,47 @@ | ||||||||||||||||||||||
| import React, { useState } from 'react' | ||||||||||||||||||||||
| import Time from './Time' | ||||||||||||||||||||||
| import Weatherrr from './Weatherrr' | ||||||||||||||||||||||
| const weather = require('openweather-apis'); | ||||||||||||||||||||||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't you use import here?
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| function Inputcity() { | ||||||||||||||||||||||
| const [cooord, setcooord] = useState({ lati: '51.5085', long: '-0.1257', cityy: 'London' }) | ||||||||||||||||||||||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. writing it like |
||||||||||||||||||||||
| const [city, setcity] = useState('London') | ||||||||||||||||||||||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you have a typo here
Suggested change
and maybe you can make it like this
Suggested change
|
||||||||||||||||||||||
| const submit = () => { | ||||||||||||||||||||||
| weather.setLang('en'); | ||||||||||||||||||||||
| weather.setCity(`${city}`); | ||||||||||||||||||||||
Mahmood83367 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
| weather.setUnits('metric'); | ||||||||||||||||||||||
| weather.setAPPID('f7d454f5834522dcb92bcf5d38a1db14'); | ||||||||||||||||||||||
Mahmood83367 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||
| weather.getAllWeather(function (err, info) { | ||||||||||||||||||||||
| if (err) { | ||||||||||||||||||||||
| alert('Input a valid City') | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+15
to
+17
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the error could be not just an invalid city, so you have to think about them all |
||||||||||||||||||||||
| else { | ||||||||||||||||||||||
| setcooord({ lati: info.coord.lat, long: info.coord.lon, cityy: info.name }) | ||||||||||||||||||||||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the city here is hard coded, you should make it variable |
||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+15
to
+20
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| }); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const loctate = () => { | ||||||||||||||||||||||
| navigator.geolocation.getCurrentPosition(function (position) { | ||||||||||||||||||||||
| setcooord({ lati: position.coords.latitude, long: position.coords.longitude, cityy: 'Mosul' }) | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| } | ||||||||||||||||||||||
| const cityhandler = (event) => { | ||||||||||||||||||||||
| setcity(event.target.value) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| return ( | ||||||||||||||||||||||
| <div> | ||||||||||||||||||||||
| <div> | ||||||||||||||||||||||
| <input type='text' value={city} onChange={cityhandler} autoFocus /> | ||||||||||||||||||||||
| <button onClick={submit}>OK</button> | ||||||||||||||||||||||
| <button onClick={loctate}>Loctate My Location</button> | ||||||||||||||||||||||
|
Comment on lines
+37
to
+39
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you have to activate the submit on enter |
||||||||||||||||||||||
| </div> | ||||||||||||||||||||||
| <Time /> | ||||||||||||||||||||||
| <Weatherrr lat={cooord.lati} long={cooord.long} cityName={cooord.cityy} /> | ||||||||||||||||||||||
| </div> | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| export default Inputcity | ||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| import React, { Component } from 'react'; | ||
|
|
||
|
|
||
| class Listing extends Component { | ||
|
|
||
| constructor(props) { | ||
| super(props) | ||
| this.state = { | ||
| records: [] | ||
| } | ||
| } | ||
|
|
||
| componentDidMount() { | ||
| fetch('https://jsonplaceholder.typicode.com/users') | ||
| .then(response => response.json()) | ||
| .then(records => { | ||
| this.setState({ | ||
| records: records | ||
| }) | ||
| }) | ||
| .catch(error => console.log(error)) | ||
| } | ||
|
|
||
| renderListing() { | ||
| let recordList = [] | ||
| this.state.records.map(record => { | ||
| return recordList.push(<li key={record.id}>{record.name}</li>) | ||
| }) | ||
|
|
||
| return recordList; | ||
| } | ||
|
|
||
| render() { | ||
| return ( | ||
| <ul> | ||
| {this.renderListing()} | ||
| </ul> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| export default Listing; |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,23 @@ | ||||||
| import React, { useState, useEffect } from 'react' | ||||||
| import moment from 'moment' | ||||||
|
|
||||||
| function Time() { | ||||||
| const [time, settime] = useState(moment().format('MMMM Do YYYY, h:mm:ss a')) | ||||||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
|
||||||
| const hanleTime = () => { | ||||||
| settime(moment().format('MMMM Do YYYY, h:mm:ss a')) | ||||||
| } | ||||||
| useEffect(() => { | ||||||
| const Timer = setInterval(hanleTime, 1000); | ||||||
| return () => { | ||||||
| clearInterval(Timer) | ||||||
| } | ||||||
| }, []) | ||||||
| return ( | ||||||
| <div> | ||||||
| {time} | ||||||
| </div> | ||||||
| ) | ||||||
| } | ||||||
|
|
||||||
| export default Time | ||||||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,26 @@ | ||||||||||
| import ReactWeather, { useOpenWeather } from 'react-open-weather'; | ||||||||||
| import React from 'react' | ||||||||||
|
|
||||||||||
|
|
||||||||||
| const Weatherrr = (props) => { | ||||||||||
| const { data, isLoading, errorMessage } = useOpenWeather({ | ||||||||||
| key: 'f7d454f5834522dcb92bcf5d38a1db14', | ||||||||||
| lat: `${props.lat}`, //lat | ||||||||||
| lon: `${props.long}`, //lon | ||||||||||
|
Comment on lines
+8
to
+9
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| lang: 'en', | ||||||||||
| unit: 'metric', // values are (metric, standard, imperial) | ||||||||||
| }); | ||||||||||
| return ( | ||||||||||
| <ReactWeather | ||||||||||
| isLoading={isLoading} | ||||||||||
| errorMessage={errorMessage} | ||||||||||
| data={data} | ||||||||||
| lang="en" | ||||||||||
| locationLabel={props.cityName} // town | ||||||||||
| unitsLabels={{ temperature: 'C', windSpeed: 'Km/h' } | ||||||||||
| } | ||||||||||
| showForecast | ||||||||||
| /> | ||||||||||
| ); | ||||||||||
| }; | ||||||||||
| export default Weatherrr | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove any dependency that you are not using
there something dependencies hell, try to read