Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | 10x 91x 91x 91x | import { alpha } from '@mui/material/styles';
import { alertClasses } from '@mui/material/Alert';
// ----------------------------------------------------------------------
const COLORS = ['info', 'success', 'warning', 'error'];
// ----------------------------------------------------------------------
export function alert(theme) {
const lightMode = theme.palette.mode === 'light';
const rootStyles = (ownerState) => {
const standardVariant = ownerState.variant === 'standard';
const filledVariant = ownerState.variant === 'filled';
const outlinedVariant = ownerState.variant === 'outlined';
const colorStyle = COLORS.map((color) => ({
...(ownerState.severity === color && {
// STANDARD
...(standardVariant && {
color: theme.palette[color][lightMode ? 'darker' : 'lighter'],
backgroundColor: theme.palette[color][lightMode ? 'lighter' : 'darker'],
[`& .${alertClasses.icon}`]: {
color: theme.palette[color][lightMode ? 'main' : 'light'],
},
}),
// FILLED
...(filledVariant && {
color: theme.palette[color].contrastText,
backgroundColor: theme.palette[color].main,
}),
// OUTLINED
...(outlinedVariant && {
backgroundColor: alpha(theme.palette[color].main, 0.08),
color: theme.palette[color][lightMode ? 'dark' : 'light'],
border: `solid 1px ${alpha(theme.palette[color].main, 0.16)}`,
[`& .${alertClasses.icon}`]: {
color: theme.palette[color].main,
},
}),
}),
}));
return [...colorStyle];
};
return {
MuiAlert: {
styleOverrides: {
root: ({ ownerState }) => rootStyles(ownerState),
icon: {
opacity: 1,
},
},
},
MuiAlertTitle: {
styleOverrides: {
root: {
marginBottom: theme.spacing(0.5),
fontWeight: theme.typography.fontWeightSemiBold,
},
},
},
};
}
|