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

프로필 페이지 너비 수정 및 스켈레톤 ui 구현 #352

Merged
merged 8 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
3 changes: 0 additions & 3 deletions src/pages/GamesDetailPage/GamesDetailPage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

import { useState } from 'react';

import { ErrorBoundary } from 'react-error-boundary';
import toast from 'react-hot-toast';

import { useNavigate, useParams } from 'react-router-dom';

import { Avatar } from '@components/Avatar';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ type BoxProps = {
export const Box = styled.div<BoxProps>`
height: ${(props) => props.height};
`;

export const ProfileWrapper = styled.div`
margin: 0 16px;
`;
18 changes: 13 additions & 5 deletions src/pages/MannerScoreReviewPage/MannerScoreReviewPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { useEffect, useState } from 'react';
import { Suspense, useEffect, useState } from 'react';
import { useNavigate } from 'react-router-dom';

import { Profile } from '@pages/ProfilePage/Profile';
import { ProfileSkeleton } from '@pages/ProfilePage';
import { Profile } from '@pages/ProfilePage';

import { Avatar } from '@components/Avatar';
import { Header } from '@components/Header';
Expand All @@ -27,6 +28,7 @@ import {
BackwardWrapper,
Box,
MemberListContainer,
ProfileWrapper,
ReviewPageContainer,
TextWrapper,
} from './MannerScoreReviewPage.style';
Expand Down Expand Up @@ -222,9 +224,15 @@ export const MannerScoreReviewPage = () => {
</Flex>
<Modal isOpen={isOpen} close={() => setIsOpen(false)}>
<Modal.Content>
<Profile
memberId={teammateList[currentSelectedMemberIndex].memberId}
/>
<ProfileWrapper>
<Suspense fallback={<ProfileSkeleton />}>
{isOpen && (
<Profile
memberId={teammateList[currentSelectedMemberIndex].memberId}
/>
)}
</Suspense>
</ProfileWrapper>
</Modal.Content>
</Modal>
</ReviewPageContainer>
Expand Down
9 changes: 3 additions & 6 deletions src/pages/ProfilePage/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,8 @@ export const Profile = ({ memberId }: { memberId: Member['id'] }) => {
: '없음'}
</CrewGroup>
</ProfileField>
<ProfileField category="획득한 뱃지">{'없음'}</ProfileField>
<ProfileField category="자기소개">
<Introduce>
<Text>{profile.introduction}</Text>
</Introduce>
<Introduce>{profile.introduction}</Introduce>
</ProfileField>
</FlexItem>
<Modal isOpen={isModalOpen} close={() => setIsModalOpen(false)}>
Expand All @@ -202,7 +199,7 @@ export const Profile = ({ memberId }: { memberId: Member['id'] }) => {
);
};

const ProfileField = ({ category, children }: ProfileFieldProps) => {
export const ProfileField = ({ category, children }: ProfileFieldProps) => {
return (
<ProfileFieldContainer>
<Text size="1.2rem" weight={700}>
Expand All @@ -217,7 +214,7 @@ const ProfileField = ({ category, children }: ProfileFieldProps) => {

const EventButton = ({ text, width, onClick }: EventButtonProps) => (
<Button
width={width ?? '160px'}
width={width ?? '50%'}
height="32px"
backgroundColor="white"
textColor={theme.PALETTE.GRAY_400}
Expand Down
15 changes: 4 additions & 11 deletions src/pages/ProfilePage/ProfilePage.style.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import styled from '@emotion/styled';

import { Flex } from '@components/shared/Flex';

const MAX_WIDTH = '480px';
import { Text } from '@components/shared/Text';

export const ProfileContainer = styled.div`
${({ theme }) => theme.STYLES.LAYOUT}
min-height: 100dvh;
display: flex;
justify-content: center;
`;

export const Main = styled.div`
margin: 10px 0;
display: flex;
justify-content: center;
width: 100%;
`;

Expand All @@ -40,7 +36,6 @@ export const ItemBox = styled.div<{ border?: string }>`
`;

export const ProfileFieldContainer = styled.div`
max-width: ${MAX_WIDTH};
width: 100%;
`;

Expand All @@ -52,15 +47,13 @@ export const CrewGroup = styled.div`
flex-wrap: wrap;
`;

export const Introduce = styled.div`
export const Introduce = styled(Text)`
background-color: ${({ theme }) => theme.PALETTE.GRAY_100};
border-radius: 20px;
width: 100%;
padding: 16px;
display: inline-block;
& > p {
white-space: pre-wrap;
}
white-space: pre-wrap;
word-break: break-all;
`;

export const PointerFlex = styled(Flex)`
Expand Down
11 changes: 11 additions & 0 deletions src/pages/ProfilePage/ProfilePageSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Header } from '@components/Header';

import { ProfileContainer } from './ProfilePage.style';
import { ProfileSkeleton } from './ProfileSkeleton';

export const ProfilePageSkeleton = () => (
<ProfileContainer>
<Header isLogo={false} isRightContainer={true} />
<ProfileSkeleton />
</ProfileContainer>
);
54 changes: 54 additions & 0 deletions src/pages/ProfilePage/ProfileSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Skeleton } from '@components/Skeleton';
import { Flex } from '@components/shared/Flex';

import { theme } from '@styles/theme';

import { ProfileField } from './Profile';
import { FlexItem, Main } from './ProfilePage.style';

export const ProfileSkeleton = () => (
<Main>
<Skeleton
width="100%"
height="30px"
radius="5px"
defaultColor={theme.PALETTE.GRAY_100}
gradientColor={theme.PALETTE.GRAY_200}
>
<FlexItem>
<Flex align="flex-end" gap={8}>
<Skeleton.Item width="40px" height="24px" />
<Skeleton.Item width="100px" height="17px" />
</Flex>
<Flex justify="center" gap={40} align="center">
<Skeleton.Item width="100px" height="100px" radius="50px" />
<Skeleton.Item width="58px" height="78px" />
<Skeleton.Item width="35px" height="78px" />
</Flex>

<Flex justify="center" gap={10}>
<Skeleton.Item width="50%" radius="0.75rem" height="32px" />
<Skeleton.Item width="50%" radius="0.75rem" height="32px" />
</Flex>

<ProfileField category="포지션">
{Array(5)
.fill(null)
.map((_, index) => (
<Skeleton.Item width="45px" height="45px" key={index} />
))}
</ProfileField>
<ProfileField category="소속 크루">
{Array(3)
.fill(null)
.map((_, index) => (
<Skeleton.Item width="45px" height="45px" key={index} />
))}
</ProfileField>
<ProfileField category="자기소개">
<Skeleton.Item width="100%" height="32px" radius="20px" />
</ProfileField>
</FlexItem>
</Skeleton>
</Main>
);
3 changes: 3 additions & 0 deletions src/pages/ProfilePage/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
export * from './ProfilePage';
export * from './ProfilePageSkeleton';
export * from './ProfileSkeleton';
export * from './Profile';
7 changes: 6 additions & 1 deletion src/routes/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { CrewsDetailPageLoading } from '@pages/CrewsDetailPage';
import { GamesDetailPageLoading } from '@pages/GamesDetailPage';
import { Layout } from '@pages/Layout';
import { MainPageLoading } from '@pages/MainPage';
import { ProfilePageSkeleton } from '@pages/ProfilePage';
import { CardListPageSkeleton } from '@pages/__components__/CardListPageSkeleton';
import { ManagePageSkeleton } from '@pages/__components__/ManagePageSkeleton';

Expand Down Expand Up @@ -176,7 +177,11 @@ export const router = createBrowserRouter([
},
{
path: 'profile/:id',
element: <ProfilePage />,
element: (
<Suspense fallback={<ProfilePageSkeleton />}>
<ProfilePage />
</Suspense>
),
},
{ path: 'profile/update', element: <h1>프로필 수정 페이지</h1> },
{
Expand Down
Loading