diff --git a/src/components/__snapshots__/component-playground.test.js.snap b/src/components/__snapshots__/component-playground.test.js.snap index 2f6696f6c..df7c06ed8 100644 --- a/src/components/__snapshots__/component-playground.test.js.snap +++ b/src/components/__snapshots__/component-playground.test.js.snap @@ -1069,7 +1069,6 @@ exports[` Should render with a custom background color 1` >

Should render with a custom code block 1`] = ` >
diff --git a/src/components/component-playground.js b/src/components/component-playground.js index 346881df5..ac4752f7b 100644 --- a/src/components/component-playground.js +++ b/src/components/component-playground.js @@ -18,13 +18,13 @@ export const PlaygroundProvider = styled(LiveProvider)` overflow: hidden; `; -const PlaygroundPreview = styled(LivePreview)` +const PlaygroundPreview = styled(({ className }) => ( + +))` padding: 0.5rem; min-height: 100%; - background: ${(props) => ( - props.previewBackgroundColor || '#fff' - )}; + background: ${p => p.previewBackgroundColor || '#fff'}; `; const PlaygroundEditor = styled(LiveEditor)` @@ -86,48 +86,63 @@ const PlaygroundError = styled(LiveError)` padding: 0.5rem; `; -const ComponentPlayground = ({ - code, - previewBackgroundColor, - scope = {}, - theme = 'dark' -}) => { - const useDarkTheme = theme === 'dark'; - - if (useDarkTheme) { - require('../themes/default/prism.dark.css'); - } else { - require('../themes/default/prism.light.css'); +class ComponentPlayground extends Component { + onKeyUp = evt => { + evt.stopPropagation(); + }; + + onKeyDown = evt => { + evt.stopPropagation(); + }; + + render() { + const { + code, + previewBackgroundColor, + scope = {}, + theme = 'dark' + } = this.props; + + const useDarkTheme = theme === 'dark'; + + if (useDarkTheme) { + require('../themes/default/prism.dark.css'); + } else { + require('../themes/default/prism.light.css'); + } + + return ( + + + Live Preview + Source Code + + + + + + + + + + + + + + ); } - - return ( - - - Live Preview - Source Code - - - - - - - - - - - - - - ); -}; +} ComponentPlayground.propTypes = { code: PropTypes.string,