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

Refactor: Detail페이지 useSkeleton 적용 #305

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const DefaultSkeleton = styled.div`
background-color: #dbdbdb;
position: relative;
overflow: hidden;
animation: ${loading} 1.7s ease-in-out infinite;
animation: ${loading} 1.5s ease-in-out infinite;

&:before {
content: "";
Expand Down
4 changes: 3 additions & 1 deletion co-kkiri/src/components/domains/detail/DetailCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import DetailCardSkeleton from "@/components/commons/Skeleton/DetailCardSkeleton
import { PostDetails } from "@/lib/api/post/type";
import { formatDate } from "@/utils/formatDate";
import { postDetailInitialData } from "@/lib/initialData/detail";
import useSkeleton from "@/hooks/useSkeleton";

interface DetailCardProps {
postDetails: PostDetails;
Expand All @@ -15,10 +16,11 @@ interface DetailCardProps {
export default function DetailCard({ postDetails, className, cardRef, isLoading }: DetailCardProps) {
const { type, recruitEndAt, progressPeriod, positions, progressWay, contactWay, capacity, stacks, link } =
postDetails;
const isVisibleSkeleton = useSkeleton(isLoading);

return (
<div className={className} ref={cardRef}>
{isLoading || postDetails === postDetailInitialData ? (
{isVisibleSkeleton || postDetails === postDetailInitialData ? (
<DetailCardSkeleton page="detail" />
) : (
<ProjectDetailCard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { PostDetails, PostApplyStatus } from "@/lib/api/post/type";
import { ContentSkeleton, TitleSkeleton } from "@/components/commons/Skeleton/TextSkeleton";
import UserProfileSkeleton from "@/components/commons/Skeleton/UserProfileSkeleton";
import { postDetailInitialData } from "@/lib/initialData/detail";
import useSkeleton from "@/hooks/useSkeleton";

interface RecruitmentPostProps {
postDetails: PostDetails;
Expand All @@ -28,6 +29,7 @@ export default function RecruitmentPost({ isLoading, postDetails, postApplyStatu
viewCount,
scrapCount,
} = postDetails;
const isVisibleSkeleton = useSkeleton(isLoading);

const userInfo = { nickname, profileImageUrl, id };
const isMine = postApplyStatus === "OWNER";
Expand All @@ -36,14 +38,14 @@ export default function RecruitmentPost({ isLoading, postDetails, postApplyStatu

return (
<S.Container className={className}>
{isLoading || postDetails === postDetailInitialData ? (
{isVisibleSkeleton || postDetails === postDetailInitialData ? (
<TitleSkeleton page="detail" />
) : (
<S.Title>{postTitle}</S.Title>
)}
<S.Box>
<S.PostInfoWrapper>
{isLoading || postDetails === postDetailInitialData ? (
{isVisibleSkeleton || postDetails === postDetailInitialData ? (
<UserProfileSkeleton />
) : (
<>
Expand All @@ -56,7 +58,7 @@ export default function RecruitmentPost({ isLoading, postDetails, postApplyStatu
{isMine && <PostManagementButtons />}
</S.Box>
<S.HorizontalDivider />
{isLoading || postDetails === postDetailInitialData ? (
{isVisibleSkeleton || postDetails === postDetailInitialData ? (
<ContentSkeleton />
) : (
<S.Content dangerouslySetInnerHTML={sanitizedContent} />
Expand Down
4 changes: 3 additions & 1 deletion co-kkiri/src/components/domains/detail/StatusBasedButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import TOAST from "@/constants/toast";
import { useNavigate } from "react-router-dom";
import { useHandleError } from "@/hooks/useHandleError";
import ButtonSkeleton from "@/components/commons/Skeleton/ButtonSkeleton";
import useSkeleton from "@/hooks/useSkeleton";

interface MappedButtonProps {
postApplyStatus: PostApplyStatus;
Expand All @@ -37,6 +38,7 @@ export default function StatusBasedButton({
const pushToast = useToast();
const navigate = useNavigate();
const handleError = useHandleError();
const isVisibleSkeleton = useSkeleton(isLoading);

const { applyMutation, cancelMutation } = usePostMutation();

Expand Down Expand Up @@ -93,7 +95,7 @@ export default function StatusBasedButton({

return (
<div className={className}>
{isLoading || !postApplyStatus ? (
{isVisibleSkeleton || !postApplyStatus ? (
<ButtonSkeleton />
) : (
<StyledButton
Expand Down
Loading