-
Notifications
You must be signed in to change notification settings - Fork 11
/
StatusIcon.tsx
35 lines (31 loc) · 959 Bytes
/
StatusIcon.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { Icons } from '../icons/Icons';
import { Status, StatusLevel } from '../../types/Status';
import React from 'react';
import styled from 'styled-components';
// == styles =======================================================================================
const Icon = styled.img`
position: absolute;
right: 1px;
bottom: 1px;
height: 14px;
`;
// == component ====================================================================================
const StatusIcon = ( { className, status }: {
className?: string;
status: Status<any> | null;
} ): JSX.Element | null => {
// null status icon for null status
if ( status == null ) { return null; }
return (
<Icon
as={
status.level === StatusLevel.ERROR ? Icons.Error :
status.level === StatusLevel.WARNING ? Icons.Warning :
Icons.Info
}
className={ className }
data-stalker={ status.message }
/>
);
};
export { StatusIcon };