Skip to content

Commit

Permalink
Merge pull request #4004 from martinmacko47/info-proptypes
Browse files Browse the repository at this point in the history
Fix autodetection of used components in info addon
  • Loading branch information
ndelangen authored Aug 24, 2018
2 parents 887d64b + 622c5c3 commit 447a45f
Show file tree
Hide file tree
Showing 4 changed files with 315 additions and 2 deletions.
98 changes: 98 additions & 0 deletions addons/info/src/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1250,6 +1250,55 @@ exports[`addon Info should render <Info /> and external markdown 1`] = `
</Styled(pre)>
</Pre>
</div>
<div>
<h1
style={
Object {
"borderBottom": "1px solid #EEE",
"fontSize": "25px",
"margin": "20px 0 0 0",
"padding": "0 0 5px 0",
}
}
>
Prop Types
</h1>
<div
key="TestComponent_0"
>
<h2
style={
Object {
"margin": "20px 0 0 0",
}
}
>
"
TestComponent
" Component
</h2>
<Component
excludedPropTypes={Array []}
maxPropArrayLength={3}
maxPropObjectKeys={3}
maxPropStringLength={50}
type={[Function]}
>
<PropTable
excludedPropTypes={Array []}
maxPropArrayLength={3}
maxPropObjectKeys={3}
maxPropStringLength={50}
propDefinitions={Array []}
type={[Function]}
>
<small>
No propTypes defined!
</small>
</PropTable>
</Component>
</div>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -2601,6 +2650,55 @@ containing **bold**, *cursive* text, \`code\` and [a link](https://github.com)"
</Styled(pre)>
</Pre>
</div>
<div>
<h1
style={
Object {
"borderBottom": "1px solid #EEE",
"fontSize": "25px",
"margin": "20px 0 0 0",
"padding": "0 0 5px 0",
}
}
>
Prop Types
</h1>
<div
key="TestComponent_0"
>
<h2
style={
Object {
"margin": "20px 0 0 0",
}
}
>
"
TestComponent
" Component
</h2>
<Component
excludedPropTypes={Array []}
maxPropArrayLength={3}
maxPropObjectKeys={3}
maxPropStringLength={50}
type={[Function]}
>
<PropTable
excludedPropTypes={Array []}
maxPropArrayLength={3}
maxPropObjectKeys={3}
maxPropStringLength={50}
propDefinitions={Array []}
type={[Function]}
>
<small>
No propTypes defined!
</small>
</PropTable>
</Component>
</div>
</div>
</div>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions addons/info/src/components/Story.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,8 @@ class Story extends Component {
innerChildren.forEach(extract);
return;
}
if (innerChildren.props && innerChildren.props.innerChildren) {
extract(innerChildren.props.innerChildren);
if (innerChildren.props && innerChildren.props.children) {
extract(innerChildren.props.children);
}
if (
typeof innerChildren === 'string' ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,23 @@ exports[`Storyshots Button addons composition 1`] = `
</button>
</pre>
</div>
<div>
<h1
style="margin:20px 0 0 0;padding:0 0 5px 0;font-size:25px;border-bottom:1px solid #EEE"
>
Prop Types
</h1>
<div>
<h2
style="margin:20px 0 0 0"
>
"InfoButton" Component
</h2>
<small>
No propTypes defined!
</small>
</div>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -573,6 +590,16 @@ exports[`Storyshots Button with new info 1`] = `
</tbody>
</table>
</div>
<div>
<h2
style="margin:20px 0 0 0"
>
"InfoButton" Component
</h2>
<small>
No propTypes defined!
</small>
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,33 @@ exports[`Storyshots Addons|Info.GitHub issues #1814 1`] = `
</button>
</pre>
</div>
<div>
<h1
style="margin:20px 0 0 0;padding:0 0 5px 0;font-size:25px;border-bottom:1px solid #EEE"
>
Prop Types
</h1>
<div>
<h2
style="margin:20px 0 0 0"
>
"" Component
</h2>
<small>
No propTypes defined!
</small>
</div>
<div>
<h2
style="margin:20px 0 0 0"
>
"" Component
</h2>
<small>
No propTypes defined!
</small>
</div>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -5019,6 +5046,167 @@ exports[`Storyshots Addons|Info.Options.propTablesExclude Exclude component from
</button>
</pre>
</div>
<div>
<h1
style="margin:20px 0 0 0;padding:0 0 5px 0;font-size:25px;border-bottom:1px solid #EEE"
>
Prop Types
</h1>
<div>
<h2
style="margin:20px 0 0 0"
>
"BaseButton" Component
</h2>
<table
class="css-1uhv8nx e1vdo5380"
>
<thead>
<tr>
<th
class="css-11b5gui e6fp4ir1"
>
property
</th>
<th
class="css-11b5gui e6fp4ir1"
>
propType
</th>
<th
class="css-11b5gui e6fp4ir1"
>
required
</th>
<th
class="css-11b5gui e6fp4ir1"
>
default
</th>
<th
class="css-11b5gui e6fp4ir1"
>
description
</th>
</tr>
</thead>
<tbody>
<tr>
<td
class="css-1qcb1f7 e6fp4ir0"
>
disabled
</td>
<td
class="css-1qcb1f7 e6fp4ir0"
>
<span />
</td>
<td
class="css-11b5gui e6fp4ir0"
>
-
</td>
<td
class="css-11b5gui e6fp4ir0"
>
<span
style="color:#a11"
>
false
</span>
</td>
<td
class="css-11b5gui e6fp4ir0"
/>
</tr>
<tr>
<td
class="css-1qcb1f7 e6fp4ir0"
>
label
</td>
<td
class="css-1qcb1f7 e6fp4ir0"
>
<span />
</td>
<td
class="css-11b5gui e6fp4ir0"
>
yes
</td>
<td
class="css-11b5gui e6fp4ir0"
>
-
</td>
<td
class="css-11b5gui e6fp4ir0"
/>
</tr>
<tr>
<td
class="css-1qcb1f7 e6fp4ir0"
>
onClick
</td>
<td
class="css-1qcb1f7 e6fp4ir0"
>
<span />
</td>
<td
class="css-11b5gui e6fp4ir0"
>
-
</td>
<td
class="css-11b5gui e6fp4ir0"
>
<span
style="color:#170"
>
onClick
</span>
</td>
<td
class="css-11b5gui e6fp4ir0"
/>
</tr>
<tr>
<td
class="css-1qcb1f7 e6fp4ir0"
>
style
</td>
<td
class="css-1qcb1f7 e6fp4ir0"
>
<span />
</td>
<td
class="css-11b5gui e6fp4ir0"
>
-
</td>
<td
class="css-11b5gui e6fp4ir0"
>
<span
style="color:#666"
>
{}
</span>
</td>
<td
class="css-11b5gui e6fp4ir0"
/>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit 447a45f

Please sign in to comment.