|
| 1 | +import Box from '@mui/material/Box'; |
| 2 | +import Grid from '@mui/material/Grid'; |
| 3 | +import Typography from '@mui/material/Typography'; |
| 4 | +import ErrorImage from './collaboration.png' |
| 5 | + |
| 6 | +interface ErrorPageProps { |
| 7 | + /** The title to display. */ |
| 8 | + title: React.ReactNode | string; |
| 9 | + /** The message to display. */ |
| 10 | + message: React.ReactNode | string; |
| 11 | + /** Additional actions to display below the message. */ |
| 12 | + actions?: React.ReactNode; |
| 13 | + /** Additional content to display below the message and above the actions. */ |
| 14 | + children?: React.ReactNode; |
| 15 | + /** The source URL of the image to display. Defaults to a Red Hat-branded image. */ |
| 16 | + image?: string; |
| 17 | +} |
| 18 | + |
| 19 | +const ErrorPageGutters = { |
| 20 | + xs: 3, |
| 21 | + md: 6, |
| 22 | + lg: 9, |
| 23 | + xl: 12, |
| 24 | +} |
| 25 | + |
| 26 | +export const ErrorPage = ({ title, message, actions, image = ErrorImage, children }: ErrorPageProps) => ( |
| 27 | + <Grid container sx={{ flexGrow: 1 }} spacing={0}> |
| 28 | + <Grid item xs={12} md={6} sx={{ display: 'flex', flexDirection: 'column', justifyContent: 'center' }}> |
| 29 | + <Box sx={{ px: ErrorPageGutters, display: 'flex', flexDirection: 'column', gap: 3 }}> |
| 30 | + <Typography variant="h1" gutterBottom> |
| 31 | + {title} |
| 32 | + </Typography> |
| 33 | + |
| 34 | + <Typography variant="subtitle1" gutterBottom> |
| 35 | + {message} |
| 36 | + </Typography> |
| 37 | + |
| 38 | + {children} |
| 39 | + <div data-testid="error-page-actions"> |
| 40 | + {actions} |
| 41 | + </div> |
| 42 | + </Box> |
| 43 | + </Grid> |
| 44 | + <Grid item xs={12} md={6} sx={{ display: 'flex' }}> |
| 45 | + <Box component="img" src={image} alt="" aria-hidden="true" sx={{ maxWidth: '100%', maxHeight: '100vh', |
| 46 | + objectFit: 'contain', px: ErrorPageGutters }} /> |
| 47 | + </Grid> |
| 48 | + </Grid> |
| 49 | +); |
0 commit comments