session-desktop/ts/components/session/icon/SessionIconButton.tsx

62 lines
1.2 KiB
TypeScript
Raw Normal View History

import React from 'react';
import classNames from 'classnames';
2019-12-09 06:23:33 +01:00
import { Props, SessionIcon } from '../icon';
2019-12-11 07:48:54 +01:00
interface SProps extends Props {
onClick: any;
}
export class SessionIconButton extends React.PureComponent<SProps> {
public static readonly extendedDefaults = {
onClick: () => null,
};
public static readonly defaultProps = {
2019-12-11 07:48:54 +01:00
...SessionIcon.defaultProps,
...SessionIconButton.extendedDefaults,
};
2019-12-09 03:57:18 +01:00
2019-12-05 06:12:33 +01:00
constructor(props: any) {
super(props);
this.clickHandler = this.clickHandler.bind(this);
}
2019-12-05 06:12:33 +01:00
public render() {
2019-12-09 04:09:43 +01:00
const {
iconType,
iconSize,
iconColor,
iconRotation,
iconPadded,
} = this.props;
2019-12-05 06:12:33 +01:00
return (
<div
2019-12-09 03:48:04 +01:00
className={classNames(
'session-icon-button',
2019-12-09 04:09:43 +01:00
iconSize,
iconPadded ? 'padded' : ''
2019-12-09 03:48:04 +01:00
)}
2019-12-05 06:12:33 +01:00
role="button"
onClick={e => {
this.clickHandler(e);
}}
2019-12-05 06:12:33 +01:00
>
<SessionIcon
2019-12-09 04:09:43 +01:00
iconType={iconType}
iconSize={iconSize}
iconColor={iconColor}
iconRotation={iconRotation}
/>
2019-12-05 06:12:33 +01:00
</div>
);
}
private clickHandler(e: any) {
if (this.props.onClick) {
e.stopPropagation();
this.props.onClick();
}
2019-12-05 06:12:33 +01:00
}
}