-
Notifications
You must be signed in to change notification settings - Fork 9
/
Layout.tsx
83 lines (73 loc) · 2.3 KB
/
Layout.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import React from 'react'
import { styled } from '@mui/material/styles'
import { Divider, Grid, Link, Paper, Typography } from '@mui/material'
import { Build as BuildIcon } from '@mui/icons-material'
import Breadcrumbs, { BreadcrumbsProps } from './Breadcrumbs.js'
import ResponsiveHelper from './ResponsiveHelper.js'
import { CsrfToken } from '../models/models.js'
const PREFIX = 'Layout'
const classes = {
root: `${PREFIX}-root`,
spacing: `${PREFIX}-spacing`,
devModePaper: `${PREFIX}-devModePaper`,
swaggerLink: `${PREFIX}-swaggerLink`
}
const StyledGrid = styled(Grid)((
{
theme
}
) => ({
[`&.${classes.root}`]: {
textAlign: 'center',
padding: theme.spacing(2)
},
[`& .${classes.spacing}`]: {
marginBottom: theme.spacing(2)
},
[`& .${classes.devModePaper}`]: {
padding: theme.spacing(1)
},
[`& .${classes.swaggerLink}`]: {
display: 'block',
clear: 'both'
}
}))
interface LayoutProps extends BreadcrumbsProps {
devMode?: boolean
children: React.ReactNode
csrfToken?: CsrfToken
}
export default function Layout (props: LayoutProps): JSX.Element {
const devBlock = props.devMode === true && props.csrfToken ?
(
<>
<div className={`${classes.swaggerLink} ${classes.spacing}`}>
<Paper variant='outlined' className={classes.devModePaper}>
<Typography component='span' variant='subtitle1'>
<BuildIcon fontSize='small' /> Development Mode:
</Typography>
<Typography component='span'>
<Link href={`/swagger?csrfToken=${String(props.csrfToken.token)}`} target='_blank'>Swagger UI</Link>
</Typography>
</Paper>
</div>
<div style={{ position: 'fixed', right: '25px', top: '25px', zIndex: 999 }}>
<ResponsiveHelper />
</div>
</>
) :
null
return (
<StyledGrid container className={classes.root}>
<Grid item sm={12} md={10} lg={9}>
{devBlock}
<div className={classes.spacing}><Breadcrumbs {...props} /></div>
<div className={classes.spacing}>{props.children}</div>
<Divider className={classes.spacing} />
<footer>
<Typography>{`Copyright © ${new Date().getFullYear()} The Regents of the University of Michigan`}</Typography>
</footer>
</Grid>
</StyledGrid>
)
}