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

Make prefersDark lazy #134

Closed schickling closed 3 years ago

schickling commented 3 years ago

Currently prefersDark is a const as defined here: https://github.com/hipstersmoothie/storybook-dark-mode/blob/master/src/Tool.tsx#L35

This leads to errors in non-browser contexts. Example:

image

I'd suggest to make prefersDark a lazily invoked function.

schickling commented 3 years ago

Turns out https://github.com/hipstersmoothie/storybook-dark-mode/issues/132 fixes this.