Skip to content

Instantly share code, notes, and snippets.

@erichulburd
Created October 27, 2016 15:48
Show Gist options
  • Save erichulburd/1833bce198aaa25d7c20e1ad649abe56 to your computer and use it in GitHub Desktop.
Save erichulburd/1833bce198aaa25d7c20e1ad649abe56 to your computer and use it in GitHub Desktop.
import React from 'react';
import styles from './styles.scss';
import classnames from 'classnames';
/**
* Button params:
* size: {'xs', 'sm', 'md', 'lg'}
* rounded: {true, false}
* color = {'gray', 'red','blue','green'}
* weight = {'xtralight', 'light', 'normal', 'bold'}
* uppercase = {true, false}
* lowercase = {true, false}
* boxShaddow = {true, false}
* onClick = function
* children = Button text
*/
const Button = ({
size = 'sm',
rounded = false,
color = 'gray',
weight = 400,
uppercase = false,
lowercase = false,
boxShadow = false,
onClick,
children
}) => {
const sizeClass = styles[size];
const roundedClass = rounded ? styles.rounded : '';
const colorClass = styles[color];
const weightClass = styles['weight-' + weight];
const upperCaseClass = uppercase ? styles.upperCase : '';
const lowerCaseClass = lowercase ? styles.lowerCase : '';
const boxShadowClass = boxShadow ? styles.boxShadow : '';
return (
<button
className={classnames(
styles.button,
sizeClass,
roundedClass,
colorClass,
weightClass,
upperCaseClass,
lowerCaseClass,
boxShadowClass
)}
onClick={onClick}
>
{children}
</button>
);
}
Button.propTypes = {
size: React.PropTypes.string,
rounded: React.PropTypes.bool,
color: React.PropTypes.string,
weight: React.PropTypes.string,
uppercase: React.PropTypes.bool,
lowercase: React.PropTypes.bool,
boxShadow: React.PropTypes.bool,
onClick: React.PropTypes.func,
children: React.PropTypes.node.isRequired
};
module.exports = Button;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment