Skip to content

Eugene Reznik #5

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weather</title>
<link rel="stylesheet" href="style.css">
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script defer src="script.js"></script>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@300&display=swap" rel="stylesheet">
</head>
<body>
<section id="ios">
<h1>Current Weather</h1>
<input id="cityInput" type="text" placeholder="Enter valid city name">
<button id="submitButton">Submit</button>
<h2 id="cityName"></h2>
<div id="results">
<h2 id="cityTemp"></h2>
<img id="weatherIcon" src="" alt="">
</div>
</section>
<!-- <section id="tk">
<div><p>THE</p></div>
<div><p>TEMPERATURE</p></div>
<div><p>IN</p></div>
<input id="cityInput" type="text" placeholder="ENTER VALID CITY NAME">
<button id="submitButton">⏎</button>
<div><p>IS</p></div>
<div id="cityTemp"></div>
<div><p>BUT</p></div>
<div><p>IT</p></div>
<div><p>REALLY</p></div>
<div><p>FEELS</p></div>
<div><p>LIKE</p></div>
<div id="realFeel"></div>
<img id="weatherIcon" src="" alt="">
<img id="weatherIcon" src="" alt="">
<img id="weatherIcon" src="" alt="">
<h1>The Temperature In</h1>
<input id="cityInput" type="text" placeholder="Enter valid city name">
<button id="submitButton">⏎</button>
<h2 id="cityName"></h2>
<div id="results">
<h2 id="cityTemp">is</h2>
<img id="weatherIcon" src="" alt="">
</div>
</section> -->
</body>
</html>
27 changes: 27 additions & 0 deletions script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const apiKey = "fb24dfeacb134b2f96c220226230504";
const button = document.querySelector('button');
const cityInput = document.querySelector('input');
const cityName = document.querySelector('#cityName');
const cityTemp = document.querySelector('#cityTemp');
const weatherIcon = document.querySelector('#weatherIcon')

button.addEventListener('click',
async ()=>{
console.log('button clicked')
let city = cityInput.value;
let response = await axios.get(
`http://api.weatherapi.com/v1/current.json?key=${apiKey}&q=${city}&aqi=no`
)
let temp = response.data.current.temp_f;
let icon = response.data.current.condition.icon;
cityName.textContent = `The temperture in ${city} is:`;
// cityName.textContent = `Is:`;
cityTemp.textContent = `${temp}ºF`;
weatherIcon.setAttribute('src', icon)
// console.log(response.data.error.message)
// if (response.data.error.message = "No matching location found."){
// cityName.textContent = response.data.error.message
// }
}

)
39 changes: 39 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
section{
color: white;
text-align: center;
font-family: 'Open Sans', sans-serif;
max-width: 300px;
height: 300px;
margin: auto;
padding: 3rem;
margin-top: 10vh;
background-image: linear-gradient(rgb(36, 100, 230), rgb(46,206,242));
border-radius: 15px;
}
input , button{
background-color: white;
border-radius: 5px;
border: none;
padding: .5rem;
text-align: center;
}
#cityName{
font-size: 1rem;
margin-top: 2rem;
}
#cityTemp{
/* border: lightgrey solid 1px; */
/* width: fit-content; */
margin: auto;
padding: .5rem;
/* font-size: 2rem; */
}
#results{
display: flex;
width: fit-content;
margin: auto;
}

h1{
font-size: 2rem;
}