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(486) - Only show props if there are props #488
Conversation
Codecov Report
@@ Coverage Diff @@
## master #488 +/- ##
==========================================
+ Coverage 94.35% 94.54% +0.18%
==========================================
Files 96 96
Lines 1258 1283 +25
Branches 273 283 +10
==========================================
+ Hits 1187 1213 +26
+ Misses 68 67 -1
Partials 3 3
Continue to review full report at Codecov.
|
@@ -74,6 +75,7 @@ export default class ReactComponent extends Component { | |||
: <ExamplePlaceholder name={name} /> | |||
} | |||
tabButtons={ | |||
showPropsButton && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There may be other tabs, not just props. I’m thinking that this may be not that easy to fix ;-)
What are the other other tabs?
…On Sun, 11 Jun 2017, 10:50 a.m. Artem Sapegin, ***@***.***> wrote:
***@***.**** requested changes on this pull request.
------------------------------
In src/rsg-components/ReactComponent/ReactComponent.js
<#488 (comment)>
:
> @@ -74,6 +75,7 @@ export default class ReactComponent extends Component {
: <ExamplePlaceholder name={name} />
}
tabButtons={
+ showPropsButton &&
There may be other tabs, not just props. I’m thinking that this may be not
that easy to fix ;-)
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#488 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABALdQnAX4BrKNTWSXSBCSHxlMy_2pMuks5sC7iCgaJpZM4N2Vy2>
.
|
Doesn’t matter (there are none now) but the |
@@ -44,6 +44,7 @@ export default class ReactComponent extends Component { | |||
const { component } = this.props; | |||
const { name, slug, pathLine } = component; | |||
const { description, examples = [], tags = {} } = component.props; | |||
const showPropsButton = component.props.props || (component.props.methods || {}).length > 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this check won’t work:
!![] === true
({}).length === undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here is the right check: https://github.com/styleguidist/react-styleguidist/blob/master/src/rsg-components/Usage/Usage.js
Didn't know that about the slot but the props button receives the whole props including the methods and props of the component so I updated the code to only show or hide the methods component @sapegin |
package-lock.json
Outdated
@@ -54,7 +54,7 @@ | |||
"readable-stream": { | |||
"version": "2.2.11", | |||
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.2.11.tgz", | |||
"integrity": "sha512-h+8+r3MKEhkiVrwdKL8aWs1oc1VvBu33ueshOvS26RsZQ3Amhx/oO3TKe4lApSV9ueY6as8EAh7mtuFjdlhg9Q==", | |||
"integrity": "sha1-B5azH412iAB/8Lk6gIjTSqF8D3I=", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you have some weird version of npm. Why it changes all hashes to SHA1? ;-/
1. More consistent condition code 2. Return null insatead of undefined 3. Add PropTypes 4. Add tests
I’ve made some tweaks (see my commits) and merged. Thanks! |
@sapegin Awesome ! |
Closes #486