Storybook: Theme variables(brandTitle, brandUrl, brandImage) not working

Created on 15 Apr 2019  Β·  22Comments  Β·  Source: storybookjs/storybook

Describe the bug
Even if I set brandTitle, brandUrl, brandImage on theme object, It doesn't work at all(5.1.0-alpha.27)

To Reproduce
Set any combinations of brandTitle, brandUrl, brandImage of defined, undefined, null on theme object.

Expected behavior
SidebarHeading should be rendered according to the inputs from options

System:

  • OS: Windows10, Ubuntu 18.04
  • Browser: chrome, firefox
  • Framework: react
  • Version: 5.1.0-alpha.27
bug theming

All 22 comments

It also doesn't work in 5.0.6

@KaboomFox Just FYI, reason for not working is different for version 5.0.6 and this 5.1.0-alpha.27.

Released version 5.0.6 had a bug and PR that fixes merged to 5.1.0.-alpha.7 which is not released yet.

Problem with this version(5.1.0-alpha.27 actually from 5.1.0-alpha.10) is that It is not working at all.

πŸ‘

@lonyele So if I cherry-pick https://github.com/storybooks/storybook/pull/6120 into master do you think it will fix 5.0.x?

@shilman Yes, If you cherry-pick into master then It will fix for 5.0.x (solve #5866 #6476 )

However, If you release 5.1.x then the bug will arise with the exact same problem I stated here.

Thanks for the clarification @lonyele !

I'll release the patch and follow-up to make sure that the new bug gets fixed in 5.1.x

κ°μ‚¬ν•©λ‹ˆλ‹€ πŸ™

@shilman Whaaaaaat μ•ˆλ…•ν•˜μ„Έμš”~ Recently, I've started trying to contribute to open source as a mean of learning. Let's see how it goes

@lonyele ν™”μ΄νŒ…! γ…‹γ…‹γ…‹γ…‹

I just cleared my localstorage and this is what the brand section looks like

Screen Shot 2019-04-16 at 4 31 01 PM

@hipstersmoothie I'm releasing a new version now with the fix from #6120. Can you try again in a few mins?

Yeah sure. I'm stepping through the code and it seems like my theme is represented in two different places in the state.

Screen Shot 2019-04-16 at 4 55 37 PM

you can see ui.theme has the brandImage set properly and on the root (theme) does not

Also I'm currently on the latest storybook alpha

seems to be something to do with checkDeprecatedThemeOptions(options)

Also from my reading of the code it seems like the keys of deprecatedThemeOptions are the deprecations and not the values. I think the appropriate code is

const checkDeprecatedThemeOptions = (options: Options) => {
  // Check the deprecated options exist
  if (Object.keys(deprecatedThemeOptions).find(v => !!options[v])) {
    return applyDeprecatedThemeOptions(options);
  }
  return {};
};

applyDeprecatedThemeOptions would also need to be changed because it will override the configured theme.

const applyDeprecatedThemeOptions = deprecate(
  ({ name, url }: Options, userOptions: any): PartialThemeVars => ({
    brandTitle: userOptions.brandTitle || name,
    brandUrl: userOptions.brandUrl || url,
    brandImage: userOptions.brandImage || null,
  }),
  deprecationMessage(deprecatedThemeOptions)
);

My PR seems to fix the brandTitle and brandUrl but the image is still not there

Although it seems like the combination of these two PRs would solve my issues

https://github.com/storybooks/storybook/pull/6522
https://github.com/storybooks/storybook/pull/6476

Feel free to choose those over mine! It does about the same thing

Shiver me timbers!! I just released https://github.com/storybooks/storybook/releases/tag/v5.1.0-alpha.30 containing PR #6543 that references this issue. Upgrade today to try it out!

Because it's a pre-release you can find it on the @next NPM tag.

Ooh-la-la!! I just released https://github.com/storybooks/storybook/releases/tag/v5.0.10 containing PR #6543 that references this issue. Upgrade today to try it out!

Was this page helpful?
0 / 5 - 0 ratings