import React, { HTMLAttributes } from 'react'; import classNames from 'classnames'; import './index.scss'; import SuccessIcon from '../icons/success.svg'; import InfoIcon from '../icons/info.svg'; import WarningIcon from '../icons/warning.svg'; import ErrorIcon from '../icons/error.svg'; import LoadingIcon from '../icons/loading.svg'; export interface AlertProps extends HTMLAttributes { children?: React.ReactNode; type?: 'success' | 'info' | 'warning' | 'error' | 'loading'; defineIcon?: React.ReactNode; } const Alert: React.FC = (props) => { const { children, type, defineIcon, ...rest } = props; const render = () => { if (type === 'success' && !defineIcon) { return ; } if (type === 'info') { return ; } if (type === 'warning') { return ; } if (type === 'error') { return ; } if (type === 'loading') { return ; } if (defineIcon) { return defineIcon; } }; return (
{render()}

{children}

); }; Alert.defaultProps = { children: '', type: 'success', defineIcon: '' }; export default Alert;