create SwitchBox comp
This commit is contained in:
parent
3ec5ec415e
commit
56268d2392
24
components/SwitchBox.js
Normal file
24
components/SwitchBox.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import styles from "./SwitchBox.module.css";
|
||||||
|
|
||||||
|
const SwitchBox = ({ onClick, systemUsed }) => {
|
||||||
|
return (
|
||||||
|
<div className={styles.wrapper}>
|
||||||
|
<p
|
||||||
|
className={styles.switch}
|
||||||
|
style={{ color: systemUsed == "metric" ? "green" : "black" }}
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
|
Metric System
|
||||||
|
</p>
|
||||||
|
<p
|
||||||
|
className={styles.switch}
|
||||||
|
style={{ color: systemUsed == "metric" ? "black" : "green" }}
|
||||||
|
onClick={onClick}
|
||||||
|
>
|
||||||
|
Imperial System
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SwitchBox;
|
9
components/SwitchBox.module.css
Normal file
9
components/SwitchBox.module.css
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
.wrapper {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.switch {
|
||||||
|
margin: 0 10px;
|
||||||
|
cursor: pointer;
|
||||||
|
display: inline;
|
||||||
|
}
|
@ -2,6 +2,8 @@ import { useState, useEffect } from "react";
|
|||||||
import Image from "next/image";
|
import Image from "next/image";
|
||||||
|
|
||||||
import Metrics from "../components/Metrics";
|
import Metrics from "../components/Metrics";
|
||||||
|
import SwitchBox from "../components/SwitchBox";
|
||||||
|
|
||||||
import { convertTime, ctoF, timeToAMPM } from "../services/converters";
|
import { convertTime, ctoF, timeToAMPM } from "../services/converters";
|
||||||
import { isPM } from "../services/utils";
|
import { isPM } from "../services/utils";
|
||||||
|
|
||||||
@ -126,22 +128,7 @@ const App = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Metrics styles={styles} data={weatherData} systemUsed={systemUsed} />
|
<Metrics styles={styles} data={weatherData} systemUsed={systemUsed} />
|
||||||
<div className={styles.switchBox}>
|
<SwitchBox onClick={changeSystem} systemUsed={systemUsed} />
|
||||||
<p
|
|
||||||
className={styles.switch}
|
|
||||||
style={{ color: systemUsed == "metric" ? "green" : "black" }}
|
|
||||||
onClick={changeSystem}
|
|
||||||
>
|
|
||||||
Metric System
|
|
||||||
</p>
|
|
||||||
<p
|
|
||||||
className={styles.switch}
|
|
||||||
style={{ color: systemUsed == "metric" ? "black" : "green" }}
|
|
||||||
onClick={changeSystem}
|
|
||||||
>
|
|
||||||
Imperial System
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : weatherData && weatherData.message ? (
|
) : weatherData && weatherData.message ? (
|
||||||
|
@ -78,16 +78,6 @@
|
|||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.switchBox {
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.switch {
|
|
||||||
margin: 0 10px;
|
|
||||||
cursor: pointer;
|
|
||||||
display: inline;
|
|
||||||
}
|
|
||||||
|
|
||||||
.errScr {
|
.errScr {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user