diff --git a/.storybook/config.js b/.storybook/config.js index f86e966a7e01..b63aabdaa7ab 100644 --- a/.storybook/config.js +++ b/.storybook/config.js @@ -1,6 +1,5 @@ import { configure } from '@kadira/storybook'; configure(function () { - require('../styles.css'); require('../src/stories/Story'); }, module); diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js index b729b721602a..115532575ea6 100644 --- a/.storybook/webpack.config.js +++ b/.storybook/webpack.config.js @@ -15,6 +15,11 @@ const config = { loaders: ['style', 'raw'], include: path.resolve(__dirname, '../'), }, + { + test: /\.json?$/, + loaders: ['json'], + include: path.resolve(__dirname, '../'), + } ], }, }; diff --git a/package.json b/package.json index c8fabe08f435..ef44fe19ae4e 100644 --- a/package.json +++ b/package.json @@ -18,32 +18,33 @@ "publish-storybook": "bash .scripts/publish_storybook.sh" }, "devDependencies": { - "react": "^15.0.0", - "react-dom": "^15.0.0", + "@kadira/storybook": "^1.31.0", + "babel-cli": "^6.5.0", "babel-core": "^6.5.0", + "babel-eslint": "^6.0.2", "babel-loader": "^6.2.4", + "babel-plugin-transform-runtime": "^6.5.0", "babel-polyfill": "^6.5.0", "babel-preset-es2015": "^6.5.0", "babel-preset-react": "^6.5.0", "babel-preset-stage-0": "^6.5.0", - "babel-plugin-transform-runtime": "^6.5.0", - "babel-cli": "^6.5.0", + "chai": "^3.5.0", + "enzyme": "^2.2.0", "eslint": "^2.7.0", - "babel-eslint": "^6.0.2", "eslint-config-airbnb": "^7.0.0", "eslint-plugin-babel": "^3.2.0", + "eslint-plugin-jsx-a11y": "^0.6.2", "eslint-plugin-react": "^4.3.0", - "mocha": "^2.4.5", - "chai": "^3.5.0", - "sinon": "^1.17.3", - "enzyme": "^2.2.0", - "react-addons-test-utils": "^15.0.0", + "git-url-parse": "^6.0.1", "jsdom": "^8.3.1", - "eslint-plugin-jsx-a11y": "^0.6.2", - "@kadira/storybook": "^1.31.0", - "style-loader": "^0.13.1", + "json-loader": "^0.5.4", + "mocha": "^2.4.5", "raw-loader": "^0.5.1", - "git-url-parse": "^6.0.1" + "react": "^15.0.0", + "react-addons-test-utils": "^15.0.0", + "react-dom": "^15.0.0", + "sinon": "^1.17.3", + "style-loader": "^0.13.1" }, "peerDependencies": { "react": "^0.14.7 || ^15.0.0" @@ -51,6 +52,7 @@ "dependencies": { "babel-runtime": "^6.5.0", "markdown-modest": "github:markdowncss/modest", + "markdown-to-react-components": "^0.2.0", "react-addons-create-fragment": "^15.1.0", "react-remarkable": "^1.1.1" }, diff --git a/src/components/Story.js b/src/components/Story.js index a8b6b2765822..9ee42878554a 100644 --- a/src/components/Story.js +++ b/src/components/Story.js @@ -1,7 +1,21 @@ import React from 'react'; -import Remarkable from 'react-remarkable'; +import MTRC from 'markdown-to-react-components'; import PropTable from './PropTable'; -import Node from './Node.js'; +import Node from './Node'; +import {H1, H2, H3, H4, H5, H6, Code, Pre, P, Small, A} from './markdown' + +MTRC.configure({ + h1: H1, + h2: H2, + h3: H3, + h4: H4, + h5: H5, + h6: H6, + code: Code, + pre: Pre, + p: P, + a: A, +}); export default class Story extends React.Component { static displayName = 'Story'; @@ -48,6 +62,18 @@ export default class Story extends React.Component { padding: '0 40px', overflow: 'auto', }, + infoBody: { + fontSize: "16px", + }, + infoBody: { + color: '#444', + fontFamily: "'Open Sans Condensed', sans-serif", + fontWeight: 300, + margin: '0 auto', + maxWidth: '48rem', + lineHeight: 1.45, + padding: '.25rem', + } } constructor(...args) { @@ -63,11 +89,17 @@ export default class Story extends React.Component { } _renderInline() { + const infoBodyInlineStyle = { + borderTop: 'solid 1px #fafafa', + marginTop: '1.5em', + } + const infoBodyStyle = Object.assign(this.stylesheet.infoBody, infoBodyInlineStyle); + return (
+Example Source
+{React.Children.map(this.props.children, (root, idx) => (+))} -
{this.props.children}
;
+ }
+}
+
+export class Pre extends React.Component {
+ render() {
+ const style = {
+ fontSize: '.88em',
+ fontFamily: 'Menlo, Monaco, "Courier New", monospace',
+ backgroundColor: '#fafafa',
+ padding: '.5rem',
+ lineHeight: 1.5,
+ overflowX: 'scroll',
+ };
+
+ return {this.props.children}; + } +} + +export class Blockquote extends React.Component { + render() { + const style = { + fontSize: '1.88em', + fontFamily: 'Menlo, Monaco, "Courier New", monospace', + borderLeft: '8px solid #fafafa', + padding: '1rem', + }; + + return
{this.props.children}; + } +} diff --git a/src/components/markdown/htags.js b/src/components/markdown/htags.js new file mode 100644 index 000000000000..73bf22b652a7 --- /dev/null +++ b/src/components/markdown/htags.js @@ -0,0 +1,92 @@ +import React from 'react'; + +export class H1 extends React.Component { + render() { + const styles = { + fontFamily: 'Arimo, Helvetica, sans-serif', + color: '#777', + borderBottom: '2px solid #fafafa', + marginBottom: '1.15rem', + paddingBottom: '.5rem', + margin: '1.414rem 0 .5rem', + fontWeight: 'inherit', + lineHeight: 1.42, + textAlign: 'center', + marginTop: 0, + fontSize: '3.998rem', + }; + + return
{this.props.children}
; + } +} + +export class Small extends React.Component { + render() { + const style = {}; + + return