Skip to content
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

Theme variables(brandTitle, brandUrl, brandImage) not working #6521

Closed
lonyele opened this issue Apr 15, 2019 · 22 comments · Fixed by #6543
Closed

Theme variables(brandTitle, brandUrl, brandImage) not working #6521

lonyele opened this issue Apr 15, 2019 · 22 comments · Fixed by #6543
Milestone

Comments

@lonyele
Copy link
Member

lonyele commented Apr 15, 2019

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
@KaboomFox
Copy link

It also doesn't work in 5.0.6

@shilman shilman added this to the 5.0.x milestone Apr 15, 2019
@lonyele
Copy link
Member Author

lonyele commented Apr 16, 2019

@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.

@KaboomFox
Copy link

👍

@shilman
Copy link
Member

shilman commented Apr 16, 2019

@lonyele So if I cherry-pick #6120 into master do you think it will fix 5.0.x?

@lonyele
Copy link
Member Author

lonyele commented Apr 16, 2019

@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.

@shilman
Copy link
Member

shilman commented Apr 16, 2019

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

감사합니다 🙏

@lonyele
Copy link
Member Author

lonyele commented Apr 16, 2019

@shilman Whaaaaaat 안녕하세요~ Recently, I've started trying to contribute to open source as a mean of learning. Let's see how it goes

@shilman
Copy link
Member

shilman commented Apr 16, 2019

@lonyele 화이팅! ㅋㅋㅋㅋ

@hipstersmoothie
Copy link
Contributor

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

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

@shilman
Copy link
Member

shilman commented Apr 16, 2019

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

@hipstersmoothie
Copy link
Contributor

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

@hipstersmoothie
Copy link
Contributor

Also I'm currently on the latest storybook alpha

@hipstersmoothie
Copy link
Contributor

seems to be something to do with checkDeprecatedThemeOptions(options)

@hipstersmoothie
Copy link
Contributor

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 {};
};

@hipstersmoothie
Copy link
Contributor

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)
);

@hipstersmoothie
Copy link
Contributor

@shilman PR opened #6543

@hipstersmoothie
Copy link
Contributor

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

@hipstersmoothie
Copy link
Contributor

It is this line

https://github.com/storybooks/storybook/blob/8c4ee76dab03402b6d5a89b08a2504939d6f23e4/lib/theming/src/create.ts#L175

this prevents the user from setting a brandImage

@hipstersmoothie
Copy link
Contributor

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

#6522
#6476

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

@shilman
Copy link
Member

shilman commented Apr 18, 2019

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.

@shilman
Copy link
Member

shilman commented Apr 18, 2019

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants