-
-
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
Add params-based API to options addon #3965
Conversation
Generated by 🚫 dangerJS |
Wow I was totally gazumped by @nm123github -- nice ;) From playing around with it a bit, I think the options need to be reset, otherwise you get super weird behaviour as the options drift as you change stories. I'll rebase this PR against current
|
This is just for simplicity. I think it is best if non-framework specific stories all live in official-storybook; that way they are easier to find in the future. cc @nm123github
cc @nm123github -- FYI -- we made this shortcut so you don't need to call `addDecorator` followed by `addParameters`.
@tmeasday had no idea you were working on this too 🙂 , thanks for the review.. - I'm not sure we should have a story about this in the marko example app? I think these kind SB-wide stories should just be in official storybook, right? - We need to deal with panel resizing still, when you toggle between "addon panel open" and "addon panel closed" at any rate. From playing around with it a bit, I think the options need to be reset, otherwise you get super weird behaviour as the options drift as you change stories. |
Let me know when it's ready for review? |
I've done 1. in this PR also. So from my perspective the remaining issue is just resizing the panels when they are hidden. Let me make a couple of gifs. |
I think maybe I have confused things a little -- this PR retains top-level Notice how the Actions story's addons panel location depends on the previous story you looked at. It's even more of a problem when a story is e.g. hiding the panel. If the user sets options on every story it is not a problem, but this isn't what users will expect i don't think. In any case I think this PR has the best of both worlds (story-level options are not remembered, global options set via |
Thanks for taking care of this @tmeasday |
No worries @nm123github -- just standing on your shoulders |
On the subject on panel resizing I cannot reproduce the problem on |
@tmeasday, probably I am missing something, but playing with preview of your PR (didn't review the code yet), I do see options are persistent between stories. For example, the "Custom Storybook" name is remaining when navigating out of the story that changed it. BTW I would also limit what people can change. For example, not allow changing hierarchy options. |
49694b7
to
c865719
Compare
Codecov Report
@@ Coverage Diff @@
## master #3965 +/- ##
==========================================
+ Coverage 40.46% 40.48% +0.02%
==========================================
Files 491 491
Lines 5835 5832 -3
Branches 793 791 -2
==========================================
Hits 2361 2361
+ Misses 3085 3084 -1
+ Partials 389 387 -2
Continue to review full report at Codecov.
|
Nope, you are not missing something, I thought I had fixed the problem but it turns out only partially. Any ideas on how we could fix it properly? Would using a subscription help? I'm aware we don't want options to thrash as you go between stories. Ideally you would have the
Yeah I think maybe we should just do the |
Ok, I investigated the panel resizing. I think the reason it doesn't happen on the deployed version is that it only happens in react dev mode. More details here: tomkp/react-split-pane#309 I'm not sure if we should ship this feature until this bug is fixed? It seems like storybook is buggy to have a story hide the addon panel and the layout gets broken. Can anyone think of an easy workaround? |
I could repro this locally. Does seem strange. |
I could also fork / PR react-split-pane to try and get the bug fixed quicker |
@tmeasday If you could PR a fix that'll be amazing. I'm also a collaborator on |
I will try to play with this PR a bit =) |
Ok @igor-dv, that solves it. Let's recommend people use |
…-to-options-addon
c1d93ab
to
d9ab31c
Compare
d9ab31c
to
d309b91
Compare
Ill open an issue to update react-split-pane to 0.1.83, which would solve the |
I don't think it can be merged to 3.4 |
On further investigation, @tmeasday I think I'll have to make additional changes, updating to 0.1.83 breaks the drag action in layouts somehow, it drags extremely slow. |
@igor-dv, yeah this v4 only as params aren’t in v3 @wuweiweiwu any idea why? Afaict the function I changed is only called from Let me know if I can assist! |
We can just add a deprecation warning to v3.4. Just so sad to pollute a beauty of the v4 with deprecations 😢 |
Can’t really deprecate something until an alternative is in place! I think it’s fine to have something ( |
@tmeasday not sure yet. I think edit: seems the new changes also breaks dragging in strict mode. It removed the size invalidation checks |
Issue:
Options API wasn’t using params and couldn’t really be used per-story
What I did
.add(name, story, { options: {… } })
.setOptions
internally to reset each time, rather than remembering the previous state (and only overriding new keys). This didn’t really make sense and was broken when you switched between stories that set options, unless they all set all options, which users aren’t going to do.STILL OUTSTANDING
When you change panels via options it does not re-calculate sizing. So if you hide the addons panel, it will leave a bunch of empty space. Can someone who knows the internals give me some advice on how to re-calculate sizes when options are set?
How to test
Is this testable with Jest or Chromatic screenshots?
There are some jest test that touch on it, but the UI is not currently captured by our screenshots for these stories.
Does this need a new example in the kitchen sink apps?
Yes, done.
Does this need an update to the documentation?
Yes,
done(TODO).If your answer is yes to any of these, please make sure to include it in your PR.
For maintainers only: Please tag your pull request with at least one of the following:
["cleanup", "BREAKING CHANGE", "feature request", "bug", "documentation", "maintenance", "dependencies", "other"]