Skip to content

Instantly share code, notes, and snippets.

@chadspencer
Last active September 25, 2020 15:51
Show Gist options
  • Save chadspencer/b2d6987b385f5e7bbe0eeb1d41ec8dd3 to your computer and use it in GitHub Desktop.
Save chadspencer/b2d6987b385f5e7bbe0eeb1d41ec8dd3 to your computer and use it in GitHub Desktop.
import { cx, css } from 'emotion';
const button = {
background: black,
color: white,
'& + &': {
marginLeft: '8px',
}
};
const buttonPrimary = {
background: red,
};
const buttonSecondary = {
background: green,
};
const sibling = {
'& + &': {
marginLeft: '8px',
}
};
const classes = cx(
css(button),
{[css(buttonPrimary)]: this.props.type === 'primary'},
{[css(buttonSecondary)]: this.props.type === 'secondary'},
);
render(
<button
className={`${classes} ${css(sibling)}`}
/>
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment