Skip to content

Commit 2407c2d

Browse files
Johan BookJohan Book
Johan Book
authored and
Johan Book
committed
feat(web-ui): add animation to like button
1 parent 0f720ce commit 2407c2d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

services/web-ui/src/pages/BlogPostListPage/components/BlogPostLikeButton/BlogPostLikeButton.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { ReactElement } from "react";
22

33
import { Favorite, FavoriteBorder } from "@mui/icons-material";
44
import { IconButton } from "@mui/material";
5+
import { useAnimate } from "framer-motion";
56

67
import {
78
CreateBlogPostReactionCommand,
@@ -23,6 +24,7 @@ export function BlogPostLikeButton({
2324
blogPostId,
2425
reactionId,
2526
}: BlogPostLikeButtonProps): ReactElement {
27+
const [scope, animate] = useAnimate();
2628
const createMutation = useMutation({
2729
mutationFn: (
2830
createBlogPostReactionCommand: CreateBlogPostReactionCommand
@@ -52,6 +54,8 @@ export function BlogPostLikeButton({
5254
return;
5355
}
5456

57+
animate(scope.current, { scale: [1, 1.4, 1] }, { duration: 0.4 });
58+
5559
await createMutation.mutateAsync(
5660
{ blogPostId, reaction: ":like" },
5761
{
@@ -72,6 +76,7 @@ export function BlogPostLikeButton({
7276
color={reactionId ? "primary" : "default"}
7377
disabled={isLoading}
7478
onClick={handleToggleReaction}
79+
ref={scope}
7580
>
7681
{reactionId ? <Favorite /> : <FavoriteBorder />}
7782
</IconButton>

0 commit comments

Comments
 (0)