import { colors, Styles } from '@0xproject/react-shared'; import * as _ from 'lodash'; import * as React from 'react'; export interface IconButtonProps { iconName: string; labelText?: string; onClick: () => void; color?: string; } interface IconButtonState { isHovering: boolean; } export class IconButton extends React.Component { public static defaultProps: Partial = { onClick: _.noop, labelText: '', color: colors.mediumBlue, }; public constructor(props: IconButtonProps) { super(props); this.state = { isHovering: false, }; } public render(): React.ReactNode { const styles: Styles = { root: { cursor: 'pointer', opacity: this.state.isHovering ? 0.5 : 1, }, icon: { color: this.props.color, fontSize: 20, }, label: { color: this.props.color, fontSize: 10, }, }; return (
{!_.isEmpty(this.props.labelText) && (
{this.props.labelText}
)}
); } private _onToggleHover(isHovering: boolean): void { this.setState({ isHovering, }); } }