Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/imweb/redemo

react demo component
https://github.com/imweb/redemo

component demo documentation react

Last synced: 28 days ago
JSON representation

react demo component

Awesome Lists containing this project

README

        

[![Npm Package](https://img.shields.io/npm/v/redemo.svg?style=flat-square)](https://www.npmjs.com/package/redemo)
[![Npm Downloads](http://img.shields.io/npm/dm/redemo.svg?style=flat-square)](https://www.npmjs.com/package/redemo)
[![Dependency Status](https://david-dm.org/gwuhaolin/redemo.svg?style=flat-square)](https://npmjs.org/package/redemo)

[中文文档](https://github.com/gwuhaolin/blog/issues/1)

# redemo
When you write a react component, you may need tell others how to use it by write some demos.
Redemo is used to help write demo for react component in a easy way, is't pretty and simple to use.



redemo

## feature
- doc: write doc in markdown for this demo
- code: show source code for this demo
- propTypes: auto list react component `propTypes` document form comment in your component source instead of write by yourself

## install
use it from npm in webpack
```bash
npm i redemo
```

then install webpack dependencies
```html
npm i raw-loader react-docgen@next docgen-loader --save-dev
```

## example
Let's write a demo for a `Button` component

```js
import ReDemo from 'redemo';
import Button from './button';

// load propTypes by docgen-loader from button component source code
const docgen = require('!!docgen-loader!../button');

// load source code by raw-loader from button component source code
const code = require('!!raw-loader!../button');

// write doc for this demo in markdown
const doc = `
### react component used to demonstrate react component
#### structure
- in top section is demo instance to play
- circle button in right are toggle for **component propTypes** and **demo source code**
- propTypes table show all prop's info for this component
- in bottom is source code for this demo
`

demo component instance

```

## API
see `ReDemo`'s all props [here](https://imweb.github.io/redemo/)

## In practice
- [imuix](http://imweb.github.io/imuix/)