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

카드제작 컴포넌트 디렉토리 구조 및 코드 리팩토링 #58

Merged
merged 33 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
13eca9d
Merge branch 'dev' of github.com:side-project-cdmnkh/my-pokemon into Min
cdm1263 Jan 16, 2024
f947e58
Design: framer motion으로 box shadow 추가 및 border 색상 변경
cdm1263 Jan 16, 2024
9e81719
Design: 카드 저장버튼 스타일링
cdm1263 Jan 17, 2024
e7227ca
Rename: cardEdit 디렉토리명을 cardMaker로 변경
cdm1263 Jan 17, 2024
2506494
Rename: searchPokemon 디렉토리로 이동
cdm1263 Jan 17, 2024
10738e4
Refactor: PokemonSearch 참조 디렉토리 변경
cdm1263 Jan 17, 2024
c61e4f0
Rename: selectPokemon 으로 컴포넌트 이동
cdm1263 Jan 17, 2024
2389f6e
Rename: select와 search와 card로 scss 파일 분리
cdm1263 Jan 17, 2024
89e8a1e
Rename: CardsRow 에서 SelectPokemon 으로 컴포넌트명 변경
cdm1263 Jan 17, 2024
9c672b8
Rename: PokemonSearch에서 SearchPokemon으로 컴포넌트명 변경
cdm1263 Jan 17, 2024
99276d2
Rename: CardPage를 CardEditPage로 변경
cdm1263 Jan 17, 2024
0b9e22c
Rename: list 디렉토리를 dex로 변경
cdm1263 Jan 17, 2024
fb51c12
Rename: PokemonList 를 PokemonDex로 변경
cdm1263 Jan 17, 2024
d5464f2
Feat: 랜덤한 별칭을 만드는 함수 generateRandomNicknames 추가
cdm1263 Jan 17, 2024
51297a2
Refactor: 랜덤 별칭 로직을 useSelectedPokemonForCard에 있는 generateRandomNickn…
cdm1263 Jan 17, 2024
1e3b60a
Design: title 클래스 스타일 추가
cdm1263 Jan 17, 2024
a1295fd
Refactor: state명 간략화 (randomPokemonArray -> randomPokemons)
cdm1263 Jan 17, 2024
2536427
Rename: cards scss 파일을 cardEditor와 cardEditPage로 분할
cdm1263 Jan 17, 2024
fbfc90a
Refactor: 공통된 스타일 코드 리팩토링
cdm1263 Jan 17, 2024
92bb820
Fix: container의 클래스명 오류 수정
cdm1263 Jan 18, 2024
5b43c49
Refactor: setMyclassName 함수로 라우터별 클래스명 할당처리
cdm1263 Jan 18, 2024
c4d2c60
Refactor: 클래스명 간략화
cdm1263 Jan 18, 2024
29bbbdc
Refactor: 중복 코드 정리 및 클래스명 간략화 적용
cdm1263 Jan 18, 2024
cd32471
Fix: title 클래스 스타일 추가
cdm1263 Jan 18, 2024
78c27d6
Refactor: 구조 및 클래스명 간략화
cdm1263 Jan 18, 2024
04dc730
Refactor: 구조 및 클래스명 간략화
cdm1263 Jan 18, 2024
560f589
Refactor: nickName 객체를 PokemonCard로 전달
cdm1263 Jan 18, 2024
145ab15
Refactor: 중복 코드 정리
cdm1263 Jan 18, 2024
e1935e0
Fix: pokemonNickName에 null타입 허용
cdm1263 Jan 18, 2024
7ccdc20
Refactor: 클래스명 및 스타일 코드 간략화
cdm1263 Jan 18, 2024
4d82c9a
Refactor: 클래스명 간략화 및 스타일 코드 리팩토링
cdm1263 Jan 18, 2024
dbf7c0d
Docs: 스타일 코드의 사용 컴포넌트를 나타내는 주석 추가
cdm1263 Jan 18, 2024
12f24e7
Design: 몬스터볼 이미지 배경에 추가
cdm1263 Jan 18, 2024
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
3 changes: 3 additions & 0 deletions public/monster-ball1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/monster-ball2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
98 changes: 29 additions & 69 deletions src/components/card/PokemonCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { useLocation } from 'react-router-dom';
interface PokemonCardProp {
pokemonCardData: filteredPokemonData;
pokemonNickName?: {
pokemonNickName1: string;
pokemonNickName2: string;
pokemonName: string;
pokemonNickName1: string | null;
pokemonNickName2: string | null;
pokemonName: string | null;
};
isOpen?: boolean;
}
Expand Down Expand Up @@ -38,8 +38,12 @@ const PokemonCard = ({
: `${styles[mainClassName]} ${typeClass}`;
};

const setMyClassName = (className: string) => {
return isMyPage ? styles[`${className}__my`] : styles[className];
};

const renderStatus = () => {
const statusClassName = isMyPage ? styles.status__my : styles.status;
const statusClassName = setMyClassName('status');
const columnIndex = [0, 1, 2];

return columnIndex.map((index) => (
Expand Down Expand Up @@ -73,15 +77,19 @@ const PokemonCard = ({
>
<div className={setClassName('pokemon_number')}>{`No.${data?.id}`}</div>
<div className={styles.white_block}>
<img
className={setMyClassName('monster_ball_left')}
src="/monster-ball1.svg"
alt=""
/>
<img
className={setMyClassName('monster_ball_right')}
src="/monster-ball2.svg"
alt=""
/>
<div className={setClassName('container')}>
<div className={styles.container__top}>
<div
className={
isMyPage
? `${styles.type_containter__my}`
: `${styles.type_containter}`
}
>
<div className={setMyClassName('container__top')}>
<div className={setMyClassName('type_containter')}>
{data?.types.map((pokemonType: TypesType) => (
<Plate
key={pokemonType.type.name}
Expand All @@ -90,85 +98,37 @@ const PokemonCard = ({
))}
</div>
<img
className={
isMyPage
? `${styles.pokemon_image__my}`
: `${styles.pokemon_image}`
}
className={setMyClassName('pokemon_image')}
src={
data.id !== 1013 ? data.sprites : '/pokemonImg/그우린차.webp'
}
alt="포켓몬 이미지"
/>
<div className={styles.pokemon_intro}>
<div
className={
isMyPage
? `${styles.pokemon_name__my}`
: `${styles.pokemon_name}`
}
>
<span
className={
isMyPage
? `${styles.text__small__my}`
: `${styles.text__small}`
}
>
<div className={setMyClassName('pokemon_name')}>
<span className={setMyClassName('text_small')}>
{pokemonNickName?.pokemonNickName1}
</span>
<span
className={
isMyPage
? `${styles.text__small__my}`
: `${styles.text__small}`
}
>
<span className={setMyClassName('text_small')}>
{pokemonNickName?.pokemonNickName2}
</span>
</div>
<span
className={
isMyPage
? `${styles.text__large__my}`
: `${styles.text__large}`
}
>
<span className={setMyClassName('text_large')}>
{pokemonNickName?.pokemonName}
</span>
</div>
</div>
<div
className={
isMyPage
? `${styles.container__my__bottom}`
: `${styles.container__bottom}`
}
>
<div className={setMyClassName('container__bottom')}>
{renderStatus()}
<div>
<img
className={isMyPage ? `${styles.logo__my}` : `${styles.logo}`}
className={setMyClassName('logo')}
src="/logo-pokehub.png"
alt="PoketHub"
/>
<div className={styles.total_stat}>
<span
className={
isMyPage
? `${styles.text__small__my}`
: `${styles.text__small}`
}
>
Total
</span>
<span
className={
isMyPage
? `${styles.text__large__my}`
: `${styles.text__large}`
}
>
<span className={setMyClassName('text_small')}>Total</span>
<span className={setMyClassName('text_large')}>
{data?.stats.reduce(
(acc, baseStat) => acc + baseStat.base_stat,
0,
Expand Down
Loading
Loading