2019-03-01 16:49:11 +00:00
|
|
|
import React from 'react';
|
2021-03-31 17:47:17 +00:00
|
|
|
import { CustomIcon } from '../../lib/Icons';
|
|
|
|
import { STATUS_COLORS } from '../../constants/colors';
|
2019-03-01 16:49:11 +00:00
|
|
|
|
2021-07-23 19:27:52 +00:00
|
|
|
interface IStatus {
|
|
|
|
status: string;
|
|
|
|
size: number;
|
|
|
|
style: any;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Status = React.memo(({ status, size, style, ...props }: IStatus) => {
|
2021-03-31 17:47:17 +00:00
|
|
|
const name = `status-${ status }`;
|
|
|
|
const isNameValid = CustomIcon.hasIcon(name);
|
|
|
|
const iconName = isNameValid ? name : 'status-offline';
|
|
|
|
const calculatedStyle = [{
|
|
|
|
width: size, height: size, textAlignVertical: 'center'
|
|
|
|
}, style];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<CustomIcon
|
|
|
|
style={calculatedStyle}
|
|
|
|
size={size}
|
|
|
|
name={iconName}
|
|
|
|
color={STATUS_COLORS[status] ?? STATUS_COLORS.offline}
|
|
|
|
{...props}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2019-03-01 16:49:11 +00:00
|
|
|
export default Status;
|