sistent icon indicating copy to clipboard operation
sistent copied to clipboard

[refactor]: Modernize FlipCard Architecture

Open Katotodan opened this issue 6 months ago • 2 comments

Notes for Reviewers

Description

This PR refactors the FlipCard component to align with modern CSS 3D animation standards and improves the Developer Experience (DX).

Changes

  1. Logic: Switched from a JS-timed visibility toggle to a CSS 3D transform stack. The front and back faces are now rendered simultaneously but positioned back-to-back. Previously the background, and other properties were related to the theme (ThemeProvider); theme can be set differently based on a project. This PR aims to give a developer much control over the background, padding, size of the component from the project this component is imported to.

  2. API:

  • Deprecated array-based children.

  • Introduced frontElement and backElement for better clarity.

  • Added flipAction (hover/click) to increase component versatility.

  1. Styling: Used shouldForwardProp in MUI's styled utility to prevent custom props from leaking to the DOM.

Testing Instructions

  • Import FlipCard and pass two distinct components to frontElement and backElement.

  • Toggle the flipAction prop between hover and click (set to click by default).

  • Verify that the animation remains smooth even when the CPU is under load (since it is now GPU-accelerated).

  • Ensure that the container have a reasonable size cause the FlipCard will take the entire size of its container.

This PR fixes #1546

Signed commits

  • [x] Yes, I signed my commits.

Katotodan avatar May 13 '26 21:05 Katotodan

Before

https://github.com/user-attachments/assets/6bee461b-c5bf-4748-9ad0-6b23e36332f9

As you can see from the video above, I was not able to change the background of the card from the project I was working on. Setting also the height was diffucult, same as padding. This PR aims to solve that.

After

https://github.com/user-attachments/assets/a96ac1c1-29d7-45be-a869-0433031011cd

Katotodan avatar May 13 '26 21:05 Katotodan

Oops! Wrong button!

arjunmehta-git avatar May 21 '26 21:05 arjunmehta-git