Skip to content

Commit c7ac0d9

Browse files
committed
Feat: 로딩 화면 추가
1 parent eaf9f74 commit c7ac0d9

File tree

3 files changed

+66
-43
lines changed

3 files changed

+66
-43
lines changed

components/home-animation.tsx

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,39 @@ export function HeaderSection({
1515
setMounted(true);
1616
}, []);
1717

18+
if (!mounted) {
19+
return (
20+
<section className="space-y-2 sm:space-y-3 md:space-y-4">
21+
<h1 className="text-lg sm:text-xl lg:text-2xl font-bold">{title}</h1>
22+
<p className="text-sm sm:text-base text-muted-foreground">{description}</p>
23+
</section>
24+
);
25+
}
26+
1827
return (
19-
mounted && (
20-
<motion.section
21-
className="space-y-2 sm:space-y-3 md:space-y-4"
22-
initial={{ opacity: 0, y: 20 }}
23-
animate={{ opacity: 1, y: 0 }}
24-
transition={{ duration: 0.2, ease: "easeOut" }}
28+
<motion.section
29+
className="space-y-2 sm:space-y-3 md:space-y-4"
30+
initial={{ opacity: 0, y: 20 }}
31+
animate={{ opacity: 1, y: 0 }}
32+
transition={{ duration: 0.2, ease: "easeOut" }}
33+
>
34+
<motion.h1
35+
className="text-lg sm:text-xl lg:text-2xl font-bold"
36+
initial={{ opacity: 0 }}
37+
animate={{ opacity: 1 }}
38+
transition={{ delay: 0.1, duration: 0.2 }}
39+
>
40+
{title}
41+
</motion.h1>
42+
<motion.p
43+
className="text-sm sm:text-base text-muted-foreground"
44+
initial={{ opacity: 0 }}
45+
animate={{ opacity: 1 }}
46+
transition={{ delay: 0.15, duration: 0.2 }}
2547
>
26-
<motion.h1
27-
className="text-lg sm:text-xl lg:text-2xl font-bold"
28-
initial={{ opacity: 0 }}
29-
animate={{ opacity: 1 }}
30-
transition={{ delay: 0.1, duration: 0.2 }}
31-
>
32-
{title}
33-
</motion.h1>
34-
<motion.p
35-
className="text-sm sm:text-base text-muted-foreground"
36-
initial={{ opacity: 0 }}
37-
animate={{ opacity: 1 }}
38-
transition={{ delay: 0.15, duration: 0.2 }}
39-
>
40-
{description}
41-
</motion.p>
42-
</motion.section>
43-
)
48+
{description}
49+
</motion.p>
50+
</motion.section>
4451
);
4552
}
4653

@@ -49,18 +56,26 @@ export function PostGrid({ children }: { children: ReactNode }) {
4956
useEffect(() => {
5057
setMounted(true);
5158
}, []);
52-
return (
53-
mounted && (
54-
<motion.section
55-
initial={{ opacity: 0 }}
56-
animate={{ opacity: 1 }}
57-
transition={{ delay: 0.2, duration: 0.2 }}
58-
>
59+
if (!mounted) {
60+
return (
61+
<section>
5962
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5">
6063
{children}
6164
</div>
62-
</motion.section>
63-
)
65+
</section>
66+
);
67+
}
68+
69+
return (
70+
<motion.section
71+
initial={{ opacity: 0 }}
72+
animate={{ opacity: 1 }}
73+
transition={{ delay: 0.2, duration: 0.2 }}
74+
>
75+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5">
76+
{children}
77+
</div>
78+
</motion.section>
6479
);
6580
}
6681

components/post-animation.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,23 @@ export default function PostAnimation({ children }: { children: ReactNode }) {
1919
useEffect(() => {
2020
setMounted(true);
2121
}, []);
22-
return (
23-
mounted && (
24-
<motion.article
25-
className="rounded-lg p-2 sm:p-7 max-w-3xl mx-auto"
26-
initial={{ opacity: 0, y: 20 }}
27-
animate={{ opacity: 1, y: 0 }}
28-
transition={{ duration: 0.2, ease: "easeOut" }}
29-
>
22+
if (!mounted) {
23+
return (
24+
<article className="rounded-lg p-2 sm:p-7 max-w-3xl mx-auto">
3025
{children}
31-
</motion.article>
32-
)
26+
</article>
27+
);
28+
}
29+
30+
return (
31+
<motion.article
32+
className="rounded-lg p-2 sm:p-7 max-w-3xl mx-auto"
33+
initial={{ opacity: 0, y: 20 }}
34+
animate={{ opacity: 1, y: 0 }}
35+
transition={{ duration: 0.2, ease: "easeOut" }}
36+
>
37+
{children}
38+
</motion.article>
3339
);
3440
}
3541

hooks/use-mobile.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use client";
2+
13
import * as React from "react"
24

35
const MOBILE_BREAKPOINT = 768

0 commit comments

Comments
 (0)