Skip to content

Commit 22b5dbc

Browse files
committed
Refactor: post에 스켈레톤 적용
1 parent f35fc1e commit 22b5dbc

2 files changed

Lines changed: 47 additions & 23 deletions

File tree

src/pages/Post/index.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@ import { modifyPostRepresentativeStatusApi, deletePostApi } from '@apis/post';
77
import { isPostRepresentativeAtom, postIdAtom, userAtom } from '@recoil/Post/PostAtom';
88
import { getCurrentUserId } from '@utils/getCurrentUserId';
99

10+
import back from '@assets/arrow/left.svg';
1011
import Delete from '@assets/default/delete.svg';
1112
import Edit from '@assets/default/edit.svg';
1213
import Pin from '@assets/default/pin.svg';
1314

1415
import BottomSheet from '@components/BottomSheet';
1516
import BottomSheetMenu from '@components/BottomSheet/BottomSheetMenu';
1617
import OptionsBottomSheet from '@components/BottomSheet/OptionsBottomSheet';
18+
import { OODDFrame } from '@components/Frame/Frame';
1719
import Modal from '@components/Modal';
20+
import Skeleton from '@components/Skeleton';
21+
import TopBar from '@components/TopBar/index';
1822

1923
import type { BottomSheetMenuProps } from '@components/BottomSheet/BottomSheetMenu/dto';
2024
import type { BottomSheetProps } from '@components/BottomSheet/dto';
@@ -23,6 +27,8 @@ import type { ModalProps } from '@components/Modal/dto';
2327

2428
import PostBase from './PostBase/index';
2529

30+
import { PicWrapper, NameWrapper, InfoWrapper, PostWrapper } from './styles';
31+
2632
const Post: React.FC = () => {
2733
const user = useRecoilValue(userAtom);
2834
const postId = useRecoilValue(postIdAtom);
@@ -37,6 +43,8 @@ const Post: React.FC = () => {
3743
const [modalContent, setModalContent] = useState('');
3844
const [postPinStatus, setPostPinStatus] = useState<'지정' | '해제'>('지정');
3945

46+
const [isLoading, setIsLoading] = useState(true);
47+
4048
const navigate = useNavigate();
4149
const currentUserId = getCurrentUserId();
4250

@@ -87,6 +95,10 @@ const Post: React.FC = () => {
8795
};
8896

8997
useEffect(() => {
98+
setTimeout(() => {
99+
setIsLoading(false);
100+
}, 5000);
101+
90102
// 현재 게시글이 내 게시글인지 확인
91103
if (user?.id && postId) {
92104
setIsMyPost(currentUserId === user.id);
@@ -163,6 +175,25 @@ const Post: React.FC = () => {
163175
content: modalContent,
164176
};
165177

178+
if (isLoading) {
179+
return (
180+
<OODDFrame>
181+
<TopBar LeftButtonSrc={back} onClickLeftButton={() => navigate(-1)} />
182+
<InfoWrapper>
183+
<PicWrapper>
184+
<Skeleton width={40} height={40} borderRadius={40} />
185+
</PicWrapper>
186+
<NameWrapper>
187+
<Skeleton width={100} height={20} />
188+
</NameWrapper>
189+
</InfoWrapper>
190+
<PostWrapper>
191+
<Skeleton width="100%" height={800} />
192+
</PostWrapper>
193+
</OODDFrame>
194+
);
195+
}
196+
166197
return (
167198
<>
168199
<PostBase onClickMenu={handleMenuOpen} />

src/pages/Post/styles.tsx

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,21 @@
11
import { styled } from 'styled-components';
22

3-
export const InputLayout = styled.div`
3+
export const InfoWrapper = styled.div`
44
display: flex;
5-
flex-direction: column;
6-
justify-content: center;
7-
align-items: center;
5+
flex-direction: row;
6+
align-items: left;
7+
`;
8+
9+
export const PicWrapper = styled.div`
10+
margin-left: 47px;
11+
`;
12+
13+
export const NameWrapper = styled.div`
14+
margin-left: 10px;
15+
margin-top: 10px;
16+
`;
817

9-
textarea {
10-
display: block;
11-
width: calc(100% - 3rem);
12-
height: 5.75rem;
13-
border-radius: 0.125rem;
14-
border: 0.0625rem solid ${({ theme }) => theme.colors.gray[600]};
15-
margin-bottom: 5.875rem;
16-
z-index: 2;
17-
margin-top: -3.75rem;
18-
outline: none;
19-
padding: 0.8125rem 0.9375rem;
20-
font-family: 'Pretendard Variable';
21-
font-size: 1rem;
22-
font-style: normal;
23-
font-weight: 300;
24-
line-height: 150%;
25-
color: ${({ theme }) => theme.colors.text.primary};
26-
resize: none;
27-
}
18+
export const PostWrapper = styled.div`
19+
margin-top: 10px;
20+
padding-inline: 30px;
2821
`;

0 commit comments

Comments
 (0)