Skip to content

Instantly share code, notes, and snippets.

@adeelibr
Last active April 16, 2019 19:29
Show Gist options
  • Select an option

  • Save adeelibr/904e2d0181f0c12d930f3dc9b30e9a16 to your computer and use it in GitHub Desktop.

Select an option

Save adeelibr/904e2d0181f0c12d930f3dc9b30e9a16 to your computer and use it in GitHub Desktop.
If/else hell & it's atonement Part 4
const MyButton = ({ theme, rounded, hover, animation, content }) => {
let className = '';
if (theme === 'default') {
className = rounded ? 'default-btn rounded' : 'default-btn';
if (hover) {
className = className + ' hover';
}
} else if (theme === 'primary') {
if (rounded) {
if (hover) {
if (animation) {
className = 'primary-btn rounded hover my-custom-animation';
} else {
className = 'primary-btn rounded hover';
}
} else {
className = 'primary-btn rounded';
}
} else {
if (hover) {
className = 'primary-btn hover';
} else {
className = 'primary-btn';
}
}
}
return (
<button className={className}>{content}</button>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment