in src/components/Snackbar/Snackbar.js [29:134]
export default function AppSnackbar(props) {
const [open, setOpen] = React.useState(props.ops.open);
const [type, setType] = React.useState('')
const [color, setColor] = React.useState(Branding.accent);
const [vertical, setVertical] = React.useState('top');
const [horizontal, setHorizontal] = React.useState('center');
if (props.ops.open !== open) {
setOpen(props.ops.open);
};
if (props.ops.type !== type) {
setType(props.ops.type);
switch (props.ops.type) {
case 'error':
setColor(Branding.negative);
break;
case 'warn':
setColor(Branding.warning);
break;
case 'info':
setColor(Branding.info);
break;
case 'success':
setColor(Branding.positive);
break;
default:
setColor(Branding.neutral);
break;
}
};
if (props.ops.vertical !== vertical) {
setVertical(props.ops.vertical);
};
if (props.ops.horizontal !== horizontal) {
setHorizontal(props.ops.horizontal);
};
const handleClose = (event, reason) => {
if (reason === 'clickaway') {
return;
}
props.ops.open = false;
setOpen(false);
};
return (
<Snackbar
style={{
backgroundColor: color || '',
}}
anchorOrigin={{
vertical: vertical,
horizontal: horizontal,
}}
open={open}
autoHideDuration={props.ops.autoHide}
onClose={handleClose}
message={props.ops.message || ''}
key={vertical + horizontal}
>
<SnackbarContent style={{
backgroundColor: color || '',
}}
message={
<span id="client-snackbar">
{props.ops.type === 'error' && (
<IconButton size="small" aria-label="error" color="inherit" onClick={handleClose}>
<ErrorOutlineOutlinedIcon fontSize="small" />
</IconButton>
)}
{props.ops.type === 'warn' && (
<IconButton size="small" aria-label="error" color="inherit" onClick={handleClose}>
<ReportProblemOutlinedIcon fontSize="small" />
</IconButton>
)}
{props.ops.type === 'info' && (
<IconButton size="small" aria-label="error" color="inherit" onClick={handleClose}>
<ErrorOutlineOutlinedIcon fontSize="small" />
</IconButton>
)}
{props.ops.type === 'success' && (
<IconButton size="small" aria-label="error" color="inherit" onClick={handleClose}>
<CheckCircleOutlineOutlinedIcon fontSize="small" />
</IconButton>
)}
{props.ops.message}
</span>
}
action={
<React.Fragment>
<IconButton size="small" aria-label="close" color="inherit" onClick={handleClose}>
<CloseIcon fontSize="small" />
</IconButton>
</React.Fragment>
}
/>
</Snackbar>
);
}