Skip to content
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

fix(motion): make createPresenceComponentVariant support motion groups #33996

Merged

Conversation

robertpenner
Copy link
Collaborator

@robertpenner robertpenner commented Mar 14, 2025

Background and Motivation

  • When we added motion groups to motion components, i.e. arrays of motion atoms for enter and exit:
  • So we developed a more functional approach for creating presence variants:
  • We started using motion groups extensively, so we refactored away from createPresenceComponentVariant to the new variant creation approach.
    • This left createPresenceComponentVariant as essentially a lame duck: we had published it so we couldn't remove it, only deprecate.

Previous Behavior

  • The current functional variant approach has more boilerplate and moving parts than createPresenceComponentVariant.
    • Devs have to understand how to find the relevant helper function such as createCollapsePresence and pipe that result into createPresenceComponent.
    • So it is more complex to teach people how to create variants, compared to the old method.
    • This isn't horrible DX, but what if we could return to the simplicity of createPresenceComponentVariant?

New Behavior

  • With the insights gained from the functional approach, this PR re-implements createPresenceComponentVariant to work with motion groups.
  • We can teach createPresenceComponentVariant in documentation again: celebration, not deprecation.
  • We can simplify presence implementations by refactoring back to createPresenceComponentVariant.

Example of simplified variant creation

Before:

// two functions imported and called
export const FadeRelaxed = createPresenceComponent(createFadePresence({ enterDuration: motionTokens.durationGentle }));

After:

// one function imported and called
export const FadeRelaxed = createPresenceComponentVariant(Fade, { enterDuration: motionTokens.durationGentle });

Future Work

Work is underway to migrate Fade and Scale back to createPresenceComponentVariant:

Related Issue(s)

@robertpenner robertpenner force-pushed the fix/create-presence-variant branch from 3597ce2 to 88d14d0 Compare March 14, 2025 21:01
@robertpenner robertpenner self-assigned this Mar 14, 2025
Copy link

Pull request demo site: URL

@robertpenner robertpenner force-pushed the fix/create-presence-variant branch from 0606952 to 442c42d Compare March 18, 2025 17:16
Copy link

github-actions bot commented Mar 18, 2025

📊 Bundle size report

Package & Exports Baseline (minified/GZIP) PR Change
react-components
react-components: entire library
1.225 MB
308.799 kB
1.225 MB
308.762 kB
-83 B
-37 B
Unchanged fixtures
Package & Exports Size (minified/GZIP)
react-accordion
Accordion (including children components)
107.568 kB
33.01 kB
react-components
react-components: Button, FluentProvider & webLightTheme
69.638 kB
20.24 kB
react-components
react-components: Accordion, Button, FluentProvider, Image, Menu, Popover
225.885 kB
65.402 kB
react-components
react-components: FluentProvider & webLightTheme
44.473 kB
14.597 kB
react-dialog
Dialog (including children components)
101.691 kB
30.584 kB
react-motion
@fluentui/react-motion - createMotionComponent()
4.928 kB
2.119 kB
react-motion
@fluentui/react-motion - createPresenceComponent()
5.779 kB
2.495 kB
react-motion
@fluentui/react-motion - PresenceGroup
1.714 kB
819 B
react-portal-compat
PortalCompatProvider
8.39 kB
2.64 kB
react-timepicker-compat
TimePicker
109.01 kB
36.221 kB
react-toast
Toast (including Toaster)
101.793 kB
30.657 kB
react-tree
FlatTree
148.348 kB
42.568 kB
react-tree
PersonaFlatTree
149.093 kB
42.712 kB
react-tree
PersonaTree
145.299 kB
41.568 kB
react-tree
Tree
144.56 kB
41.443 kB
🤖 This report was generated against 428d26e1ec1e331df5e7b68320a9ec06a2944a11

@robertpenner robertpenner force-pushed the fix/create-presence-variant branch from 7464bf1 to a7c2486 Compare March 19, 2025 20:24
@robertpenner robertpenner changed the title fix(motion): make createPresenceMotionVariant work with motion arrays fix(motion): make createPresenceMotionVariant work with motion groups Mar 19, 2025
@robertpenner robertpenner marked this pull request as ready for review March 19, 2025 21:24
@robertpenner robertpenner requested review from a team as code owners March 19, 2025 21:24
@robertpenner robertpenner changed the title fix(motion): make createPresenceMotionVariant work with motion groups fix(motion): make createPresenceMotionVariant support motion groups Mar 19, 2025
@robertpenner robertpenner changed the title fix(motion): make createPresenceMotionVariant support motion groups fix(motion): make createPresenceComponentVariant support motion groups Mar 19, 2025
@robertpenner robertpenner force-pushed the fix/create-presence-variant branch from 5dc8189 to 44f3e79 Compare March 25, 2025 11:13
@robertpenner robertpenner merged commit 8f84c46 into microsoft:master Mar 26, 2025
12 checks passed
@robertpenner robertpenner deleted the fix/create-presence-variant branch March 26, 2025 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants