-
Notifications
You must be signed in to change notification settings - Fork 47
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 context.storyGlobals
#95
Conversation
Is this change backwards compatible? |
I thought we moved to a different model with |
As much as adding anything to the context can be -- users can set arbitrary fields on the context, so theoretically it's possible someone out there is setting
However, the actual calculated I'm pretty sure we shouldn't change the meaning of You really only want access to |
But why do we need it then? Why would you want to know the global has been overridden? Except for manager concerns in storybook itself, which can just compare My feeling is that |
We could consider not making available. Certainly addons need it in the manager to determine if a global has been overridden (theoretically you can check if One option would be to not put it in the context just yet (and just add it to the |
Sounds good to me @tmeasday ! |
as discussed here: ComponentDriven/csf#95 (comment)
Following on from #92 -- add
context.storyGlobals
.This is added to the very initial context (
ContextForEnhancers
) reflecting that we know it from back then.Later (at render time) we'll also gain
context.globals
; which is the story's globals combined with the current value of the "user globals". Typically this is what user code would look at.I'm not sure if we want to also add
context.userGlobals
to that layer (ContextForEnhancers
) -- strictly speaking you cannot inferuserGlobals
fromglobals - storyGlobals
. Then again it's unclear why you'd want to know the value of an overridden "user global".Second question: should we make
context.storyGlobals
nullable, if the story does not set any global overrides?📦 Published PR as canary version:
0.1.12--canary.95.1b1fb52.0
✨ Test out this PR locally via:
npm install @storybook/csf@0.1.12--canary.95.1b1fb52.0 # or yarn add @storybook/csf@0.1.12--canary.95.1b1fb52.0