session-desktop/ts/components/session/icon/SessionIconButton.tsx
2021-07-30 16:12:36 +10:00

58 lines
1.4 KiB
TypeScript

import React from 'react';
import classNames from 'classnames';
import { SessionIcon, SessionIconProps } from '../icon';
import { SessionNotificationCount } from '../SessionNotificationCount';
import { DefaultTheme, useTheme } from 'styled-components';
interface SProps extends SessionIconProps {
onClick?: any;
notificationCount?: number;
isSelected?: boolean;
theme?: DefaultTheme;
isHidden?: boolean;
}
export const SessionIconButton = (props: SProps) => {
const {
iconType,
iconSize,
iconColor,
iconRotation,
isSelected,
notificationCount,
theme,
glowDuration,
glowStartDelay,
noScale,
isHidden,
} = props;
const clickHandler = (e: any) => {
if (props.onClick) {
e.stopPropagation();
props.onClick();
}
};
const themeToUSe = theme || useTheme();
return (
<div
className={classNames('session-icon-button', iconSize, isSelected ? 'no-opacity' : '')}
role="button"
onClick={clickHandler}
style={{ display: isHidden ? 'none' : 'flex' }}
>
<SessionIcon
iconType={iconType}
iconSize={iconSize}
iconColor={iconColor}
iconRotation={iconRotation}
theme={themeToUSe}
glowDuration={glowDuration}
glowStartDelay={glowStartDelay}
noScale={noScale}
/>
{Boolean(notificationCount) && <SessionNotificationCount count={notificationCount} />}
</div>
);
};