-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
refactor(motion): simplify variant creation, starting with Collapse #32939
Open
robertpenner
wants to merge
3
commits into
microsoft:master
Choose a base branch
from
robertpenner:refactor/motion-variant
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
refactor(motion): simplify variant creation, starting with Collapse #32939
robertpenner
wants to merge
3
commits into
microsoft:master
from
robertpenner:refactor/motion-variant
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
robertpenner
changed the title
refactor(motion): simplify variant creation w/functional approach, starting with Collapse
refactor(motion): simplify variant creation, starting with Collapse
Sep 27, 2024
📊 Bundle size reportUnchanged fixtures
|
Perf Analysis (
|
Scenario | Render type | Master Ticks | PR Ticks | Iterations | Status |
---|---|---|---|---|---|
Avatar | mount | 659 | 651 | 5000 | |
Button | mount | 310 | 293 | 5000 | |
Field | mount | 1151 | 1139 | 5000 | |
FluentProvider | mount | 721 | 737 | 5000 | |
FluentProviderWithTheme | mount | 80 | 89 | 10 | |
FluentProviderWithTheme | virtual-rerender | 36 | 36 | 10 | |
FluentProviderWithTheme | virtual-rerender-with-unmount | 89 | 77 | 10 | |
MakeStyles | mount | 883 | 866 | 50000 | |
Persona | mount | 1759 | 1736 | 5000 | |
SpinButton | mount | 1389 | 1387 | 5000 | |
SwatchPicker | mount | 1623 | 1708 | 5000 |
fabricteam
reviewed
Sep 27, 2024
createPresenceComponent, | ||
createPresenceComponentVariant, | ||
} from '@fluentui/react-motion'; | ||
import { motionTokens, createPresenceComponent } from '@fluentui/react-motion'; |
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.
🕵🏾♀️ visual regressions to review in the fluentuiv9 Visual Regression Report
Avatar Converged 2 screenshots
Image Name | Diff(in Pixels) | Image Type |
---|---|---|
Avatar Converged.Badge Mask RTL.chromium.png | 1 | Changed |
Avatar Converged.badgeMask.chromium.png | 12 | Changed |
Drawer 1 screenshots
Image Name | Diff(in Pixels) | Image Type |
---|---|---|
Drawer.overlay drawer full.chromium.png | 1155 | Changed |
robertpenner
force-pushed
the
refactor/motion-variant
branch
from
October 2, 2024 20:53
915f1e2
to
f3e7ff5
Compare
…arting with Collapse
robertpenner
force-pushed
the
refactor/motion-variant
branch
from
October 2, 2024 21:12
f3e7ff5
to
7e11a56
Compare
robertpenner
force-pushed
the
refactor/motion-variant
branch
from
October 2, 2024 21:41
7e3d66c
to
a5d040b
Compare
robertpenner
force-pushed
the
refactor/motion-variant
branch
from
October 2, 2024 21:51
a5d040b
to
060eee8
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issue(s)
Motivation
The current mechanism for creating variants of motion components,
createPresenceComponentVariant
, has several shortcomings:enter
andexit
are arrays of motion atoms.a. It's also not clear what the solution would look like, to target an array item in the existed override object.
a.
duration
andeasing
are nested insideenter: { duration: ... }
,exit: { duration: ... }
, and optionallyall: { duration: ...}
as a shortcut.b. This now looks less maintainable and more complicated to teach, compared to a flat structure, where all properties are on the same level, e.g.
{ enterEasing: ..., enterDuration: ..., exitEasing: ..., exitDuration: ... }
.createPresenceComponentVariant(Fade, overrides)
mechanism relies on the motion componentFade
to store a reference to the motion molecule from which it was created.a. This reference is accessed through a special Symbol lookup (
MOTION_DEFINITION
), which is set bycreatePresenceComponent
.b. In hindsight, this feels a bit clunky and magical, if there can be a simpler way.
Solution
There is a simpler way to create variants using a more functional approach:
createCollapsePresence
that accepts variant parameters (e.g. duration, easing), which are locked into the variant.createCollapsePresence
returns a motion function which accepts runtime parameters (e.g.animateOpacity
).createCollapsePresence
can be passed tocreatePresenceComponent
directly, eliminating the need forcreatePresenceComponentVariant
:createPresenceComponentVariant
function and its helper functionoverridePresenceMotion
:Collapse
are transparently visible and validated:Future Work
Fade
.Collapse
anorientation
runtime param andhorizontal
option to collapse width.