Skip to content

Commit fe57df6

Browse files
committed
Migrate material-ui config to gatsby-plugin-material-ui
1 parent be0871e commit fe57df6

File tree

7 files changed

+82
-172
lines changed

7 files changed

+82
-172
lines changed

gatsby-config.js

+40
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
const red = require("@material-ui/core/colors/red").default
2+
const blue = require("@material-ui/core/colors/blue").default
3+
14
module.exports = {
25
siteMetadata: {
36
title: "Ohjelmoinnin MOOC 2019",
@@ -144,6 +147,43 @@ module.exports = {
144147
{
145148
resolve: "gatsby-transformer-moocfi-exercises"
146149
},
150+
{
151+
resolve: 'gatsby-plugin-material-ui',
152+
options: {
153+
theme: {
154+
palette: {
155+
primary: {
156+
light: blue[300],
157+
main: blue[500],
158+
dark: blue[700],
159+
},
160+
secondary: {
161+
light: red[300],
162+
main: red[500],
163+
dark: red[700],
164+
},
165+
},
166+
typography: {
167+
useNextVariants: true,
168+
},
169+
overrides: {
170+
MuiButton: {
171+
root: {
172+
textTransform: "none",
173+
},
174+
},
175+
MuiTypography: {
176+
body2: {
177+
fontSize: "16px",
178+
},
179+
subheading: {
180+
fontSize: "18px",
181+
},
182+
},
183+
},
184+
}
185+
}
186+
},
147187
`gatsby-plugin-meta-redirect` // make sure to put last in the array
148188
]
149189
};

gatsby-ssr.js

-44
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,3 @@
55
*/
66

77
// You can delete this file if you're not using it
8-
/* eslint-disable react/no-danger */
9-
10-
const React = require('react')
11-
const { renderToString } = require('react-dom/server')
12-
const JssProvider = require('react-jss/lib/JssProvider').default
13-
const getPageContext = require('./src/getPageContext').default
14-
15-
function replaceRenderer({
16-
bodyComponent,
17-
replaceBodyHTMLString,
18-
setHeadComponents,
19-
}) {
20-
// Get the context of the page to collected side effects.
21-
const muiPageContext = getPageContext()
22-
23-
const bodyHTML = renderToString(
24-
<JssProvider registry={muiPageContext.sheetsRegistry}>
25-
{bodyComponent}
26-
</JssProvider>
27-
)
28-
29-
replaceBodyHTMLString(bodyHTML)
30-
setHeadComponents([
31-
<style
32-
type="text/css"
33-
id="jss-server-side"
34-
key="jss-server-side"
35-
dangerouslySetInnerHTML={{
36-
__html: muiPageContext.sheetsRegistry.toString(),
37-
}}
38-
/>,
39-
])
40-
}
41-
42-
exports.replaceRenderer = replaceRenderer
43-
44-
// It's not ready yet: https://github.com/gatsbyjs/gatsby/issues/8237.
45-
//
46-
// const withRoot = require('./src/withRoot').default;
47-
// const WithRoot = withRoot(props => props.children);
48-
49-
// exports.wrapRootElement = ({ element }) => {
50-
// return <WithRoot>{element}</WithRoot>;
51-
// };

package-lock.json

+38-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"gatsby-plugin-catch-links": "^2.0.9",
2020
"gatsby-plugin-google-analytics": "^2.0.8",
2121
"gatsby-plugin-manifest": "^2.0.13",
22+
"gatsby-plugin-material-ui": "^1.2.4",
2223
"gatsby-plugin-meta-redirect": "^1.1.1",
2324
"gatsby-plugin-react-helmet": "^3.0.5",
2425
"gatsby-plugin-sharp": "^2.0.17",
@@ -35,8 +36,8 @@
3536
"gatsby-transformer-remark": "^2.1.19",
3637
"interactjs": "^1.3.4",
3738
"jquery": "^3.3.1",
38-
"pdf-slideshow": "^0.1.4",
3939
"moment": "^2.24.0",
40+
"pdf-slideshow": "^0.1.4",
4041
"prismjs": "^1.15.0",
4142
"react": "^16.7.0",
4243
"react-dom": "^16.7.0",

src/getPageContext.js

-71
This file was deleted.

src/templates/Layout.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import ContentArea from "../components/ContentArea"
55
import TopBar from "../components/TopBar"
66
import { StaticQuery, graphql } from "gatsby"
77
import * as store from "store"
8-
import withMaterialUiRoot from "./withMaterialUiRoot"
98
import Pheromones from "../util/pheromones"
109
import styled from "styled-components"
1110

@@ -30,6 +29,7 @@ import {
3029
MEDIUM_LARGE_BREAKPOINT,
3130
SMALL_MEDIUM_BREAKPOINT,
3231
} from "../util/constants"
32+
import withSimpleErrorBoundary from "../util/withSimpleErrorBoundary"
3333

3434
fontAwesomeConfig.autoAddCss = false
3535

@@ -169,4 +169,4 @@ class Layout extends React.Component {
169169
}
170170
}
171171

172-
export default withMaterialUiRoot(Layout)
172+
export default withSimpleErrorBoundary(Layout)

0 commit comments

Comments
 (0)