2019-12-05 01:04:48 +01:00
|
|
|
import React from 'react';
|
|
|
|
import classNames from 'classnames';
|
|
|
|
|
2019-12-11 05:51:14 +01:00
|
|
|
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',
|
2019-12-20 06:08:57 +01:00
|
|
|
Success = 'success',
|
2019-12-11 05:51:14 +01:00
|
|
|
Danger = 'danger',
|
|
|
|
Warning = 'warning',
|
2020-01-02 03:21:37 +01:00
|
|
|
None = '',
|
2019-12-05 01:04:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
interface Props {
|
2020-01-08 09:16:01 +01:00
|
|
|
text?: string;
|
2019-12-11 05:51:14 +01:00
|
|
|
buttonType: SessionButtonType;
|
|
|
|
buttonColor: SessionButtonColor;
|
|
|
|
onClick: any;
|
2019-12-05 01:04:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export class SessionButton extends React.PureComponent<Props> {
|
2019-12-11 05:51:14 +01:00
|
|
|
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() {
|
2019-12-11 05:51:14 +01:00
|
|
|
const { buttonType, buttonColor, text } = this.props;
|
2019-12-05 01:04:48 +01:00
|
|
|
|
2019-12-16 00:03:50 +01:00
|
|
|
const buttonTypes = [];
|
|
|
|
|
|
|
|
buttonTypes.push(buttonType);
|
|
|
|
if (buttonType.includes('-outline')) {
|
|
|
|
buttonTypes.push(buttonType.replace('-outline', ''));
|
|
|
|
}
|
|
|
|
|
2019-12-05 01:04:48 +01:00
|
|
|
return (
|
2019-12-11 05:51:14 +01:00
|
|
|
<div
|
2019-12-16 00:03:50 +01:00
|
|
|
className={classNames('session-button', ...buttonTypes, buttonColor)}
|
2019-12-05 06:46:15 +01:00
|
|
|
role="button"
|
2019-12-11 04:05:23 +01:00
|
|
|
onClick={this.clickHandler}
|
2019-12-11 05:51:14 +01:00
|
|
|
>
|
2020-01-08 09:16:01 +01:00
|
|
|
{this.props.children || text}
|
2019-12-05 06:12:33 +01:00
|
|
|
</div>
|
2019-12-05 01:04:48 +01:00
|
|
|
);
|
|
|
|
}
|
2019-12-11 05:51:14 +01:00
|
|
|
|
|
|
|
private clickHandler(e: any) {
|
|
|
|
if (this.props.onClick) {
|
|
|
|
e.stopPropagation();
|
|
|
|
this.props.onClick();
|
|
|
|
}
|
|
|
|
}
|
2019-12-05 01:04:48 +01:00
|
|
|
}
|