import {FunctionComponent} from 'react'; import cls from 'classnames'; import {Transition} from '@core0/transition'; import {Icon} from '@core0/icon'; import {SnackbarType} from './snackbar-type.enum'; import cn from './snackbar.module.styl'; export interface SnackbarItemProps { onClose(): void; message: string; type: SnackbarType; duration?: number; } export const SnackbarItem: FunctionComponent = props => { const { onClose = () => {}, type, message } = props; const isSuccessType = type === SnackbarType.Success; const isErrorType = type === SnackbarType.Error; const isWarningType = type === SnackbarType.Warning; const isComparisonInfoType = type === SnackbarType.ComparisonInfo; /* **************************************** * Event Handlers **************************************** */ function closeIconClickHandler() { onClose(); } return (
{ isSuccessType || isComparisonInfoType ? : null} { isErrorType ? : null} { isWarningType ? : null} {message}
); };