hipstersmoothie / storybook-dark-mode

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

Current param not being respected #206

Closed beltranrengifo closed 1 year ago

beltranrengifo commented 1 year ago

Hi there! I'm having a bug with this storybook here. I set the current param as light but I can see how it changes when color schema in the system preferences is changed. Also, if OS set to dark mode and the SB is opened in a fresh window, the SB is shown in dark mode... :(

As stated in this pr and in the documentation, the other way is expected, isn't it?

image image
export const parameters = {
    docs: {
        container: DocsContainer,
        page: DocsPage,
        inlineStories: true,
        prepareForInline: (Story: StoryType) => <Story />,
    },
    layout: 'centered',
    options: {
        storySort: {
            method: 'alphabetical',
            order: STORYBOOK_ROOTS_ORDER,
        },
    },
    darkMode: {
        dark: { ...themes.dark },
        light: { ...themes.normal },
        current: 'light',
        stylePreview: true,
    },
};

Is this a bug or am I missing something? Thanks!

beltranrengifo commented 1 year ago

hi! after digging a bit, in the case that a user sets current: 'light' and the OS in dark mode, my guess is:

I guess the problem is around this ifs I'll try to take a closer look

beltranrengifo commented 1 year ago

Fixed in release v2.0.5