1
1
mirror of https://github.com/jxnblk/mdx-deck.git synced 2024-11-25 15:50:39 +03:00

Merge pull request #296 from Taar/advanced-docs

Update Advanced Docs
This commit is contained in:
Brent Jackson 2019-06-19 14:15:40 -04:00 committed by GitHub
commit df8ee77ad4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,8 +20,9 @@ at the [default set of components](../packages/components/src/mdx-components.js)
## Custom Provider component
A custom Provider component can be added to the theme to wrap the entire application.
This is useful for adding custom context providers in React or adding persistent UI elements to the entire deck.
A custom Provider component is useful for adding custom context providers in React or adding persistent UI elements to the entire deck.
To define a custom Provider component, you'll need to import it into your custom theme and set it using the key `Provider` like shown below:
```js
// example theme.js
@ -44,6 +45,37 @@ which can be used to show custom page numbers or add other elements to the UI.
- `step`: (number) the current visible step in an Appear or Step component
- Each slide includes a `meta` object with a `notes` field when the Notes component is used within a slide
#### Example
The example below will display the current slide out of the total amount of slides.
```js
// Example Provider.js
import React from 'react'
function AtTheBottomCenter ({ children }) {
const css = {
position: 'absolute',
left: 0,
right: 0,
bottom: 0,
color: #ffffff;
textAlign: 'center',
}
return <div css={css}>
{children}
</div>
}
export function Provider ({ children, ...props }) {
return <>
{children}
<AtTheBottomCenter>{props.index}/{props.slides.length}</AtTheBottomCenter>
</>
}
```
## Combining multiple mdx files
Unlike the official `@mdx-js/loader`,