[refactor]: Modernize FlipCard Architecture
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
-
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.
-
API:
-
Deprecated array-based children.
-
Introduced frontElement and backElement for better clarity.
-
Added flipAction (hover/click) to increase component versatility.
- 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.
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
Oops! Wrong button!