add stats card

This commit is contained in:
madarsbiss 2021-07-20 18:46:46 +03:00
parent 66119f2e86
commit 553096f8a1
52 changed files with 61 additions and 31 deletions

View File

@ -4,6 +4,7 @@ import Image from "next/image";
export default function Home() { export default function Home() {
const [input, setInput] = useState(); const [input, setInput] = useState();
const [defaultValue, setDefaultValue] = useState("Search a city...");
const [isCurrentActive, setIsCurrentActive] = useState(true); const [isCurrentActive, setIsCurrentActive] = useState(true);
const [weatherData, setWeatherData] = useState(); const [weatherData, setWeatherData] = useState();
@ -16,7 +17,9 @@ export default function Home() {
const data = await res.json(); const data = await res.json();
console.log(data); console.log(data);
setWeatherData({ ...data }); setWeatherData({ ...data });
setInput(""); setInput("");
// setDefaultValue("sss");
}; };
const something = (event) => { const something = (event) => {
@ -69,43 +72,59 @@ 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} to ${
weatherData.wind.gust
} ${degToCompass(weatherData.wind.deg)}`}
</p>
<p> <p>
Time:{" "} Time:{" "}
{new Date( {new Date(
weatherData.dt * 1000 + weatherData.timezone * 1000 weatherData.dt * 1000 + weatherData.timezone * 1000
).toLocaleString("en-US")} ).toLocaleString("en-US")}
</p> </p>
<p>Sunrise: {weatherData.sys.sunrise}</p>
<p>Sunstet: {weatherData.sys.sunset}</p>
</div> </div>
)} )}
<div className={styles.statsWrapper}> <div className={styles.statsWrapper}>
<h1>Stats info</h1> <input
<div className={styles.statsBox}> type="text"
<div>Stats card1</div> className={styles.searchInput}
<div>Stats card2</div> defaultValue={defaultValue}
<div>Stats card3</div> placeholder="🔍 Search a city ..."
<div>Stats card4</div> value={input}
<div>Stats card5</div> onFocus={(e) => (e.target.value = "")}
<div>Stats card6</div> onChange={(e) => setInput(e.target.value)}
</div> onKeyDown={(e) => something(e)}
/>
{weatherData && (
<div className={styles.statsBox}>
<div>Stats card1</div>
<div>Stats card2</div>
<div>Visibility: {weatherData.visibility / 1000} km</div>
<div>
<p>Humidity: {weatherData.main.humidity}</p>
</div>
<div>
<p>
Wind:{" "}
{` ${weatherData.wind.speed} ${degToCompass(
weatherData.wind.deg
)}`}
</p>
</div>
<div style={{ padding: "20px", border: "1px solid grey" }}>
<p>
Sunrise:{" "}
{new Date(
weatherData.sys.sunrise * 1000 + weatherData.timezone * 1000
).toLocaleString("en-US")}
</p>
<p>
Sunset:{" "}
{new Date(weatherData.sys.sunset * 1000).toLocaleString(
"en-US"
)}
</p>
</div>
</div>
)}
</div> </div>
<input
type="text"
className={styles.searchInput}
defaultValue="Search a cities..."
value={input}
onFocus={(e) => (e.target.value = "")}
onChange={(e) => setInput(e.target.value)}
onKeyDown={(e) => something(e)}
/>
</div> </div>
); );
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -8,7 +8,7 @@
backdrop-filter: blur(3px); backdrop-filter: blur(3px);
-webkit-backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
border-radius: 30px; border-radius: 30px;
border: 1px solid rgba(255, 255, 255, 0.18); /* border: 1px solid rgba(255, 255, 255, 0.18); */
display: grid; display: grid;
grid-template-columns: 1fr 2fr; grid-template-columns: 1fr 2fr;
} }
@ -30,14 +30,20 @@
.statsWrapper { .statsWrapper {
background-color: rgb(247, 247, 247); background-color: rgb(247, 247, 247);
padding: 30px; padding: 30px;
text-align: right;
border-radius: 0 30px 30px 0;
} }
.statsBox { .statsBox {
display: grid; display: grid;
grid-template-columns: 1fr 1fr 1fr; grid-template-columns: 1fr 1fr 1fr;
gap: 20px;
border-radius: 20px;
} }
.statsCard { .statsCard {
background: rgba(255, 255, 255, 0.95);
} }
.mainTemp { .mainTemp {
@ -45,12 +51,17 @@
} }
.searchInput { .searchInput {
margin-top: 200px; margin-bottom: 20px;
height: 40px; height: 40px;
width: 300px; width: 300px;
border: none; border: none;
padding: 0 10px; padding: 0 10px;
color: #242424; color: #c5c5c5;
/* background-color: none; */
font-size: 20px; font-size: 20px;
background: rgba(255, 255, 255, 0.25); text-align: right;
/* background-color: rgb(247, 247, 247); */
border-radius: 20px;
font-family: "Varela Round", sans-serif;
font-size: 18px;
} }