I have been playing around with styled-components
and conditional rendering for a couple of days now and i have noticed some animation lag because of this i am not sure if it is actually related to styled-components
or something else this is my button component can you please check if these checks are too heavy ? or could i have something else affecting the performance ?
export const StyledButton = styled.button`
cursor: pointer;
border-radius: ${borderRadius};
outline: none;
// inputs: color, outlined
// default
border: 1px solid transparent;
color: ${({ theme, color }) => !color && theme.buttonText};
background-color: ${({ theme, color }) => !color && theme.buttonBackground};
// regular
color: ${({ color, outlined }) => !outlined && color && colors.white};
background-color: ${({ color, outlined }) => !outlined && color};
// outlined
color: ${({ color, outlined }) => outlined && color};
background-color: ${({ color, outlined }) => outlined && color && `transparent`};
border-color: ${({ color }) => color};
transition: background-color 350ms linear, color 350ms linear;
svg {
transition: stroke 350ms linear;
// default
stroke: ${({ theme, color }) => !color && theme.buttonText};
// regular
stroke: ${({ color, outlined }) => !outlined && color && colors.white};
// outlined
stroke: ${({ color, outlined }) => outlined && color};
}
* > * {
transition: color 350ms linear;
// default
color: ${({ theme, color }) => !color && theme.buttonText};
// regular
color: ${({ color, outlined }) => !outlined && color && colors.white};
// outlined
color: ${({ color, outlined }) => outlined && color};
}
&:hover {
// default
color: ${({ theme, color }) => !color && theme.buttonBackground};
background-color: ${({ theme, color }) => !color && theme.buttonText};
// regular
color: ${({ color, outlined }) => !outlined && color};
background-color: ${({ color, outlined }) => !outlined && color && "transparent"};
// outlined
color: ${({ color, outlined }) => outlined && color && colors.white};
background-color: ${({ color, outlined }) => outlined && color};
svg {
// default
stroke: ${({ theme, color }) => !color && theme.buttonBackground};
// regular
stroke: ${({ color, outlined }) => !outlined && color};
// outlined
stroke: ${({ color, outlined }) => outlined && color && colors.white};
}
* > * {
// default
color: ${({ theme, color }) => !color && theme.buttonBackground};
// regular
color: ${({ color, outlined }) => !outlined && color};
// outlined
color: ${({ color, outlined }) => outlined && color && colors.white};
}
}
`;