Skip to content

Commit 072963b

Browse files
authored
Feat: 마이페이지 온도 색상, 숫자 표시 (#407)
Related to: #392
1 parent 8bcede2 commit 072963b

File tree

3 files changed

+49
-21
lines changed

3 files changed

+49
-21
lines changed

src/components/Common/LoginMobCard.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { ReactNode } from "react";
33
const LoginMobCard = ({ children }: { children: ReactNode }) => {
44
return (
55
<div className="flex justify-center items-center">
6-
<div className="w-[773px] min-h-[100vh] bg-white flex">
6+
<div className="w-[773px] min-h-[100vh] bg-white max-w-[50rem] flex">
77
<div className="w-full px-[15.3rem] py-[11.2rem] _sm:px-[2rem] _sm:py-[11.2rem] _md:px-[2rem] _md:py-[11.2rem]">
88
{children}
99
</div>

src/components/MyPage/MyPage/MyProfile/MyProfile.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function MyProfile() {
1212
const { data } = useGetMyProfile();
1313

1414
if (!data) {
15-
return;
15+
return null;
1616
}
1717

1818
const frameGet = localStorage.getItem(FRAMEID);
@@ -63,7 +63,7 @@ function MyProfile() {
6363
<SettingButton />
6464
</div>
6565
</div>
66-
<div className="w-full flex justify-end h-full items-end">
66+
<div className="w-full flex justify-end h-full items-end pr-[2rem]">
6767
<Temperature temperature={data.progressBar} />
6868
</div>
6969
</div>

src/components/MyPage/MyPage/Temperature/Temperature.tsx

+46-18
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,56 @@
11
import temperatureIndicator from "@/assets/icon/temperature-indicator.svg";
2+
23
interface Props {
34
temperature: number;
45
}
6+
57
function Temperature({ temperature }: Props) {
6-
let realTemperature;
7-
if (temperature <= -36.5) {
8-
realTemperature = `calc(0% - 0.78rem)`;
9-
} else if (temperature > -36.5 && temperature < 63.5)
10-
realTemperature = `calc(${36.5 + temperature}% - 0.78rem)`;
11-
else if (temperature >= 63.5) realTemperature = `calc(100% - 0.78rem)`;
8+
temperature += 36.5;
9+
10+
if (temperature <= 0) {
11+
temperature = 0;
12+
} else if (temperature >= 100) {
13+
temperature = 100;
14+
}
15+
16+
const temperatureColorConditions = [
17+
{ max: 10, color: "#7EC7FC" },
18+
{ max: 20, color: "#72EF86" },
19+
{ max: 36.5, color: "#FFEF5C" },
20+
{ max: 65, color: "#FFAD62" },
21+
{ max: 100, color: "#E76B6B" },
22+
];
23+
24+
const getTemperatureColor = () => {
25+
for (const condition of temperatureColorConditions) {
26+
if (temperature <= condition.max) {
27+
return `bg-[${condition.color}]`;
28+
}
29+
}
30+
};
1231

1332
return (
14-
<div className="w-[22.4rem] _sm:w-[18rem] h-[2.5rem] _sm:h-[1.9rem] flex relative">
15-
<img
16-
src={temperatureIndicator}
17-
alt="temperature-indicator"
18-
className="absolute top-[-1rem] "
19-
style={{ left: realTemperature }}
20-
/>
21-
<div className="bg-[#7EC7FC] w-[12%] h-full rounded-l-[2.4rem]" />
22-
<div className="bg-[#72EF86] w-[21%] h-full" />
23-
<div className="bg-[#FFEF5C] w-[24%] h-full" />
24-
<div className="bg-[#FFAD62] w-[21%] h-full" />
25-
<div className="bg-[#E76B6B] w-[22%] h-full rounded-r-[2.4rem]" />
33+
<div className="w-[21.5rem] _sm:w-[18rem] h-[2.5rem] _sm:h-[1.9rem] flex relative">
34+
<div
35+
className="z-10 w-[4.5rem] absolute top-[-2.7rem] -translate-x-[0.75rem]"
36+
style={{ left: `${temperature}%` }}
37+
>
38+
<p className="text-center text-[1.4rem] _sm:text-[1.2rem] font-medium text-[#777] -translate-x-[1.5rem]">
39+
{temperature}
40+
</p>
41+
<img
42+
src={temperatureIndicator}
43+
alt="temperature-indicator"
44+
className="w-[1.5rem]"
45+
/>
46+
</div>
47+
48+
<div className="relative h-full w-full bg-[#D9D9D9] rounded-[2.4rem]">
49+
<div
50+
className={`${getTemperatureColor()} absolute h-full rounded-[2.4rem]`}
51+
style={{ width: `${temperature}%` }}
52+
/>
53+
</div>
2654
</div>
2755
);
2856
}

0 commit comments

Comments
 (0)