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

[Drawer] Investigate custom motion components migration #33634

Open
robertpenner opened this issue Jan 13, 2025 · 1 comment
Open

[Drawer] Investigate custom motion components migration #33634

robertpenner opened this issue Jan 13, 2025 · 1 comment
Assignees

Comments

@robertpenner
Copy link
Collaborator

robertpenner commented Jan 13, 2025

Drawer uses one-off motion components currently.

Investigate the challenges of refactoring the Drawer motions to reusable Slide and Fade motion components.

Custom Motion Components

InlineDrawerMotion

  • fade + slide
  • We could make a standard Slide with animateOpacity for this.

OverlayDrawerMotion

  • fade + slide + shadow
  • We could make an Elevate motion component for the shadow.

OverlaySurfaceBackdropMotion

  • fade
  • This is very close to the existing Fade, except for the dynamic durations (see comment below).

Other Considerations

  • The slide is RTL-aware, via dir from useFluent().
  • The slide distance is configured by a CSS var --fui-Drawer--size.
  • Durations are relative to width (see comment below for more detail).
@robertpenner
Copy link
Collaborator Author

robertpenner commented Jan 13, 2025

Opacity transitions occur in all 3 of the custom motion components for Drawer.

OverlaySurfaceBackdropMotion is very close to the Fade component; the difference is that the duration is dynamic, based on a size parameter:

export const OverlaySurfaceBackdropMotion = createPresenceComponent(({ size }: OverlayDrawerSurfaceMotionParams) => {
  const keyframes = [{ opacity: 0 }, { opacity: 1 }];
  const duration = durations[size];

  return {
    enter: {
      keyframes,
      easing: motionTokens.curveLinear,
      duration,
    },
    exit: {
      keyframes: [...keyframes].reverse(),
      easing: motionTokens.curveLinear,
      duration,
    },
  };
});

The size-to-duration mappings are:

  small: motionTokens.durationGentle,
  medium: motionTokens.durationSlow,
  large: motionTokens.durationSlower,
  full: motionTokens.durationUltraSlow,

Some of these durations are not represented in our Fade variants.

@robertpenner robertpenner self-assigned this Jan 13, 2025
@robertpenner robertpenner changed the title [Drawer] Migrate to Fade motion component [Drawer] Investigate fade migration Jan 13, 2025
@robertpenner robertpenner changed the title [Drawer] Investigate fade migration [Drawer] Investigate fade + slide migration Jan 13, 2025
@robertpenner robertpenner changed the title [Drawer] Investigate fade + slide migration [Drawer] Investigate custom motion components migration Jan 13, 2025
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

No branches or pull requests

1 participant