Skip to content

Commit

Permalink
feat: create Loading component and apply it to routes
Browse files Browse the repository at this point in the history
  • Loading branch information
lumirlumir committed Oct 16, 2024
1 parent a386658 commit 44a58f2
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 1 deletion.
Binary file added public/images/loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion src/app/categories/[tag]/page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import Link from 'next/link';
import { Fragment, Suspense } from 'react';
import { FaBook, FaTag, FaRegCalendarPlus, FaRegCalendarXmark } from 'react-icons/fa6';

import Loading from '@/components/common/Loading';

import { PATH_DOCS, EXT_MD_REGEXP } from '@/constants';
import { compareMarkdownDocument } from '@/utils/compare';
import { readMarkdownTagTree } from '@/utils/fs';
Expand All @@ -24,7 +26,7 @@ export default async function Page({ params, searchParams }) {
const tagTree = await readMarkdownTagTree(PATH_DOCS);

return (
<Suspense key={sort + order} fallback={<span>loading...</span>}>
<Suspense key={sort + order} fallback={<Loading />}>
{tagTree[params.tag]
.sort(compareMarkdownDocument(sort, order))
.map(({ basename, data: { title, description, created, updated, tags } }) => (
Expand Down
5 changes: 5 additions & 0 deletions src/app/posts/[markdown]/loading.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import LoadingGif from '@/components/common/Loading';

export default function Loading() {
return <LoadingGif />;
}
19 changes: 19 additions & 0 deletions src/components/common/Loading/Loading.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Image from 'next/image';

import styles from './Loading.module.scss';

export default function Loading({ content }) {
return (
<div className={styles.loading}>
<div>
<Image
src={'/images/loading.gif'}
width={48}
height={48}
alt="GitHub gif loading image"
/>
<div>{content} 불러오는 중...</div>
</div>
</div>
);
}
3 changes: 3 additions & 0 deletions src/components/common/Loading/Loading.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.loading {
@include props-flex-center;
}
3 changes: 3 additions & 0 deletions src/components/common/Loading/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Loading from './Loading';

export default Loading;

0 comments on commit 44a58f2

Please sign in to comment.