Skip to content

Commit

Permalink
refactor: skeleton quiz list 추가 및 client 컴포넌트 세팅
Browse files Browse the repository at this point in the history
  • Loading branch information
minsgy committed Jan 14, 2024
1 parent ff3bef4 commit b9cc44c
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/app/(AppBarHeader)/toks-main/_components/SkeletonCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import clsx from 'clsx';
import React from 'react';

import { Skeleton } from '@/common/components/Skeleton';

type Props = {
quizType?: 'ox' | 'default';
};

export const SkeletonCardList = () => {
return (
<div className="flex h-full flex-col gap-8px">
<SkeletonCard quizType="ox" />
<SkeletonCard />
<SkeletonCard quizType="ox" />
<SkeletonCard />
<SkeletonCard quizType="ox" />
<SkeletonCard />
</div>
);
};

const SkeletonCard = ({ quizType = 'default' }: Props) => {
return (
<div
className={clsx(
'flex h-220px w-full min-w-180px gap-20px rounded-12px bg-gray-110 px-16px py-20px'
)}
>
<div className="flex h-full flex-1 animate-pulse flex-col justify-between">
<div className="flex flex-col">
<div className="flex gap-8px">
<Skeleton className="h-[20px] w-[40px]" />
<Skeleton className="h-[20px] w-[40px]" />
</div>
</div>
<div className="flex flex-col justify-between gap-8px rounded-8px">
<Skeleton className="h-[20px] w-4/5" />
<Skeleton className="h-[20px]" />
<Skeleton className="h-[20px] w-3/5" />
</div>
<Skeleton className="h-[14px]" />
</div>
<div className="flex w-[120px] animate-pulse flex-col gap-8px">
{quizType === 'ox' ? (
<>
<Skeleton className="h-1/2" />
<Skeleton className="h-1/2" />
</>
) : (
<Skeleton className="h-full" />
)}
</div>
</div>
);
};
13 changes: 13 additions & 0 deletions src/common/components/Skeleton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { ClassNameValue, twMerge } from 'tailwind-merge';

type Props = {
className?: ClassNameValue;
};

export const Skeleton = ({ className }: Props) => {
return (
<div
className={twMerge('h-[20px] w-full rounded-[8px] bg-gray-90', className)}
/>
);
};
4 changes: 4 additions & 0 deletions src/common/providers/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
QueryClient,
QueryClientProvider,
} from '@tanstack/react-query';
import { ReactQueryDevtools } from '@tanstack/react-query-devtools';
import { PropsWithChildren, useState } from 'react';
import { RecoilRoot } from 'recoil';

Expand Down Expand Up @@ -33,6 +34,9 @@ export default function RootProvider({ children }: PropsWithChildren) {
<RecoilRoot>
<GlobalPortal.Provider>{children}</GlobalPortal.Provider>
</RecoilRoot>
<ReactQueryDevtools
initialIsOpen={process.env.NEXT_PUBLIC_MODE === 'local'}
/>
</QueryClientProvider>
);
}
1 change: 1 addition & 0 deletions src/queries/useQuizListInfinityQuery/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
'use client';
import { useInfiniteQuery } from '@tanstack/react-query';
import { useRecoilValue } from 'recoil';

Expand Down

0 comments on commit b9cc44c

Please sign in to comment.