Live data from Hacker News

CSS now has an if() conditional function

caniuse.com

21–30 of 245 posts

Re: CSS now has an if() conditional function

#21
post #12

Earlier quoted context omitted.

> How did this happen? That's pretty simple - Google has poured tons of money into Chrome and Mozilla. Google is not a charity so this was a strategic investment. > You should go over to the CSS working group and let them know That wouldn't work, money is what ultimately matters there.

[flagged]

> And the other browser vendors with conflicitng interests just go along with it?

When there's a conflict of interest they don't (Apple refuses to implement some APIs that would help making their walled garden app store more obsolete). But just maintaining a duopoly (Mozilla is funded by Google) is not a conflicting interest itself.

> Did you come to that opinion after engaging in the discussions with them?

With employees? There's no point. If you have a well paid job you will never accept the fact that what you're doing might not be so good after all..

Re: CSS now has an if() conditional function

#23
post #4

It's a great way to make conditional styles without having to use JavaScript; however, having used JS for years to make theme color and icon sets that rely on CSS properties, I'm not sure I particularly like this method. I feel like you have to smear a lot of logic across your CSS whereas with JS you can reduce your theme to a data structure and just have a simple function to setup all the CSS variables based on that…

Javascript always suffer from FOUC problem though (Unless it's server side). Although the if() css function seems to just be syntax suger of standard @media query. So it doesn't really add anything to solve existing problems.

Edited: It seems it can also be toggled from css variable? So it might actually fix some existing problems.

Re: CSS now has an if() conditional function

#24
post #21

Earlier quoted context omitted.

[flagged]

> And the other browser vendors with conflicitng interests just go along with it? When there's a conflict of interest they don't (Apple refuses to implement some APIs that would help making their walled garden app store more obsolete). But just maintaining a duopoly (Mozilla is funded by Google) is not a conflicting interest itself. > Did you come to that opinion after engaging in the discussions with them? With empl…

> When there's a conflict of interest they don't (Apple refuses to implement some APIs that would help making their walled garden app store more obsolete). But just maintaining a duopoly (Mozilla is funded by Google) is not a conflicting interest itself.

What makes you think Apple wants to maintain any sort of duopoly? Do you think they're happy that Edge became a Chrome skin?

> With employees? There's no point. If you have a well paid job you will never accept the fact that what you're doing might not be so good after all..

Damn, so you haven't even tried discussing your issues with the people responsible? You seem to have a really strong opinion on something you haven't engaged with at all.

Re: CSS now has an if() conditional function

#27

I'm not sure turning CSS into a full blown language is a good idea. With all the cascading in place, it is already a bit hard to determine why certain styles are applied. Now with this, we will be spending more brain cells debugging CSS issues.

On the contrary, a lot of the reason CSS is confusing is because it's full of insane hacks people have to do to get the behaviour they want. A straight-up if statement is much simpler than many of the horrors I've seen.

Re: CSS now has an if() conditional function

#28

I'm not really sure I understand this. How is the new if() conditional function different from using @media (width ...) when adapting layouts to browser width?

Its basically the same, just more convinent syntax.

I think if can also do string equality on variable values, which is a bit new but also niche. The main point is just to do @media but inside a property decleration.

Re: CSS now has an if() conditional function

#29
post #4

It's a great way to make conditional styles without having to use JavaScript; however, having used JS for years to make theme color and icon sets that rely on CSS properties, I'm not sure I particularly like this method. I feel like you have to smear a lot of logic across your CSS whereas with JS you can reduce your theme to a data structure and just have a simple function to setup all the CSS variables based on that…

The primary goal is to just have a more concise way to do @media queries. Its not intended as a replacement for most uses of JS

Re: CSS now has an if() conditional function

#30
post #9

If we could do it over, knowing that we'd eventually get to this point, would https://en.wikipedia.org/wiki/JavaScript_Style_Sheets have been the better path?

I would say no. I think CSS is a good language and made good choices.

And honestly we already essentially have this with CSS related apis in js. The examples in that article are basically identical to how you set css in js on modern web browsers with slightly different naming conventions.

Post reply on HN