Hacker News
points by akersten 4 days ago | 0 comments
It makes me so angry that they named the CSS function `light-dark` instead of leaving the door open to allowing generic user- or site-specified color schemes. I mean it was right there in all the other mechanisms around this feature, they just had to read and think about why these are structured the way they are, and why "light" and "dark" were always values and not keywords in all of these..:

    - <meta name="color-scheme" content="light dark">
    
    - :root { color-scheme: light dark }

    - @media (prefers-color-scheme: dark) { }

    - <picture><source media="(prefers-color-scheme: dark)">
.... and then we've got `light-dark()`, the goofy looking dragon hanging out to the side of these majestic, forward-thinking parts of the specification.

Did they not look at the prior art and notice that "one of these things is not like the other?" All the other pieces of this puzzle, conceivably, could have one day had something like `:root { color-scheme: halloween }` or `@media (prefers-color-scheme: supercontrast)` but no, we're just going to cement `light-dark()` as the only two possible color schemes we'd ever want to switch between forever.

[–] omer_balyali 4 days ago
Color schemes (luminance modes) and color themes (aesthetic styles) are not the same thing. Halloween theme can have light and dark schemes.

Also, prefers-contrast media query exists, which can be used in combination with the luminance modes (color-scheme): halloween-light, halloween-dark, halloween-light-high-contrast, halloween-dark-high-contrast.

https://news.ycombinator.com/item?id=47832705

[–] have_faith 4 days ago
It’s always irked me that light and dark are given privileged positions in the namespace. They’re just themes (or schemes if you like), like all the other possible themes.
[–] steve1977 4 days ago
I'd argue that they are modes of themes, not themes themselves.
[–] Timon3 4 days ago
IMO this would have been the perfect way to ensure the feature won't be useful for anyone. You need buy-in from both developers and users for something like this. Developing one alternate color scheme that everyone supports is a thousand times easier to justify than developing n alternate color schemes that most people don't care about.

And by naming the function `light-dark()`, they explicitly left the door open to introduce something like you suggest in the future. Had they already named the function something more generic, it would limit the flexibility of any future API!

[–] BoppreH 4 days ago
I actually like `light-dark`. It's a shortcut to something that can be done more comprehensively with other, longer forms, but tailored to the most common (by far!) use case. It's a wart in the spec (specific color schemes as keywords) so that we can remove the warts in our code (media query blocks in CSS).

It's not like CSS was pure and elegant to begin with, so why not add an oddity that is actually useful?

[–] tshaddox 4 days ago
I’m not sure what kind of function you’re asking for that would support arbitrary user-defined themes. With the if() function and/or @function declarations you could build pretty much any system you want for defining theme-specific values for arbitrary themes.
[–] hexasquid 4 days ago
Web standards are discussed in the open aren't they? I'll see if I can find what reasoning lead to this.
[–] hexasquid 4 days ago
https://github.com/w3c/csswg-drafts/issues/7561 appears to be a place to start digging
[–] Griffinsauce 4 days ago
A real loss for colour blind people. This could have been a vehicle for colourblind-aware themes.