-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Add slide-up/slide-down animations for modal open/close and improve overlay fade #16074
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add slide-up/slide-down animations for modal open/close and improve overlay fade #16074
Conversation
✅ Deploy Preview for ethereumorg ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@pettinarip Mind giving this a review from a performance stand point? |
|
This issue is stale because it has been open 30 days with no activity. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @MOSHKA-GOT! Sorry for delays on this one... Love the overall patch, but wanted to try and clean this up a bit to avoid adding unnecessary keyframes to the tailwind config.
Took a look, and this code modal behaves identical to the ui/sheet component we use, so I refactored CodeModal.tsx to use the sheet components instead of the dialogs. This allows simply applying side="bottom" for the animation.
Your approach to removing the isModalOpen && conditional indeed helps maintain the exit transition, and then radix-ui removes these nodes from the DOM tree when it's complete, which lgtm from a performance stand point.
Since the animations were simplified using ui/sheet, I reverted the tailwind config changes, leaving the animations as they were. While in there, patched the ui/dialog-modal component to use animate-fade-in which already existed, to avoid needing the other animate-contentShow or animate-overlayShow transitions.
As a small design aside, while in here I updated the close button to use "Close" which is in line with our more modern approach to these, added rounded corners to the top to match homepage design, and removed the excessive padding around the code block itself to clean things up.
Bringing this in! Thanks again for the help @MOSHKA-GOT!
|
@all-contributors please add @MOSHKA-GOT for code |
|
I've put up a pull request to add @MOSHKA-GOT! 🎉 |

Description
This PR updates the modal component to improve UX by adding open and close animations for both the modal content and the overlay background.
CodeExamples.tsx:CodeModalto allow close animation before unmounting.dialog-modal.tsx:animate-contentShowwithslide-upandslide-downanimations.overlay-fade-outanimation for smooth background disappearance.grid place-items-end,overflow-hidden).These changes ensure that when the modal closes, it slides down instead of disappearing abruptly.
Before / After
▶ Before (open/close without smooth close)
1.mp4
▶ After (slide-up on open, slide-down on close, overlay fade)
2.mp4