Skip to content

Add smooth hover transitions to PostCard#290

Open
param-chandarana wants to merge 2 commits into
QuoteVote:mainfrom
param-chandarana:feat/smooth-hover-transitions
Open

Add smooth hover transitions to PostCard#290
param-chandarana wants to merge 2 commits into
QuoteVote:mainfrom
param-chandarana:feat/smooth-hover-transitions

Conversation

@param-chandarana

Copy link
Copy Markdown

Description

  • Add CSS transition with cubic-bezier easing for smooth animations
  • Replace non-existent animation with transform translateY effect
  • Card now lifts 4px on hover with 300ms bounce transition
  • Fixes instant hover effect by applying CSS transitions
  • Add test file
  • Follows contribution guidelines and uses Prettier formatting

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Chore (refactoring, documentation, or other non-functional changes)

Related Issue

Closes #176

Checklist:

  • I have read the Contributing Guidelines.
  • My code follows the Code Style of this project.
  • I have added tests that prove my fix is effective or that my feature works. See Testing Guidelines.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.

- Add CSS transition with cubic-bezier easing for smooth animations
- Replace non-existent animation with transform translateY effect
- Card now lifts 4px on hover with 300ms bounce transition
- Fixes instant hover effect by applying CSS transitions

Follows contribution guidelines and uses Prettier formatting.
- Add test file following project testing patterns
- Tests verify component renders correctly
- Tests check for smooth hover transition styles
- Uses withTestWrapper like other component tests
- Note: Tests have same environment issue as existing tests (jsdom/psl)

Satisfies testing requirement from contribution guidelines.
Copilot AI review requested due to automatic review settings February 11, 2026 10:39
@netlify

netlify Bot commented Feb 11, 2026

Copy link
Copy Markdown

Deploy Preview for quotevote ready!

Name Link
🔨 Latest commit 471ae28
🔍 Latest deploy log https://app.netlify.com/projects/quotevote/deploys/698c5c73f876530008d6ae1c
😎 Deploy Preview https://deploy-preview-290--quotevote.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses issue #176 by making the PostCard hover effect animate smoothly (instead of applying instantly), replacing the previous (non-functional) animation-based approach with a transform: translateY(-4px) lift and a CSS transition.

Changes:

  • Added a cubic-bezier transition on the PostCard root and updated :hover to lift the card using transform.
  • Reformatted several style blocks / JSX sections in PostCard.jsx (mostly formatting/indentation changes).
  • Added a new PostCard snapshot test file.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 4 comments.

File Description
package-lock.json Large lockfile regeneration/metadata changes in addition to the UI fix.
client/src/components/Post/PostCard.jsx Adds hover transition + lift transform; includes additional formatting changes.
client/src/components/Post/PostCard.test.jsx Adds a new snapshot test and a hover-related test placeholder.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

value: 'T',
},
},
created: new Date().toISOString(),

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

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

created is set with new Date().toISOString(), which makes the snapshot output time-dependent (and likely flaky because PostCard formats it via moment(created)). Use a fixed timestamp string in the test data so snapshots are deterministic.

Suggested change
created: new Date().toISOString(),
created: '2024-01-01T00:00:00.000Z',

Copilot uses AI. Check for mistakes.
Comment on lines +43 to +46
it('renders correctly', () => {
const { container } = render(<PostCardWrapper />)
expect(container.firstChild).toMatchSnapshot()
})

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

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

This test uses toMatchSnapshot(), but the PR doesn’t include a corresponding snapshot file under client/src/components/Post/__snapshots__. Without committing the generated snapshot, CI runs will fail unless snapshots are updated during the run.

Copilot uses AI. Check for mistakes.
Comment on lines +51 to +53

// Verify the card element exists
expect(card).toBeTruthy()

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

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

The "renders with smooth hover transition styles" test only checks that the card element exists, which doesn’t validate the transition/hover behavior it claims to cover. Consider asserting the generated styles (e.g., transition includes 300ms and the :hover rule includes translateY(-4px)) so the test actually protects this change.

Suggested change
// Verify the card element exists
expect(card).toBeTruthy()
// Verify the card element exists
expect(card).toBeTruthy()
if (!card) return
// Verify the transition includes a 300ms duration
const computedStyle = window.getComputedStyle(card)
const transitionValue = computedStyle.transition || ''
expect(transitionValue).toContain('300ms')
// Verify the hover rule applies a translateY(-4px) transform
const cardClassName = Array.from(card.classList).find((name) =>
name.includes('cardRootStyle'),
)
let hoverTransform = ''
if (cardClassName && document.styleSheets) {
for (const sheet of Array.from(document.styleSheets)) {
let rules
try {
rules = sheet.cssRules || []
} catch {
continue
}
for (const rule of Array.from(rules)) {
if (
rule.selectorText &&
rule.selectorText.includes(`.${cardClassName}:hover`)
) {
hoverTransform = rule.style && rule.style.transform
break
}
}
if (hoverTransform) break
}
}
expect(hoverTransform).toContain('translateY(-4px)')

Copilot uses AI. Check for mistakes.
Comment on lines 389 to 406
const { upQuote, downQuote } = useMemo(() => {
if (!votes || votes?.length === 0) {
return {
return {
upQuote: 0,
downQuote: 0,
}
}

return {
upQuote: votes.filter((vote) => vote.type === 'UPVOTE' || vote.type?.toUpperCase() === 'UP').length,
downQuote: votes.filter((vote) => vote.type === 'DOWNVOTE' || vote.type?.toUpperCase() === 'DOWN').length,
upQuote: votes.filter(
(vote) => vote.type === 'UPVOTE' || vote.type?.toUpperCase() === 'UP',
).length,
downQuote: votes.filter(
(vote) =>
vote.type === 'DOWNVOTE' || vote.type?.toUpperCase() === 'DOWN',
).length,
}
}, [votes])

Copilot AI Feb 11, 2026

Copy link

Choose a reason for hiding this comment

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

upQuote and downQuote are computed in a useMemo but never used in the component. This adds unnecessary work and can trigger lint no-unused-vars failures; either use these values in the UI or remove the useMemo until it’s needed.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

issue on hovering effect on card section

2 participants