Skip to content

Commit 8c4ff86

Browse files
johanbookJohan Book
and
Johan Book
authored
feat(web-ui): add animation to reaction button (#676)
* chore(web-ui): add framer-motion * feat(web-ui): add animation to like button * feat(api): send notification to profiles that reacted to blog post --------- Co-authored-by: Johan Book <{ID}+{username}@users.noreply.github.com>
1 parent c7c8731 commit 8c4ff86

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed

services/api/src/features/blogs/application/handlers/event-handlers/notify-organization-on-posted-blog-post-comment.handler.ts

+2
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class NotifyOrganizationOnPostedBlogPostCommentHandler
4848
relations: {
4949
comments: true,
5050
profile: true,
51+
reactions: true,
5152
},
5253
where: {
5354
id: event.blogPostId,
@@ -69,6 +70,7 @@ export class NotifyOrganizationOnPostedBlogPostCommentHandler
6970
const profileIds = [
7071
blogPost.profileId,
7172
...blogPost.comments.map((comment) => comment.profileId),
73+
...blogPost.reactions.map((reaction) => reaction.profileId),
7274
].filter((id) => id !== event.profileId);
7375

7476
await this.notificationService.notifyProfiles(profileIds, notification);

services/web-ui/package-lock.json

+65
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

services/web-ui/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"@types/uuid": "^9.0.1",
4949
"@use-gesture/react": "^10.2.26",
5050
"dayjs": "^1.11.8",
51+
"framer-motion": "^10.16.16",
5152
"i18next": "^22.5.1",
5253
"i18next-browser-languagedetector": "^7.0.2",
5354
"i18next-http-backend": "^2.2.1",

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)