UNPKG

@unicity/design-system

Version:

A comprehensive React component library built on Material-UI with advanced theming capabilities including neumorphism design support

21 lines 1.19 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import React from 'react'; import { AlertTitle, IconButton, Collapse } from '@mui/material'; import { Close } from '@mui/icons-material'; import { StyledAlert } from './Alert.style'; export const Alert = ({ severity = 'info', variant = 'standard', title, children, closable = false, open = true, onClose, icon, showIcon = true, action, ...props }) => { const [isOpen, setIsOpen] = React.useState(open); React.useEffect(() => { setIsOpen(open); }, [open]); const handleClose = () => { setIsOpen(false); if (onClose) { onClose(); } }; const closeAction = closable ? (_jsx(IconButton, { "aria-label": "close", color: "inherit", size: "small", onClick: handleClose, children: _jsx(Close, { fontSize: "inherit" }) })) : undefined; const alertAction = action || closeAction; return (_jsx(Collapse, { in: isOpen, children: _jsxs(StyledAlert, { severity: severity, variant: variant, icon: showIcon ? icon : false, action: alertAction, ...props, children: [title && _jsx(AlertTitle, { children: title }), children] }) })); }; //# sourceMappingURL=Alert.js.map