2018-07-28 21:21:36 +03:00
# mdx-deck
2018-07-29 23:06:55 +03:00
![](https://s3.amazonaws.com/jxnblk/mdx-deck.gif)
2018-08-05 18:33:04 +03:00
[MDX][]-based presentation decks
2018-07-29 19:11:24 +03:00
2018-07-30 02:08:19 +03:00
[![Build Status][badge]][travis]
2018-07-30 02:09:31 +03:00
[![Version][version-badge]][npm]
2018-07-31 02:16:39 +03:00
[![Downloads][downloads-badge]][npm]
2018-07-30 02:08:19 +03:00
[badge]: https://img.shields.io/travis/jxnblk/mdx-deck.svg?style=flat-square
[travis]: https://travis-ci.org/jxnblk/mdx-deck
2018-07-30 02:09:31 +03:00
[version-badge]: https://img.shields.io/npm/v/mdx-deck.svg?style=flat-square
2018-07-30 02:08:19 +03:00
[downloads-badge]: https://img.shields.io/npm/dw/mdx-deck.svg?style=flat-square
[npm]: https://npmjs.com/package/mdx-deck
2018-07-30 02:09:55 +03:00
```sh
npm i -D mdx-deck
```
2018-07-29 21:19:37 +03:00
- :memo: Write presentations in markdown
2018-08-05 21:09:16 +03:00
- :atom_symbol: Import and use [React components ](#imports )
- :nail_care: Customizable [themes ](#theming ) and components
2018-07-29 21:17:53 +03:00
- :zero: Zero-config CLI
2018-08-03 22:55:34 +03:00
- :tipping_hand_woman: [Presenter mode ](#presenter-mode )
- :notebook: [Speaker notes ](#speaker-notes )
2018-07-29 21:17:53 +03:00
2018-07-29 23:38:32 +03:00
[View demo ](https://jxnblk.com/mdx-deck )
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 21:38:37 +03:00
Add a run script to your `package.json` with the mdx-deck CLI
pointing to the `.mdx` file to start the dev server:
```json
"scripts": {
"start": "mdx-deck deck.mdx"
}
```
Start the dev server:
2018-07-29 19:21:37 +03:00
2018-07-28 21:21:36 +03:00
```sh
2018-07-29 21:38:37 +03:00
npm start
2018-07-28 21:21:36 +03:00
```
2018-08-29 01:42:29 +03:00
## Videos & Articles
2018-07-31 01:30:57 +03:00
2018-08-29 01:42:29 +03:00
- [Egghead Tutorial][egghead] by [Andrew Del Prete ](https://github.com/andrewdelprete ).
- [mdx-deck: slide decks powered by markdown and react][kcd-medium] by [Kent C. Dodds][]
- [Make Fast & Beautiful Presentations with MDX-Deck][hw-video] by [Harry Wolff][] ([Demo][hw-demo])
- [What is MDX][kcd-video] by [Kent C. Dodds][]
2018-07-31 01:30:57 +03:00
[egghead]: https://egghead.io/lessons/react-build-a-slide-deck-with-mdx-deck-using-markdown-react
2018-09-03 22:48:08 +03:00
[Kent C. Dodds]: https://mobile.twitter.com/kentcdodds
2018-08-29 01:42:29 +03:00
[kcd-video]: http://youtu.be/d2sQiI5NFAM?a
[kcd-medium]: https://blog.kentcdodds.com/mdx-deck-slide-decks-powered-by-markdown-and-react-bfc6d6af20da
[hw-video]: https://www.youtube.com/watch?v=LvP2EqCiQMg& feature=youtu.be
[hw-demo]: https://github.com/hswolff/mdx-deck-demo
2018-09-03 22:48:08 +03:00
[Harry Wolff]: https://mobile.twitter.com/hswolff
2018-07-31 01:30:57 +03:00
2018-08-25 23:50:49 +03:00
## Quick Start
To create a new presentation with zero-configuration, run the following command to generate a presentation deck in a new folder:
```sh
npm init deck my-presentation-name
```
2018-07-31 01:30:57 +03:00
2018-08-05 21:43:36 +03:00
## Using MDX
2018-07-29 02:28:36 +03:00
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 >
```
2018-09-03 22:48:08 +03:00
Read more about MDX syntax in the [MDX Docs][MDX].
2018-08-05 21:43:36 +03:00
## Theming
2018-07-29 02:28:36 +03:00
2018-08-05 18:33:04 +03:00
mdx-deck uses [styled-components][] for styling, making practically any part of the presentation themeable.
2018-07-29 19:37:09 +03:00
### Built-in Themes
2018-08-05 18:38:21 +03:00
< div >
< img src = 'docs/images/future.png' width = '256' / >
< img src = 'docs/images/comic.png' width = '256' / >
< img src = 'docs/images/yellow.png' width = '256' / >
< / div >
2018-08-05 18:37:43 +03:00
2018-07-29 20:18:00 +03:00
mdx-deck includes several built-in themes to change the look and feel of the presentation.
2018-07-31 02:00:45 +03:00
Export `theme` from your MDX file to enable a theme.
2018-07-29 20:18:00 +03:00
```mdx
2018-07-30 08:17:31 +03:00
export { dark as theme } from 'mdx-deck/themes'
2018-07-29 20:18:00 +03:00
# Dark Theme
```
2018-08-05 20:11:25 +03:00
MDX uses [exports ](https://github.com/mdx-js/mdx#exports ) as a way for files to communicate with their parent components.
2018-08-05 17:14:46 +03:00
For a list of available themes see the [Themes Docs ](docs/themes.md ).
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
```
2018-08-05 18:27:17 +03:00
The theme should be an object with fields for fonts, colors, and CSS for individual components.
It's recommended that all custom themes extend the default theme as a base.
2018-07-29 02:28:36 +03:00
```js
2018-08-05 20:11:25 +03:00
// example theme.js
2018-08-14 08:40:24 +03:00
import theme from 'mdx-deck/themes'
2018-08-05 00:29:38 +03:00
export default {
2018-08-05 18:27:17 +03:00
// extends the default theme
...theme,
// add a custom font
font: 'Roboto, sans-serif',
// custom colors
colors: {
text: '#f0f',
background: 'black',
2018-09-03 22:48:08 +03:00
link: '#0ff',
2018-08-05 00:29:38 +03:00
}
}
```
2018-08-05 18:27:17 +03:00
Read more about theming in the [Theming docs ](docs/theming.md )
2018-07-29 02:28:36 +03:00
2018-08-01 02:27:52 +03:00
### Components
2018-08-05 18:27:17 +03:00
mdx-deck includes built-in components to help with creating presentations, including a full screen Image component, the Appear component that allows stepping through parts of a single slide, and the Notes component for adding speaker notes.
2018-08-04 00:30:39 +03:00
2018-08-05 20:11:25 +03:00
Read more in the [components docs ](docs/components.md ).
2018-08-04 00:30:39 +03:00
2018-08-29 01:42:29 +03:00
### Libraries
These third-party libraries are great for use with mdx-deck.
- [CodeSurfer][]: React component for scrolling, zooming and highlighting code.
2018-09-03 22:43:44 +03:00
[codesurfer]: https://github.com/pomber/code-surfer
2018-08-29 01:42:29 +03:00
2018-07-29 02:28:36 +03:00
### Layouts
Each slide can include a custom layout around its content.
2018-07-31 01:54:18 +03:00
This can be used as a substitute for slide templates found in other presentation apps and libraries.
```js
// example Layout.js
import React from 'react'
2018-09-03 22:43:44 +03:00
export default ({ children }) => (
2018-07-31 01:54:18 +03:00
< div
style={{
width: '100vw',
height: '100vw',
backgroundColor: 'tomato'
}}>
{children}
< / div >
2018-09-03 22:43:44 +03:00
)
2018-07-31 01:54:18 +03:00
```
2018-07-29 02:28:36 +03:00
```mdx
import Layout from './Layout'
# No Layout
---
export default Layout
# Custom Layout
```
2018-07-31 01:54:18 +03:00
The layout component will wrap the MDX elements within that slide,
which means you can use a nested ThemeProvider or target elements with CSS-in-JS.
2018-08-05 20:11:25 +03:00
### Built-in Layouts
mdx-deck includes some built-in layouts for inverting theme colors and changing the layout of a slide. Read more about [built-in layouts ](docs/components.md#layouts ).
2018-08-04 00:36:51 +03:00
2018-08-03 03:32:56 +03:00
## Presenter Mode
mdx-deck includes a built-in presenter mode, with a preview of the next slide and a timer.
2018-08-05 18:39:34 +03:00
![presenter mode screenshot ](docs/images/presenter-mode.png )
2018-08-04 00:43:01 +03:00
2018-08-03 03:32:56 +03:00
To use presenter mode:
2018-08-03 03:34:11 +03:00
- Open two windows in the same browser, with the same URL on two different screens. (this should work in both development and exported presentations)
2018-08-04 18:14:36 +03:00
- In your window press the `Option + P` (`Alt + P`) key to enter presenter mode.
2018-08-03 03:32:56 +03:00
- Display the other window on the screen for the audience to see.
- Control the presentation from your window by using the left and right arrow keys; the other window should stay in sync
2018-08-03 05:15:33 +03:00
### Speaker Notes
Notes that only show in presenter mode can be added to any slide.
Speaker notes can be added in one of the following two ways:
**Markdown:** Use the `notes` language attribute in a fenced code block to add speaker notes.
````mdx
# Slide Content
```notes
These are only visible in presenter mode
```
````
**Notes Component:** Use the `Notes` component to create more complex speaker notes.
2018-09-03 22:43:44 +03:00
```mdx
2018-08-03 05:15:33 +03:00
import { Notes } from 'mdx-deck'
# Slide Content
< Notes >
Only visible in presenter mode
< / Notes >
2018-09-03 22:43:44 +03:00
```
2018-08-03 05:15:33 +03:00
2018-08-05 21:35:40 +03:00
## Overview Mode
2018-08-05 21:39:54 +03:00
![Overview Mode ](docs/images/overview-mode.png )
2018-08-05 21:38:42 +03:00
2018-08-05 21:35:40 +03:00
When editing a slide deck, toggle overview mode with `Option + O` .
This shows a list of all slides on the left and a preview of the current slide on the right.
## Keyboard Shortcuts
2018-08-04 18:14:36 +03:00
2018-09-03 22:43:44 +03:00
| Key | Description |
| ----------- | ------------------------------------------------------------------- |
| Left Arrow | Go to previous slide (or step in [Appear][]) |
| Right Arrow | Go to next slide (or step in [Appear][]) |
| Space | Go to next slide (or step in [Appear][]) |
| Up Arrow | Hide current step in [Appear][] component without navigating slides |
| Down Arrow | Show next step in [Appear][] component without navigating slides |
| Option + P | Toggle [Presenter Mode ](#presenter-mode ) |
| Option + O | Toggle [Overview Mode ](#overview-mode ) |
| Option + G | Toggle grid view mode |
2018-08-04 18:14:36 +03:00
2018-09-03 22:48:08 +03:00
[Appear]: docs/components.md#appear
2018-08-29 01:08:04 +03:00
2018-07-29 02:28:36 +03:00
## Exporting
2018-07-31 01:54:18 +03:00
Add a `build` script to your `package.json` to export a presentation as HTML with a JS bundle.
2018-07-29 19:37:09 +03:00
2018-07-31 01:54:18 +03:00
```json
"scripts": {
"build": "mdx-deck build deck.mdx"
}
2018-07-29 19:37:09 +03:00
```
2018-08-15 03:59:58 +03:00
See more exporting options in the [Exporting Documentation ](docs/exporting.md )
2018-08-01 02:12:55 +03:00
2018-07-30 03:31:30 +03:00
## CLI Options
```
-p --port Dev server port
--no-open Prevent from opening in default browser
-d --out-dir Output directory for exporting
2018-08-25 17:43:14 +03:00
--no-html Disable static HTML rendering
2018-08-15 04:09:33 +03:00
--out-file Filename for screenshot or PDF export
--width Width in pixels
--height Height in pixels
2018-08-27 01:12:29 +03:00
--webpack Path to webpack config file
2018-07-30 03:31:30 +03:00
```
2018-08-05 18:27:17 +03:00
## Docs
2018-07-29 19:37:09 +03:00
2018-08-05 18:27:17 +03:00
- [Theming ](docs/theming.md )
2018-08-05 19:49:27 +03:00
- [Built-in Themes ](docs/themes.md )
2018-08-05 20:11:25 +03:00
- [Layouts ](docs/layouts.md )
2018-08-05 18:27:17 +03:00
- [Components ](docs/components.md )
2018-08-15 03:59:58 +03:00
- [Exporting ](docs/exporting.md )
2018-08-05 20:03:25 +03:00
- [Advanced Usage ](docs/advanced.md )
2018-08-05 18:27:17 +03:00
- [React API ](docs/react.md )
2018-07-29 19:37:09 +03:00
2018-09-02 01:24:11 +03:00
## Examples
- [Design Systems & React][design-systems-react] by [Diana Mount ](https://mobile.twitter.com/broccolini )
- [Bringing Brazil to the Cloud, Now][brazil-now] by [Guillermo Rauch ](https://mobile.twitter.com/rauchg/ )
- [Simplify React][simplify-react] by [Kent C. Dodds ](https://mobile.twitter.com/kentcdodds )
- [I Got 99 Problems but GraphQL Ain't One][99-problems] by [Sara Vieira ](https://mobile.twitter.com/NikkitaFTW )
2018-09-03 22:43:44 +03:00
- [Stop de #divFest ][stop-div-fest] by [Sara Vieira ](https://mobile.twitter.com/NikkitaFTW )
2018-09-02 01:24:11 +03:00
2018-07-29 01:49:02 +03:00
---
2018-07-29 20:20:57 +03:00
### Related
- [MDX][]
2018-09-02 01:24:11 +03:00
- [mdx-go][]
2018-07-29 23:26:54 +03:00
- [ok-mdx][]
- [Compositor x0][]
2018-07-29 20:20:57 +03:00
- [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-09-03 22:48:08 +03:00
[MDX]: https://github.com/mdx-js/mdx
2018-07-29 23:26:54 +03:00
[ok-mdx]: https://github.com/jxnblk/ok-mdx
2018-09-03 22:48:08 +03:00
[Compositor x0]: https://github.com/c8r/x0
2018-07-29 02:28:36 +03:00
[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-09-03 22:48:08 +03:00
[Spectacle]: https://github.com/FormidableLabs/spectacle
2018-09-02 01:24:11 +03:00
[mdx-go]: https://github.com/jxnblk/mdx-go
2018-08-29 01:42:29 +03:00
<!-- examples -->
2018-09-03 22:43:44 +03:00
2018-09-02 01:24:11 +03:00
[design-systems-react]: https://github-ds.now.sh/#0
2018-08-29 01:42:29 +03:00
[brazil-now]: https://braziljs.now.sh
2018-09-02 01:24:11 +03:00
[simplify-react]: https://simply-react.netlify.com/#0
[99-problems]: https://99-problems-graphql-aint-one.now.sh/#0
2018-09-03 22:43:44 +03:00
[stop-div-fest]: https://stop-div-fest.now.sh/