forked from tl-its-umich-edu/canvas-course-manager-next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
InlineErrorAlert.tsx
50 lines (43 loc) · 1.24 KB
/
InlineErrorAlert.tsx
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
import React from 'react'
import { styled } from '@mui/material/styles'
import { Grid, Paper } from '@mui/material'
import { Error as ErrorIcon } from '@mui/icons-material'
import { red } from '@mui/material/colors'
const PREFIX = 'InlineErrorAlert'
const classes = {
alert: `${PREFIX}-alert`,
icon: `${PREFIX}-icon`
}
const StyledPaper = styled(Paper)((
{
theme
}
) => ({
[`&.${classes.alert}`]: {
marginBottom: theme.spacing(2),
padding: theme.spacing(1),
color: theme.palette.error.dark,
backgroundColor: red[50]
},
[`& .${classes.icon}`]: {
color: theme.palette.error.main
}
}))
interface InlineAlertProps {
children: React.ReactNode
icon?: boolean
}
/*
Temporary implementation of inline Alert. This is implemented in Material UI 4's lab package
but is part of the core later in 5. We can use that once we update.
*/
export default function InlineErrorAlert (props: InlineAlertProps): JSX.Element {
return (
<StyledPaper className={classes.alert} elevation={0} role='alert'>
<Grid container spacing={2} alignItems='center' direction='row' wrap='nowrap'>
<Grid item><ErrorIcon className={classes.icon} /></Grid>
<Grid item>{props.children}</Grid>
</Grid>
</StyledPaper>
)
}