-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added Suspense skeletons for news page
- Loading branch information
1 parent
e5a61a9
commit 5f62df8
Showing
13 changed files
with
214 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export function generateMetadata() { | ||
return { | ||
title: 'Test', | ||
}; | ||
} | ||
|
||
export default function Article() { | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import { | ||
Pagination, | ||
PaginationContent, | ||
PaginationEllipsis, | ||
PaginationItem, | ||
PaginationNext, | ||
PaginationPrevious, | ||
} from '@/components/ui/Pagination'; | ||
|
||
type PaginationCarouselSkeletonProps = { | ||
className?: string; | ||
t: { | ||
goToPreviousPage: string; | ||
previous: string; | ||
morePages: string; | ||
goToNextPage: string; | ||
next: string; | ||
}; | ||
}; | ||
|
||
function PaginationCarouselSkeleton({ | ||
className, | ||
t, | ||
}: PaginationCarouselSkeletonProps) { | ||
return ( | ||
<Pagination className={className}> | ||
<PaginationContent> | ||
<PaginationItem> | ||
<PaginationPrevious | ||
className='cursor-not-allowed opacity-50 hover:bg-transparent' | ||
href='#' | ||
goToPreviousPage={t.goToPreviousPage} | ||
previous={t.previous} | ||
aria-disabled={true} | ||
tabIndex={-1} | ||
/> | ||
</PaginationItem> | ||
{Array.from({ length: 4 }).map((_, index) => ( | ||
<PaginationItem className='cursor-not-allowed opacity-50' key={index}> | ||
<PaginationEllipsis morePages='' /> | ||
</PaginationItem> | ||
))} | ||
<PaginationItem> | ||
<PaginationNext | ||
className='cursor-not-allowed opacity-50 hover:bg-transparent' | ||
href='#' | ||
goToNextPage={t.goToNextPage} | ||
next={t.next} | ||
aria-disabled={true} | ||
tabIndex={-1} | ||
/> | ||
</PaginationItem> | ||
</PaginationContent> | ||
</Pagination> | ||
); | ||
} | ||
|
||
export { PaginationCarouselSkeleton }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { cx } from '@/lib/utils'; | ||
|
||
import { NewsCard } from '@/components/news/NewsCard'; | ||
|
||
type NewsCardGridProps = { | ||
newsData: { | ||
id: number; | ||
internal: boolean; | ||
title: string; | ||
date: string; | ||
photoUrl: string; | ||
}[]; | ||
t: { | ||
internalArticle: string; | ||
}; | ||
}; | ||
|
||
function NewsCardGrid({ newsData, t }: NewsCardGridProps) { | ||
return ( | ||
<div className='grid h-192 grid-rows-4 gap-4 xs:h-96 xs:grid-cols-3 xs:grid-rows-2 md:grid-cols-4 lg:h-112'> | ||
{newsData.slice(0, 4).map((data, index) => ( | ||
<NewsCard | ||
className={cx( | ||
index === 0 && 'row-span-1 xs:col-span-2 md:row-span-2', | ||
index === 1 && 'col-span-1 row-span-1 md:col-span-2', | ||
index === 3 && 'row-span-1 xs:col-span-2 md:col-span-1', | ||
)} | ||
key={data.id} | ||
id={data.id} | ||
internal={data.internal} | ||
title={data.title} | ||
date={data.date} | ||
photoUrl={data.photoUrl} | ||
t={{ | ||
internalArticle: t.internalArticle, | ||
}} | ||
/> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
export { NewsCardGrid, type NewsCardGridProps }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import * as React from 'react'; | ||
|
||
import { cx } from '@/lib/utils'; | ||
|
||
import { | ||
NewsCardGrid, | ||
type NewsCardGridProps, | ||
} from '@/components/news/NewsCardGrid'; | ||
import { Skeleton } from '@/components/ui/Skeleton'; | ||
|
||
function NewsCardGridSuspense({ ...props }: NewsCardGridProps) { | ||
return ( | ||
<React.Suspense | ||
fallback={ | ||
<div className='grid h-192 grid-rows-4 gap-4 xs:h-96 xs:grid-cols-3 xs:grid-rows-2 md:grid-cols-4 lg:h-112'> | ||
{Array.from({ length: 4 }).map((_, index) => ( | ||
<Skeleton | ||
className={cx( | ||
'h-full w-full', | ||
index === 0 && 'row-span-1 xs:col-span-2 md:row-span-2', | ||
index === 1 && 'col-span-1 row-span-1 md:col-span-2', | ||
index === 3 && 'row-span-1 xs:col-span-2 md:col-span-1', | ||
)} | ||
key={index} | ||
/> | ||
))} | ||
</div> | ||
} | ||
> | ||
<NewsCardGrid {...props} /> | ||
</React.Suspense> | ||
); | ||
} | ||
|
||
export { NewsCardGridSuspense }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as React from 'react'; | ||
|
||
import { PaginationCarouselSkeleton } from '@/components/layout/PaginationCarouselSkeleton'; | ||
import { | ||
NewsItemGrid, | ||
type NewsItemGridProps, | ||
} from '@/components/news/NewsItemGrid'; | ||
import { NewsItemSkeleton } from '@/components/news/NewsItemSkeleton'; | ||
|
||
function NewsItemGridSuspense({ ...props }: NewsItemGridProps) { | ||
return ( | ||
<React.Suspense | ||
fallback={ | ||
<> | ||
<div className='grid min-h-[752px] grid-cols-1 gap-4 sm:min-h-[368px] sm:grid-cols-2 lg:min-h-[240px] lg:grid-cols-3'> | ||
{Array.from({ length: 6 }).map((_, index) => ( | ||
<NewsItemSkeleton key={index} /> | ||
))} | ||
</div> | ||
<PaginationCarouselSkeleton className='my-6' t={props.t} /> | ||
</> | ||
} | ||
> | ||
<NewsItemGrid {...props} /> | ||
</React.Suspense> | ||
); | ||
} | ||
|
||
export { NewsItemGridSuspense }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Skeleton } from '@/components/ui/Skeleton'; | ||
|
||
function NewsItemSkeleton() { | ||
return ( | ||
<div className='flex gap-4 overflow-hidden rounded-lg'> | ||
<div className='relative h-28 w-28 flex-shrink-0'> | ||
<Skeleton className='h-full w-full rounded-lg object-cover object-center' /> | ||
</div> | ||
<div className='w-full py-2 pr-1'> | ||
<Skeleton className='h-[18px] w-5/6 py-[5px]' /> | ||
<Skeleton className='h-[12px] w-2/3 py-[2px] sm:h-[14px] sm:py-[3px] [&:not(:first-child)]:mt-2' /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export { NewsItemSkeleton }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters