2018-08-24 06:33:11 +00:00
|
|
|
import React from 'react';
|
2018-08-16 12:04:40 +00:00
|
|
|
import styled, { css } from 'styled-components';
|
|
|
|
import PropTypes from 'prop-types';
|
2018-08-24 06:33:11 +00:00
|
|
|
import Icon from 'components/Icon';
|
2018-08-16 12:04:40 +00:00
|
|
|
import colors from 'config/colors';
|
|
|
|
|
|
|
|
const Wrapper = styled.button`
|
2018-08-24 06:33:11 +00:00
|
|
|
padding: ${props => (props.icon ? '4px 24px 4px 15px' : '11px 24px')};
|
2018-08-16 12:04:40 +00:00
|
|
|
border-radius: 3px;
|
|
|
|
font-size: 14px;
|
|
|
|
font-weight: 300;
|
|
|
|
cursor: pointer;
|
|
|
|
background: ${colors.GREEN_PRIMARY};
|
|
|
|
color: ${colors.WHITE};
|
|
|
|
border: 0;
|
|
|
|
&:hover {
|
|
|
|
background: ${colors.GREEN_SECONDARY};
|
|
|
|
}
|
|
|
|
&:active {
|
|
|
|
background: ${colors.GREEN_TERTIARY};
|
|
|
|
}
|
|
|
|
${props => props.disabled && css`
|
|
|
|
pointer-events: none;
|
|
|
|
color: ${colors.TEXT_SECONDARY};
|
|
|
|
background: ${colors.GRAY_LIGHT};
|
|
|
|
`}
|
|
|
|
`;
|
|
|
|
|
2018-08-24 06:33:11 +00:00
|
|
|
const IconWrapper = styled.span`
|
|
|
|
margin-right: 8px;
|
|
|
|
`;
|
|
|
|
|
2018-08-16 12:04:40 +00:00
|
|
|
const Button = ({
|
2018-08-24 06:33:11 +00:00
|
|
|
text, icon, onClick, disabled, blue, white,
|
2018-08-16 12:04:40 +00:00
|
|
|
}) => (
|
|
|
|
<Wrapper
|
2018-08-24 06:33:11 +00:00
|
|
|
icon={icon}
|
2018-08-16 12:04:40 +00:00
|
|
|
onClick={onClick}
|
|
|
|
disabled={disabled}
|
|
|
|
blue={blue}
|
|
|
|
white={white}
|
2018-08-24 06:33:11 +00:00
|
|
|
>
|
|
|
|
{icon && (
|
|
|
|
<IconWrapper>
|
|
|
|
<Icon
|
|
|
|
icon={icon.type}
|
|
|
|
color={icon.color}
|
|
|
|
size={icon.size}
|
|
|
|
/>
|
|
|
|
</IconWrapper>
|
|
|
|
)}
|
|
|
|
{text}
|
2018-08-16 12:04:40 +00:00
|
|
|
</Wrapper>
|
|
|
|
);
|
|
|
|
|
|
|
|
Button.propTypes = {
|
|
|
|
onClick: PropTypes.func,
|
|
|
|
disabled: PropTypes.bool,
|
|
|
|
blue: PropTypes.bool,
|
|
|
|
white: PropTypes.bool,
|
2018-08-24 06:33:11 +00:00
|
|
|
icon: PropTypes.shape({
|
|
|
|
type: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
|
|
color: PropTypes.string,
|
|
|
|
size: PropTypes.number,
|
|
|
|
}),
|
2018-08-16 12:04:40 +00:00
|
|
|
text: PropTypes.string.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
Button.defaultProps = {
|
|
|
|
onClick: () => {},
|
|
|
|
disabled: false,
|
|
|
|
blue: false,
|
|
|
|
white: false,
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Button;
|