Skip to content

Commit

Permalink
feat: Create a button component
Browse files Browse the repository at this point in the history
  • Loading branch information
jerelmiller committed Jun 28, 2020
1 parent c196f68 commit 528d371
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/components/Button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import styles from './Button.module.scss';

const Button = ({
as: Component = 'button',
children,
className,
variant,
...props
}) => (
<Component
{...props}
className={cx(className, styles.button, styles[variant])}
>
{children}
</Component>
);

Button.VARIANT = {
PRIMARY: 'primary',
NORMAL: 'normal',
};

Button.propTypes = {
as: PropTypes.elementType,
children: PropTypes.node,
className: PropTypes.string,
type: PropTypes.oneOf(['button', 'submit', 'reset']),
variant: PropTypes.oneOf(Object.values(Button.VARIANT)).isRequired,
};

export default Button;
25 changes: 25 additions & 0 deletions src/components/Button.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.button {
display: inline-flex;
align-items: center;
justify-content: center;
padding: 0.5rem 1rem;
font-size: 0.875rem;
font-weight: 600;
border-radius: 3px;
font-family: var(--primary-font-family);
cursor: pointer;
border-width: 1px;
border-style: solid;
}

.primary {
color: #fff;
border-color: var(--color-brand-800);
background-color: var(--color-brand-800);
}

.normal {
color: var(--color-neutrals-800);
border-color: var(--color-neutrals-100);
background-color: var(--color-neutrals-100);
}

0 comments on commit 528d371

Please sign in to comment.