Skip to content

Commit bb9ef64

Browse files
authored
Merge pull request codeit-13-3team#41 from codeit-13-3team/feature/reviewer-list-ui-enhancement
feat: ReviewerRanking UI 개선 및 팔로워 count, 리뷰 count 1000단위로 K 표시
2 parents 41bcf76 + 471d6ba commit bb9ef64

File tree

2 files changed

+48
-29
lines changed

2 files changed

+48
-29
lines changed

src/components/home/ReviewerRanking.tsx

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useQuery } from '@tanstack/react-query';
22
import { getUserRanking } from '@/api/user';
3+
import Link from 'next/link';
34

45
const ReviewerRanking = () => {
56
const {
@@ -15,37 +16,49 @@ const ReviewerRanking = () => {
1516
if (error) return <div>랭킹 조회 중 오류가 발생했습니다: {error.message}</div>;
1617
if (!userRanking) return <div>아직 등록된 리뷰어가 없습니다.</div>;
1718

19+
function formatNumber(count: number): string {
20+
if (count >= 1000) {
21+
return (count / 1000).toFixed(count >= 10000 ? 0 : 1) + 'K';
22+
}
23+
return count.toString();
24+
}
25+
26+
const Count = 1200;
27+
1828
return (
1929
<ul className="w-full flex flex-row flex-nowrap gap-[15px] lg:flex-col lg:overflow-x-auto lg:gap-6">
2030
{userRanking?.map((user, index) => (
21-
<li key={user.id} className="flex items-center flex-shrink-0">
22-
<div className="bg-white rounded-full w-9 h-9 mr-[10px]"></div>
23-
<div className="flex flex-col">
24-
<div className="flex items-center gap-[5px] mb-[5.5px] flex-shrink-0">
25-
{index === 0 && (
26-
<p className="text-[10px] text-pink bg-[#FF2F9F1A] py-[2px] px-[6px] rounded-[50px] flex-shrink-0">
27-
1등
28-
</p>
29-
)}
30-
{index === 1 && (
31-
<p className="text-[10px] text-green bg-[#05D58B1A] py-[2px] px-[6px] rounded-[50px] flex-shrink-0">
32-
2등
31+
<li key={user.id} className="flex-shrink-0">
32+
<Link
33+
href={`/user/${user.id}`}
34+
className="flex items-center flex-shrink-0 text-inherit hover:no-underline"
35+
>
36+
<div className="bg-white rounded-full w-9 h-9 mr-[10px]"></div>
37+
<div className="flex flex-col">
38+
<div className="flex items-center gap-[5px] mb-[5.5px] flex-shrink-0">
39+
<div
40+
className={`text-[10px] py-[2px] px-[6px] rounded-[50px] flex-shrink-0 ${
41+
index === 0
42+
? 'bg-[#FF2F9F1A] text-pink'
43+
: index === 1
44+
? 'bg-[#05D58B1A] text-green'
45+
: index === 2
46+
? 'bg-[#9FA6B21A] text-gray-100'
47+
: 'bg-[#9FA6B21A] text-gray-100'
48+
}`}
49+
>
50+
{index + 1}
51+
</div>
52+
<p className="text-[14px] font-medium block truncate max-w-[10ch] lg:text-[16px]">
53+
{user.nickname}
3354
</p>
34-
)}
35-
{index === 2 && (
36-
<p className="text-[10px] text-gray-100 bg-[#9FA6B21A] py-[2px] px-[6px] rounded-[50px] flex-shrink-0">
37-
3등
38-
</p>
39-
)}
40-
<p className="text-[14px] font-medium block truncate max-w-[10ch] lg:text-[16px]">
41-
{user.nickname}
42-
</p>
43-
</div>
44-
<div className="flex items-center gap-[10px] text-[10px] text-gray-200 font-light lg:text-[12px]">
45-
<p>팔로워 {user.followersCount}</p>
46-
<p>리뷰 {user.reviewCount}</p>
55+
</div>
56+
<div className="flex items-center gap-[10px] text-[10px] text-gray-200 font-light lg:text-[12px]">
57+
<p>팔로워 {formatNumber(user.followersCount)}</p>
58+
<p>리뷰 {formatNumber(user.reviewCount)}</p>
59+
</div>
4760
</div>
48-
</div>
61+
</Link>
4962
</li>
5063
))}
5164
</ul>

src/pages/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@ const Home = () => {
2222
/>
2323

2424
<div className="flex min-w-0 flex-col lg:flex-row-reverse gap-[10px]">
25-
<div className="flex flex-col mb-[60px] lg:border-l-[1px] lg:border-black-400 lg:pl-[30px] lg:h-screen pt-[30px] px-5">
26-
<p className="text-[14px] mb-5">리뷰어 랭킹</p>
27-
<div className="overflow-x-auto w-full">
25+
<div className="flex flex-col mb-[60px] lg:border-l-[1px] lg:border-black-400 lg:pl-[30px] lg:h-screen pt-[30px]">
26+
<p className="text-[14px] mb-5 px-5">리뷰어 랭킹</p>
27+
<div
28+
className="overflow-x-scroll w-full px-5"
29+
style={{
30+
scrollbarWidth: 'none',
31+
msOverflowStyle: 'none',
32+
}}
33+
>
2834
<ReviewerRanking />
2935
</div>
3036
</div>

0 commit comments

Comments
 (0)