From 7deb989a108c319db83a7622876ad7eb11ed11cc Mon Sep 17 00:00:00 2001 From: madarsbiss Date: Tue, 20 Jul 2021 22:54:21 +0300 Subject: [PATCH] code cleanup --- pages/index.js | 68 ++++++++++++++---------------------------- styles/Home.module.css | 15 ++++++---- styles/globals.css | 1 + 3 files changed, 34 insertions(+), 50 deletions(-) diff --git a/pages/index.js b/pages/index.js index 1d7b55f..f022a6a 100644 --- a/pages/index.js +++ b/pages/index.js @@ -4,13 +4,14 @@ import Image from "next/image"; export default function Home() { const [input, setInput] = useState("mumbai"); + const [systemUsed, setSystemUsed] = useState("metric"); const [weatherData, setWeatherData] = useState(); const clickHandler = async () => { const res = await fetch("/api/data", { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ input }), + body: JSON.stringify({ input, systemUsed }), }); const data = await res.json(); console.log(data); @@ -55,6 +56,10 @@ export default function Home() { return time; }; + const changeSystem = () => { + console.log("system changed"); + }; + // console.log(convertTime(weatherData.dt, weatherData.timezone)); return ( @@ -64,6 +69,7 @@ export default function Home() {

{weatherData.name}, {weatherData.sys.country}

+

{weatherData.weather[0].description}

@@ -78,22 +84,25 @@ export default function Home() { {Math.round(weatherData.main.temp)}°

Feels like {Math.round(weatherData.main.feels_like)}°

- - {/*

- {convertTime(weatherData.dt, weatherData.timezone)[0].split(":")[0]} - :00 -

*/} )}
- (e.target.value = "")} - onChange={(e) => setInput(e.target.value)} - onKeyDown={(e) => something(e)} - /> +
+

+ Today at:{" "} + {convertTime(weatherData.dt, weatherData.timezone)[0].split(":")[0]} + :00 +

+ (e.target.value = "")} + onChange={(e) => setInput(e.target.value)} + onKeyDown={(e) => something(e)} + /> +
+ {weatherData && (
@@ -155,24 +164,6 @@ export default function Home() {
- {/*
- Visibility: {weatherData.visibility / 1000} km -
*/} - - {/*
-

- Wind:{" "} - {` ${weatherData.wind.speed} ${degToCompass( - weatherData.wind.deg - )}`} -

- weatherIcon -
*/}

Sunrise

@@ -194,19 +185,6 @@ export default function Home() {

AM

- - {/*

- Sunrise:{" "} - {new Date( - weatherData.sys.sunrise * 1000 + weatherData.timezone * 1000 - ).toLocaleString("en-US")} -

*/} - {/*

- Sunset:{" "} - {new Date(weatherData.sys.sunset * 1000).toLocaleString( - "en-US" - )} -

*/}

Sunset

diff --git a/styles/Home.module.css b/styles/Home.module.css index be74dd8..72788ae 100644 --- a/styles/Home.module.css +++ b/styles/Home.module.css @@ -32,11 +32,16 @@ border-radius: 0 30px 30px 0; } +.titleAndSearch { + display: grid; + grid-template-columns: 2fr 1fr; + gap: 20px; +} + .statsBox { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; - border-radius: 20px; } @@ -58,13 +63,13 @@ .searchInput { margin-bottom: 20px; height: 40px; - width: 200px; - border: 2px solid rgb(230, 230, 230); + border: 2px solid rgb(34, 34, 34); + /* border: none; */ padding: 0 10px; - color: #c5c5c5; + color: #303030; font-size: 20px; text-align: right; - border-radius: 20px; + border-radius: 3px; font-family: "Varela Round", sans-serif; font-size: 18px; } diff --git a/styles/globals.css b/styles/globals.css index 114c4ef..5e95c53 100644 --- a/styles/globals.css +++ b/styles/globals.css @@ -17,6 +17,7 @@ body { ); font-family: "Varela Round", sans-serif; min-height: 100vh; + padding-top: 50px; } a {