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

Fix styled-components related performance issues #21

Open
kumar303 opened this issue Sep 14, 2020 · 0 comments
Open

Fix styled-components related performance issues #21

kumar303 opened this issue Sep 14, 2020 · 0 comments

Comments

@kumar303
Copy link
Owner

There are still some cases where skeleton-kit references theme props in styles. We should make sure that for all of those cases, we return inline styles, such as this:

const OpacityPulse = styled.span.attrs((props): { style: CSSProperties } => {
const max = props.theme.skeletonKit.loopDurationMaxSec;
const min = props.theme.skeletonKit.loopDurationMinSec;
const range = max - min;
if (range < 0) {
throw new Error(
`loopDurationMinSec (${min}) cannot be greater than loopDurationMax (${max})`
);
}
const animationDuration = `${Math.random() * range + min}s`;
return {
style: {
animationDuration,
},
};
})`
animation: ${pulseOpacity} infinite cubic-bezier(0.65, 0.05, 0.36, 1);
@media (prefers-reduced-motion: reduce) {
animation: none;
}
`;

Otherwise, styled-components will create new classes for the entire matrix of all possibilities (I think?). This was causing a warning for randomized values, which was the main problem up above in OpacityPulse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant