Skip to content

Instantly share code, notes, and snippets.

@JoshK2
Created October 23, 2019 13:36
Show Gist options
  • Save JoshK2/7618367c17195a3d8a33408e82b356f0 to your computer and use it in GitHub Desktop.
Save JoshK2/7618367c17195a3d8a33408e82b356f0 to your computer and use it in GitHub Desktop.
simple Button component - build react typescript component in isolation
import React, { Component, CSSProperties } from 'react';
type ButtonProps = {
text: string,
disable?: boolean,
onClick: Function
}
const css: CSSProperties = {
padding: '5px 9px',
border: '0',
borderRadius: '3px',
fontSize: 16,
cursor: 'pointer',
color: '#fafafa',
outline: 'none',
}
export default class Button extends Component<ButtonProps, {}> {
render() {
const { text, disable = false, onClick } = this.props;
return (
<button style={{ backgroundColor: disable ? '#cdcdcd' : '#2196F3', ...css }} onClick={(e) => onClick(e)}>
{text}
</button>
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment