Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix autodetection of used components in info addon #4004

Merged
merged 4 commits into from
Aug 24, 2018
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
>
<thead>
<tr>
<th
class="css-11b5gui"
>
property
</th>
<th
class="css-11b5gui"
>
propType
</th>
<th
class="css-11b5gui"
>
required
</th>
<th
class="css-11b5gui"
>
default
</th>
<th
class="css-11b5gui"
>
description
</th>
</tr>
</thead>
<tbody>
<tr>
<td
class="css-1qcb1f7"
>
disabled
</td>
<td
class="css-1qcb1f7"
>
<span />
</td>
<td
class="css-11b5gui"
>
-
</td>
<td
class="css-11b5gui"
>
<span
style="color:#a11"
>
false
</span>
</td>
<td
class="css-11b5gui"
/>
</tr>
<tr>
<td
class="css-1qcb1f7"
>
label
</td>
<td
class="css-1qcb1f7"
>
<span />
</td>
<td
class="css-11b5gui"
>
yes
</td>
<td
class="css-11b5gui"
>
-
</td>
<td
class="css-11b5gui"
/>
</tr>
<tr>
<td
class="css-1qcb1f7"
>
onClick
</td>
<td
class="css-1qcb1f7"
>
<span />
</td>
<td
class="css-11b5gui"
>
-
</td>
<td
class="css-11b5gui"
>
<span
style="color:#170"
>
onClick
</span>
</td>
<td
class="css-11b5gui"
/>
</tr>
<tr>
<td
class="css-1qcb1f7"
>
style
</td>
<td
class="css-1qcb1f7"
>
<span />
</td>
<td
class="css-11b5gui"
>
-
</td>
<td
class="css-11b5gui"
>
<span
style="color:#666"
>
{}
</span>
</td>
<td
class="css-11b5gui"
/>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
Expand Down