Skip to content

feat: add animation to like button#2082

Merged
ghostdevv merged 7 commits intonpmx-dev:mainfrom
ShroXd:feat/like-button-particle-effect
Mar 21, 2026
Merged

feat: add animation to like button#2082
ghostdevv merged 7 commits intonpmx-dev:mainfrom
ShroXd:feat/like-button-particle-effect

Conversation

@ShroXd
Copy link
Contributor

@ShroXd ShroXd commented Mar 15, 2026

🔗 Linked issue

n/a

🧭 Context

Add a cute animation to like button to make it interesting.

📚 Description

Screen.Recording.2026-03-15.at.13.23.10.mov

We also support prefers-reduced-motion for users who prefer less animation.

Screen.Recording.2026-03-15.at.16.31.10.mov

@vercel
Copy link

vercel bot commented Mar 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Mar 21, 2026 10:41pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Mar 21, 2026 10:41pm
npmx-lunaria Ignored Ignored Mar 21, 2026 10:41pm

Request Review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 64c75296-bc2d-4ab9-94a8-31f044affbc5

📥 Commits

Reviewing files that changed from the base of the PR and between 46bf412 and 7151a96.

📒 Files selected for processing (2)
  • app/components/Package/Likes.vue
  • test/nuxt/a11y.spec.ts
✅ Files skipped from review due to trivial changes (2)
  • test/nuxt/a11y.spec.ts
  • app/components/Package/Likes.vue

📝 Walkthrough

Walkthrough

Removes the local like implementation from app/components/Package/Header.vue and replaces it with a PackageLikes component invocation. Adds app/components/Package/Likes.vue: a Vue 3 script-setup component that fetches like state from /api/social/likes/{packageName}, gates actions behind auth, performs optimistic updates with revert-on-error, shows loading/pending state, and implements animated heart and “+1” float with reduced-motion support. Adds an accessibility test that mounts Likes.vue and asserts no axe violations.

Possibly related PRs

Suggested reviewers

  • danielroe
  • graphieros
  • trueberryless
🚥 Pre-merge checks | ✅ 1
✅ Passed checks (1 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description accurately describes the changes: adding animation to the like button with accessibility support for reduced motion preferences.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8ff1b775-7b84-4f15-84f0-69de56ea8405

📥 Commits

Reviewing files that changed from the base of the PR and between a170292 and 7965e70.

📒 Files selected for processing (1)
  • app/components/Package/Header.vue

@codecov
Copy link

codecov bot commented Mar 15, 2026

Codecov Report

❌ Patch coverage is 51.92308% with 25 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/components/Package/Likes.vue 51.92% 17 Missing and 8 partials ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
app/components/Package/Header.vue (1)

192-193: ⚠️ Potential issue | 🟡 Minor

Clear likeFloatTimer during unmount to avoid stale callback updates.

likeFloatTimer is created/reset correctly, but it is never cancelled on component teardown. A delayed callback can still run after navigation and mutate stale refs.

Proposed fix
 onBeforeUnmount(() => {
+  if (likeFloatTimer !== null) {
+    clearTimeout(likeFloatTimer)
+    likeFloatTimer = null
+  }
   packageHeaderHeight.value = 0
 })

Also applies to: 232-243

🧹 Nitpick comments (1)
app/components/Package/Header.vue (1)

219-276: Split likeAction into smaller helpers.

This handler now combines input guards, animation orchestration, optimistic state, and network reconciliation. Breaking it into focused helpers would improve readability and make edge-case testing easier.

As per coding guidelines, "Keep functions focused and manageable (generally under 50 lines)".


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f354cea2-52c0-4e29-8b7a-d9daca44b82a

📥 Commits

Reviewing files that changed from the base of the PR and between 7965e70 and 7b79149.

📒 Files selected for processing (1)
  • app/components/Package/Header.vue

@serhalp serhalp added the ux Related to wider UX decisions label Mar 15, 2026
@ghostdevv ghostdevv force-pushed the feat/like-button-particle-effect branch from ad12f22 to 6af5512 Compare March 21, 2026 22:28
Copy link
Contributor

@ghostdevv ghostdevv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it! I moved the likes stuff to it's own component but didn't change any of the logic you added in 7965e70

@ghostdevv ghostdevv changed the title feat: add effect to like button feat: add animation to like button Mar 21, 2026
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
app/components/Package/Likes.vue (1)

47-52: Consider extracting the handle for type safety.

After the guard on line 48, user.value?.handle is known to be defined. However, passing it with optional chaining on line 82 may confuse TypeScript narrowing. Extracting to a local constant would improve clarity and ensure the correct type is passed.

✨ Proposed refactor
 const likeAction = async () => {
-  if (user.value?.handle == null) {
+  const handle = user.value?.handle
+  if (handle == null) {
     authModal.open()
     return
   }
   // ... later in the function ...
-  const result = await togglePackageLike(props.packageName, currentlyLiked, user.value?.handle)
+  const result = await togglePackageLike(props.packageName, currentlyLiked, handle)

Also applies to: 82-82


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 238df784-e850-4b09-b147-5cb8ef4475b0

📥 Commits

Reviewing files that changed from the base of the PR and between 7b79149 and 46bf412.

📒 Files selected for processing (3)
  • app/components/Package/Header.vue
  • app/components/Package/Likes.vue
  • test/nuxt/a11y.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/components/Package/Header.vue

@ghostdevv ghostdevv added this pull request to the merge queue Mar 21, 2026
@ghostdevv ghostdevv removed this pull request from the merge queue due to a manual request Mar 21, 2026
@ghostdevv ghostdevv force-pushed the feat/like-button-particle-effect branch from 46bf412 to 896723f Compare March 21, 2026 22:37
@ghostdevv ghostdevv enabled auto-merge March 21, 2026 22:37
@ghostdevv ghostdevv added this pull request to the merge queue Mar 21, 2026
Merged via the queue into npmx-dev:main with commit 4294ada Mar 21, 2026
19 of 20 checks passed
@ShroXd
Copy link
Contributor Author

ShroXd commented Mar 22, 2026

Love it! I moved the likes stuff to it's own component but didn't change any of the logic you added in 7965e70

Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ux Related to wider UX decisions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants