diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..862c918 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,10 @@ + +# The MIT License (MIT) +Copyright (c) 2018 Brent Jackson + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/README.md b/README.md index dedd454..5be4977 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ npm i mdx-deck ``` +## Getting Started + Create an [MDX][] file and separate each slide with `---`. ````mdx @@ -51,6 +53,14 @@ import { Box } from 'grid-styled' ### Theming +mdx-deck uses [styled-components][] for styling. + +### Built-in Themes + +TK + +### Custom Themes + A custom theme can be provided by exporting `theme` from the MDX file. ```mdx @@ -64,17 +74,34 @@ The theme should be an object based on [styled-system][]'s theme schema. ```js // example theme.js export default { - font: 'Menlo, monospace', + font: 'Georgia', + monospace: 'Menlo, monospace', fontSizes: [ 16, 24, 32, 48, 64, 96, 128 ], colors: { - text: '#f0f', - background: '#000', - link: '#0ff' + text: '#000', + background: 'transparent', + link: '#07c', + heading: '#000', + quote: '#000', + pre: '#f0f', + preBackground: '#333', + code: '#f0f', + codeBackground: 'transparent', }, css: { // apply any styles to the root element + }, + // custom CSS can be provided to any of the default components: + heading: { + fontWeight: 400 + }, + link: { + textDecoration: 'none', + '&:hover': { + textDecoration: 'underline', + } } } ``` @@ -104,9 +131,71 @@ export default Layout # Custom Layout ``` +### 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 +``` + ## Exporting -TK +Run the `build` command to export a presentation as HTML with a JS bundle. + +```sh +mdx-deck build deck.mdx +``` + +## React API + +mdx-deck components can be used in any React application, such as [create-react-app][] or [next.js][]. + +### 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 () => + +``` + +View the source for other components available for use. --- @@ -115,13 +204,12 @@ TK - [ ] exporting docs - [ ] components docs - [ ] Provider docs -- [x] Full Image component -- [x] Root provider -- [x] default styles -- [x] export build -- [x] URL hash + +[MIT License][LICENSE.md] [MDX]: https://github.com/mdx-js/mdx [MDXProvider]: https://github.com/mdx-js/mdx#mdxprovider [styled-system]: https://github.com/jxnblk/styled-system [styled-components]: https://github.com/styled-components/styled-components +[create-react-app]: https://github.com/facebook/create-react-app +[next.js]: https://github.com/zeit/next.js/ diff --git a/src/index.js b/src/index.js index f85e848..c6af8d1 100644 --- a/src/index.js +++ b/src/index.js @@ -34,15 +34,10 @@ const CarouselInner = styled.div([], { transform: `translateX(${-100 * props.index}%)` })) -export class Carousel extends React.Component { - render () { - return ( - - - - ) - } -} +export const Carousel = props => + + + export const Slide = styled.div([], { flex: 'none', @@ -122,7 +117,7 @@ export const Root = styled.div([], { height ) -export default class SlideDeck extends React.Component { +export class SlideDeck extends React.Component { static propTypes = { slides: PropTypes.array.isRequired, } @@ -210,3 +205,5 @@ export default class SlideDeck extends React.Component { ) } } + +export default SlideDeck diff --git a/src/theme.js b/src/theme.js index 89c0584..18c3fdc 100644 --- a/src/theme.js +++ b/src/theme.js @@ -6,7 +6,7 @@ export default { ], colors: { text: '#000', - background: '#fff', + background: 'transparent', link: '#07c', heading: '#000', quote: '#000',