hipstersmoothie / storybook-dark-mode

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

The classTarget=html affect the root instead of the html inside the preview #234

Open C0ZEN opened 1 year ago

C0ZEN commented 1 year ago

From the docs, the option classTarget will be passed to a querySelector() inside the iframe. Yet, when clicking the dark mode toggle button, it is affecting the first selector matching instead of the one inside the iframe.

Configuration:

export const parameters = {
  darkMode: {
    classTarget: 'html'
  }
};

DOM example:

Due to this, the dark mode implementation of my components is not working.

hipstersmoothie commented 1 year ago

Want to submit a pr to fix?

Iuriy-Budnikov commented 1 year ago

I have the same issue