-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GGFE-46] Game Result List 스타일 #814
Changes from 36 commits
3da03dd
1c342e1
59b3fd6
f00b980
6350f15
2f196b2
3b1ccbb
8a06ccf
c728c01
a56c0bd
6e38b88
f976205
0a25ca9
7db73d9
f920d3e
407ba63
c309630
e5b2d6e
361431e
83a8d19
94b8a24
b53d16c
656466f
ae024eb
6357fbd
5d8c31d
3a748a1
8fa839d
aee4162
33aa9a7
d4676f8
0919d04
ed059d2
c3c94bc
1d6d014
18ab404
b919dc1
4222c8b
574e153
5249a13
a5c5efd
d9517e8
16ff419
68056a8
5579eb4
b9bdc56
737c3b2
990de09
c556a10
c9011c6
f0398fc
e490c9d
8e97121
edc60f8
c56791a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,66 @@ | ||
import React from 'react'; | ||
import { FaChevronDown } from 'react-icons/fa'; | ||
import { Game } from 'types/gameTypes'; | ||
import GameResultEmptyItem from './GameResultEmptyItem'; | ||
import GameResultBigItem from './big/GameResultBigItem'; | ||
import GameResultSmallItem from './small/GameResultSmallItem'; | ||
import styles from 'styles/game/GameResultItem.module.scss'; | ||
import useGameResultList from 'hooks/game/useGameResultList'; | ||
import { SeasonMode } from 'types/mainType'; | ||
|
||
interface GameResultListProps { | ||
path: string; | ||
radioMode?: SeasonMode; | ||
} | ||
|
||
export default function GameResultList({ path }: GameResultListProps) { | ||
export default function GameResultList({ | ||
path, | ||
radioMode, | ||
}: GameResultListProps) { | ||
const { data, status, fetchNextPage, isLast, clickedGameItem, pathName } = | ||
useGameResultList(path); | ||
|
||
const isGamePage = pathName === '/game'; | ||
|
||
if (status === 'loading') return <GameResultEmptyItem status={status} />; | ||
|
||
if (status === 'success' && !data?.pages[0].games.length) | ||
return <GameResultEmptyItem status={status} />; | ||
|
||
return ( | ||
<div> | ||
<div className={styles['gameResultWrapper']}> | ||
{status === 'success' && ( | ||
<> | ||
{data?.pages.map((gameList, index) => ( | ||
<div key={index}> | ||
{gameList.games.map((game: Game) => { | ||
{data?.pages.map((gameList, pageIndex) => ( | ||
<React.Fragment key={pageIndex}> | ||
{gameList.games.map((game: Game, index) => { | ||
const type = Number.isInteger(index / 2) ? 'LIGHT' : 'DARK'; | ||
return clickedGameItem === game.gameId ? ( | ||
<GameResultBigItem key={game.gameId} game={game} /> | ||
<GameResultBigItem | ||
key={game.gameId} | ||
game={game} | ||
zIndexList={!isGamePage} | ||
radioMode={radioMode} | ||
/> | ||
) : ( | ||
<GameResultSmallItem key={game.gameId} game={game} /> | ||
<GameResultSmallItem | ||
key={game.gameId} | ||
type={type} | ||
game={game} | ||
zIndexList={!isGamePage} | ||
radioMode={radioMode} | ||
/> | ||
); | ||
})} | ||
</div> | ||
</React.Fragment> | ||
))} | ||
{pathName === '/game' && !isLast && ( | ||
<div className={styles.getButton}> | ||
<input | ||
type='button' | ||
value='더 보기' | ||
onClick={() => fetchNextPage()} | ||
/> | ||
</div> | ||
{isGamePage && !isLast && ( | ||
<button | ||
className={styles['getButton']} | ||
onClick={() => fetchNextPage()} | ||
> | ||
<FaChevronDown /> | ||
</button> | ||
Comment on lines
+57
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
)} | ||
</> | ||
)} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { getTimeAgo } from 'utils/handleTime'; | ||
import { GameStatus, GameMode } from 'types/gameTypes'; | ||
import { SeasonMode } from 'types/mainType'; | ||
import styles from 'styles/game/GameResultItem.module.scss'; | ||
|
||
interface GameResultBigScoreProps { | ||
|
@@ -8,6 +9,7 @@ interface GameResultBigScoreProps { | |
time: string; | ||
scoreTeam1?: number; | ||
scoreTeam2?: number; | ||
radioMode?: SeasonMode; | ||
} | ||
|
||
export default function GameResultBigScore({ | ||
|
@@ -16,18 +18,23 @@ export default function GameResultBigScore({ | |
time, | ||
scoreTeam1, | ||
scoreTeam2, | ||
radioMode, | ||
}: GameResultBigScoreProps) { | ||
return ( | ||
<div className={styles.bigScoreBoard}> | ||
{makeScoreStatus(status, time)} | ||
{makeScoreStatus(status, time, radioMode)} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 컴포넌트 형식으로 바꿔보시는건 어떨까요 |
||
<div className={styles.gameScore}> | ||
{mode === 'NORMAL' ? 'VS' : `${scoreTeam1} : ${scoreTeam2}`} | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
function makeScoreStatus(status: GameStatus, time: string) { | ||
function makeScoreStatus( | ||
status: GameStatus, | ||
time: string, | ||
radioMode: SeasonMode | ||
) { | ||
switch (status) { | ||
case 'LIVE': | ||
return <div className={styles.gameStatusLive}>Live</div>; | ||
|
@@ -40,7 +47,14 @@ function makeScoreStatus(status: GameStatus, time: string) { | |
</div> | ||
); | ||
case 'END': | ||
return <div className={styles.gameStatusEnd}>{getTimeAgo(time)}</div>; | ||
return ( | ||
<div | ||
className={`${styles['gameStatusEnd']} | ||
${radioMode ? styles[radioMode.toLowerCase()] : ''}`} | ||
> | ||
{getTimeAgo(time)} | ||
</div> | ||
); | ||
default: | ||
return null; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,34 @@ | ||
import Link from 'next/link'; | ||
import React from 'react'; | ||
import { useRouter } from 'next/router'; | ||
import { FaChevronRight } from 'react-icons/fa'; | ||
import GameResult from 'components/game/GameResult'; | ||
import RankList from 'components/rank/RankList'; | ||
import styles from 'styles/main/Section.module.scss'; | ||
|
||
type SectionProps = { | ||
sectionTitle: string; | ||
path: string; | ||
}; | ||
|
||
type pathType = { | ||
[key: string]: JSX.Element; | ||
}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. type pathType = Record<string, JSX.Element>; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오... Record type은 처음 봤는데 Index Signature랑 동일한거네요...! |
||
|
||
export default function xSection({ path }: SectionProps) { | ||
export default function Section({ sectionTitle, path }: SectionProps) { | ||
const router = useRouter(); | ||
const pathCheck: pathType = { | ||
game: <GameResult />, | ||
rank: <RankList toggleMode={'rank'} isMain={true} />, | ||
}; | ||
|
||
return ( | ||
<div className={styles.sectionWrap}> | ||
<Link href={`/${path}`}>더보기 ▹</Link> | ||
<div className={styles['sectionWrap']}> | ||
<div className={styles['titleWrap']}> | ||
<span>{sectionTitle}</span> | ||
<button onClick={() => router.push(`/${path}`)}> | ||
<FaChevronRight /> | ||
</button> | ||
</div> | ||
<section>{pathCheck[path]}</section> | ||
</div> | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
React.Fragment가
<> </>
요걸 지칭하는걸로 알고 있는데 키값을 쓸 수 있는건 처음알았네요👍There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
div
태그를 지우고 빈 태그를 쓰고 싶었는데,<> </>
에는 직접 키값을 넣지 못하더라구요..ㅎㅎReact.Fragment
에는 키값을 쓸 수 있길래 이걸로 써 줬습니다 😁There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
빈 태그 대신에 React.Fragment 쓸 수 있다는 것 배우고 갑니다!