Skip to content

Instantly share code, notes, and snippets.

@renatorib
Last active March 10, 2017 03:36
Show Gist options
  • Save renatorib/06e9b57a9e7edab89a553a0f34427a6e to your computer and use it in GitHub Desktop.
Save renatorib/06e9b57a9e7edab89a553a0f34427a6e to your computer and use it in GitHub Desktop.
A Button, wrong way. 2.
import React from 'react';
import cn from 'classnames';
type Props = {
isSquare?: boolean,
isRound?: boolean,
isCircle?: boolean,
isOutline?: boolean,
color: string,
children: string,
};
const Button = ({ children, isSquare, isRound, isCircle, isOutline, color }: Props) => {
const c = (name) => `Button--${name}`;
const classes = cn('Button', { 'Button--square': isSquare, /* etc */ });
const colorStyles = isOutline ? { color, borderColor: color } : { backgroundColor: color };
return (
<button className={classes} style={{ ...colorStyles }}>
{children}
</button>
);
};
export default Button;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment