2018-07-28 21:21:36 +03:00
|
|
|
|
|
|
|
# mdx-deck
|
|
|
|
|
2018-07-29 19:17:00 +03:00
|
|
|
[MDX][]-based presention decks
|
2018-07-28 21:21:36 +03:00
|
|
|
|
2018-07-29 19:11:24 +03:00
|
|
|
**Beta**
|
|
|
|
|
2018-07-28 21:21:36 +03:00
|
|
|
```sh
|
|
|
|
npm i mdx-deck
|
|
|
|
```
|
|
|
|
|
2018-07-29 21:17:53 +03:00
|
|
|
- :spiral_note_pad: Write presentations in markdown
|
|
|
|
- :atom_symbol: Import and use React components
|
|
|
|
- :nail_care: Customizable themes and components
|
|
|
|
- :zero: Zero-config CLI
|
|
|
|
|
2018-07-29 19:37:09 +03:00
|
|
|
## Getting Started
|
|
|
|
|
2018-07-29 19:21:37 +03:00
|
|
|
Create an [MDX][] file and separate each slide with `---`.
|
|
|
|
|
2018-07-29 02:28:36 +03:00
|
|
|
````mdx
|
2018-07-28 21:21:36 +03:00
|
|
|
# This is the title of my deck
|
|
|
|
---
|
|
|
|
# About Me
|
|
|
|
---
|
|
|
|
```jsx
|
|
|
|
<CodeSnippet />
|
|
|
|
```
|
|
|
|
---
|
2018-07-29 01:49:02 +03:00
|
|
|
import Demo from './components/Demo'
|
2018-07-28 21:21:36 +03:00
|
|
|
|
|
|
|
<Demo />
|
|
|
|
---
|
|
|
|
# The end
|
|
|
|
````
|
|
|
|
|
2018-07-29 19:21:37 +03:00
|
|
|
Run the CLI pointing to the `.mdx` file to start the dev server:
|
|
|
|
|
2018-07-28 21:21:36 +03:00
|
|
|
```sh
|
|
|
|
mdx-deck deck.mdx
|
|
|
|
```
|
|
|
|
|
2018-07-29 02:28:36 +03:00
|
|
|
## Usage
|
|
|
|
|
|
|
|
MDX can use Markdown syntax and render React components with JSX.
|
|
|
|
|
|
|
|
### Imports
|
|
|
|
|
|
|
|
To import components, use ES import syntax separated with empty lines from any markdown or JSX syntax.
|
|
|
|
|
|
|
|
```mdx
|
|
|
|
import { Box } from 'grid-styled'
|
|
|
|
|
|
|
|
<Box color='tomato'>
|
|
|
|
Hello
|
|
|
|
</Box>
|
|
|
|
```
|
|
|
|
|
|
|
|
### Theming
|
|
|
|
|
2018-07-29 19:37:09 +03:00
|
|
|
mdx-deck uses [styled-components][] for styling.
|
|
|
|
|
|
|
|
### Built-in Themes
|
|
|
|
|
2018-07-29 20:18:00 +03:00
|
|
|
mdx-deck includes several built-in themes to change the look and feel of the presentation.
|
|
|
|
|
|
|
|
```mdx
|
|
|
|
export { dark as theme } from 'ok-cli/themes'
|
|
|
|
|
|
|
|
# Dark Theme
|
|
|
|
```
|
|
|
|
|
|
|
|
The following themes are available:
|
|
|
|
|
|
|
|
- `theme`: default theme with white background
|
|
|
|
- `dark`: black background dark theme
|
|
|
|
- `future`: dark theme with Avenir Next
|
2018-07-29 20:19:11 +03:00
|
|
|
- `condensed`: dark theme with Roboto Condensed
|
2018-07-29 19:37:09 +03:00
|
|
|
|
|
|
|
### Custom Themes
|
|
|
|
|
2018-07-29 02:28:36 +03:00
|
|
|
A custom theme can be provided by exporting `theme` from the MDX file.
|
|
|
|
|
|
|
|
```mdx
|
|
|
|
export { default as theme } from './theme'
|
|
|
|
|
|
|
|
# Hello
|
|
|
|
```
|
|
|
|
|
|
|
|
The theme should be an object based on [styled-system][]'s theme schema.
|
|
|
|
|
|
|
|
```js
|
|
|
|
// example theme.js
|
|
|
|
export default {
|
2018-07-29 19:37:09 +03:00
|
|
|
font: 'Georgia',
|
|
|
|
monospace: 'Menlo, monospace',
|
2018-07-29 02:28:36 +03:00
|
|
|
fontSizes: [
|
|
|
|
16, 24, 32, 48, 64, 96, 128
|
|
|
|
],
|
|
|
|
colors: {
|
2018-07-29 19:37:09 +03:00
|
|
|
text: '#000',
|
|
|
|
background: 'transparent',
|
|
|
|
link: '#07c',
|
|
|
|
heading: '#000',
|
|
|
|
quote: '#000',
|
|
|
|
pre: '#f0f',
|
|
|
|
preBackground: '#333',
|
|
|
|
code: '#f0f',
|
|
|
|
codeBackground: 'transparent',
|
2018-07-29 02:28:36 +03:00
|
|
|
},
|
|
|
|
css: {
|
|
|
|
// apply any styles to the root element
|
2018-07-29 19:37:09 +03:00
|
|
|
},
|
|
|
|
// custom CSS can be provided to any of the default components:
|
|
|
|
heading: {
|
|
|
|
fontWeight: 400
|
|
|
|
},
|
|
|
|
link: {
|
|
|
|
textDecoration: 'none',
|
|
|
|
'&:hover': {
|
|
|
|
textDecoration: 'underline',
|
|
|
|
}
|
2018-07-29 02:28:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### Custom Components
|
|
|
|
|
2018-07-29 20:18:00 +03:00
|
|
|
mdx-deck includes default components for MDX, but to provide custom components to the [MDXProvider][], export a `components` object.
|
2018-07-29 02:28:36 +03:00
|
|
|
|
|
|
|
```mdx
|
|
|
|
export { default as components } from './components'
|
|
|
|
|
|
|
|
# Custom Components
|
|
|
|
```
|
|
|
|
|
|
|
|
### Layouts
|
|
|
|
|
|
|
|
Each slide can include a custom layout around its content.
|
|
|
|
|
|
|
|
```mdx
|
|
|
|
import Layout from './Layout'
|
|
|
|
|
|
|
|
# No Layout
|
|
|
|
|
|
|
|
---
|
|
|
|
export default Layout
|
|
|
|
|
|
|
|
# Custom Layout
|
|
|
|
```
|
|
|
|
|
2018-07-29 19:37:09 +03:00
|
|
|
### Custom Provider
|
|
|
|
|
|
|
|
A custom Provider component can be exported to wrap the entire application.
|
|
|
|
This is useful for adding custom context providers, such as a ThemeProvider.
|
|
|
|
|
|
|
|
```mdx
|
|
|
|
export { default as Provider } from './Provider'
|
|
|
|
|
|
|
|
# Hello
|
|
|
|
```
|
|
|
|
|
2018-07-29 02:28:36 +03:00
|
|
|
## Exporting
|
|
|
|
|
2018-07-29 19:37:09 +03:00
|
|
|
Run the `build` command to export a presentation as HTML with a JS bundle.
|
|
|
|
|
|
|
|
```sh
|
|
|
|
mdx-deck build deck.mdx
|
|
|
|
```
|
|
|
|
|
|
|
|
## React API
|
|
|
|
|
2018-07-29 20:18:00 +03:00
|
|
|
mdx-deck components can also be used in any React application, such as [create-react-app][] or [next.js][].
|
2018-07-29 19:37:09 +03:00
|
|
|
|
|
|
|
### Webpack Loader
|
|
|
|
|
|
|
|
mdx-deck uses a custom webpack loader to split MDX files into an array of slides. Use this loader to import mdx files in a webpack application.
|
|
|
|
|
|
|
|
```js
|
|
|
|
// example webpack.config.js
|
|
|
|
module.exports = {
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
test: /\.mdx$/,
|
|
|
|
ignore: /node_modules/,
|
|
|
|
use: [
|
|
|
|
'babel-loader',
|
|
|
|
'mdx-deck/loader'
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
### SlideDeck Component
|
|
|
|
|
|
|
|
```js
|
|
|
|
import React from 'react'
|
|
|
|
import { SlideDeck } from 'mdx-deck'
|
|
|
|
import slides from './deck.mdx'
|
|
|
|
import theme from './theme'
|
|
|
|
import components from './components'
|
|
|
|
|
|
|
|
export default () =>
|
|
|
|
<SlideDeck
|
|
|
|
slides={slides}
|
|
|
|
theme={theme}
|
|
|
|
components={components}
|
|
|
|
width='100vw'
|
|
|
|
height='100vh'
|
|
|
|
/>
|
|
|
|
```
|
|
|
|
|
|
|
|
View the source for other components available for use.
|
2018-07-29 02:28:36 +03:00
|
|
|
|
2018-07-29 01:49:02 +03:00
|
|
|
---
|
|
|
|
|
2018-07-29 20:20:57 +03:00
|
|
|
### Related
|
|
|
|
|
|
|
|
- [MDX][]
|
|
|
|
- [styled-components][]
|
|
|
|
- [styled-system][]
|
|
|
|
- [Spectacle][]
|
|
|
|
|
2018-07-29 20:21:24 +03:00
|
|
|
[MIT License](LICENSE.md)
|
2018-07-29 01:49:02 +03:00
|
|
|
|
2018-07-28 21:21:36 +03:00
|
|
|
[MDX]: https://github.com/mdx-js/mdx
|
2018-07-29 02:28:36 +03:00
|
|
|
[MDXProvider]: https://github.com/mdx-js/mdx#mdxprovider
|
|
|
|
[styled-system]: https://github.com/jxnblk/styled-system
|
2018-07-29 19:11:24 +03:00
|
|
|
[styled-components]: https://github.com/styled-components/styled-components
|
2018-07-29 19:37:09 +03:00
|
|
|
[create-react-app]: https://github.com/facebook/create-react-app
|
|
|
|
[next.js]: https://github.com/zeit/next.js/
|
2018-07-29 20:20:57 +03:00
|
|
|
[Spectacle]: https://github.com/FormidableLabs/spectacle
|