-
Notifications
You must be signed in to change notification settings - Fork 6
/
wrap-root-element.js
68 lines (62 loc) · 1.49 KB
/
wrap-root-element.js
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
import React from 'react'
import { ApolloProvider } from '@apollo/react-hooks'
// Import font
import 'typeface-lato'
import { MDXProvider } from '@mdx-js/react'
import * as CustomComponents from './.cache/components'
import CodeBlock from './src/components/pattern-library/CodeBlock/CodeBlock.js'
import {
Box,
Container,
Grid,
Table,
TableBody,
TableCell,
TableHead,
TableRow,
Typography,
Hidden
} from '@material-ui/core'
import { client } from './src/apollo/client'
import {
AppStatusProvider,
DownloadProvider
} from './src/stores'
import ErrorBoundary from './src/components/ErrorBoundary'
import { ThemeProvider } from '@material-ui/core/styles'
import theme from './src/js/mui/theme'
/**
* Custom components comes from the cache file we create when gatsby runs its build process
*/
const mdxComponents = {
pre: props => <div {...props} />,
p: props => <div {...props} />,
code: CodeBlock,
a: CustomComponents.Link,
...CustomComponents,
Box,
Container,
Grid,
Table,
TableBody,
TableCell,
TableHead,
TableRow,
Typography,
Hidden
}
export const wrapRootElement = ({ element }) => (
<ErrorBoundary>
<ThemeProvider theme={theme}>
<ApolloProvider client={client}>
<AppStatusProvider>
<DownloadProvider>
<MDXProvider components={ mdxComponents }>
{element}
</MDXProvider>
</DownloadProvider>
</AppStatusProvider>
</ApolloProvider>
</ThemeProvider>
</ErrorBoundary>
)