-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add transition
prop to <Dialog />
component
#3307
Merged
Merged
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
Internally this will make sure that the `Dialog` itself gets wrapped in a `<Transition />` component. Next, the `<DialogPanel>` will also be wrapped in a `<TransitionChild />` component. We also re-introduce the `DialogBackdrop` that will also be wrapped in a `<TransitionChild />` component based on the `transition` prop of the `Dialog`. This simplifies the `<Dialog />` component, especially now that we can use transitions with data attributes. E.g.: ```tsx <Transition show={open}> <Dialog onClose={setOpen}> <TransitionChild enter="ease-in-out duration-300" enterFrom="opacity-0" enterTo="opacity-100" leave="ease-in-out duration-300" leaveFrom="opacity-100" leaveTo="opacity-0" > <div /> </TransitionChild> <TransitionChild enter="ease-in-out duration-300" enterFrom="opacity-0 scale-95" enterTo="opacity-100 scale-100" leave="ease-in-out duration-300" leaveFrom="opacity-100 scale-100" leaveTo="opacity-0 scale-95" > <DialogPanel> {/* … */} </DialogPanel> </TransitionChild> </Dialog> </Transition> ``` ↓↓↓↓↓ ```tsx <Transition show={open}> <Dialog onClose={setOpen}> <TransitionChild> <div className="ease-in-out duration-300 data-[closed]:opacity-0 data-[closed]:scale-95" /> </TransitionChild> <TransitionChild> <DialogPanel className="ease-in-out duration-300 data-[closed]:opacity-0 data-[closed]:scale-95 bg-white"> {/* … */} </DialogPanel> </TransitionChild> </Dialog> </Transition> ``` ↓↓↓↓↓ ```tsx <Dialog transition open={open} onClose={setOpen}> <DialogBackdrop className="ease-in-out duration-300 data-[closed]:opacity-0 data-[closed]:scale-95" /> <DialogPanel className="ease-in-out duration-300 data-[closed]:opacity-0 data-[closed]:scale-95 bg-white"> {/* … */} </DialogPanel> </Dialog> ```
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
thecrypticace
approved these changes
Jun 20, 2024
This was referenced Jul 13, 2024
This was referenced Jul 27, 2024
This was referenced Aug 15, 2024
This was referenced Aug 31, 2024
This was referenced Sep 10, 2024
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.
This PR adds a
transition
prop to the<Dialog />
component. Internally it uses the<Transition />
and<TransitionChild />
components to coordinate the transitions.The
<Dialog />
itself will be wrapped in a<Transition />
, the<DialogPanel />
will be wrapped in a<TransitionChild />
, and to make the backdrop transition happen we re-introduced the<DialogBackdrop />
component which is adiv
wrapped in a<TransitionChild />
.Recently we introduced
data-*
attribute based transitions (#3273) to simplify transitions. This also introduced thetransition
prop on components such as:ComboboxOptions
DisclosurePanel
ListboxOptions
MenuItems
PopoverPanel
This PR now also adds it to the
<Dialog />
component. This is what a migration could look like:↓↓↓↓↓ Converted to use
data-*
attributes↓↓↓↓↓ Using the new
transition
prop