session-desktop/ts/components/session/SessionButton.tsx

63 lines
1.3 KiB
TypeScript
Raw Normal View History

2019-12-05 01:04:48 +01:00
import React from 'react';
import classNames from 'classnames';
export enum SessionButtonType {
Brand = 'brand',
BrandOutline = 'brand-outline',
Default = 'default',
DefaultOutline = 'default-outline',
Square = 'square',
SquareOutline = 'square-outline',
Simple = 'simple',
}
export enum SessionButtonColor {
Green = 'green',
White = 'white',
Primary = 'primary',
Secondary = 'secondary',
Danger = 'danger',
Warning = 'warning',
2019-12-05 01:04:48 +01:00
}
interface Props {
text: string;
buttonType: SessionButtonType;
buttonColor: SessionButtonColor;
onClick: any;
2019-12-05 01:04:48 +01:00
}
export class SessionButton extends React.PureComponent<Props> {
public static defaultProps = {
buttonType: SessionButtonType.Default,
buttonColor: SessionButtonColor.Primary,
onClick: () => null,
};
constructor(props: any) {
super(props);
this.clickHandler = this.clickHandler.bind(this);
}
2019-12-05 01:04:48 +01:00
public render() {
const { buttonType, buttonColor, text } = this.props;
2019-12-05 01:04:48 +01:00
return (
<div
className={classNames('session-button', buttonType, buttonColor)}
role="button"
onClick={this.clickHandler}
>
2019-12-05 06:12:33 +01:00
{text}
</div>
2019-12-05 01:04:48 +01:00
);
}
private clickHandler(e: any) {
if (this.props.onClick) {
e.stopPropagation();
this.props.onClick();
}
}
2019-12-05 01:04:48 +01:00
}