Skip to content
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

Merged
Merged
Show file tree
Hide file tree
Changes from 36 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
3da03dd
[Style] [GGFE-46] BigItem, SmallItem 기본 스타일 적용
yoouyeon May 31, 2023
1c342e1
[Style] [GGFE-46] Item들의 winrate, size 디테일 적용
yoouyeon Jun 1, 2023
59b3fd6
[Style] [GGFE-46] SmallItem 스타일 적용
yoouyeon Jun 1, 2023
f00b980
[Style] [GGFE-46] Item min-width로 변경
yoouyeon Jun 1, 2023
6350f15
[Style] [GGFE-46] Item 역순으로 z-index 적용
yoouyeon Jun 1, 2023
2f196b2
[Fix] [GGFE-46] 누락된 click event 추가, 불필요한 div 제거
yoouyeon Jun 1, 2023
3b1ccbb
[Fix] [GGFE-46] map key error 수정
yoouyeon Jun 2, 2023
8a06ccf
[Chore] [GGFE-46] z-index 삭제로 불필요해진 요소들 삭제
yoouyeon Jun 3, 2023
c728c01
[Style] [GGFE-46] 변경된 디자인에 맞게 Item style 수정
yoouyeon Jun 3, 2023
a56c0bd
[Style] [GGFE-46] main page section title 디자인 적용
yoouyeon Jun 3, 2023
6e38b88
[Chore] [GGFE-46] 불필요한 태그와 주석 제거
yoouyeon Jun 5, 2023
f976205
[Style] [GGFE-46] Item 디테일 수정
yoouyeon Jun 5, 2023
0a25ca9
[Style] [GGFE-46] radio button 기본 디자인 적용
yoouyeon Jun 5, 2023
7db73d9
[Style] [GGFE-46] 더보기 버튼 스타일 수정
yoouyeon Jun 5, 2023
f920d3e
[Style] [GGFE-46] 매칭 버튼 z-index 수정
yoouyeon Jun 5, 2023
407ba63
[Chore] [GGFE-46] 불필요한 내용 삭제
yoouyeon Jun 5, 2023
c309630
[Style] [GGFE-46] BigItem z-index 설정으로 가려지는 문제 수정
yoouyeon Jun 6, 2023
e5b2d6e
[Style] [GGFE-46] game page에 다른 스타일 적용
yoouyeon Jun 8, 2023
361431e
[Style] [GGFE-46] GameResultItem min-width 수정
yoouyeon Jun 8, 2023
83a8d19
[Style] [GGFE-46] BigItem 그림자 수정
yoouyeon Jun 8, 2023
94b8a24
[Style] [GGFE-46] Game Page winRate 수정
yoouyeon Jun 8, 2023
b53d16c
[Style] [GGFE-46] radio mode에 따른 배경색 적용
yoouyeon Jun 8, 2023
656466f
[Style] [GGFE-46] 상태에 따른 BigItem 기본 디자인 수정
yoouyeon Jun 12, 2023
ae024eb
[Test] [GGFE-46] BigItem argTypes 정의 추가
yoouyeon Jun 12, 2023
6357fbd
[Style] [GGFE-46] radio mode에 따른 SmallItem 배경색 적용
yoouyeon Jun 12, 2023
5d8c31d
[Style] [GGFE-46] ModeRadioBox 스타일 적용
yoouyeon Jun 12, 2023
3a748a1
[Style] [GGFE-46] Game Status 디자인 적용
yoouyeon Jun 12, 2023
8fa839d
[Style] [GGFE-46] radio mode에 따라 status 디자인 변경 적용
yoouyeon Jun 12, 2023
aee4162
[Style] [GGFE-46] 점수 간격과 배경색 수정
yoouyeon Jun 12, 2023
33aa9a7
[Style] [GGFE-46] Game Page Title 스타일 적용
yoouyeon Jun 12, 2023
d4676f8
Merge branch 'GGFE-00/Feat/api-refactoring' of https://github.com/42o…
yoouyeon Jun 13, 2023
0919d04
[Feat] [GGFE-46] 불필요한 z-index 속성 삭제
yoouyeon Jun 13, 2023
ed059d2
[Chore] [GGFE-46] storybook 기본 배경색 변경
yoouyeon Jun 13, 2023
c3c94bc
[Style] [GGFE-46] UserGameSearchBar 스타일 적용
yoouyeon Jun 13, 2023
1d6d014
[Style] [GGFE-46] ModeWrap margin-bottom 수정
yoouyeon Jun 13, 2023
18ab404
[Chore] [GGFE-46] 불필요한 주석 제거
yoouyeon Jun 13, 2023
b919dc1
[Fix] [GGFE-46] searchBar reset button 문제 수정
yoouyeon Jun 13, 2023
4222c8b
[Style] [GGFE-46] ScoreStatus 컴포넌트로 분리
yoouyeon Jun 13, 2023
574e153
[Chore] [GGFE-46] Index Signature를 Record 타입으로 변경
yoouyeon Jun 13, 2023
5249a13
[Style] [GGFE-46] notiBar z-index 수정
yoouyeon Jun 13, 2023
a5c5efd
[Test] [GGFE-64] MatchManualModal 스토리 추가
yoouyeon Jun 14, 2023
d9517e8
[Feat][GGFE-64] 라디오박스의 위치에 따라 다른 배경 적용
yoouyeon Jun 14, 2023
16ff419
[Test] [GGFE-64] StoryArgs 추가
yoouyeon Jun 14, 2023
68056a8
[Style] [GGFE-64] 제목과 배경 스타일 적용
yoouyeon Jun 14, 2023
5579eb4
[Style] [GGFE-64] 본문 배경과 확인 버튼 스타일 적용
yoouyeon Jun 14, 2023
b9bdc56
[Style] [GGFE-64] radioBox와 제목 간격 수정
yoouyeon Jun 14, 2023
737c3b2
[Fix] [GGFE-64] ManualModal에서 Label 효과가 없던 문제 수정
yoouyeon Jun 14, 2023
990de09
[Style] [GGFE-64] Modal, RadioBox Detail 수정
yoouyeon Jun 14, 2023
c556a10
[Chore] [GGFE-64] ManualContent Record 타입으로 변경
yoouyeon Jun 14, 2023
c9011c6
[Chore] [GGFE-64] 불필요한 div 태그 주석
yoouyeon Jun 14, 2023
f0398fc
[Chore] [GGFE-64] 불필요한 콘솔 출력 제거
yoouyeon Jun 14, 2023
e490c9d
[Chore] [GGFE-64] 불필요한 주석 제거
yoouyeon Jun 14, 2023
8e97121
[Feat] [GGFE-64] Icon 속성 추가
yoouyeon Jun 14, 2023
edc60f8
[Feat] [GGFE-64] ContentTitle 컴포넌트 추가
yoouyeon Jun 14, 2023
c56791a
Merge pull request #824 from 42organization/GGFE-64-게임-매뉴얼-모달
42sungwook Jun 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const preview: Preview = {
date: /Date$/,
},
},
backgrounds: {
default: 'purple',
values: [{ name: 'purple', value: '#301451' }],
},
},
decorators: [
(Story: StoryFn) => (
Expand Down
2 changes: 1 addition & 1 deletion components/game/GameResult.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function GameResult({ mode, season }: GameResultProps) {
<div>
{path && (
<QueryClientProvider client={queryClient}>
<GameResultList path={path} />
<GameResultList path={path} radioMode={mode} />
</QueryClientProvider>
)}
</div>
Expand Down
52 changes: 36 additions & 16 deletions components/game/GameResultList.tsx
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}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React.Fragment가 <> </>요걸 지칭하는걸로 알고 있는데 키값을 쓸 수 있는건 처음알았네요👍

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

div 태그를 지우고 빈 태그를 쓰고 싶었는데, <> </> 에는 직접 키값을 넣지 못하더라구요..ㅎㅎ React.Fragment에는 키값을 쓸 수 있길래 이걸로 써 줬습니다 😁

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

빈 태그 대신에 React.Fragment 쓸 수 있다는 것 배우고 갑니다!

{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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

)}
</>
)}
Expand Down
19 changes: 14 additions & 5 deletions components/game/big/GameResultBigItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,39 @@ import { clickedGameItemState } from 'utils/recoil/game';
import GameResultBigScore from 'components/game/big/GameResultBigScore';
import GameResultBigTeam from 'components/game/big/GameResultBigTeam';
import styles from 'styles/game/GameResultItem.module.scss';
import { SeasonMode } from 'types/mainType';

interface GameResultBigItemProps {
game: Game;
radioMode?: SeasonMode;
zIndexList: boolean;
}

function GameResultBigItem({ game }: GameResultBigItemProps) {
function GameResultBigItem({
game,
zIndexList,
radioMode,
}: GameResultBigItemProps) {
const { mode, team1, team2, status, time, gameId } = game;
const setClickedItemId = useSetRecoilState(clickedGameItemState);
return (
<div
className={`${styles.bigContainer}
${styles[mode.toLowerCase()]}`}
onClick={() => setClickedItemId(gameId)}
id={String(gameId)}
className={`${styles['bigItemContainer']} ${
zIndexList ? styles['zIndexList'] : ''
} ${radioMode ? styles[radioMode.toLowerCase()] : ''}`}
>
<GameResultBigTeam team={team1} />
<GameResultBigTeam team={team1} zIndexList={zIndexList} />
<GameResultBigScore
mode={mode}
status={status}
time={time}
scoreTeam1={team1.score}
scoreTeam2={team2.score}
radioMode={radioMode}
/>
<GameResultBigTeam team={team2} />
<GameResultBigTeam team={team2} zIndexList={zIndexList} />
</div>
);
}
Expand Down
20 changes: 17 additions & 3 deletions components/game/big/GameResultBigScore.tsx
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 {
Expand All @@ -8,6 +9,7 @@ interface GameResultBigScoreProps {
time: string;
scoreTeam1?: number;
scoreTeam2?: number;
radioMode?: SeasonMode;
}

export default function GameResultBigScore({
Expand All @@ -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)}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

컴포넌트 형식으로 바꿔보시는건 어떨까요
해당 함수 방식이 () => JSX.element라서 가능해 보이거든요

<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>;
Expand All @@ -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;
}
Expand Down
19 changes: 12 additions & 7 deletions components/game/big/GameResultBigTeam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@ import styles from 'styles/game/GameResultItem.module.scss';

interface GameResultBigTeamProps {
team: Team;
zIndexList?: boolean;
}

export function isRankPlayerType(arg: Player | RankPlayer): arg is RankPlayer {
return 'wins' in arg;
}

export default function GameResultBigTeam({ team }: GameResultBigTeamProps) {
export default function GameResultBigTeam({
team,
zIndexList,
}: GameResultBigTeamProps) {
return (
<div className={styles.bigTeam}>
{team.players.map((player, index) => (
Expand All @@ -26,12 +30,13 @@ export default function GameResultBigTeam({ team }: GameResultBigTeamProps) {
<div className={styles.userId}>{player.intraId}</div>
</div>
</Link>
<div className={styles.winRate}>
<span>
{isRankPlayerType(player)
? `${player.wins}승 ${player.losses}패`
: `Lv. ${player.level}`}
</span>
<div
className={`${styles['winRate']}
${zIndexList && styles['zIndexWinRate']}`}
>
{isRankPlayerType(player)
? `${player.wins}승 ${player.losses}패`
: `Lv. ${player.level}`}
</div>
</div>
))}
Expand Down
20 changes: 16 additions & 4 deletions components/game/small/GameResultSmallItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,32 @@ import { clickedGameItemState } from 'utils/recoil/game';
import GameResultSmallScore from 'components/game/small/GameResultSmallScore';
import GameResultSmallTeam from 'components/game/small/GameResultSmallTeam';
import styles from 'styles/game/GameResultItem.module.scss';
import { SeasonMode } from 'types/mainType';

interface GameResultSmallItemProps {
game: Game;
type: 'LIGHT' | 'DARK';
zIndexList: boolean;
radioMode?: SeasonMode;
}

function GameResultSmallItem({ game }: GameResultSmallItemProps) {
function GameResultSmallItem({
game,
type,
zIndexList,
radioMode,
}: GameResultSmallItemProps) {
const { mode, team1, team2, gameId } = game;
const setClickedItemId = useSetRecoilState(clickedGameItemState);

return (
<div
className={`${styles.smallContainer}
${styles[mode.toLowerCase()]}`}
onClick={() => setClickedItemId(gameId)}
id={String(gameId)}
className={`${styles['smallItemContainer']}
${styles[type.toLowerCase()]} ${
radioMode !== undefined ? styles[radioMode.toLowerCase()] : ''
} ${zIndexList ? styles['zIndexList'] : ''}`}
onClick={() => setClickedItemId(gameId)}
>
<GameResultSmallTeam team={team1} position={'Left'} />
<GameResultSmallScore
Expand Down
28 changes: 12 additions & 16 deletions components/game/small/GameResultSmallTeam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@ export default function GameResultSmallTeam({
position,
}: GameResultSmallTeamProps) {
return (
<div className={styles.smallTeam}>
<div className={styles[position]}>
{team.players.map((player, index) => (
<PlayerImage
key={index}
src={player.userImageUri}
styleName={'gameResultSmall' + position}
size={20}
/>
))}
<span>
{team.players.map((player) => (
<div key={player.intraId}>{player.intraId}</div>
))}
</span>
</div>
<div className={`${styles['smallTeam']} ${styles[position]}`}>
{team.players.map((player, index) => (
<PlayerImage
key={index}
src={player.userImageUri}
styleName={'gameResultSmall'}
size={20}
/>
))}
{team.players.map((player) => (
<span key={player.intraId}>{player.intraId}</span>
))}
</div>
);
}
16 changes: 12 additions & 4 deletions components/main/Section.tsx
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;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type pathType = Record<string, JSX.Element>;

Copy link
Member Author

Choose a reason for hiding this comment

The 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}`}>더보기 &#9657;</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>
);
Expand Down
16 changes: 13 additions & 3 deletions components/mode/modeItems/ModeRadiobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,25 @@ import styles from 'styles/mode/ModeRadiobox.module.scss';
interface ModeRadioboxProps {
mode: SeasonMode;
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
zIndexList?: boolean;
}

export default function ModeRadiobox({ mode, onChange }: ModeRadioboxProps) {
export default function ModeRadiobox({
mode,
onChange,
zIndexList,
}: ModeRadioboxProps) {
const modes: { type: SeasonMode; name: string }[] = [
{ type: 'BOTH', name: '전체' },
{ type: 'NORMAL', name: '일반' },
{ type: 'RANK', name: '랭크' },
];

return (
<div className={styles.modeButtons}>
<div
className={`${styles.modeButtons}
${zIndexList && styles['zIndexListButton']}`}
>
{modes.map(({ type, name }) => (
<label key={type} htmlFor={type}>
<input
Expand All @@ -24,7 +32,9 @@ export default function ModeRadiobox({ mode, onChange }: ModeRadioboxProps) {
onChange={onChange}
checked={mode === type}
/>
<div className={styles.modeButton}>{name}</div>
<div className={`${styles.modeButton} ${styles[mode.toLowerCase()]}`}>
{name}
</div>
</label>
))}
</div>
Expand Down
Loading