Skip to content

Commit 3dcac47

Browse files
committed
fix: 모바일에서 gradient 보이지 않는 문제 해결
1 parent 2efb0d4 commit 3dcac47

File tree

3 files changed

+56
-22
lines changed

3 files changed

+56
-22
lines changed

src/pages/LetterBox/components/LetterBoxItem.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,15 @@ const LetterBoxItem = ({
3030
className="flex h-fit w-fit flex-col items-center"
3131
onClick={() => handleClickItem(boxId)}
3232
>
33-
<div className="text-gray-70 flex h-25 w-20 flex-col gap-1.5 bg-linear-to-b from-[#D5B695] to-[#B3895D] p-1.5">
33+
<div className="text-gray-70 window-bg flex h-25 w-20 flex-col gap-1.5 bg-linear-to-b p-1.5">
3434
<p
3535
className={twMerge(
3636
'body-m from-white px-1',
3737
isClosed
3838
? 'bg-[repeating-linear-gradient(#D9D9D9,#D9D9D9_17px,#C2C2C2_17px,#C2C2C2_23px)]'
39-
: 'bg-linear-to-b',
40-
isChecked ? 'to-[#FFF5ED]' : 'to-[#FFF4F2]',
39+
: isChecked
40+
? 'window-top-checked'
41+
: 'window-top-unChecked',
4142
)}
4243
>
4344
{zipCode}
@@ -48,7 +49,7 @@ const LetterBoxItem = ({
4849
<div
4950
className={twMerge(
5051
'flex grow flex-col bg-linear-to-b',
51-
isChecked ? 'from-[#FFF7E3] to-[#FFE197]' : 'from-[#FFF4F2] to-[#FFE6E3]',
52+
isChecked ? 'window-bottom-checked' : 'window-bottom-unChecked',
5253
)}
5354
>
5455
<p className="body-r mt-auto mr-[1px] text-right">{letterCount}</p>

src/pages/LetterBox/index.tsx

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { useEffect, useState } from 'react';
1+
import { useQuery } from '@tanstack/react-query';
2+
import { useNavigate } from 'react-router';
23

34
import { getMailbox } from '@/apis/mailBox';
45
import DoorImg from '@/assets/images/door.png';
@@ -13,25 +14,34 @@ interface LetterBoxData {
1314
oppositeZipCode: string;
1415
active: boolean;
1516
oppositeRead: boolean;
16-
// totalLetters: number;
17+
letterCount: number;
1718
}
19+
20+
const fetchMailLists = async () => {
21+
const response = await getMailbox();
22+
if (!response) throw new Error();
23+
const data: LetterBoxData[] = response.data;
24+
// 정렬?
25+
return data;
26+
};
27+
1828
const LetterBoxPage = () => {
19-
const [letterBox, setLetterBox] = useState<LetterBoxData[]>([]);
29+
const {
30+
data: letterBox = [],
31+
isLoading,
32+
isError,
33+
} = useQuery({
34+
queryKey: ['mailbox'],
35+
queryFn: fetchMailLists,
36+
staleTime: 1000 * 60 * 5,
37+
gcTime: 1000 * 60 * 10,
38+
});
39+
40+
const navigate = useNavigate();
2041

21-
const fetchMailLists = async () => {
22-
try {
23-
const response = await getMailbox();
24-
if (!response) throw new Error();
25-
const data: LetterBoxData[] = response.data;
26-
// 정렬?
27-
setLetterBox(data);
28-
} catch (error) {
29-
console.error(error);
30-
}
31-
};
32-
useEffect(() => {
33-
fetchMailLists();
34-
}, []);
42+
if (isError) {
43+
navigate('/NotFound');
44+
}
3545

3646
return (
3747
<main className="flex grow flex-col items-center px-5 pt-20">
@@ -42,7 +52,9 @@ const LetterBoxPage = () => {
4252
</p>
4353
<section className="letter-box-bg flex grow flex-col items-center px-4 pt-5">
4454
<div className="flex w-full flex-col gap-5">
45-
{letterBox.length > 0 ? (
55+
{isLoading ? (
56+
<p className="body-m text-gray-60 text-center">로딩중..</p>
57+
) : letterBox.length > 0 ? (
4658
chunkBox(
4759
letterBox.map((data: LetterBoxData, index) => (
4860
<LetterBoxItem

src/styles/utilities.css

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,25 @@
8787
.letter-gradient {
8888
background: linear-gradient(to bottom, #ffffff, #f2f2f2);
8989
}
90+
91+
/* letter-box */
92+
.window-bg {
93+
background: linear-gradient(to bottom, #d5b695, #b3895d);
94+
}
95+
96+
.window-top-checked {
97+
background: linear-gradient(to bottom, #ffffff, #fff5ed);
98+
}
99+
100+
.window-top-unChecked {
101+
background: linear-gradient(to bottom, #ffffff, #fff4f2);
102+
}
103+
104+
.window-bottom-checked {
105+
background: linear-gradient(to bottom, #FFF7E3, #FFE197);
106+
}
107+
108+
.window-bottom-unChecked {
109+
background: linear-gradient(to bottom, #FFF4F2, #FFE6E3);
110+
}
90111
}

0 commit comments

Comments
 (0)