storybookjs / storybook Public
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
addon-backgrounds: global context not initially updated with color #15632
Comments
After some digging, it looks like the so-called storybook/lib/client-api/src/story_store.ts Lines 216 to 228 in 209b6c4
@ghengeveld could you shed some light on this per you changes in #15056? Basically, adding // preview.js
export const parameters = {
+ globals: {
+ backgrounds: {}
+ },
backgrounds: {
// ... Still doesn't solve the default case where no global param is present. @ghengeveld seeing as you know the globals code fairly well, do you have any ideas why the globals from an addon would not be populated until the |
this looks like a bug with also cc @stevensacks since you're using the same pattern in your i18n work AFAICT what's going on here is that the globals code in core assumes that the globals are declared statically, either by the end user or by addons. what that would look like: // .storybook/preview.js
export const globalTypes = { ... };
export const globals = { ... }; If you don't declare a
Given this pattern, we could fix the problem:
I think the first fix is closer to the design intent of globals. WDYT? |
I think I agree @shilman |
@shilman based on the inability to statically define the initial background color are you okay with the changes in #15640? |
Describe the bug
When using
@storybook/addons-backgrounds
in a react project with a customDecorator
, the initial/default background value is not passed to thecontext.globals
.I have a project performing text contrast logic where I need the initial value to pass to javascript.
To Reproduce
console.log
of thecontext.globals
shows and empty object.context.globals
now includes the selected value.System
Additional context
Could be related to #14846
The text was updated successfully, but these errors were encountered: