Skip to content

Commit 3021ccd

Browse files
committed
feat: 애니메이션 일부 수정
1 parent 79e5fed commit 3021ccd

4 files changed

Lines changed: 35 additions & 35 deletions

File tree

app/category/[slug]/_components/category-post-item.tsx

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
1-
"use client";
2-
31
import dayjs from "dayjs";
4-
import { motion } from "motion/react";
52
import Image from "next/image";
63

74
import { Post } from "@/interfaces/post";
85

96
export function CategoryPostItem({
107
post,
11-
delay,
128
}: {
139
post: Omit<Post, "content">;
14-
delay: number;
1510
}) {
1611
return (
17-
<motion.div
18-
className="group flex cursor-pointer flex-col gap-3 rounded-xl p-3 transition-all duration-200 hover:bg-neutral-50 dark:hover:bg-neutral-800 sm:flex-row sm:gap-5"
19-
initial={{ opacity: 0, y: 24 }}
20-
animate={{ opacity: 1, y: 0 }}
21-
transition={{
22-
delay,
23-
duration: 0.6,
24-
ease: [0.25, 0.1, 0.25, 1],
25-
}}
26-
>
12+
<div className="group flex cursor-pointer flex-col gap-3 rounded-xl p-3 transition-all duration-200 hover:bg-neutral-50 dark:hover:bg-neutral-800 sm:flex-row sm:gap-5">
2713
<div className="relative h-44 w-full overflow-hidden rounded-lg sm:h-[100px] sm:w-[160px] sm:min-w-[160px]">
2814
<Image
2915
src={post.thumbnail}
@@ -53,6 +39,6 @@ export function CategoryPostItem({
5339
</span>
5440
</div>
5541
</div>
56-
</motion.div>
42+
</div>
5743
);
5844
}

app/category/[slug]/page.tsx

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ import { notFound } from "next/navigation";
66
import { getCategories } from "@/apis/category";
77
import { getPostsByCategory } from "@/apis/post";
88
import { FadeInUp } from "@/components/animation/fade-in-up";
9+
import {
10+
StaggerChildren,
11+
StaggerItem,
12+
} from "@/components/animation/stagger-children";
913
import { SITE_NAME } from "@/constants/site-metadata";
1014

1115
import { CategoryPostItem } from "./_components/category-post-item";
@@ -68,7 +72,7 @@ export default async function CategoryPage({ params }: CategoryPageProps) {
6872

6973
return (
7074
<div className="py-8 sm:py-10">
71-
<FadeInUp>
75+
<FadeInUp delay={0.1}>
7276
<div className="mb-4 flex items-center gap-3 sm:mb-2 sm:gap-4">
7377
<Link href="/">
7478
<ChevronLeft className="size-7 text-neutral-500 sm:size-8" />
@@ -81,17 +85,22 @@ export default async function CategoryPage({ params }: CategoryPageProps) {
8185
</div>
8286
</div>
8387
</FadeInUp>
84-
<div className="flex flex-col gap-3 sm:gap-4">
85-
{posts.map((post, index) => (
86-
<Link
87-
href={`/post/${post.category}/${post.slug}`}
88-
key={post.slug}
89-
className="block"
90-
>
91-
<CategoryPostItem post={post} delay={0.1 + index * 0.07} />
92-
</Link>
88+
<StaggerChildren
89+
className="flex flex-col gap-3 sm:gap-4"
90+
baseDelay={0.2}
91+
staggerDelay={0.06}
92+
>
93+
{posts.map((post) => (
94+
<StaggerItem key={post.slug}>
95+
<Link
96+
href={`/post/${post.category}/${post.slug}`}
97+
className="block"
98+
>
99+
<CategoryPostItem post={post} />
100+
</Link>
101+
</StaggerItem>
93102
))}
94-
</div>
103+
</StaggerChildren>
95104
</div>
96105
);
97106
}

src/components/animation/fade-in-up.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,14 @@ interface FadeInUpProps {
1111
export const FadeInUp = ({ children, delay = 0, className }: FadeInUpProps) => {
1212
return (
1313
<motion.div
14-
initial={{ opacity: 0, y: 28 }}
15-
animate={{ opacity: 1, y: 0 }}
14+
initial={{ opacity: 0, y: 16, filter: "blur(4px)" }}
15+
animate={{ opacity: 1, y: 0, filter: "blur(0px)" }}
1616
transition={{
17-
duration: 0.7,
17+
type: "spring",
18+
stiffness: 200,
19+
damping: 22,
20+
mass: 1,
1821
delay,
19-
ease: [0.25, 0.1, 0.25, 1],
2022
}}
2123
className={className}
2224
>

src/components/animation/stagger-children.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const StaggerChildren = ({
1313
children,
1414
className,
1515
baseDelay = 0,
16-
staggerDelay = 0.12,
16+
staggerDelay = 0.06,
1717
}: StaggerChildrenProps) => {
1818
return (
1919
<motion.div
@@ -45,13 +45,16 @@ export const StaggerItem = ({
4545
return (
4646
<motion.div
4747
variants={{
48-
hidden: { opacity: 0, y: 24 },
48+
hidden: { opacity: 0, y: 16, filter: "blur(4px)" },
4949
visible: {
5050
opacity: 1,
5151
y: 0,
52+
filter: "blur(0px)",
5253
transition: {
53-
duration: 0.6,
54-
ease: [0.25, 0.1, 0.25, 1],
54+
type: "spring",
55+
stiffness: 200,
56+
damping: 22,
57+
mass: 1,
5558
},
5659
},
5760
}}

0 commit comments

Comments
 (0)