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

[Mantine UI Series] Transition #3

Open
reboottime opened this issue Jul 5, 2023 · 3 comments
Open

[Mantine UI Series] Transition #3

reboottime opened this issue Jul 5, 2023 · 3 comments

Comments

@reboottime
Copy link
Owner

reboottime commented Jul 5, 2023

Overview

This React daily article discusses the design of the Transition component in Mantine UI, and its rationales - CSS3 transitions and corresponding JavaScript events.

@reboottime
Copy link
Owner Author

reboottime commented Jul 5, 2023

The rationales: CSS3 transition and JavaScript Transition Events

How CSS3 transition works

  1. You declare the transition works on which property with what kind of animation function and duration
  2. Triggering change on the transition property which triggers the transition. An example is to adding decoration class to a main class and trigger property changes.

For example

.notification {
   background: red;
   height: 24px;
   width: 100px;
   transition: background-color ease .2s;
}

.notification.warning {
  background-color: yellow;
}

Corresponding JavaScript events

@reboottime
Copy link
Owner Author

reboottime commented Jul 5, 2023

Mantine UI Transition component

  • The Transition component in Mantine UI serves as a wrapper
    • that generates and applies transition styles to its child.

    • binds event listeners on different transition stages, such as onEnter, onExit, onEntered, etc.

    • define transition triggering via the mounted property

Here's an example code snippet that demonstrates the usage of the Transition component:

<Transition mounted={opened} transition={scaleY} duration={200} timingFunction="ease">
  {(styles) => (
    <Paper
      shadow="md"
      style={{ ...styles, position: 'absolute', top: 0, left: 0, right: 0, height: rem(120) }}
      ref={clickOutsideRef}
    >
      Dropdown
    </Paper>
  )}
</Transition>

As you see above, the child(only one direct child) of the Transition component is implemented as a function. .

@reboottime
Copy link
Owner Author

@reboottime reboottime changed the title [Mantine UI series] Transition [Mantine UI Series] Transition Jul 5, 2023
@reboottime reboottime added the 2023 label Aug 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant