Skip to content

Commit 3d3f304

Browse files
authored
Merge pull request #11 from JM17/feat/animated-entry-list
feat(Entry): Add basic fade in with grow animation
2 parents 97bb478 + 0c3c965 commit 3d3f304

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

app/routes/entries/index.tsx

+26-18
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { format, parseISO, startOfWeek } from "date-fns";
77
import { createEntry, deleteEntry, getEntries } from "~/model/entry.server";
88
import NavButton from "~/components/buttons/nav-button";
99
import RemoveButton from "~/components/buttons/remove-button";
10+
import { AnimatePresence, motion } from "framer-motion";
1011

1112
export async function action({ request }: ActionArgs) {
1213
const userId = await requireUserId(request);
@@ -62,24 +63,31 @@ function EntryList({ entries, title }: EntryListProps) {
6263
return (
6364
<div>
6465
<p>{title}</p>
65-
{entries.map((entry) => (
66-
<div key={entry.id}>
67-
<ul className="ml-8 list-disc">
68-
<li>
69-
<span className={"inline-flex items-baseline"}>
70-
<Link
71-
to={entry.id}
72-
prefetch={"intent"}
73-
className={"mr-2 hover:text-gray-300"}
74-
>
75-
{entry.text}
76-
</Link>
77-
<RemoveButton id={entry.id} />
78-
</span>
79-
</li>
80-
</ul>
81-
</div>
82-
))}
66+
<div>
67+
<ul className="ml-8 list-disc">
68+
<AnimatePresence>
69+
{entries.map((entry) => (
70+
<motion.li
71+
key={entry.id}
72+
initial={{ height: 0, opacity: 0 }}
73+
animate={{ height: 24, opacity: 1 }}
74+
exit={{ height: 0, opacity: 0 }}
75+
>
76+
<span className={"inline-flex items-baseline"}>
77+
<Link
78+
to={entry.id}
79+
prefetch={"intent"}
80+
className={"mr-2 hover:text-gray-300"}
81+
>
82+
{entry.text}
83+
</Link>
84+
<RemoveButton id={entry.id} />
85+
</span>
86+
</motion.li>
87+
))}
88+
</AnimatePresence>
89+
</ul>
90+
</div>
8391
</div>
8492
);
8593
}

0 commit comments

Comments
 (0)