Skip to content

Instantly share code, notes, and snippets.

@huang47
Created December 8, 2019 23:37
Show Gist options
  • Save huang47/297d0c9a8f17dba080f56b873b6bb021 to your computer and use it in GitHub Desktop.
Save huang47/297d0c9a8f17dba080f56b873b6bb021 to your computer and use it in GitHub Desktop.
// @flow
import React, { type ComponentType } from 'react';
import type { TIcon, TColor } from '../type';
import AbstractButton from './AbstractButton';
import { Size, type TSize } from '../renderer/size';
export type ButtonProps<TValue> = {
disabled: boolean,
backgroundColor: TColor,
color: TColor,
icon: TIcon,
label: string,
renderer: ComponentType<*>,
size: TSize,
value: TValue,
width: number,
onPress: TValue => void,
};
export default class Button<T> extends React.PureComponent<ButtonProps<T>> {
static Size = Size;
render() {
const {
backgroundColor,
color,
disabled,
icon,
label,
renderer: ButtonRenderer,
size,
value,
width,
onPress,
} = this.props;
return (
<AbstractButton disabled={disabled} value={value} onPress={onPress}>
<ButtonRenderer
backgroundColor={backgroundColor}
color={color}
disabled={disabled}
icon={icon}
label={label}
size={size}
width={width}
/>
</AbstractButton>
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment