Skip to content

Commit eba4e37

Browse files
Merge pull request #97 from Atharva0506/refactor/animated-loading-spinner
Refactor: utilize loading component with animated logo
2 parents 84bdd4d + ec61539 commit eba4e37

3 files changed

Lines changed: 26 additions & 10 deletions

File tree

app/loading.tsx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1-
export default function Loading() {
2-
return null
1+
import Image from "next/image";
2+
3+
interface LoadingProps {
4+
message?: string;
35
}
6+
7+
export default function Loading({ message }: LoadingProps = {}) {
8+
const displayMessage = message ?? "Loading...";
9+
10+
return (
11+
<div className="min-h-screen bg-gradient-to-br from-green-50 via-yellow-50 to-[#FFC517]/10 flex items-center justify-center">
12+
<div className="text-center">
13+
<Image
14+
src="/logo-animated.gif"
15+
alt={displayMessage}
16+
width={80}
17+
height={80}
18+
unoptimized
19+
className="w-20 h-20 mx-auto mb-4"
20+
/>
21+
<p className="text-gray-600">{displayMessage}</p>
22+
</div>
23+
</div>
24+
);
25+
}

app/page.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import BlogCard from "@/components/blog-card"
77
import Pagination from "@/components/pagination"
88
import Link from "next/link"
99
import Footer from "@/components/footer"
10+
import Loading from "@/app/loading"
1011
import type { PaginatedPosts } from "@/types/blog"
1112

1213
export default function HomePage() {
@@ -59,14 +60,7 @@ export default function HomePage() {
5960
)
6061

6162
if (loading) {
62-
return (
63-
<div className="min-h-screen bg-gradient-to-br from-green-50 via-yellow-50 to-[#FFC517]/10 flex items-center justify-center">
64-
<div className="text-center">
65-
<div className="animate-spin rounded-full h-12 w-12 border-b-2 border-[#228B22] mx-auto mb-4"></div>
66-
<p className="text-gray-600">Loading articles...</p>
67-
</div>
68-
</div>
69-
)
63+
return <Loading message="Loading articles..." />
7064
}
7165

7266
if (!paginatedData) {

public/logo-animated.gif

1.72 MB
Loading

0 commit comments

Comments
 (0)