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

프로필 페이지 #82

Merged
merged 4 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
51 changes: 51 additions & 0 deletions src/features/user/styles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { styled } from 'styled-components';
export const BadgeWrapper = styled.div`
display: flex;
margin-top: 39px;
width: 100%;
gap: 12px;
justify-content: space-between;
padding: 0 17px;
> ul {
display: flex;
flex-wrap: wrap;
gap: 25px;
}
`;
export const PaginationIcon = styled.img<{ $rotate?: string }>`
width: 9px;
height: 20px;
transform: rotate(${({ $rotate }) => $rotate || 0});
`;
export const PaginationButton = styled.button`
border: 0;
background-color: transparent;
`;
export const BadgeListItem = styled.li`
display: flex;
flex-direction: column;
gap: 11px;
> div {
display: flex;
justify-content: center;
align-items: center;
width: 133px;
height: 141px;
flex-shrink: 0;
border-radius: 8px;
border: 2px solid #ffe161;
background: #ffefaa;
}
> h5 {
border-radius: 8px;
border: 2px solid #ffefaa;
background: #ffe161;
color: #fff;
text-align: center;
font-size: 12px;
font-style: normal;
font-weight: 700;
line-height: 24px; /* 266.667% */
text-transform: lowercase;
}
`;
57 changes: 57 additions & 0 deletions src/features/user/ui/BadgeContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import {
BadgeListItem,
BadgeWrapper,
PaginationButton,
PaginationIcon,
} from '../styles';
import { getImageUrl } from '@/utils/getImageUrl';

const testBadgeList = [
{
id: 1,
badgeImage: '테스트뱃지.webp',
badgeTitle: '왕',
},
{
id: 2,
badgeImage: '테스트뱃지.webp',
badgeTitle: '왕왕',
},
{
id: 3,
badgeImage: '테스트뱃지.webp',
badgeTitle: '왕대대',
},
{
id: 4,
badgeImage: '테스트뱃지.webp',
badgeTitle: '왕대대왕',
},
];
export default function BadgeContainer() {
return (
<>
<BadgeWrapper>
<PaginationButton>
<PaginationIcon src={getImageUrl('뱃지-다음버튼.svg')} />
</PaginationButton>
<ul>
{testBadgeList.map(badgeItem => (
<BadgeListItem key={badgeItem.id}>
<div>
<img src={getImageUrl(badgeItem.badgeImage)} />
</div>
<h5>{badgeItem.badgeTitle}</h5>
</BadgeListItem>
))}
</ul>
<PaginationButton>
<PaginationIcon
src={getImageUrl('뱃지-다음버튼.svg')}
$rotate="180deg"
/>
</PaginationButton>
</BadgeWrapper>
</>
);
}
10 changes: 10 additions & 0 deletions src/features/user/ui/ProfileImage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { getImageUrl } from '@/utils/getImageUrl';

export default function ProfileImage() {
//기능 제작 시 자기 캐릭터에서 프로필이미지 추출하는 로직 추가
return (
<>
<img src={getImageUrl('테스트프로필.svg')} />
</>
);
}
112 changes: 112 additions & 0 deletions src/pages/profile/Profile.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
import CokoLogo from '@common/layout/CokoLogo';
import MenuBar from '@common/layout/MenuBar';
import { Layout, LeftSection, RightSection, Wrapper } from '@/style/style';
import Header from '@common/layout/Header';
import {
BadgeLabel,
JoinDateLabel,
LevelDiv,
MyProgressDiv,
MyQuizInfoDiv,
UserNameLabel,
ProfileSection,
BadgeSection,
LevelList,
LevelLabel,
MyCharacterImage,
} from './styles';
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
import {
BadgeLabel,
JoinDateLabel,
LevelDiv,
MyProgressDiv,
MyQuizInfoDiv,
UserNameLabel,
ProfileSection,
BadgeSection,
LevelList,
LevelLabel,
MyCharacterImage,
} from './styles';
import * as S from "./styles";

. . .

//사용시
<S.BadeLabel />
<S.JoinDateLabel />

위와 같이 사용해 보는건 어떨까요?🧐

S-dot이라고 불리는 방식인데, 이런식으로 적으면 아래와 같은 이점이 있습니다.

  • 해당 컴포넌트가 styled-componet라는것도 명확해짐
  • 스타일을 작성하실 때, S. 으로 접근이 가능하기 때문에 편리함
  • import 부분을 간소화 할 수 있다.

생각해보시고, 적용해보시는 것을 추천드립니다!👏

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

미니 프로젝트에서 적용했던 방법인데 프로젝트를 하다보니 이런 세세한 부분을 놓쳐버렸네요 😢
다시 복기시켜주셔서 감사합니다.
@zzzRYT 님 의견대로 import 구문쪽에 간소화되는게 좋은 것 같습니다!
꼼꼼하게 봐주셔서 감사합니다 😊

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

26d1e68 커밋에서 해당 방식을 적용시켰습니다. 확실히 import 구문이 간소화되네요 ㅎㅎ

Copy link
Collaborator

Choose a reason for hiding this comment

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

@zzzRYT 님께서 말씀하신 것처럼 해당 컴포넌트가 styled-componet라는 점, import 부분 간소화 등 장점이 확실한 방법입니다.

아쉬운 점이라면 스타일드 컴포넌트 파일 안에 내가 필요로 하지 않는 스타일까지 있다면 S-dot 방식을 사용할 떄 그런 필요로 하지 않는 스타일까지 import 시키기 때문에 스타일드 컴포넌트 파일 자체가 조금 무거운 편이라면 약간의 시간차가 발생할 수 있다네용😊

import ProfileImage from '@features/user/ui/ProfileImage';
import ProgressBar from '@features/progress/ui/ProgressBar';
import { getImageUrl } from '@/utils/getImageUrl';
import BadgeContainer from '@features/user/ui/BadgeContainer';
import React from 'react';
const levelList = [60, 50, 40, 30, 20, 10];
export default function Profile() {
return (
<>
<Wrapper>
<LeftSection>
<CokoLogo />
<MenuBar />
</LeftSection>
<RightSection>
<Header />

<LevelDiv>
<div>
<MyCharacterImage src={getImageUrl('테스트캐릭터.svg')} />
<LevelLabel>Level.1</LevelLabel>
</div>
<LevelList>
{levelList.map(level => (
<React.Fragment key={level}>
<li>
<span>Level.{level} </span> -
</li>
<li>&mdash;</li>
</React.Fragment>
))}
</LevelList>
<ProgressBar
$progress={40}
$maxProgress={100}
$height="20px"
$innerBgColor="#FFD100;"
$boxBgColor="#FFEFAA"
style={{
width: '600px',
position: 'absolute',
transform: 'rotate(-90deg)',
right: '-270px',
top: '300px',
}}
/>
</LevelDiv>
</RightSection>
</Wrapper>
<Layout>
<ProfileSection>
<div>
<ProfileImage />
<UserNameLabel>유저 이름</UserNameLabel>
<JoinDateLabel>2024.10.01</JoinDateLabel>
</div>
<MyProgressDiv>
<p>
코코에 접속한 지 벌써 <span>20</span>일이 됐어요 !
</p>
<img src={getImageUrl('출석일수.svg')}></img>
<div>
<p>진행도</p>
<ProgressBar
$progress={40}
$maxProgress={100}
$height="20px"
$innerBgColor="#BFD683"
$boxBgColor="#85705F"
style={{
width: '283px',
}}
/>
</div>
<MyQuizInfoDiv>
<p>
푼 문제 <span>52</span>개
</p>
<p>
틀린 문제 <span>52</span>개
</p>
<p>
안 푼 문제 <span>52</span>개
</p>
</MyQuizInfoDiv>
</MyProgressDiv>
</ProfileSection>
<BadgeSection>
<BadgeLabel>나의 뱃지</BadgeLabel>
<BadgeContainer />
</BadgeSection>
</Layout>
</>
);
}
Loading