React Display Window
React Display Window is a simple tool to write documentation for when having a full guide is overkill. React Display Window is therefore best suited for one component libraries or libraries where all of the components are related.
It's also very useful during the development stage of these components libraries because it allows you to see the code working and running like in a real usage environment.
React Display Window
React Display Window is a simple tool to write documentation for when having a full guide is overkill. React Display Window is therefore best suited for one component libraries or libraries where all of the components are related.
It's also very useful during the development stage of these components libraries because it allows you to see the code working and running like in a real usage environment.
Installation
Install it as any other dev dependency in your repo:
Usage
First we create an .mdx
file which would contain the documentation of the project. You can use React and markdown inside this file.
Next, we just have to run React Display Window and point it to our file:
And that's it. You can now go to the url displayed in your console and have a look at your newly created display window for your component.
Once you're happy with your documentation, you can run:
And this will build your documentation and make it available in the folder specified. After, you can deploy it using github pages or any other static provider.
Example
An example repo can be found at Drawbotics/button
Components
TOC
A component that will render all the headers inside the file as a table of contents with links to specific sections.
PlayGround
A component that will render children
and will also display the code used.
PropsTable
A component that will render a table with all the propTypes
the passed component accepts.
Knobs
Similar to playground in that it renders it's children
but instead of showing the code used, it will display some controls to manipulate in real time the props that component accepts. It also takes a defaults
props where default values for the props can be specified.
Common Patterns
Add a custom title and dependencies
Since we can use React inside our doc file, adding a custom title or dependencies is as simple as installing react-helmet
and using it at the top of our docs: