@unicity/design-system
Version:
A comprehensive React component library built on Material-UI with advanced theming capabilities including neumorphism design support
24 lines • 1.6 kB
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { Alert, Slide, IconButton, } from '@mui/material';
import { Close } from '@mui/icons-material';
import { StyledSnackbar } from './Snackbar.style';
function SlideTransition(props) {
return _jsx(Slide, { ...props, direction: "up" });
}
export const Snackbar = ({ open, onClose, message, severity, showCloseButton = false, position = { vertical: 'bottom', horizontal: 'left' }, autoHideDuration = 6000, action, useAlert = false, TransitionComponent = SlideTransition, ...props }) => {
const handleClose = (event, reason) => {
if (reason === 'clickaway') {
return;
}
if (onClose) {
onClose(event, reason);
}
};
const closeButton = showCloseButton ? (_jsx(IconButton, { size: "small", "aria-label": "close", color: "inherit", onClick: handleClose, children: _jsx(Close, { fontSize: "small" }) })) : null;
const snackbarAction = action || closeButton;
if (useAlert && severity) {
return (_jsx(StyledSnackbar, { open: open, autoHideDuration: autoHideDuration, onClose: handleClose, anchorOrigin: position, TransitionComponent: TransitionComponent, ...props, children: _jsx(Alert, { onClose: handleClose, severity: severity, variant: "filled", sx: { width: '100%' }, children: message }) }));
}
return (_jsx(StyledSnackbar, { open: open, autoHideDuration: autoHideDuration, onClose: handleClose, message: message, action: snackbarAction, anchorOrigin: position, TransitionComponent: TransitionComponent, ...props }));
};
//# sourceMappingURL=Snackbar.js.map