-
Notifications
You must be signed in to change notification settings - Fork 672
/
index.js
55 lines (49 loc) · 1.13 KB
/
index.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
import {
jsx,
useThemeUI,
ThemeProvider as CoreProvider,
} from '@theme-ui/core'
import { ColorModeProvider } from '@theme-ui/color-modes'
import { MDXProvider } from '@theme-ui/mdx'
import { Global } from '@emotion/core'
const BodyStyles = ({ theme = {} }) => {
if (theme.useBodyStyles === false) return false
return jsx(Global, {
styles: theme => {
const fontFamily = theme.fonts && theme.fonts.body
const fontWeight = theme.fontWeights && theme.fontWeights.body
const lineHeight = theme.lineHeights && theme.lineHeights.body
return {
body: {
fontFamily,
fontWeight,
lineHeight,
}
}
}
})
}
export const ThemeProvider = ({
theme,
components,
children
}) => {
const outer = useThemeUI()
if (typeof outer.setColorMode === 'function') {
return jsx(CoreProvider, { theme },
jsx(MDXProvider, {
components,
children
})
)
}
return jsx(CoreProvider, { theme },
jsx(ColorModeProvider, null,
jsx(BodyStyles, { theme }),
jsx(MDXProvider, {
components,
children
})
)
)
}