Skip to content

Instantly share code, notes, and snippets.

@baptadn
Last active February 4, 2019 15:48
Show Gist options
  • Select an option

  • Save baptadn/1d9e0ced343b1dfd41bb4529f5a91b7c to your computer and use it in GitHub Desktop.

Select an option

Save baptadn/1d9e0ced343b1dfd41bb4529f5a91b7c to your computer and use it in GitHub Desktop.
🌈 TypeScript + Material UI + Styled component + React
import * as React from 'react';
import styled from 'styled-components';
import Button, { ButtonProps } from '@material-ui/core/Button';
interface IProps {
intent?: 'danger' | 'default' | 'success';
}
const ButtonSFC: React.SFC<ButtonProps & IProps> = ({ children, ...props }) => <Button {...props}>{children}</Button>;
const CustomButton = styled(ButtonSFC)`
&& {
border-radius: 0;
background-color: ${props => props.intent === 'danger' : 'red' : 'green'};
}
`;
CustomButton.defaultProps = {
intent: 'default',
};
export default CustomButton;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment