hipstersmoothie / storybook-dark-mode

A storybook addon that lets your users toggle between dark and light mode.
MIT License
435 stars 56 forks source link

Storybook `brandTitle` and `brandLogo` is not working with `storybook-dark-mode` #157

Closed saikat-samanta closed 1 year ago

saikat-samanta commented 3 years ago

Input ==>>

// .storybook/manager.js

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

addons.setConfig({
  theme: create({
    base: "light",
    brandTitle: "foo",
    brandUrl: "https://www.xyz.com/",
    brandImage:
      "https://manufac-analytics-images.s3.ap-south-1.amazonaws.com/logos/landscape/black/Manufac_Final-2.png",
  }),
});

Output ===>> image

aberhamm commented 3 years ago

Experiencing the same issue.

h0t-p1xels commented 2 years ago

I had this same problem, I have solved it by removing all theming from .storybook/manager.js and instead added it under light in .storybook/preview.js.

This is working but I now get a flash of Storybooks default theming before my custom theme loads :(

// .storybook/preview.js

import { themes } from "@storybook/theming"
import storybookBrandImage from "./StorybookBrandImage.png"

export const parameters = {
    darkMode: {
        current: "light",
        light: {
            ...themes.normal,

            brandTitle: "yourTitle", 
            brandUrl: "yourURL",
            brandImage: storybookBrandImage, 

       }
       dark: {
            ...themes.dark,

       }
   }
}

If anyone knows a solution to the default theming flash before my custom theming loads, please let me know 🙏🏽

rafaelrinaldi commented 2 years ago

@nikkipantony Thank you for sharing your workaround. I am using it to fix the aforementioned issue.

h0t-p1xels commented 2 years ago

@rafaelrinaldi glad it helped 👍

Miguel-Bento-Github commented 2 years ago

@nikkipantony Solution is great and the only thing I can add to improve this workaround is that you can keep yourTheme.js file, export it and spread it.

// yourTheme.js
export const brandTheme = {
  light: {
    base: "light",
    colorPrimary: "#222",
    colorSecondary: "#eed457",
    brandTitle: "JS",
    brandUrl: "https://en.wikipedia.org/wiki/JavaScript",
    brandImage:
      "https://upload.wikimedia.org/wikipedia/commons/thumb/6/6a/JavaScript-logo.png/600px-JavaScript-logo.png",
  },
};
// preview.js
import { themes } from "@storybook/theming";
import { brandTheme } from "./theme";

export const parameters = {
  darkMode: {
    current: "light",
    light: {
      ...themes.normal,
      ...brandTheme.light,
    },
    dark: {
      ...themes.dark,
    },
  },
};

Thanks Nikki!

vishnup-ditto commented 1 year ago

Can we please have a fix for this or mention something on the README. I spent a couple of hours without understanding this addon was causing issues.

hipstersmoothie commented 1 year ago

@vishnup-ditto would you be will to submit a PR?

VictorJSV commented 1 year ago

This issue should be closed, because the solution is in the Readme.md https://github.com/hipstersmoothie/storybook-dark-mode#configuration