import { Head } from 'mdx-deck'; export { default as theme } from './theme'; import { LiveCode } from 'mdx-deck-live-code';
<title>mdx-deck-live-code demo</title>mdx-deck-live-code Demonstration 🤯
Live code JSX and Javascript with previews, directly in your slides
<LiveCode title="Customization" code={`
{\`\`}
<LiveCode code={`
mdx-deck
theme:
{\`export default {
...theme,
liveCode: {
container: {
// container styles
},
editor: {
// editor styles
},
preview: {
// preview styles
},
error: {
// error styles
}
}
};\`}
<LiveCode
title={Smart handling of focus and arrow keys
}
code={`
While in the editor, use either one of the key combos
-
ESC
-
CTRL + M
(Windows and Linux) -
CTRL + SHIFT + M
(Mac)
<LiveCode
title="It even does React Functional Components, thanks to react-live"
code={() => { const componentType = "Functional Component"; return (<p>Hi, I'm a {componentType}!</p>) }
}
editorProps={{ style: { fontSize: '0.5em', background: '#001628' } }}
/>
<LiveCode
title="... and classes"
code={class MyComp extends React.Component { constructor(){ this.state = { value: 'class' }; } render() { return ( <div> <p> This is a {this.state.value} component! </p> <input onChange={ (e) => this.setState({value: e.target.value}) } value={this.state.value} /> </div> ); } }
}
size="large"
editorProps={{ style: { fontSize: '0.5em', background: '#001628' } }}
/>
<LiveCode
title="In fact, it does anything react-live does!"
code={const sayWhaaat = 'Hello'; const toWhooo = 'world!'; const GreetDaPeeps = () => ( <p> {sayWhaaat} {toWhooo} </p> ); render(GreetDaPeeps);
}
providerProps={{ noInline: true }}
editorProps={{ style: { fontSize: '0.5em', background: '#001628' } }}
/>
<LiveCode code={require('!raw-loader!./external-file.js')} size="large" previewProps={{ style: { fontSize: '0.8em' } }} editorProps={{ style: { fontSize: '0.5em', background: '#001628' } }} />
See more at the mdx-deck-live-code repository
By @DrReinhold