-
-
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
Use per-story parameters in Notes addon #3373
Conversation
Use official-storybook stories
Wow, so cool! Can we do the same for |
addons/notes/README.md
Outdated
|
||
```js | ||
import { storiesOf } from '@storybook/react'; | ||
import { configure, addDecorator } from '@storybook/react`; // <- whichever storybook version you use |
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.
The "version" word is a bit confusing here =)
addons/notes/src/index.js
Outdated
channel.emit('storybook/notes/add_notes', marked(text)); | ||
return (getStory, context) => { | ||
const { parameters: { notes } } = context; | ||
console.log({ options, getStory, context, notes }); |
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.
Left by mistake?
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.
😬
Yes, definitely, as well as some others. I just wanted to get this out there and find out what people thought. For instance, are we OK with addons just claiming parameter namespaces ( Any other objections? If not I will put a few utilities together that make this easier to do in each case and do the obvious things in the other addons. |
Would like to see some explicit 👍 from some other interested folks before moving forward here. |
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.
Interesting. It's not that different from what we used to be doing so I wouldn't call this an API revamp by any means. It is slightly better so I definitely welcome this tweak.
I think for an API v2, we should think about an API that resembles more like the content being rendered. I'm not a huge fan of these multiple function parameters in the .add()
variants. The chaining of functions is also a bit bizarre withNotes()()
. The way we declare storiesOf()
is also a bit strange, and its also easy to miss the module
parameter at the end as well.
Looks fine to me.
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.
Very cool.
If this PR is targeting the v4, probably, it worth removing unneeded exports.
) | ||
`; | ||
|
||
storiesOf('Addons|Notes', module) |
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.
Please add these example to the other frameworks too
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.
Yep!
@igor-dv do you mean the old Either we deprecate in an upcoming 3.4.x release (in which case this all needs to be backported to 3.4, probably not a great plan), or we leave the current API around (marked deprecated) until 5.0. I'm OK with that, really. |
OK, I'll call that a quorum. Will finish off this PR then follow it up with similar changes to other addons. |
You should probably take a look at https://github.com/storybooks/SBNext/blob/POC-bundler/examples/react/in/button/button.example.js |
@Hypnosphi / @danielduan I expect the concept of parameters to come through to the new API however---people will still need a way to annotate their "pure" examples with instructions for SB/documentation. This isn't the place to discuss the exact API but one idea might be to add a property to the exported function: export const example1 = () => <Component>with children</Component>;
example1.storyParameters = {
notes: 'This is the story note that will appear in the storybook UI'
} |
Codecov Report
@@ Coverage Diff @@
## master #3373 +/- ##
==========================================
+ Coverage 36.65% 36.69% +0.03%
==========================================
Files 458 458
Lines 10124 10135 +11
Branches 895 886 -9
==========================================
+ Hits 3711 3719 +8
- Misses 5854 5877 +23
+ Partials 559 539 -20
Continue to review full report at Codecov.
|
Updated the remaining app layers and addressed the other things on this ticket. |
Also removed Next up I will factor out a utility to make this easy to generalize and deprecate the current API as part of that. |
Now we have per-story parameters, we can change the addon APIs to be more ergonomic via the use of parameters.
This PR is a first pass at changing the notes addon to use a parameter named
notes
. I want to put it out there to try and flush out any problems with the approach and get feedback before following up with changing the other addons.New API:
Instead of:
We now do
To test
See the
official-storybook
.