From dd08f988dec85f42f2202bfad0589278a3d22a34 Mon Sep 17 00:00:00 2001 From: klopez4212 Date: Mon, 8 Jun 2026 18:47:24 +0100 Subject: [PATCH] Animate reaction counts (#904) --- .../features/messages/ui/MessageReactions.tsx | 11 +- desktop/src/features/pulse/ui/NoteCard.tsx | 7 +- desktop/src/shared/styles/globals.css | 123 ++++++++++++ desktop/src/shared/ui/AnimatedCount.tsx | 183 ++++++++++++++++++ .../src/shared/ui/animatedCountParts.test.mjs | 34 ++++ desktop/src/shared/ui/animatedCountParts.ts | 47 +++++ 6 files changed, 399 insertions(+), 6 deletions(-) create mode 100644 desktop/src/shared/ui/AnimatedCount.tsx create mode 100644 desktop/src/shared/ui/animatedCountParts.test.mjs create mode 100644 desktop/src/shared/ui/animatedCountParts.ts diff --git a/desktop/src/features/messages/ui/MessageReactions.tsx b/desktop/src/features/messages/ui/MessageReactions.tsx index 5bb6a7159..b43088128 100644 --- a/desktop/src/features/messages/ui/MessageReactions.tsx +++ b/desktop/src/features/messages/ui/MessageReactions.tsx @@ -6,6 +6,7 @@ import type { TimelineReaction } from "@/features/messages/types"; import { cn } from "@/shared/lib/cn"; import { emojiDisplayName } from "@/shared/lib/emojiName"; import { rewriteRelayUrl } from "@/shared/lib/mediaUrl"; +import { AnimatedCount } from "@/shared/ui/AnimatedCount"; import { isPositiveEmojiParticle, useEmojiBurst, @@ -433,7 +434,10 @@ function ReactionPill({ type="button" > - {reaction.count} + ); } @@ -463,7 +467,10 @@ function ReactionPill({ reaction={reaction} className={REACTION_GLYPH_CLASSES} /> - {reaction.count} + diff --git a/desktop/src/features/pulse/ui/NoteCard.tsx b/desktop/src/features/pulse/ui/NoteCard.tsx index 67f438386..a3e71f89f 100644 --- a/desktop/src/features/pulse/ui/NoteCard.tsx +++ b/desktop/src/features/pulse/ui/NoteCard.tsx @@ -14,6 +14,7 @@ import { useNoteByIdQuery } from "@/features/pulse/hooks"; import { getReplyParent, noteSnippet } from "@/features/pulse/lib/replies"; import type { UserNote } from "@/shared/api/socialTypes"; import type { ChannelMember, UserProfileSummary } from "@/shared/api/types"; +import { AnimatedCount } from "@/shared/ui/AnimatedCount"; import { Markdown } from "@/shared/ui/markdown"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/shared/ui/tooltip"; import { UserAvatar } from "@/shared/ui/UserAvatar"; @@ -149,9 +150,7 @@ export function NoteCard({ const activeActionClass = "text-primary"; const countPlaceholder = ; const reactionCountLabel = - reactionCount > 0 ? ( - {reactionCount} - ) : null; + reactionCount > 0 ? : null; const currentUserAvatarUrl = currentUserProfile?.avatarUrl ?? null; const replyParentId = getReplyParent(note); @@ -224,7 +223,7 @@ export function NoteCard({