Skip to content

Commit

Permalink
#12 Add userItem skeleton
Browse files Browse the repository at this point in the history
  • Loading branch information
limyeonsang committed Jul 8, 2022
1 parent b328345 commit 1c0e481
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 27 deletions.
10 changes: 5 additions & 5 deletions pages/myPage/viewFollow.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC, useEffect, useState } from "react";
import { FC, useState } from "react";
import styled from "@emotion/styled";
import { UserItem, SelectButton } from "@views/viewFollow";
import { UserItem, SelectButton, UserItemSkeleton } from "@views/viewFollow";
import { useQuery } from "react-query";
import queryKey from "@constants/queryKey";
import { getFollowerList, getFollowingList } from "@apis/myPage";
Expand All @@ -12,14 +12,14 @@ const ViewFollowContainer: FC = () => {
const [isFollower, setIsFollower] = useState<boolean>(true);

if (res1.isLoading || res1.isLoading) {
return <div>loading</div>;
return <UserItemSkeleton />;
}

if (res1.isError || res2.isError) {
return <div>error</div>;
}

const whatMap = () => (isFollower ? res1.data : res2.data);
const whatsSelected = () => (isFollower ? res1.data : res2.data);

return (
<Container>
Expand All @@ -43,7 +43,7 @@ const ViewFollowContainer: FC = () => {
initalName="follower-list"
/>
<UserItems>
{whatMap().map((ele) => (
{whatsSelected().map((ele) => (
<UserItem key={ele.id} profile={ele.profile} name={ele.name} />
))}
</UserItems>
Expand Down
44 changes: 22 additions & 22 deletions views/myPage/UserInfoSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
import styled from "@emotion/styled";

const UserInfoSkeleton = () => (
<Container>
<Outer>
<ProfileImage />
<Inner>
<Name>ㅇㅇㅇ</Name>
<FollowContainer>
<Follow>ㅇㅇㅇ 0</Follow>
<Follow>ㅇㅇㅇ 0</Follow>
</FollowContainer>
</Inner>
</Outer>
</Container>
);

export default UserInfoSkeleton;

const Container = styled.section`
background-color: ${({ theme }) => theme.colors.grayscale.scale10};
padding: 16px 20px;
Expand All @@ -16,7 +33,7 @@ const ProfileImage = styled.div`
border-radius: 50%;
width: 65px;
height: 65px;
background-color: ${({ theme }) => theme.colors.grayscale.scale40};
background-color: ${({ theme }) => theme.colors.grayscale.scale50};
`;

const Inner = styled.div`
Expand All @@ -33,30 +50,13 @@ const FollowContainer = styled.div`

const Follow = styled.p`
font-size: 14px;
color: ${({ theme }) => theme.colors.grayscale.scale20};
background-color: ${({ theme }) => theme.colors.grayscale.scale20};
color: ${({ theme }) => theme.colors.grayscale.scale50};
background-color: ${({ theme }) => theme.colors.grayscale.scale50};
`;

const Name = styled.p`
font-size: 16px;
color: ${({ theme }) => theme.colors.grayscale.scale20};
background-color: ${({ theme }) => theme.colors.grayscale.scale20};
color: ${({ theme }) => theme.colors.grayscale.scale50};
background-color: ${({ theme }) => theme.colors.grayscale.scale50};
margin-bottom: 3px;
`;

const UserInfoSkeleton = () => (
<Container>
<Outer>
<ProfileImage />
<Inner>
<Name>ㅇㅇㅇ</Name>
<FollowContainer>
<Follow>ㅇㅇㅇ 0</Follow>
<Follow>ㅇㅇㅇ 0</Follow>
</FollowContainer>
</Inner>
</Outer>
</Container>
);

export default UserInfoSkeleton;
45 changes: 45 additions & 0 deletions views/viewFollow/UserItemSkeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import styled from "@emotion/styled";

const UserItemSkeleton = () => (
<Container>
{Array(5)
.fill(0)
.map((_, idx) => (
<UserItemConatainer key={idx}>
<ProfileImage />
<Name>ㅇㅇㅇㅇㅇㅇㅇㅇㅇ</Name>
</UserItemConatainer>
))}
</Container>
);

export default UserItemSkeleton;

const Container = styled.section`
height: 100vh;
display: flex;
flex-direction: column;
`;

const UserItemConatainer = styled.div`
width: 100%;
background-color: ${({ theme }) => theme.colors.grayscale.scale10};
display: flex;
flex-direction: row;
align-items: center;
padding: 12px 20px;
`;

const ProfileImage = styled.div`
border-radius: 50%;
background-color: ${({ theme }) => theme.colors.grayscale.scale50};
width: 48px;
height: 48px;
`;

const Name = styled.p`
font-size: 14px;
margin-left: 20px;
background-color: ${({ theme }) => theme.colors.grayscale.scale50};
color: ${({ theme }) => theme.colors.grayscale.scale50};
`;
1 change: 1 addition & 0 deletions views/viewFollow/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { default as UserItem } from "./UserItem";
export { default as SelectButton } from "./SelectButton";
export { default as UserItemSkeleton } from "./UserItemSkeleton";

0 comments on commit 1c0e481

Please sign in to comment.