forked from spotify/reactochart
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add prettier & eslint code style rules * Remove legacy code and evaluate any todos * Only send valid XYPlot props to children. Resolves spotify#22 * Check against master list of scaleTypes * Implement invertX and invertY scale * Alphabetically sort props displayed on docs * Update documentation for x and y axis labels and titles * Clean up code and todos * includeXZero and includeYZero props + test
- Loading branch information
Kris Salvador
authored
May 1, 2018
1 parent
f7f6e5e
commit 9dfd64b
Showing
21 changed files
with
853 additions
and
528 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,63 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import _ from 'lodash'; | ||
import remark from 'remark'; | ||
import remarkReact from 'remark-react'; | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
import _ from "lodash"; | ||
import remark from "remark"; | ||
import remarkReact from "remark-react"; | ||
|
||
export default class ComponentDocs extends React.Component { | ||
render() { | ||
const {name, propDocs, children} = this.props; | ||
const { name, propDocs, children } = this.props; | ||
const sortedProps = _(_.get(propDocs, "props")) | ||
.toPairs() | ||
.sortBy(0) | ||
.fromPairs() | ||
.value(); | ||
|
||
return <div className="container-fluid component-docs"> | ||
<div className="row"> | ||
<h2>{name}</h2> | ||
</div> | ||
|
||
{propDocs.description ? | ||
return ( | ||
<div className="container-fluid component-docs"> | ||
<div className="row"> | ||
<p className="component-description"> | ||
{renderMarkdown(propDocs.description)} | ||
</p> | ||
<h2>{name}</h2> | ||
</div> | ||
: null | ||
} | ||
|
||
<div className="row prop-docs"> | ||
<h4>{name} props:</h4> | ||
{_.map(_.get(propDocs, 'props'), (propInfo, propKey) => { | ||
return <div key={propKey} className="prop-doc"> | ||
<strong>{propKey}</strong>: {_.get(propInfo, 'type.name', 'unknown')} | ||
{propInfo.description ? <br/> : null} | ||
{propInfo.description ? | ||
<span className="prop-description"> | ||
{renderMarkdown(propInfo.description)} | ||
</span> | ||
: null} | ||
{propDocs.description ? ( | ||
<div className="row"> | ||
<p className="component-description"> | ||
{renderMarkdown(propDocs.description)} | ||
</p> | ||
</div> | ||
) : null} | ||
|
||
{propInfo.defaultValue ? | ||
<div className="prop-default"> | ||
default value: <code>{propInfo.defaultValue.value}</code> | ||
<div className="row prop-docs"> | ||
<h4>{name} props:</h4> | ||
{_.map(sortedProps, (propInfo, propKey) => { | ||
return ( | ||
<div key={propKey} className="prop-doc"> | ||
<strong>{propKey}</strong>:{" "} | ||
{_.get(propInfo, "type.name", "unknown")} | ||
{propInfo.description ? <br /> : null} | ||
{propInfo.description ? ( | ||
<span className="prop-description"> | ||
{renderMarkdown(propInfo.description)} | ||
</span> | ||
) : null} | ||
{propInfo.defaultValue ? ( | ||
<div className="prop-default"> | ||
default value: <code>{propInfo.defaultValue.value}</code> | ||
</div> | ||
) : null} | ||
</div> | ||
: null} | ||
</div> | ||
})} | ||
</div> | ||
); | ||
})} | ||
</div> | ||
|
||
{children} | ||
</div> | ||
{children} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
function renderMarkdown(markdownText = '') { | ||
function renderMarkdown(markdownText = "") { | ||
return remark() | ||
.use(remarkReact) | ||
.processSync(markdownText) | ||
.contents; | ||
} | ||
.processSync(markdownText).contents; | ||
} |
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
Oops, something went wrong.