Skip to content

Commit

Permalink
✨ feat: skeleton ui 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
chaaerim committed Mar 2, 2024
1 parent b6a586d commit cf60c0d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/app/template.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { CategoryBottomSheet } from './toks-main/components/CategoryBottomSheet'
export default function Template({ children }: StrictPropsWithChildren) {
// TODO: useAuth hook 구현
// TODO: useLogin Modal hook 구현
// TODO: GlobalPortal 제거
const pathName = usePathname();

return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export const SkeletonSlider = () => {
return <div></div>;
return (
<div className="aspect-w-3 aspect-h-1 z-0 h-130px w-full animate-pulse rounded-12px bg-gray-110"></div>
);
};
25 changes: 18 additions & 7 deletions src/app/toks-main/components/MainPageSlider/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
'use client';
import { useSuspenseQuery } from '@tanstack/react-query';
import { useQuery } from '@tanstack/react-query';

import { NoticeSlider } from '@/common';

import { SkeletonSlider } from './SkeletonSlider';
import { QUERY_KEYS } from '../../constants/queryKeys';
import { getNotices } from '../../remotes/notice';

export const MainPageSlider = () => {
const { data: notices } = useSuspenseQuery({
const {
data: notices,
isLoading,
isSuccess,
} = useQuery({
queryKey: [QUERY_KEYS.GET_NOTICES],
queryFn: async () => {
try {
Expand All @@ -18,9 +22,16 @@ export const MainPageSlider = () => {
},
});

const imageInfo = notices.bottomBanners.map((el) => {
return { imageUrl: el.imageUrl, landingUrl: el.landingUrl };
});
if (isLoading) {
return <SkeletonSlider />;
}

if (isSuccess) {
const imageInfo = notices.bottomBanners.map((el) => {
return { imageUrl: el.imageUrl, landingUrl: el.landingUrl };
});
return <NoticeSlider images={imageInfo} />;
}

return <NoticeSlider images={imageInfo} />;
return null;
};
7 changes: 2 additions & 5 deletions src/app/toks-main/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
import { useEffect, useState } from 'react';
import { useRecoilState } from 'recoil';

import { FloatingButton, SSRSuspense, Toast, ToastProps } from '@/common';
import { FloatingButton, Toast, ToastProps } from '@/common';
import { useToast } from '@/common/hooks';
import { isVisibleFloatingButtonBottomSheetAtom } from '@/store';

import { CardList } from './components/CardList';
import { MainPageBottomSheet } from './components/MainPageBottomSheet';
import { MainPageSlider } from './components/MainPageSlider';
import { SkeletonSlider } from './components/MainPageSlider/SkeletonSlider';

function ToksMainPage() {
const { getSavedToastInfo, clearSavedToast } = useToast();
Expand All @@ -34,9 +33,7 @@ function ToksMainPage() {
title={toastData.title}
/>
)}
<SSRSuspense fallback={<SkeletonSlider />}>
<MainPageSlider />
</SSRSuspense>
<MainPageSlider />
<div className="h-24px" />
<CardList />

Expand Down

0 comments on commit cf60c0d

Please sign in to comment.