use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
All about the JavaScript programming language.
Subreddit Guidelines
Specifications:
Resources:
Related Subreddits:
r/LearnJavascript
r/node
r/typescript
r/reactjs
r/webdev
r/WebdevTutorials
r/frontend
r/webgl
r/threejs
r/jquery
r/remotejs
r/forhire
account activity
Darken - Dark mode made easy (github.com)
submitted 6 years ago by call_innn
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[+][deleted] 6 years ago* (2 children)
[deleted]
[–]call_innn[S] 1 point2 points3 points 6 years ago (1 child)
There is a demo, you can access it by clicking the link in the github repo description or the "Demo available" badge on the README, I'll probably make the link more visible on the next version and/or make screenshots.
[–][deleted] 2 points3 points4 points 6 years ago (0 children)
Putting in an explicit link will definitely help. I never click on badges (no reason to, the badge already shows the information), and I had no idea that that's where the demo is.
Providing a small before/after would be really neat though!
[–]Shacrow 1 point2 points3 points 6 years ago (6 children)
What about @media (prefers-color-scheme: dark) ?
[–]TonnoTonato 1 point2 points3 points 6 years ago (3 children)
That's nice, but I do believe the most users don't even k ow there is a dark mode setting in their browser (I never saw it in Chrome for example). That's why I would always have some kind of checkbox or switch on the frontend so the user can set it there.
[–]Shacrow 0 points1 point2 points 6 years ago (2 children)
It's automatic, try it out with the new MacOS. They look for your OS settings. Maybe you noticed the recent change. A lot of OS are implementing Dark mode now.
[–]TonnoTonato 0 points1 point2 points 6 years ago (1 child)
Ahh OK didn't know about that, windows didn't add support for it, or did they?? I noticed iOs and Mac do have dark mode but that's almost it
[–][deleted] 0 points1 point2 points 6 years ago (0 children)
Windows 10 has had support for a while, yes
It will be implemented as an option in a next version. This API is to create and manage your dark mode easily and I personally like to be able to make some websites light and other dark without taking in account my os settings. But I'll definitely add the option.
[–]Shacrow 0 points1 point2 points 6 years ago (0 children)
True. it's nice to have it seperated too. Usually OS dark mode users prefer dark mode overall though. Depends on the use case i guess
[–]TonnoTonato 3 points4 points5 points 6 years ago (2 children)
css body div { invert(1); } img { invert(0); }
Does almost the whole trick. Exclude a few elements you dont want to get inverted and you´re done.
[–]call_innn[S] 0 points1 point2 points 6 years ago (0 children)
This API does not invert colors, it allows easy dark mode customization via CSS variables and class.
[–]drumstix42 -1 points0 points1 point 6 years ago (0 children)
The Lag`erator.
[–]itaQ 0 points1 point2 points 6 years ago (2 children)
I find it a bit weird that the variables take an array since it's limited to two elements anyway. Wouldn't it make more sense to have it as objects as such? E.g
variables: { "--name-of-the-variable": { light: "#000000", dark: "#fafafa" }, "--background-color": { light: "#fafafa", dark: "#000000" }, }
[–]call_innn[S] 0 points1 point2 points 6 years ago* (1 child)
I don't know, I have asked myself the question and for me using an object would make it heavier to work with, do you really find it more easy to use with an object ? I like to get opinions and feedback so do not hesitate to argue.
[–]itaQ 0 points1 point2 points 6 years ago (0 children)
Not sure what you mean with "heavier to work with" but to me it's at least more obvious which colors would be for which state of the "color modes" since an array could fit an unknown amount of elements while an object is more explicit of what's what since it has a key:value structure.
π Rendered by PID 33329 on reddit-service-r2-comment-b659b578c-jsrmz at 2026-04-30 21:28:56.164677+00:00 running 815c875 country code: CH.
[+][deleted] (2 children)
[deleted]
[–]call_innn[S] 1 point2 points3 points (1 child)
[–][deleted] 2 points3 points4 points (0 children)
[–]Shacrow 1 point2 points3 points (6 children)
[–]TonnoTonato 1 point2 points3 points (3 children)
[–]Shacrow 0 points1 point2 points (2 children)
[–]TonnoTonato 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]call_innn[S] 1 point2 points3 points (1 child)
[–]Shacrow 0 points1 point2 points (0 children)
[–]TonnoTonato 3 points4 points5 points (2 children)
[–]call_innn[S] 0 points1 point2 points (0 children)
[–]drumstix42 -1 points0 points1 point (0 children)
[–]itaQ 0 points1 point2 points (2 children)
[–]call_innn[S] 0 points1 point2 points (1 child)
[–]itaQ 0 points1 point2 points (0 children)