r/javascript • • Jun 18 '20

Don't model dark mode with a boolean

https://dev.to/sebastienlorber/insight-4-don-t-model-dark-mode-with-a-boolean-ol1
2 Upvotes

15 comments sorted by

View all comments

Show parent comments

-2

u/Eggy1337 Jun 18 '20 edited Jun 18 '20
  1. No one in their right mind is using media queries which aren't widely supported without a fallback.

  2. No one in negating possibility of new values for this query. If they will be added to the spec and impement by browser vendors, people will adjust to it.

  3. Hacky solutions to setting color scheme shouldn't be supported by browsers.

  4. People will name their blog posts whatever they like.

  5. Value for this media query is literally "light | dark" in spec which you queted(!).

1

u/sebastienlorber Jun 18 '20

You focus too much on the css.

I probably didn't explain well my thoughts, but what I talk about is not specifically related to css.

More context here, where I try to find the best config option for a popular static site generator for documentation. https://github.com/facebook/docusaurus/pull/2939

In such context it's important to get the api right if we don't want to introduce breaking changes in the future to all lib users.

If you look at libs adding dark mode support you'll notice that they first name the lib like gatsby-dark-mode-plugin and expose the Conf as a boolean. I think this is a mistake, but yeah probably not a big deal.

1

u/Eggy1337 Jun 18 '20

Obviously those authors are limiting themselves to dark mode this way, but it doesn't break anything if more options are added to the spec later.

If you want to be more future proof going with original name is never a bad choice, like gatsby-prefers-color-scheme-plugin

And well, if they took that npm name and implemented it with boolean, you can always send PR.

1

u/sebastienlorber Jun 19 '20

Supporting color modes is not necessarily only a css thing. It does not have to be 100 in sync with thisediz query.

You can send PR for sure but a config breaking change is annoying where your project is used by thousands of users like it's the case here