Having some trouble creating reusable animations with Emotion. I've defined a fadeUp
animation that works well:
export const animatedFadeUp = css`
opacity: 1;
transform: translateY(0);
`;
export const fadeUp = css`
opacity: 0;
transform: translateY(var(--spacing-medium));
transition: opacity 0.5s ease-in-out,
transform 0.5s ease-in-out;
html.no-js & {
${animatedFadeUp}
}
`;
However, when applying the fadeUp
animation to an element already with its own transitions, it gets overridden. Like in the case of this button:
const Button = styled.button`
${fadeUp}
background: orange;
transition: background-color 0.5s ease-in-out;
&:hover,
&:focus {
background: gold;
}
`;
Is there a way to combine only one property? Perhaps like this:
const Button = styled.button`
${fadeUp}
background: orange;
transition: ${fadeUp.transition},
background-color 0.5s ease-in-out;
&:hover,
&:focus {
background: gold;
}
`;