-
Notifications
You must be signed in to change notification settings - Fork 154
Upgrade to styled-components v4.2.0 #374
base: master
Are you sure you want to change the base?
Conversation
Looks like this change also breaks all existing snapshot tests that relied on a styled component, as well as any that used a |
src/components/Sidebar/Sidebar.js
Outdated
@@ -251,11 +251,11 @@ export class Sidebar extends PureComponent<Props, State> { | |||
} | |||
} | |||
|
|||
const Wrapper = animated(styled.nav.attrs(props => ({ | |||
style: { | |||
const Wrapper = animated(styled.nav.attrs({ |
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.
Ups, merging master changed this to old styled-component syntax - I'll fix this.
Codecov Report
@@ Coverage Diff @@
## master #374 +/- ##
==========================================
- Coverage 58.83% 58.79% -0.04%
==========================================
Files 158 159 +1
Lines 3357 3354 -3
Branches 467 468 +1
==========================================
- Hits 1975 1972 -3
Misses 1179 1179
Partials 203 203
|
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.
I've updated the snapshots & merged master.
The warning you mentioned is because IconBase
is a functional component src of IconBase and React-Spring
is passing a ref to it as mentioned in this issue. Not sure how to fix this - the wrapping in a class component will work but feels a bit hacky.
I commented one assertion in Sidebar.test
. Not sure how to fix - we can fix this later. SetTimeout
seems to be called 7 times but it should be only called twice.
One point I've noticed - Icon selection in ProjectSettingsModal is not working correctly. The citrone icon should be marked in the screenshot below.
Awesome, thanks for taking this up. I'll try to look into the icon issue if I get the time. I believe Josh had originally noticed some performance issues when we first looked at moving to v4, did you find there to be any performance degradation? |
@superhawk610 after having a second look at the modal animation there is an issue with the project settings modal - there is no in animation & the modal is not reaching the final position and out animation is not smooth. I'll have a look if this is the same thing Josh noticed. Update |
OK, I've fixed the Selection issue is also fixed - we checked for equality but I've also improved the animation so it's correctly rendering again but there is still a lot going on but I'm not seeing if there is anything wrong.
|
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.
@melanieseltzer OK, I've fixed both mentioned issues. To the project name animation To the project selection issue |
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.
Icons look great! Animation is still not working right but I think I have a solution...
style: { | ||
transform: `translateY(${props.translateY}px)`, | ||
transform: interpolate([translateY], y => `translateY(${y}px)`), |
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.
Unfortunately this interpolate change isn't producing quite the right result... it's still sticking to the top and not having the correct offset animation. The correct behavior has offset at 50 at first, and when moving to next step, offset becomes 0 and content shifts up smoothly:
But I dug into it a little more and I think I found the solution! Remove the native
prop on Spring:
<Spring
from={{
offset: currentStepIndex === 0 ? 0 : 50,
}}
to={{
offset: currentStepIndex === 0 ? 50 : 0,
}}
// remove
native
>
And then reset this to the original code:
const Wrapper = animated(styled.div.attrs(({ translateY }) => ({
style: {
transform: `translateY(${translateY}px)`,
},
}))`
height: 75vh;
will-change: transform;
`);
This fixes it for me :) I'm not really sure what native is or why it's here, do you know?
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.
ah, OK. The native prop is there for better performance and we should keep it. docs about native prop.
Maybe inlining the translate into a style
prop in MainPane could help. I'll have a look later today.
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.
@melanieseltzer Please have a look at the animation. It should be OK now. I'm not sure why animation(styled.div)
is not working - maybe I'll create a minimal demo in a Codesandbox to see if it's happening there too.
Could be an issue with Styled-components or React-spring because animation
wrapping is recommended in React-Spring docs.
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 created a Codesandbox with it - seems like the style is not added on the element but I'm not sure why.
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.
Nice, the updated code works 👍 Not sure why it's doing this either. I noticed some more animations not firing so I went and updated them using the way you've outlined, could you double check the logic? Feel free to modify if there's a more elegant way to write these.
See #269 for previous discussion.
Changes
styled-components
to latest version (4.2.0
)injectGlobal
tocreateGlobalStyle
withComponent
at declaration toas
when instantiating componentprops => values
to top level instyled.el.attrs
calls (see styled-components#2200)SC.extend
tostyled(SC)
flow-bin
to latest version (0.95.1
) to getforwardRef
supportKnown issues
Wrapping a styled component with
animated()
fromreact-spring
seems to be the culprit for this error message, though from researching this briefly it appears to be harmless error (theref
is never used).@idoberko2 you worked on the migration to
react-spring
, perhaps you can shed some light here?Todo
styled(Component)
and<ForwardRef />
HOCs