Skip to content

Commit d338a5e

Browse files
chore: adding appear animations to modal dialog and overlay (#30258)
## **Description** This PR adds entrance animations to our modal components while ensuring accessibility through proper motion reduction support. The changes include: 1. Modal Content Animation: - Added a smooth slide-up animation with fade-in effect (400ms duration) - Uses a custom cubic-bezier timing function for natural movement - Initial 24px offset for subtle entrance 2. Modal Overlay Animation: - Added fade-in animation (250ms duration) - Uses linear timing for consistent transparency transition 3. Accessibility Considerations: - All animations respect the user's motion preferences using `prefers-reduced-motion` - When reduced motion is preferred, content appears instantly without animation - Maintains full functionality while improving the experience for users who enjoy motion These enhancements make our modals feel more polished while maintaining accessibility standards. [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/30258?quickstart=1) ## **Related issues** Fixes: MetaMask/MetaMask-planning#4047 ## **Manual testing steps** Testing Modal Motion 1. Open the [storybook build to this PR](https://diuv6g5fj9pvx.cloudfront.net/metamask-extension/13296481607/storybook-build/index.html?path=/story/components-componentlibrary-modal--default-story&globals=theme:light) 2. Search for `Modal` 3. Verify the modal overlay fades in smoothly 4. Verify the modal content slides up with a subtle animation 5. Test on different screen sizes to ensure animations remain smooth Testing Prefers Reduced Motion 1. Open Dev Tools 2. Go to the kebab menu in the top right 3. Select More Tools > Redering 4. Scroll down to enable `prefers reduced-motion` 5. Verify animation of the modal is removed ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** Modal appears instantly without animation https://github.com/user-attachments/assets/a2ba8480-8fdf-4cc1-86ec-bef95fbdb889 ### **After** Modal fades and slides in smoothly but removes animation when `prefers-reduced-motion` is enabled https://github.com/user-attachments/assets/76f6cfe9-0587-4c2c-bc47-a9f984041575 ## **Pre-merge author checklist** - [x] I've followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Extension Coding Standards](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [x] I've completed the PR template to the best of my ability - [x] I've included tests if applicable - [x] I've documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [x] I've applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-extension/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.
1 parent f7f2769 commit d338a5e

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

ui/components/component-library/modal-content/modal-content.scss

+25
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,17 @@
3535
max-height: 100%;
3636
box-shadow: var(--shadow-size-lg) var(--color-shadow-default);
3737

38+
// Animate for users who have no reduced motion preferences
39+
@media (prefers-reduced-motion: no-preference) {
40+
animation: modal-dialog-slide-up 400ms cubic-bezier(0.3, 0.8, 0.3, 1) forwards;
41+
}
42+
43+
// Don't animate for users who have reduced motion preferences
44+
@media (prefers-reduced-motion: reduce) {
45+
opacity: 1;
46+
transform: translateY(0);
47+
}
48+
3849
&--size-sm {
3950
--size: 360px;
4051

@@ -54,3 +65,17 @@
5465
}
5566
}
5667
}
68+
69+
@media (prefers-reduced-motion: no-preference) {
70+
@keyframes modal-dialog-slide-up {
71+
from {
72+
transform: translateY(24px);
73+
opacity: 0;
74+
}
75+
76+
to {
77+
transform: translateY(0);
78+
opacity: 1;
79+
}
80+
}
81+
}

ui/components/component-library/modal-overlay/modal-overlay.scss

+18
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,22 @@
77
right: 0;
88
bottom: 0;
99
z-index: design-system.$modal-z-index;
10+
opacity: 1;
11+
12+
// Don't animate for users who have reduced motion preferences
13+
@media (prefers-reduced-motion: no-preference) {
14+
animation: modal-overlay-fade-in 250ms linear forwards;
15+
}
16+
}
17+
18+
@media (prefers-reduced-motion: no-preference) {
19+
@keyframes modal-overlay-fade-in {
20+
from {
21+
opacity: 0;
22+
}
23+
24+
to {
25+
opacity: 1;
26+
}
27+
}
1028
}

0 commit comments

Comments
 (0)