Skip to content

Commit 05962c0

Browse files
committed
feat: added framer motions
1 parent fac2354 commit 05962c0

File tree

2 files changed

+39
-33
lines changed

2 files changed

+39
-33
lines changed

src/components/SnippetList.tsx

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -34,39 +34,44 @@ const SnippetList = () => {
3434
<motion.ul
3535
role="list"
3636
className="snippets"
37-
initial="hidden"
38-
animate="visible"
39-
variants={{
40-
visible: {
41-
transition: {
42-
staggerChildren: 0.1
43-
}
44-
}
45-
}}
4637
>
47-
{fetchedSnippets.map((snippet, idx) => (
48-
<motion.li
49-
key={idx}
50-
variants={{
51-
hidden: { opacity: 0, y: 20 },
52-
visible: { opacity: 1, y: 0 }
53-
}}
54-
>
55-
<motion.button
56-
className="snippet | flow"
57-
data-flow-space="sm"
58-
onClick={() => handleOpenModal(snippet)}
59-
whileHover={{ scale: 1.01 }}
60-
whileTap={{ scale: 0.98 }}
38+
<AnimatePresence mode="popLayout">
39+
{fetchedSnippets.map((snippet, idx) => (
40+
<motion.li
41+
key={idx}
42+
initial={{ opacity: 0, y: 20 }}
43+
animate={{
44+
opacity: 1,
45+
y: 0,
46+
transition: {
47+
delay: idx * 0.05,
48+
duration: 0.2
49+
}
50+
}}
51+
exit={{
52+
opacity: 0,
53+
y: -20,
54+
transition: {
55+
delay: (fetchedSnippets.length - 1 - idx) * 0.01,
56+
duration: 0.09
57+
}
58+
}}
6159
>
62-
<div className="snippet__preview">
63-
<img src={language.icon} alt={language.lang} />
64-
</div>
65-
66-
<h3 className="snippet__title">{snippet.title}</h3>
67-
</motion.button>
68-
</motion.li>
69-
))}
60+
<motion.button
61+
className="snippet | flow"
62+
data-flow-space="sm"
63+
onClick={() => handleOpenModal(snippet)}
64+
whileHover={{ scale: 1.01 }}
65+
whileTap={{ scale: 0.98 }}
66+
>
67+
<div className="snippet__preview">
68+
<img src={language.icon} alt={language.lang} />
69+
</div>
70+
<h3 className="snippet__title">{snippet.title}</h3>
71+
</motion.button>
72+
</motion.li>
73+
))}
74+
</AnimatePresence>
7075
</motion.ul>
7176

7277
<AnimatePresence mode="wait">

src/types/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ export type CategoryType = {
88
snippets: SnippetType[];
99
};
1010

11-
export type SnippetType = {
11+
export interface SnippetType {
12+
id?: string | number;
1213
title: string;
1314
description: string;
1415
code: string[];
1516
tags: string[];
1617
author: string;
17-
};
18+
}
1819

1920
export type AppState = {
2021
language: LanguageType;

0 commit comments

Comments
 (0)