From c9508d63f86838238243d77db4f4bfe776a8289e Mon Sep 17 00:00:00 2001 From: elish Date: Thu, 20 Apr 2017 15:33:40 +0300 Subject: [PATCH 1/2] add propTablesExclude option --- packages/addon-info/src/components/Story.js | 9 ++++++--- packages/addon-info/src/index.js | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/packages/addon-info/src/components/Story.js b/packages/addon-info/src/components/Story.js index be70e3a1fff0..08c62c4e176f 100644 --- a/packages/addon-info/src/components/Story.js +++ b/packages/addon-info/src/components/Story.js @@ -249,7 +249,7 @@ export default class Story extends React.Component { } // depth-first traverse and collect types - function extract(children) { + const extract = children => { if (!children) { return; } @@ -260,13 +260,15 @@ export default class Story extends React.Component { if (children.props && children.props.children) { extract(children.props.children); } - if (typeof children === 'string' || typeof children.type === 'string') { + if (typeof children === 'string' || typeof children.type === 'string' || + (Array.isArray(this.props.propTablesExclude) && // also ignore excluded types + ~this.props.propTablesExclude.indexOf(children.type))) { return; } if (children.type && !types.has(children.type)) { types.set(children.type, true); } - } + }; // extract components from children extract(this.props.children); @@ -311,6 +313,7 @@ Story.propTypes = { context: PropTypes.object, info: PropTypes.oneOfType([PropTypes.string, PropTypes.node]), propTables: PropTypes.arrayOf(PropTypes.func), + propTablesExclude: PropTypes.arrayOf(PropTypes.func), showInline: PropTypes.bool, showHeader: PropTypes.bool, showSource: PropTypes.bool, diff --git a/packages/addon-info/src/index.js b/packages/addon-info/src/index.js index a2f6f78081c3..ede94ae320ca 100644 --- a/packages/addon-info/src/index.js +++ b/packages/addon-info/src/index.js @@ -61,6 +61,7 @@ export default { showHeader: Boolean(options.header), showSource: Boolean(options.source), propTables: options.propTables, + propTablesExclude: options.propTablesExclude, styles: typeof options.styles === 'function' ? options.styles : s => s, mtrcConf, }; From 1cd8aadfe9889e29f15142b8a670918291df1b3b Mon Sep 17 00:00:00 2001 From: fabien0102 Date: Wed, 3 May 2017 12:18:46 +0200 Subject: [PATCH 2/2] Add typescript definition to addon-notes --- packages/addon-notes/package.json | 72 ++++++++++--------- .../addon-notes/storybook-addon-notes.d.ts | 7 ++ 2 files changed, 44 insertions(+), 35 deletions(-) create mode 100644 packages/addon-notes/storybook-addon-notes.d.ts diff --git a/packages/addon-notes/package.json b/packages/addon-notes/package.json index ee2ea2adada6..4f43fe80ca4e 100644 --- a/packages/addon-notes/package.json +++ b/packages/addon-notes/package.json @@ -1,35 +1,37 @@ -{ - "name": "@kadira/storybook-addon-notes", - "version": "1.0.1", - "description": "Write notes for your Storybook stories.", - "repository": { - "type": "git", - "url": "https://github.com/kadirahq/storybook-addon-notes.git" - }, - "license": "MIT", - "scripts": { - "prepublish": "node ../../scripts/prepublish.js", - "storybook": "start-storybook -p 9010", - "publish-storybook": "bash .scripts/publish_storybook.sh" - }, - "devDependencies": { - "@kadira/storybook": "*", - "git-url-parse": "^6.0.1", - "react": "^15.3.2", - "react-addons-test-utils": "^15.5.1", - "react-dom": "^15.3.2" - }, - "peerDependencies": { - "react": "*", - "@kadira/storybook-addons": "*" - }, - "dependencies": { - "babel-runtime": "^6.5.0" - }, - "main": "dist/index.js", - "keywords": [ - "react", - "storybook", - "addon" - ] -} +{ + "name": "@kadira/storybook-addon-notes", + "version": "1.0.1", + "description": "Write notes for your Storybook stories.", + "repository": { + "type": "git", + "url": "https://github.com/kadirahq/storybook-addon-notes.git" + }, + "license": "MIT", + "scripts": { + "prepublish": "node ../../scripts/prepublish.js", + "storybook": "start-storybook -p 9010", + "publish-storybook": "bash .scripts/publish_storybook.sh" + }, + "devDependencies": { + "@kadira/storybook": "*", + "@types/react": "^15.0.23", + "git-url-parse": "^6.0.1", + "react": "^15.3.2", + "react-addons-test-utils": "^15.5.1", + "react-dom": "^15.3.2" + }, + "peerDependencies": { + "react": "*", + "@kadira/storybook-addons": "*" + }, + "dependencies": { + "babel-runtime": "^6.5.0" + }, + "main": "dist/index.js", + "keywords": [ + "react", + "storybook", + "addon" + ], + "typings": "./storybook-addon-notes.d.ts" +} diff --git a/packages/addon-notes/storybook-addon-notes.d.ts b/packages/addon-notes/storybook-addon-notes.d.ts new file mode 100644 index 000000000000..fdfdaa918083 --- /dev/null +++ b/packages/addon-notes/storybook-addon-notes.d.ts @@ -0,0 +1,7 @@ +import * as React from 'react'; + +export interface WithNotesProps extends React.HTMLProps { + notes?: string; +} + +export const WithNotes: React.StatelessComponent;