feat: add animation to like button#2082
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✅ Files skipped from review due to trivial changes (2)
📝 WalkthroughWalkthroughRemoves 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
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8ff1b775-7b84-4f15-84f0-69de56ea8405
📒 Files selected for processing (1)
app/components/Package/Header.vue
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
♻️ Duplicate comments (1)
app/components/Package/Header.vue (1)
192-193:⚠️ Potential issue | 🟡 MinorClear
likeFloatTimerduring unmount to avoid stale callback updates.
likeFloatTimeris 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: SplitlikeActioninto 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
📒 Files selected for processing (1)
app/components/Package/Header.vue
ad12f22 to
6af5512
Compare
There was a problem hiding this comment.
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?.handleis 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
📒 Files selected for processing (3)
app/components/Package/Header.vueapp/components/Package/Likes.vuetest/nuxt/a11y.spec.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- app/components/Package/Header.vue
46bf412 to
896723f
Compare
Thanks!! |
🔗 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