├── .gitignore
├── .npmignore
├── README.md
├── demo
├── demo.js
├── index.html
└── vendor
│ └── prism.js
├── package.json
├── screenshot.png
├── scss
├── main.scss
└── vendor
│ └── _prism.scss
└── src
├── Styleguide.js
├── StyleguideDemo.js
├── examples
├── Blockquote.js
├── Button.js
└── Footer.js
└── test
└── StyleguideTest.js
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Compiled binary addons (http://nodejs.org/api/addons.html)
23 | build/Release
24 |
25 | # Dependency directory
26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git-
27 | node_modules
28 |
29 | dist/
30 |
31 | scss/main.css
32 | scss/main.css.map
33 | scss/.sass-cache/
34 |
35 | run.sh
36 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | /src
2 | *~
3 |
4 | run.sh
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | react-styleguide
2 | ----------------
3 | A React component that takes in other components and organizes them into an easy to use styleguide.
4 |
5 | Installation
6 | ------------
7 | ```
8 | $ npm install --save react-styleguide
9 | ```
10 |
11 | To view a working demo version,
12 |
13 | ```
14 | $ npm install
15 | $ npm run build
16 | ```
17 |
18 | And then open the `demo/index.html` file in your browser.
19 |
20 | Or visit the live demo at [http://jmfurlott.github.io/react-styleguide](http://jmfurlott.github.io/react-styleguide)
21 |
22 | Example Usage
23 | -------------
24 | Include the generated css file from `dist` if you want to use the styling that I've created in your project.
25 |
26 | Just create a new component containing the Styleguide component. Include all the components that you want in the styleguide and provide the information that you want in include in the props. The props that can be included for each are:
27 |
28 | - title
29 | - description
30 | - example (this is the code that will be displayed)
31 |
32 | Inside the `div`, include the code that should be rendered and displayed in the styleguide. This will probably be the same as the `example` prop.
33 |
34 |
35 | ```javascript
36 | var React = require('react');
37 | var Styleguide = require('react-styleguide');
38 |
39 | // If you would like to include Prism.js as the syntax highlighter
40 | var Prism from '../demo/vendor/prism.js';
41 |
42 | // Require the components that you want to include
43 | import Button from './examples/Button.js';
44 | import Blockquote from './examples/Blockquote.js';
45 |
46 | var Component = React.createClass({
47 | render: function() {
48 |
49 |
56 |
57 |
58 |
59 |
64 |
65 |
66 |
67 | ...
68 |
69 |
70 | }
71 | });
72 | ```
73 |
74 | Styleguide Options
75 | ------------------
76 | For the styleguide, the following options are available:
77 |
78 | - `codeClassName` - changes the `` class if you do not want to use Prism.js for highlighting otherwise defaults to `language-javascript`
79 | - `highlight` - a function that can be passed if you want highlight the code using a different function from Prism.js's function. Defaults to just the code example itself.
80 |
81 | Optional Includes
82 | -----------------
83 | You can have the styleguide come styling free if you desire, but it is also possible to have the included styles be used (they can be seen in the screenshots). Please look at the `demo/index.html` to see what else could be included.
84 |
85 | - Google web fonts
86 | - `main.css` located in the `dist` folder
87 | - `prism.js` located in the `demo` folder (can be included via Node.js or browser side)
88 |
89 | Any and all of these are optional but are recommended.
90 |
91 | Extending the Styles
92 | --------------------
93 | The styles of the styleguide follow a simple version of [SuitCSS](https://suitcss.github.io/), and follow a simple hierarchy. Please view the `scss/main.scss` for a look at how to style the page.
94 |
95 | Screenshots
96 | -----------
97 | 
98 |
99 | TODO
100 | ----
101 | - Better way of converting from example and example code to the styleguide (instead of including it twice, essentially)
102 | - Write tests for the component (framework is already set in place)
103 | - Make styled version responsive
104 |
105 | License
106 | -------
107 | MIT
108 |
--------------------------------------------------------------------------------
/demo/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/demo/vendor/prism.js:
--------------------------------------------------------------------------------
1 | /* http://prismjs.com/download.html?themes=prism-okaidia&languages=markup+css+clike+javascript */
2 | self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{};var Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(d instanceof a)){g.lastIndex=0;var m=g.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),O=[p,1];b&&O.push(b);var N=new a(l,u?t.tokenize(m,u):m,h);O.push(N),w&&O.push(w),Array.prototype.splice.apply(r,O)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("[object Array]"==Object.prototype.toString.call(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var s="";for(var o in i.attributes)s+=o+'="'+(i.attributes[o]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+s+">"+i.content+""+i.tag+">"},!self.document)return self.addEventListener?(self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code;self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),self.close()},!1),self.Prism):self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism);;
3 | Prism.languages.markup={comment://g,prolog:/<\?.+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+))?\s*)*\/?>/gi,inside:{tag:{pattern:/^<\/?[\w:-]+/i,inside:{punctuation:/^<\/?/,namespace:/^[\w-]+?:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi,inside:{punctuation:/=|>|"/g}},punctuation:/\/?>/g,"attr-name":{pattern:/[\w:-]+/g,inside:{namespace:/^[\w-]+?:/}}}},entity:/\?[\da-z]{1,8};/gi},Prism.hooks.add("wrap",function(t){"entity"===t.type&&(t.attributes.title=t.content.replace(/&/,"&"))});;
4 | Prism.languages.css={comment:/\/\*[\w\W]*?\*\//g,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*{))/gi,inside:{punctuation:/[;:]/g}},url:/url\((["']?).*?\1\)/gi,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/g,property:/(\b|\B)[\w-]+(?=\s*:)/gi,string:/("|')(\\?.)*?\1/g,important:/\B!important\b/gi,punctuation:/[\{\};:]/g,"function":/[-a-z0-9]+(?=\()/gi},Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/