diff --git a/components/MainCard.js b/components/MainCard.js new file mode 100644 index 0000000..4450df6 --- /dev/null +++ b/components/MainCard.js @@ -0,0 +1,47 @@ +import Image from "next/image"; + +import { ctoF } from "../services/converters"; + +import styles from "./MainCard.module.css"; + +const MainCard = ({ + city, + country, + description, + iconName, + systemUsed, + weatherData, +}) => { + return ( +
+

+ {city}, {country} +

+ +

{description}

+ + weatherIcon + +

+ {systemUsed == "metric" + ? Math.round(weatherData.main.temp) + : Math.round(ctoF(weatherData.main.temp))} + °{systemUsed == "metric" ? "C" : "F"} +

+

+ Feels like{" "} + {systemUsed == "metric" + ? Math.round(weatherData.main.feels_like) + : Math.round(ctoF(weatherData.main.feels_like))} + °{systemUsed == "metric" ? "C" : "F"} +

+
+ ); +}; + +export default MainCard; diff --git a/components/MainCard.module.css b/components/MainCard.module.css new file mode 100644 index 0000000..e13d112 --- /dev/null +++ b/components/MainCard.module.css @@ -0,0 +1,17 @@ +.weatherWrapper { + padding: 30px; +} + +.locationTitle { + font-size: 38px; + margin-bottom: 10px; +} + +.weatherDescription { + font-size: 24px; + margin-bottom: 20px; +} + +.mainTemp { + font-size: 84px; +} diff --git a/pages/index.js b/pages/index.js index f7a5165..5e9ff89 100644 --- a/pages/index.js +++ b/pages/index.js @@ -1,12 +1,12 @@ import { useState, useEffect } from "react"; -import Image from "next/image"; +import MainCard from "../components/MainCard"; import Metrics from "../components/Metrics"; import SwitchBox from "../components/SwitchBox"; import LoadingScreen from "../components/LoadingScreen"; import ErrorScreen from "../components/ErrorScreen"; -import { convertTime, ctoF, timeToAMPM } from "../services/converters"; +import { convertTime, timeToAMPM } from "../services/converters"; import { isPM } from "../services/utils"; import styles from "../styles/Home.module.css"; @@ -55,36 +55,14 @@ const App = () => { return weatherData && !weatherData.message ? (
-
-

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

- -

- {weatherData.weather[0].description} -

- - weatherIcon - -

- {systemUsed == "metric" - ? Math.round(weatherData.main.temp) - : Math.round(ctoF(weatherData.main.temp))} - °{systemUsed == "metric" ? "C" : "F"} -

-

- Feels like{" "} - {systemUsed == "metric" - ? Math.round(weatherData.main.feels_like) - : Math.round(ctoF(weatherData.main.feels_like))} - °{systemUsed == "metric" ? "C" : "F"} -

-
+
diff --git a/styles/Home.module.css b/styles/Home.module.css index 6b94ff0..eced8fb 100644 --- a/styles/Home.module.css +++ b/styles/Home.module.css @@ -15,20 +15,6 @@ display: none; } -.weatherWrapper { - padding: 30px; -} - -.locationTitle { - font-size: 38px; - margin-bottom: 10px; -} - -.weatherDescription { - font-size: 24px; - margin-bottom: 20px; -} - .statsWrapper { background-color: rgb(247, 247, 247); padding: 30px; @@ -42,10 +28,6 @@ gap: 20px; } -.mainTemp { - font-size: 84px; -} - .searchInput { margin-bottom: 20px; height: 40px;