Live data from Hacker News

CSS Custom Functions are coming

bram.us

11–20 of 90 posts

Re: CSS Custom Functions are coming

#12
post #4

Thanks. Looks hideous. @function --light-dark(--light, --dark) { result: var(--light); @media (prefers-color-scheme: dark) { result: var(--dark); } }

Yeah, I couldn't believe it at first.

If you're going to add imperative programming to CSS, just do it already. Hacking in conditionals in this way feels like a bad joke.

Re: CSS Custom Functions are coming

#13

Why do we allow Google to singlehandedly keep pumping garbage into the web ecosystem? Do they own W3C?

While I think this particular idea is bad, Google is following the W3C process for proposing new features. This is what browser vendors are supposed to do: develop the feature, document it so other vendors can implement/compete it, see if there's enough early-adopter developer interest to bother standardizing.

Re: CSS Custom Functions are coming

#15
post #4

Thanks. Looks hideous. @function --light-dark(--light, --dark) { result: var(--light); @media (prefers-color-scheme: dark) { result: var(--dark); } }

Yeah, I couldn't believe it at first. If you're going to add imperative programming to CSS, just do it already. Hacking in conditionals in this way feels like a bad joke.

[deleted]

Re: CSS Custom Functions are coming

#17
This is it. This is all I’ve wanted in CSS for the last decade. In fact, I just wanted basic mixins without function-like behavior, but this gets me there.

The comments here indicate that the article doesn’t do much to explain what this does or why you’d want it, but basically this gives you a way to reuse blocks of styles without needing to resort to e.g. utility classes or other hacks that get around specificity issues. The syntax doesn’t help explain that.

Shame about the syntax, but I’m used to it at this point.

Re: CSS Custom Functions are coming

#19

Why do we allow Google to singlehandedly keep pumping garbage into the web ecosystem? Do they own W3C?

You have a (very common) mistaken view of what the W3C is and how it works. It is NOT an independent standards body that tells browser makers what to do! In fact, it's the exact opposite: the browser makers (and Google is a big one) tell the W3C what to do.

This makes perfect sense if you think about it, because the browser makers ultimately decide what goes into the browser. If the W3C was "in charge" and tried to make Google (or another browser maker) do anything, Google could simply ignore them. That system wouldn't last.

It has to work this way ... and Google (along with Apple, Microsoft, etc.) have decided this syntax is best for them (and possibly their users).

Post reply on HN