Skip to content

Commit eaabf95

Browse files
authored
[25. 05. 26 / TASK-198] Refactor - 리더보드 UI 개선 (#37)
1 parent 28af7f6 commit eaabf95

File tree

13 files changed

+50
-89
lines changed

13 files changed

+50
-89
lines changed

src/app/(auth-required)/components/header/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { PATHS, SCREENS } from '@/constants';
1010
import { Icon, NameType } from '@/components';
1111
import { useResponsive } from '@/hooks';
1212
import { logout, me } from '@/apis';
13-
import { useModal } from '@/hooks/useModal';
13+
import { useModal } from '@/hooks';
1414
import { defaultStyle, Section, textStyle } from './Section';
1515
import { Modal } from '../notice/Modal';
1616
import { QRCode } from '../QRCode';

src/app/(auth-required)/components/notice/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useEffect, useState } from 'react';
44
import { useQuery } from '@tanstack/react-query';
55
import { notiList } from '@/apis';
66
import { PATHS } from '@/constants';
7-
import { useModal } from '@/hooks/useModal';
7+
import { useModal } from '@/hooks';
88
import { convertDateToKST } from '@/utils/dateUtil';
99
import { Modal } from './Modal';
1010

src/app/(auth-required)/layout.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { ReactElement } from 'react';
33
import { getQueryClient } from '@/utils/queryUtil';
44
import { PATHS } from '@/constants';
55
import { me, notiList } from '@/apis';
6-
import { Notice } from './components/notice';
7-
import { Header } from './components/header';
6+
import { Notice, Header } from './components';
87

98
interface IProp {
109
children: ReactElement;

src/app/(auth-required)/leaderboards/Content.tsx

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ import { useQuery } from '@tanstack/react-query';
44
import { useMemo } from 'react';
55
import { startHolyLoader } from 'holy-loader';
66
import { Dropdown } from '@/components';
7-
import { PATHS, SCREENS } from '@/constants';
8-
import { useResponsive, useSearchParam } from '@/hooks';
9-
import { leaderboardList } from '@/apis/leaderboard.request';
10-
import { LeaderboardItemType } from '@/types/leaderboard.type';
11-
import { Ranker, Rank } from './components';
7+
import { PATHS } from '@/constants';
8+
import { useSearchParam } from '@/hooks';
9+
import { leaderboardList } from '@/apis';
10+
import { LeaderboardItemType } from '@/types';
11+
import { Rank } from './Rank';
1212

1313
export type searchParamsType = {
1414
based: 'user' | 'post';
@@ -18,7 +18,6 @@ export type searchParamsType = {
1818
};
1919

2020
export const Content = () => {
21-
const width = useResponsive();
2221
const [searchParams, setSearchParams] = useSearchParam<searchParamsType>();
2322

2423
const { data: boards } = useQuery({
@@ -86,22 +85,10 @@ export const Content = () => {
8685
</div>
8786
</div>
8887

89-
<div className="h-full overflow-auto flex flex-col gap-[30px] max-TBL:gap-5">
90-
<div className="w-full flex gap-10 max-MBI:flex-col max-MBI:gap-5">
91-
<Ranker name={data?.[1].name || '유저 없음'} rank={2} count={data?.[1].value} />
92-
<Ranker
93-
name={data?.[0].name || '유저 없음'}
94-
rank={1}
95-
count={data?.[0].value}
96-
className={width < SCREENS.MBI ? 'order-first' : ''}
97-
/>
98-
<Ranker name={data?.[2].name || '유저 없음'} rank={3} count={data?.[2].value} />
99-
</div>
100-
<div className="w-full flex flex-wrap gap-10 max-TBL:gap-5">
101-
{data?.map(({ name, value }, index) =>
102-
index >= 3 ? <Rank name={name} key={index} count={value} rank={index + 1} /> : null,
103-
)}
104-
</div>
88+
<div className="w-full flex flex-wrap gap-5 overflow-auto">
89+
{data?.map(({ name, value }, index) => (
90+
<Rank name={name} key={index} count={value} rank={index + 1} />
91+
))}
10592
</div>
10693
</div>
10794
);
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { HTMLAttributes } from 'react';
2+
import { twMerge } from 'tailwind-merge';
3+
4+
export interface IProp extends HTMLAttributes<HTMLDivElement> {
5+
name: string;
6+
rank: number;
7+
count?: string | number;
8+
suffix?: string;
9+
}
10+
11+
const colorTable = ['border-[#DAA520]', 'border-[#A9A9A9]', 'border-[#B87333]'];
12+
13+
export const Rank = ({ name, rank, count, suffix = '회' }: IProp) => {
14+
return (
15+
<div
16+
className={twMerge(
17+
'min-w-[40%] w-full p-[25px] bg-BG-SUB rounded-[4px] gap-3 justify-between flex',
18+
rank > 3 ? 'border-0' : `border-2 ${colorTable[rank - 1]}`,
19+
)}
20+
>
21+
<span
22+
data-rank={rank}
23+
className="text-T3 text-TEXT-MAIN flex items-center gap-3 before:content-[attr(data-rank)_'위'] before:text-ST4 before:text-TEXT-ALT max-TBL:text-T4 max-TBL:before:text-T5 max-MBI:text-ST4 max-MBI:before:text-ST5"
24+
>
25+
{name}
26+
</span>
27+
<span className="text-ST3 shrink-0 text-TEXT-SUB max-TBL:text-T4 max-MBI:text-ST4">
28+
{count}
29+
{suffix}
30+
</span>
31+
</div>
32+
);
33+
};

src/app/(auth-required)/leaderboards/components/Rank.tsx

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/app/(auth-required)/leaderboards/components/Ranker.tsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

src/app/(auth-required)/leaderboards/components/index.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/app/(auth-required)/leaderboards/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Metadata } from 'next';
22
import { dehydrate, HydrationBoundary } from '@tanstack/react-query';
33
import { getQueryClient } from '@/utils/queryUtil';
44
import { PATHS } from '@/constants';
5-
import { leaderboardList } from '@/apis/leaderboard.request';
5+
import { leaderboardList } from '@/apis';
66
import { Content, searchParamsType } from './Content';
77

88
export const metadata: Metadata = {

src/app/(auth-required)/main/Content.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { useInfiniteQuery, useQuery } from '@tanstack/react-query';
44
import { useEffect, useMemo } from 'react';
55
import { useInView } from 'react-intersection-observer';
6-
import { useSearchParam } from '@/hooks/useSearchParam';
6+
import { useSearchParam } from '@/hooks';
77
import { Button, Dropdown, Check } from '@/components';
88
import { postList, postSummary } from '@/apis';
99
import { PATHS, SORT_TYPE } from '@/constants';

0 commit comments

Comments
 (0)