Initially, my style sheet had the following structure:
.button {
border-radius: 3px;
display: inline-block;
padding: 14px 20px;
transition: background-color cubic-bezier(0.4, 0.0, 0.2, 1.0) 300ms;
&:hover {
background-color: transparentize($green, 0.2);
}
}
Everything was working well until I needed to inline the backgroundColor in order to work with a theming component.
import { accent1 } from 'themes/default';
export default function Button({ ...props }, {
theme: { accent1 } = { accent1 }
}) {
return (
<button
className={styles.button}
style={{ backgroundColor: accent1 }}
{...props}
/>
);
}
However, now that the background color is hard-coded, I can't figure out how to maintain the transition effect without converting it into a complex component with onMouseEnter and onMouseLeave handlers that apply an rgba color.
Is there a more efficient CSS solution to achieve this?