Skip to content

Instantly share code, notes, and snippets.

@raisiqueira
Created July 19, 2018 21:05
Show Gist options
  • Save raisiqueira/e7be464827c130127852b94a4bc95da5 to your computer and use it in GitHub Desktop.
Save raisiqueira/e7be464827c130127852b94a4bc95da5 to your computer and use it in GitHub Desktop.
import React, {PureComponent} from 'react';
import PropTypes from 'prop-types';
import styled, {css} from 'styled-components';
export default class Button extends PureComponent {
render () {
return <ButtonStyped>{this.props.title}</ButtonStyped>;
}
}
const ButtonStyped = styled.button`
${props => props.rounded && css`
border-radius: 5px
`}
background-color: ${props => (props.primary ? '#264e86' : '#eff0f4')};
color: ${props => (props.primary ? 'white' : '#264e86')};
padding: 10px;
margin: 3px;
font-size: 1em;
outline: none
`;
Button.defaultProps = {
title: 'Hello!',
primary: true,
rounded: false,
};
Button.propTypes = {
title: PropTypes.string.isRequired,
primary: PropTypes.bool,
rounded: PropTypes.bool,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment