mirror of
https://github.com/owncast/owncast.git
synced 2024-11-24 05:38:58 +03:00
a123967645
* move components folder and fix build errors Fixes https://github.com/owncast/owncast/issues/689 * Prettified Code! Co-authored-by: nebunez <nebunez@users.noreply.github.com>
68 lines
1.7 KiB
TypeScript
68 lines
1.7 KiB
TypeScript
import {
|
|
CheckCircleFilled,
|
|
ExclamationCircleFilled,
|
|
LoadingOutlined,
|
|
WarningOutlined,
|
|
} from '@ant-design/icons';
|
|
|
|
export const STATUS_RESET_TIMEOUT = 3000;
|
|
|
|
export const STATUS_ERROR = 'error';
|
|
export const STATUS_INVALID = 'invalid';
|
|
export const STATUS_PROCESSING = 'proessing';
|
|
export const STATUS_SUCCESS = 'success';
|
|
export const STATUS_WARNING = 'warning';
|
|
|
|
export type InputStatusTypes = 'error' | 'invalid' | 'proessing' | 'success' | 'warning';
|
|
|
|
export interface StatusState {
|
|
type: InputStatusTypes;
|
|
icon: any; // Element type of sorts?
|
|
message: string;
|
|
}
|
|
interface InputStates {
|
|
[key: string]: StatusState;
|
|
}
|
|
|
|
export const INPUT_STATES: InputStates = {
|
|
[STATUS_SUCCESS]: {
|
|
type: STATUS_SUCCESS,
|
|
icon: <CheckCircleFilled style={{ color: 'green' }} />,
|
|
message: 'Success!',
|
|
},
|
|
[STATUS_ERROR]: {
|
|
type: STATUS_ERROR,
|
|
icon: <ExclamationCircleFilled style={{ color: 'red' }} />,
|
|
message: 'An error occurred.',
|
|
},
|
|
[STATUS_INVALID]: {
|
|
type: STATUS_INVALID,
|
|
icon: <ExclamationCircleFilled style={{ color: 'red' }} />,
|
|
message: 'An error occurred.',
|
|
},
|
|
[STATUS_PROCESSING]: {
|
|
type: STATUS_PROCESSING,
|
|
icon: <LoadingOutlined />,
|
|
message: '',
|
|
},
|
|
[STATUS_WARNING]: {
|
|
type: STATUS_WARNING,
|
|
icon: <WarningOutlined style={{ color: '#fc0' }} />,
|
|
message: '',
|
|
},
|
|
};
|
|
|
|
// Don't like any of the default messages in INPUT_STATES? Create a state with custom message by providing an icon style with your message.
|
|
export function createInputStatus(type: InputStatusTypes, message?: string): StatusState {
|
|
if (!type || !INPUT_STATES[type]) {
|
|
return null;
|
|
}
|
|
if (!message) {
|
|
return INPUT_STATES[type];
|
|
}
|
|
return {
|
|
type,
|
|
icon: INPUT_STATES[type].icon,
|
|
message,
|
|
};
|
|
}
|