From 67a5fd584125dc6c23bb3e6069e8667b1dd0a38c Mon Sep 17 00:00:00 2001 From: hypnos Date: Thu, 9 Nov 2017 02:22:26 +0300 Subject: [PATCH 1/2] Addon-info: allow duplicate displayNames --- addons/info/src/components/Story.js | 13 +- .../src/__snapshots__/storyshots.test.js.snap | 341 ++++++++++++++++++ .../src/stories/issues.stories.js | 19 + 3 files changed, 367 insertions(+), 6 deletions(-) create mode 100644 examples/cra-kitchen-sink/src/stories/issues.stories.js diff --git a/addons/info/src/components/Story.js b/addons/info/src/components/Story.js index b0a2863075b6..a02ce066f58b 100644 --- a/addons/info/src/components/Story.js +++ b/addons/info/src/components/Story.js @@ -14,6 +14,8 @@ import { Pre } from './markdown'; global.STORYBOOK_REACT_CLASSES = global.STORYBOOK_REACT_CLASSES || []; const { STORYBOOK_REACT_CLASSES } = global; +const getName = type => type.displayName || type.name; + const stylesheet = { link: { base: { @@ -324,14 +326,13 @@ export default class Story extends React.Component { extract(this.props.children); const array = Array.from(types.keys()); - array.sort((a, b) => (a.displayName || a.name) > (b.displayName || b.name)); + array.sort((a, b) => getName(a) > getName(b)); const { maxPropObjectKeys, maxPropArrayLength, maxPropStringLength } = this.props; - const propTables = array.map(type => ( -
-

- "{type.displayName || type.name}" Component -

+ const propTables = array.map((type, i) => ( + // eslint-disable-next-line react/no-array-index-key +
+

"{getName(type)}" Component

`; +exports[`Storyshots GitHub issues #1814 1`] = ` +
+
+
+ + ); + +storiesOf('GitHub issues', module).add( + '#1814', + withInfo('HOC')(() => ( +
+ + ); + +storiesOf('Addon Info.GitHub issues', module).add( + '#1814', + withInfo('Allow Duplicate DisplayNames for HOC #1814')(() => ( +
+ + ); - -storiesOf('GitHub issues', module).add( - '#1814', - withInfo('HOC')(() => ( -
- -