-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathStatusMessage.tsx
41 lines (33 loc) · 1.06 KB
/
StatusMessage.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
36
37
38
39
40
41
import React from 'react';
import cx from 'classnames';
import InputStatusIcon from './InputStatusIcon';
export type Status = 'success' | 'info' | 'error' | 'warning' | 'loading';
export type TooltipType = 'left' | 'right';
export type StatusWithMessage = {
tooltip?: TooltipType;
status: Status;
message?: string;
};
export type StatusMessageProps = {
statusWithMessage: StatusWithMessage;
showIcon?: boolean;
small?: boolean;
};
const StatusMessage = ({ statusWithMessage, showIcon, small }: StatusMessageProps) => {
const { tooltip, status, message } = statusWithMessage;
if (message === undefined) return null;
return (
<div
className={cx({
'status-message-wrapper': !tooltip,
'status-message-wrapper-tooltip': tooltip,
'tooltip-left': tooltip === 'left',
'tooltip-right': tooltip === 'right',
})}
>
{showIcon && <InputStatusIcon status={status} small={small} />}
<span className={cx('status-message', { [status]: status })}>{message}</span>
</div>
);
};
export default StatusMessage;