Created
March 4, 2015 10:10
-
-
Save minipai/e815775079d294c14251 to your computer and use it in GitHub Desktop.
Use ReactJS to create style guide
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var React = require('react'); | |
var beautify = require('js-beautify').html | |
var StyleBlock = React.createClass({ | |
render: function () { | |
var Element = this.props.element | |
return ( | |
<div> | |
<div className="style-name"> | |
<h3> | |
{this.props.name} | |
{ | |
this.props.filepath ? | |
<small className="">file path: {this.props.filepath}</small> : '' | |
} | |
</h3> | |
{this.props.children} | |
</div> | |
<div className="style-block"> | |
<div className="style-example"> | |
<Element /> | |
</div> | |
<div className="style-code"> | |
<pre className="language-markup"> | |
<code className="language-markup"> | |
{ beautify( React.renderToStaticMarkup(<Element />), { indent_size: 2, unformatted: ['button'] }) } | |
</code> | |
</pre> | |
</div> | |
</div> | |
</div> | |
); | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment