ui update

This commit is contained in:
madarsbiss 2021-07-18 01:37:20 +03:00
parent 2ecfe20416
commit 8af6a43b36
2 changed files with 22 additions and 24 deletions

View File

@ -13,6 +13,7 @@ export default function Home() {
body: JSON.stringify({ input }), body: JSON.stringify({ input }),
}); });
const data = await res.json(); const data = await res.json();
console.log(data);
setWeatherData({ ...data }); setWeatherData({ ...data });
setInput(""); setInput("");
}; };
@ -25,14 +26,14 @@ export default function Home() {
return ( return (
<div className={styles.wrapper}> <div className={styles.wrapper}>
{/* <h1>My weather app {input}</h1> */}
{weatherData && ( {weatherData && (
<> <>
<h1> <h1 className={styles.locationTitle}>
{weatherData.name}, {weatherData.sys.country} {weatherData.name}, {weatherData.sys.country}
</h1> </h1>
<p>{weatherData.weather[0].description}</p> <p className={styles.weatherDescription}>
{weatherData.weather[0].description}
</p>
<Image <Image
alt="weatherIcon" alt="weatherIcon"
src={`/icons/${weatherData.weather[0].icon}.svg`} src={`/icons/${weatherData.weather[0].icon}.svg`}
@ -44,20 +45,19 @@ export default function Home() {
{Math.round(weatherData.main.temp)}° {Math.round(weatherData.main.temp)}°
</h1> </h1>
<p>Feels like {Math.round(weatherData.main.feels_like)}°</p> <p>Feels like {Math.round(weatherData.main.feels_like)}°</p>
<p>Humidity: {weatherData.main.humidity}</p>
<p>Wind: {weatherData.wind.speed}</p>
</> </>
)} )}
<input <input
type="text" type="text"
className={styles.searchInput} className={styles.searchInput}
defaultValue="Search a city" defaultValue="Search a cities..."
value={input} value={input}
onFocus={(e) => (e.target.value = "")} onFocus={(e) => (e.target.value = "")}
onChange={(e) => setInput(e.target.value)} onChange={(e) => setInput(e.target.value)}
onKeyDown={(e) => something(e)} onKeyDown={(e) => something(e)}
/> />
<button className={styles.searchBtn} onClick={clickHandler}>
Search
</button>
</div> </div>
); );
} }

View File

@ -1,7 +1,6 @@
.wrapper { .wrapper {
max-width: 800px; max-width: 600px;
margin: 30px auto; margin: 30px auto;
/* border: 1px solid grey; */
text-align: center; text-align: center;
padding: 30px; padding: 30px;
background: rgba(255, 255, 255, 0.25); background: rgba(255, 255, 255, 0.25);
@ -12,28 +11,27 @@
border: 1px solid rgba(255, 255, 255, 0.18); border: 1px solid rgba(255, 255, 255, 0.18);
} }
.locationTitle {
font-size: 38px;
margin-bottom: 20px;
}
.weatherDescription {
font-size: 24px;
margin-bottom: 30px;
}
.mainTemp { .mainTemp {
font-size: 84px; font-size: 84px;
} }
.searchInput { .searchInput {
margin-top: 300px; margin-top: 200px;
height: 40px; height: 40px;
width: 300px; width: 300px;
border-radius: 5px; border: none;
border: 2px solid rgb(80, 80, 80);
background-color: #d3ddea;
padding: 0 10px; padding: 0 10px;
color: #242424; color: #242424;
font-size: 20px; font-size: 20px;
} background: rgba(255, 255, 255, 0.25);
.searchBtn {
background-color: limegreen;
width: 100px;
height: 40px;
border-radius: 5px;
font-size: 20px;
padding: 0 10px;
} }