Skip to content

Commit 7f7c411

Browse files
committed
Shows vector image when post list is empty
1 parent a078711 commit 7f7c411

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

src/containers/velog/UserPosts.tsx

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import PostCardList, {
55
import { GET_POST_LIST, PartialPost } from '../../lib/graphql/post';
66
import { useQuery } from '@apollo/react-hooks';
77
import PaginateWithScroll from '../../components/common/PaginateWithScroll';
8+
import { undrawBlankCanvas } from '../../static/images';
9+
import palette from '../../lib/styles/palette';
10+
import styled from 'styled-components';
811

912
interface UserPostsProps {
1013
username: string;
@@ -45,11 +48,37 @@ const UserPosts: React.FC<UserPostsProps> = ({ username }) => {
4548

4649
return (
4750
<>
48-
<PostCardList posts={data.posts} hideUser />
51+
{data.posts.length > 0 ? (
52+
<PostCardList posts={data.posts} hideUser />
53+
) : (
54+
<EmptyBlock>
55+
<img src={undrawBlankCanvas} alt="list is empty" />
56+
<div className="message">포스트가 없습니다.</div>
57+
</EmptyBlock>
58+
)}
59+
4960
{loading && <PostCardListSkeleton forLoading hideUser={true} />}
5061
<PaginateWithScroll cursor={cursor} onLoadMore={onLoadMore} />
5162
</>
5263
);
5364
};
5465

66+
const EmptyBlock = styled.div`
67+
width: 100%;
68+
display: flex;
69+
align-items: center;
70+
flex-direction: column;
71+
margin-top: 6rem;
72+
margin-bottom: 3rem;
73+
img {
74+
width: 20rem;
75+
}
76+
.message {
77+
font-size: 2rem;
78+
color: ${palette.gray6};
79+
margin-top: 3rem;
80+
margin-bottom: 2rem;
81+
}
82+
`;
83+
5584
export default UserPosts;

0 commit comments

Comments
 (0)