-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Animate: Add types and simplify API #26965
Conversation
9a909e1
to
ea05b4b
Compare
if ( Boolean( _deprecatedOptions ) ) { | ||
deprecated( '<Animate> options prop', { | ||
version: '9.3', | ||
hint: 'Pass options directly as props instead.', | ||
} ); | ||
} |
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.
It's something that needs more updates, documentation need to be aligned:
https://github.com/WordPress/gutenberg/tree/master/packages/components/src/animateIn general, I agree with the sentiment but in practice it might start printing those depreciations in the JS console if its usage isn't updated in Gutenberg. So I would be very careful changing the public API. It also needs to be announced as Dev Note when a new version of WordPress is released so plugins could update.
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.
Thanks, @gziolo. What's required for a dev note?
// Ignore due to missing types: https://github.com/WordPress/gutenberg/pull/26429 | ||
// @ts-ignore | ||
import deprecated from '@wordpress/deprecated'; |
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.
I've been testing storybook and there's a regression I'll fix… |
Size Change: +93 B (0%) Total Size: 1.19 MB
ℹ️ View Unchanged
|
This reverts commit 6e8d8b95fca0f30af4d85b2910f114c42917a930.
002608e
to
263d043
Compare
I created a hook in #26201 with the intention of deprecating the |
Oh, and stabilise the animate hook of course. The reason I didn't do it in the other PR is that it wasn't clear to me what package it should be in. There's no hooks in the components package yet, and usually we add new hook to |
no strong opinions but the hook definitely look better in "components" because it has styles. |
Suggested here: #26965 (comment)
I'm working on the proposed alternative in #27123 |
Suggested here: #26965 (comment)
Suggested here: #26965 (comment)
Suggested here: #26965 (comment)
Description
Animate
component.Animate
component API.useAnimate
accepts anoptions
object which is a stringtype
+ some options based on the type.Animate
component acceptedtype
property (the same) anoptions
object (the other options) and achildren
render function property.The options prop doesn't correspond to
useAnimate
options (it doesn't include the type) and there seems to be no benefit to wrapping the options in an object.Animate
can pass its props (excludingchildren
) touseAnimate
.Options are still accepted although deprecated and scheduled for removal in 9.6.
Supersedes #26176
I've replaced the usage in Gutenberg that I found (just one case).
I've also updated the Animate storybook. It now uses knobs to adjust the options on the fly.
How has this been tested?
Types pass.
Storybook examples work as expected.
Screenshots
When using
options
prop, you'll see this deprecation warning (it says 9.4 but I've changed it to 9.6):Types of changes
New feature: Add types to the Animate component.
This change deprecates the
Animate
options prop and schedules it to be removed in two releases: 9.6. It will be a breaking change when this is removed.Checklist: