Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save adeelibr/bde484d3b6dcd47251d5ac9745ce87cd to your computer and use it in GitHub Desktop.
If/else hell & it's atonement Part 5
const MyButton = ({ theme, rounded, hover, animation, content }) => {
const isThemeDefault = theme === 'default'
const isThemePrimary = theme === 'primary';
const isRounded = rounded === true;
const isHover = hover === true;
const isAnimated = animation === true;
const isPrimaryAnimated = isThemePrimary && isAnimated;
let className = isThemePrimary ? 'primary-btn' : 'default-btn';
if (isRounded) {
className = `${className} rounded`;
}
if (isHover) {
className = `${className} hover`;
}
if (isPrimaryAnimated) {
className = `${className} animated`;
}
return (
<button className={className}>{content}</button>
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment