-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChanceOfRain.js
63 lines (54 loc) · 1.88 KB
/
ChanceOfRain.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import React, { useState, useEffect } from "react";
import { useSelector } from "react-redux";
import locations from "./resources/locations.json";
import humidity_img from "./resources/rain_drop.svg";
const ChanceOfRain = () => {
const page = useSelector((state) => state.page);
const location = locations.find((loc) => loc.page === page);
const [chanceOfRain, setChanceOfRain] = useState(0);
useEffect(() => {
if (location) {
setChanceOfRain(location.rain);
}
}, [location]);
return (
<>
<div className="bg-white h-[100px] w-[28%] p-0 ml-[3.5%] mt-[2%] rounded-[16px] justify-between">
<div className="flex flex-row">
<p className="font-custom text-black text-[13px] mt-[7%] ml-[15%] font-bold">
Chance of Rain
</p>
<img
src={humidity_img}
className="h-5 w-5 ml-[22%] mt-[7%]"
alt="Rain Icon"
></img>
</div>
<div className="flex flex-row justify-center mr-[5%]">
<p className="font-custom text-[18px] font-black text-black mt-[3%]">
{chanceOfRain}%
</p>
</div>
<div className="flex flex-row text-[10px]">
<p className=" ml-[10%]">0%</p>
<p className=" ml-[10%]">25%</p>
<p className=" ml-[8%]">50%</p>
<p className=" ml-[8%]">75%</p>
<p className=" ml-[8%]">100%</p>
</div>
<div className="w-[80%] mx-auto">
<div className="relative h-2 bg-gray-300 rounded-full">
<div
className="absolute top-0 left-0 h-full bg-[#5c9ce5] rounded-full"
style={{
width: `${chanceOfRain}%`,
transition: "width 0.5s ease-in-out", // Add transition property
}}
></div>
</div>
</div>
</div>
</>
);
};
export default ChanceOfRain;