Skip to content

Commit eaf9f74

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

File tree

1 file changed

+45
-32
lines changed

1 file changed

+45
-32
lines changed

components/home-animation.tsx

Lines changed: 45 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client";
22

3-
import { ReactNode } from "react";
3+
import { ReactNode, useEffect, useState } from "react";
44
import { motion } from "framer-motion";
55

66
export function HeaderSection({
@@ -10,44 +10,57 @@ export function HeaderSection({
1010
title: string;
1111
description: string;
1212
}) {
13+
const [mounted, setMounted] = useState(false);
14+
useEffect(() => {
15+
setMounted(true);
16+
}, []);
17+
1318
return (
14-
<motion.section
15-
className="space-y-2 sm:space-y-3 md:space-y-4"
16-
initial={{ opacity: 0, y: 20 }}
17-
animate={{ opacity: 1, y: 0 }}
18-
transition={{ duration: 0.2, ease: "easeOut" }}
19-
>
20-
<motion.h1
21-
className="text-lg sm:text-xl lg:text-2xl font-bold"
22-
initial={{ opacity: 0 }}
23-
animate={{ opacity: 1 }}
24-
transition={{ delay: 0.1, duration: 0.2 }}
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" }}
2525
>
26-
{title}
27-
</motion.h1>
28-
<motion.p
29-
className="text-sm sm:text-base text-muted-foreground"
30-
initial={{ opacity: 0 }}
31-
animate={{ opacity: 1 }}
32-
transition={{ delay: 0.15, duration: 0.2 }}
33-
>
34-
{description}
35-
</motion.p>
36-
</motion.section>
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+
)
3744
);
3845
}
3946

4047
export function PostGrid({ children }: { children: ReactNode }) {
48+
const [mounted, setMounted] = useState(false);
49+
useEffect(() => {
50+
setMounted(true);
51+
}, []);
4152
return (
42-
<motion.section
43-
initial={{ opacity: 0 }}
44-
animate={{ opacity: 1 }}
45-
transition={{ delay: 0.2, duration: 0.2 }}
46-
>
47-
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5">
48-
{children}
49-
</div>
50-
</motion.section>
53+
mounted && (
54+
<motion.section
55+
initial={{ opacity: 0 }}
56+
animate={{ opacity: 1 }}
57+
transition={{ delay: 0.2, duration: 0.2 }}
58+
>
59+
<div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5">
60+
{children}
61+
</div>
62+
</motion.section>
63+
)
5164
);
5265
}
5366

0 commit comments

Comments
 (0)