-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Document how to use info addon as decorator #1592
Conversation
addons/info/README.md
Outdated
It is possible to add infos by default to all components by using a global or story decorator. The drawback is you won't be able to display a distinct info message per story. | ||
|
||
``` | ||
addDecorator(withInfo()(story => story())); |
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.
Wouldn't the info addon show information on the WrapStory
component instead of the actual story component with this?
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.
@denkristoffer it could be only if you add other decorators. In this case, it's important to keep the right decorators order.
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.
Thanks! This is really an important clarification that now it is possible to use this addon in decorators as well!
Codecov Report
@@ Coverage Diff @@
## master #1592 +/- ##
==========================================
- Coverage 21.05% 20.41% -0.64%
==========================================
Files 244 241 -3
Lines 5310 5255 -55
Branches 658 638 -20
==========================================
- Hits 1118 1073 -45
- Misses 3692 3716 +24
+ Partials 500 466 -34
Continue to review full report at Codecov.
|
@usulpro wait I think @denkristoffer is right and there's something not ok with my code even if it almost works |
@slorber I just tested it, @usulpro seems to be right. It should probably be mentioned in the text, so no one gets confused. This works: addDecorator(withInfo()(story => story()))
addDecorator(withKnobs) This shows the addDecorator(withKnobs)
addDecorator(withInfo()(story => story())) |
@denkristoffer wouldn't it work better with this syntax?
But in all cases currently when displaying more infos on my component, the "more info" overlay does not include the component. I think I'm missing something but can't understand how to display the component on the more info overlay |
Honnestly I'm not sure to know exactly what I'm doing. I've mentionned to declare this decorator first as you asked but don't really understand why so I'll let you merge or not ;) |
I guess in general it should be:
(because addon Info needs context to show the title)
Do you mean that it shows (it could looks like this:
) |
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.
I've updated. Is it still required to use it as first decorator now? |
I would say that the order of decorators matters! So if you need to show info about your component it should be the *deepest` decorator and it's important to take into account that "local" decorators are deeper than "global" |
I want infos by default on all my components and it's not very important for me to add a custom text line per story