1
1
mirror of https://github.com/jxnblk/mdx-deck.git synced 2024-11-26 00:35:02 +03:00

Split out styles

This commit is contained in:
Brent Jackson 2019-04-20 13:52:05 -04:00
parent 2aa0ce5b29
commit 6ce5a1ece7
3 changed files with 19 additions and 27 deletions

View File

@ -69,7 +69,7 @@ const handleKeyDown = props => e => {
}
}
export const Keyboard = props => {
export default props => {
useEffect(() => {
const handler = handleKeyDown(props)
window.addEventListener('keydown', handler)
@ -79,11 +79,3 @@ export const Keyboard = props => {
}, [])
return false
}
const noop = () => {}
Keyboard.defaultProps = {
setState: noop,
}
export default Keyboard

View File

@ -13,6 +13,7 @@ import GoogleFonts from './GoogleFonts'
import Catch from './Catch'
import Keyboard from './Keyboard'
import Storage from './Storage'
import Style from './Style'
const NORMAL = 'normal'
const PRESENTER = 'presenter'
@ -106,11 +107,6 @@ export class MDXDeck extends React.Component {
this.setState({ metadata })
}
componentDidCatch(err) {
console.error('componentDidCatch')
console.error(err)
}
render() {
const { slides, basepath } = this.props
const { pathname } = globalHistory.location
@ -144,21 +140,10 @@ export class MDXDeck extends React.Component {
break
}
const style =
mode !== modes.PRINT ? (
<Global
styles={{
body: {
overflow: 'hidden',
},
}}
/>
) : null
return (
<Provider {...this.props} {...this.state} mode={mode} index={index}>
{style}
<Provider {...this.props} {...context}>
<Catch>
<Style {...context} />
<Keyboard {...this.props} {...context} />
<Storage {...context} />
<GoogleFonts />

View File

@ -0,0 +1,15 @@
import React from 'react'
import { Global } from '@emotion/core'
export default ({ mode, modes }) => {
if (mode === modes.PRINT) return false
return (
<Global
styles={{
body: {
overflow: 'hidden',
},
}}
/>
)
}