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

@storybook/theming brand property does not update with custom logo/svg #5878

Closed
seanmcintyre opened this issue Mar 5, 2019 · 31 comments
Closed

Comments

@seanmcintyre
Copy link

Describe the bug
brand property in @storybook/theming create() function has no effect

Expected behavior
Logo should reflect SVG component from brand property.

Screenshots
screen shot 2019-03-05 at 12 25 48 pm

Code snippets

config.ts

import {
  addParameters,
  ...
} from '@storybook/react';
...
import { theme } from './theme';
...

addParameters({
  options: {
    theme,
  },
});

theme.ts

import { create } from '@storybook/theming';
import { logo } from './logo';

export const theme = create({
  base: 'light',
  colorPrimary: PistachioLightened,
  colorSecondary: VimeoBlue,
  ...
  brand: logo,
});

logo.tsx

import React from 'react';

export const logo = ({ alt, ...props }) => (
  <svg alt={alt} {...props}>
    ...
  </svg>
);

System:

  • OS: macOS
  • Device: all
  • Browser: all
  • Framework: React
  • Addons: @storybook/theming
  • Version: 5.0.0
@kylepeeler
Copy link

I'm experiencing the same thing

@tmeasday
Copy link
Member

tmeasday commented Mar 5, 2019

I think you want brandImage? Is this a change we should document in MIGRATION.md?

@kylepeeler
Copy link

I tried both brandImage and brand and still am only seeing the title. :( Any other things to try?

@shilman
Copy link
Member

shilman commented Mar 6, 2019

I'm guessing this is probably a duplicate to #5866

@serudda
Copy link

serudda commented Mar 6, 2019

Same behavior. I modified the brand property, and nothing happens.

@kylepeeler
Copy link

FWIW The default storybook logo doesn't even show up for me, it only shows the title of the Storybook. Would this have anything to do with this? Screenshot

@regs79
Copy link

regs79 commented Mar 6, 2019

The below worked for me.

I just had to ensure I didn't have a name set in the main storybook config file under addParameters. That seems to overwrite the logo.

import { create } from '@storybook/theming';
import logo from '../app/assets/images/logo.png';

export default create({
  brandImage: logo,
});

@kylepeeler
Copy link

Yup, I had brandImage as a property within brand for some reason. Also it was helpful to note that the brandImage value should be a url (or a data url if you are using the included webpack url-loader)

@adamjang
Copy link

adamjang commented Mar 7, 2019

@regs79 Solution worked for me too. SVG's didn't work though and I couldn't have a URL set in the storybook config.

@shilman
Copy link
Member

shilman commented Mar 7, 2019

@ndelangen Since you're working on the theming documentation, please make sure this gets clarified in the docs.

@wirtzdan
Copy link

wirtzdan commented Mar 7, 2019

I got this to work with an SVG. It's important to set the width and height inside the svg.
Here is what worked for me:

logo.svg

<svg width="100" height="40" viewBox="0 0 290.72 112.41" [...]

theme.js

import { create } from "@storybook/theming";
import logo from "../src/logo.svg";

export default create({

  [...]

  brandImage: logo
});

@seanmcintyre
Copy link
Author

@wirtzdan Do you have a custom webpack config to support loading SVG files?

@shilman
Copy link
Member

shilman commented Mar 8, 2019

@seanmcintyre The reason this works without the custom webpack config is because brandImage expects a URL as its argument, not the SVG contents. The reason it's breaking on the other issue #5708 is because in that case the user wants the SVG content. (I think!)

@bennypowers
Copy link
Contributor

This is not working for me:

import { create } from '@storybook/theming';

export default create({
  base: 'light',

  colorPrimary: '#8ff8ff',
  colorSecondary: '#6e7d81',

  fontBase: "'proxima-nova', arial, sans-serif",
  fontCode: 'monospace',

  brandImage: '/logo.png',
  brandTitle: 'Components',
  brandUrl: 'https://components.dev',

})

If i load the page, then set the 'logo' property on the themeprovider via react dev tools to '/logo.png', it updates and displays normally.

@rezavation
Copy link

rezavation commented Apr 2, 2019

I have tried multiple different ways to try and load an svg as a logo but no luck.

This is what I have tried:

config.js

import logo from './logo.svg';
addParameters({
  options: {
    theme: create({
      base: 'dark',
      colorPrimary: '#somehex',
      colorSecondary: '#somehex',
      brandImage: logo,

      // UI
      appBg: '#somehex',
      appContentBg: '#somehex',
      appBorderColor: '#somehex',
      appBorderRadius: 4,

      // Typography
      fontBase: '"Open Sans", sans-serif',
      fontCode: 'monospace',
    })
  }
});

and no luck. I have also added width="100" height="40" to my svg.

The result is I still see the Storybook logo being loaded in.

There seems to be some confusion as to whether this brandImage variable is a URL to an svg, or a URL to a png, or an import of an svg, or a require of an svg using svg-inline-loader. @shilman can you clarify?

i'm using:

 "@storybook/addon-actions": "^5.1.0-alpha.20",
    "@storybook/addon-knobs": "^5.1.0-alpha.20",
    "@storybook/addon-links": "^5.1.0-alpha.20",
    "@storybook/addon-notes": "^5.1.0-alpha.20",
    "@storybook/addon-storysource": "^5.1.0-alpha.20",
    "@storybook/addons": "^5.1.0-alpha.20",
    "@storybook/angular": "^5.1.0-alpha.20",
    "@storybook/theming": "^5.1.0-alpha.20",

@shilman
Copy link
Member

shilman commented Apr 2, 2019

@rezaabedian brandImage should be a URL. Try brandImage: 'https://placehold.it/350x150' to verify

@Pixelatex
Copy link

I'm loading an svg file from my directory.

This is converted to a base64 string and prefixed with data:image/svg+xml;base64,. It doesn't show... because the image component doesn't have any size of itself. Manually adding width/height to 100% shows the logo as intended.

@rezavation
Copy link

rezavation commented Apr 3, 2019

@shilman thank you for getting back to me, I will try that.

Edit: @shilman I have tried that and no luck. Intact, if you look at the localStorage representation of the store, you see that brandImage is set to null.

Edit 2: @shilman I downgraded from 5.1.0-alpha.20 to 5.0.6 and it's working.

@Pixelatex could you provide a sample of how you do that? I'd like to do something similar!

@Pixelatex
Copy link

import Logo from '../public/assets/logo/logo.svg';
const convertSvgToBase64ImgString = SVG => `data:image/svg+xml;base64,${Buffer.from(SVG).toString('base64')}`;
const ConvertedLogo = convertSvgToBase64ImgString(Logo);

Then just use the converted logo. This works in a theme file but without height/width added on the img element, you won't see it :/

@DimitrK
Copy link

DimitrK commented Apr 12, 2019

I can't get the general branding working on Storybook 5.1.0-alpha.24. That means neither brandTitle nor brandImage seem to have an effect. The rest of the theming seems to be working fine though.

I tried the following:

  brandTitle: 'MyBrand',
  brandUrl: 'https://www.mybrand.com',
  brandImage: '/image/path/file.png',
  • Import the file, add the webpack loaders pass it as an object to the property
  • Import file and all the above - plus convert it to base64

@milesj
Copy link

milesj commented Apr 16, 2019

I got this working by removing the name from parameter options.

addParameters({
  options: {
    name: 'Name', // REMOVE THIS
    theme,
  },
});

@lonyele
Copy link
Member

lonyele commented Apr 16, 2019

@DimitrK I think you can get more info from #6521

@madhav-b
Copy link

I reproduce the same issue with Storybook version 5.0.5 I had tried with the brand, brandImage, brandTitle but with every case showing default text "Storybook". I want to replace this text with my own logo. Does anyone have any suggestion regarding this issue?

@aozora
Copy link

aozora commented Apr 22, 2019

Hi, as @milesj found out, you have to remove the "name" option, and than "brandImage" must be a url: I couldn't point it to a local asset, so using a public url just works (I use the url of my logo image on a cdn).

@stale
Copy link

stale bot commented May 13, 2019

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label May 13, 2019
@shilman shilman modified the milestones: 5.0.x, 5.1.x Jun 5, 2019
@stale stale bot removed the inactive label Jun 5, 2019
@alexdobsom
Copy link

In ./storybook/manager.js I have this code:

import { addons } from "@storybook/addons";
import { create } from "@storybook/theming/create";

addons.setConfig({
  theme: create({
    base: "light",
    brandTitle: "COMPANY NAME",
    brandUrl: "https://example.com",
    // brandImage: "https://placehold.it/350x150",
    colorPrimary: "hotpink",
    colorSecondary: "orangered"
  })
});

I can see the brandImage but the Title goes away even if the image is very small.
But why?

@shilman
Copy link
Member

shilman commented Feb 22, 2020

@alexdobsom that's the design. once you use the brandImage, it takes over. i think the rationale is that if you care enough to override the brand image you probably also care about the typography, so use a bigger image that includes that.

@ndelangen
Copy link
Member

The title IS used as the image alt/title attribute though, so you should still provide it

@resistdesign
Copy link

resistdesign commented Mar 21, 2021

Had an issue where the logo just wouldn't show, figured it was caching because I couldn't change anything about the theme, all of a sudden.

This helped me: #13200 (comment)

Essentially, you might have to run storybook with the --no-manager-cache flag.

@maneetgoyal
Copy link

Migrated to 6.3.4, seeing the same issue.

// .storybook/manager.js
import { addons } from "@storybook/addons";
import { create } from "@storybook/theming";

addons.setConfig({
  theme: create({
    base: "light",
    brandTitle: "ABC Storybook",
    brandUrl: "https://www.abc.com/",
    brandImage:
      "https://abc/xyz.png",
  }),
});

@aberhamm
Copy link

aberhamm commented Aug 12, 2021

My issue is resolved by removing the storybook-dark-mode addon.

hipstersmoothie/storybook-dark-mode#157

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

No branches or pull requests