Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7b50658

Browse files
committed
Remove page component; inline navbar / footer rendering
1 parent 707f455 commit 7b50658

File tree

4 files changed

+51
-77
lines changed

4 files changed

+51
-77
lines changed

site/components/Page/index.test.tsx

Lines changed: 0 additions & 19 deletions
This file was deleted.

site/components/Page/index.tsx

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1 @@
1-
import React from "react"
2-
import { makeStyles } from "@material-ui/core/styles"
3-
4-
import { Footer } from "./Footer"
5-
import { Navbar } from "../Navbar"
6-
7-
export const Page: React.FC<{ children: React.ReactNode }> = ({ children }) => {
8-
// TODO: More interesting styling here!
9-
10-
const styles = useStyles()
11-
12-
const header = (
13-
<div className={styles.header}>
14-
<Navbar />
15-
</div>
16-
)
17-
18-
const footer = (
19-
<div className={styles.footer}>
20-
<Footer />
21-
</div>
22-
)
23-
24-
const body = <div className={styles.body}> {children}</div>
25-
26-
return (
27-
<div className={styles.root}>
28-
{header}
29-
{body}
30-
{footer}
31-
</div>
32-
)
33-
}
34-
35-
const useStyles = makeStyles((theme) => ({
36-
root: {
37-
display: "flex",
38-
flexDirection: "column",
39-
},
40-
header: {
41-
flex: 0,
42-
},
43-
body: {
44-
height: "100%",
45-
flex: 1,
46-
},
47-
footer: {
48-
flex: 0,
49-
},
50-
}))
1+
export * from "./Footer"

site/pages/_app.tsx

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,62 @@ import ThemeProvider from "@material-ui/styles/ThemeProvider"
55

66
import { dark } from "../theme"
77
import { AppProps } from "next/app"
8+
import { makeStyles } from "@material-ui/core"
9+
import { Navbar } from "../components/Navbar"
10+
import { Footer } from "../components/Page"
11+
12+
const Contents: React.FC<AppProps> = ({ Component, pageProps }) => {
13+
const styles = useStyles()
14+
15+
const header = (
16+
<div className={styles.header}>
17+
<Navbar />
18+
</div>
19+
)
20+
21+
const footer = (
22+
<div className={styles.footer}>
23+
<Footer />
24+
</div>
25+
)
26+
27+
return (
28+
<div className={styles.root}>
29+
{header}
30+
<Component {...pageProps} />
31+
{footer}
32+
</div>
33+
)
34+
}
835

936
/**
1037
* <App /> is the root rendering logic of the application - setting up our router
1138
* and any contexts / global state management.
12-
* @returns
1339
*/
14-
15-
const MyApp: React.FC<AppProps> = ({ Component, pageProps }) => {
40+
const MyApp: React.FC<AppProps> = (appProps) => {
1641
return (
1742
<ThemeProvider theme={dark}>
1843
<CssBaseline />
19-
<Component {...pageProps} />
44+
<Contents {...appProps} />
2045
</ThemeProvider>
2146
)
2247
}
2348

49+
const useStyles = makeStyles((theme) => ({
50+
root: {
51+
display: "flex",
52+
flexDirection: "column",
53+
},
54+
header: {
55+
flex: 0,
56+
},
57+
body: {
58+
height: "100%",
59+
flex: 1,
60+
},
61+
footer: {
62+
flex: 0,
63+
},
64+
}))
65+
2466
export default MyApp

site/pages/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from "react"
22
import { makeStyles, Box, Paper } from "@material-ui/core"
33
import { AddToQueue as AddWorkspaceIcon } from "@material-ui/icons"
44

5-
import { EmptyState, Page, SplitButton } from "../components"
5+
import { EmptyState, SplitButton } from "../components"
66

77
const WorkspacesPage: React.FC = () => {
88
const styles = useStyles()
@@ -17,7 +17,7 @@ const WorkspacesPage: React.FC = () => {
1717
}
1818

1919
return (
20-
<Page>
20+
<>
2121
<div className={styles.header}>
2222
<SplitButton<string>
2323
color="primary"
@@ -37,12 +37,12 @@ const WorkspacesPage: React.FC = () => {
3737
/>
3838
</div>
3939

40-
<Paper style={{ maxWidth: "1380px", margin: "1em auto" }}>
40+
<Paper style={{ maxWidth: "1380px", margin: "1em auto", width: "100%" }}>
4141
<Box pt={4} pb={4}>
4242
<EmptyState message="No workspaces available." button={button} />
4343
</Box>
4444
</Paper>
45-
</Page>
45+
</>
4646
)
4747
}
4848

0 commit comments

Comments
 (0)