-
Notifications
You must be signed in to change notification settings - Fork 178
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
TypeScript conversion of animation
package
#12702
Conversation
# Conflicts: # tsconfig.json
Note that the main story editor does not compile at this stage, but the animation package works in isolation and can be seen in action through Storybook: `npm run storybook`.
# Conflicts: # packages/animation/src/components/AMPKeyframes.tsx # packages/animation/src/components/context.ts # packages/animation/src/components/provider.tsx # packages/animation/src/components/useStoryAnimationContext.ts # packages/animation/src/effects/backgroundPan/animationProps.js # packages/animation/src/effects/fadeIn.ts # packages/animation/src/effects/flyIn/animationProps.js # packages/animation/src/effects/pulse.ts # packages/animation/src/effects/zoom/animationProps.js # packages/animation/src/parts/defaultFields.ts # packages/animation/src/parts/simpleAnimation.js # packages/animation/src/parts/test/index.js # packages/animation/src/parts/types.js # packages/animation/src/types.js # packages/animation/src/types/index.ts # packages/animation/src/types/types.js # packages/elements/src/utils/index.ts # packages/media/src/types/mediaElement.ts
A bunch of anim constants have been converted from object to enums and thus had their casing updating from `SCREAMING_SNAKE_CASE` to `PascalCase`.
…-stories-wp into code/12207-ts-anim # Conflicts: # packages/story-editor/src/components/panels/design/animation/animation.js
Thís required creating a union type for all the animations. However, it works a little weird, so had to do a bunch of `as const` stuff in tests, so worry about typing the implementation of this in other packages, but for now this is good.
Yes, `panDirection` would be better, but it is already referenced a ton of places, so it is a lot of unnecessary work to change it.
animation
packageanimation
package
Plugin builds for f864b46 are ready 🛎️!
|
Size Change: -15.2 kB (-1%) Total Size: 2.71 MB
ℹ️ View Unchanged
|
Dunno why eslint complains, but maybe it is the missing header?
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.
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.
LGTM!
Doesn't seem ideal to define a similar element type in different packages but if there's no better alternative currently, then let's go with that.
Context
This was a big one 😅
The
animation
package is quite over-engineered and has a serious lack of DRY-ness with a lot of duplicated code, boilerplate and even logic. This is still only a partial conversion.At this stage, I would welcome a sanity check, but I actually feel pretty good about the conversion, because I can see all the animations working in Storybook (except for background effects, see todo).
To-do
Need-to-have
animation
andelements
, soelements
now depend onanimation
tsconfig
)createAnimation
(requires makingStoryAnimation
a union type with all the properties specified for each different animation type)Bugs in editor
Nice-to-have
/parts/
to/parts/simple/
and move effects to/parts/effects/
. They're all only ever referenced by the functions inside/parts/index.tsx
anyway (which will be split up above)./parts/index.tsx
into dedicated files, and add tests (esp. forgetAnimationEffectFields
)User-facing changes
None!
Testing Instructions
Test everything related to animations including old stories with animation, creating new stories with new animations, previewing animations in the editor, viewing animations in the output story.
Checklist
Type: XYZ
label to the PRFixes #12207