Live data from Hacker News

CSS Variables landing in Chrome 49

developers.google.com

51–60 of 70 posts

Re: CSS Variables landing in Chrome 49

#51
post #49
post #47

Is there a way to access it from javaScript? Can JS code set CSS --color and make it change.

It looks like this can be changed with `setProperty`. There's a demo[1] that works on Firefox 31+ and Chrome 49+ [1] https://www.broken-links.com/2014/08/28/css-variables-updati...

Thanks. I wonder if it could be creatively misused to act as a database.

Re: CSS Variables landing in Chrome 49

#52
post #18

Earlier quoted context omitted.

The CSS team has people like this, who no longer make websites: https://www.w3.org/People/Bos/CSS-variables Thus they're disconnected from current web developers. Meanwhile Smashing says something like 77% of audience uses SASS.

Ah, Bert Bos, the W3C's "style activity lead". What a joke. He's the guy who wasted a decade writing an ASCII-art based "template layout module"[1], which he was never able to persuade a single browser vendor to implement. It eventually got demoted from a working draft to a "note", which is the W3C's polite term for standards fanfiction. His other major achievement is putting his own photo on every one of the CSS wor…

To be fair though, I should also say that nowadays the CSS working group has a lot of very smart people who absolutely understand the needs of web developers/designers, and have been tireless in getting things like Flexbox specced and implemented across different browsers.

CSS is about a decade behind where it should be, but that's not the fault of the people working on it now. And I think its future is actually comparatively bright, especially with the Houdini project taking off.

Re: CSS Variables landing in Chrome 49

#53
post #18

I've wondered for years why we're using pre-processing to get variables into CSS. Given that there hasn't been a commonly advocated workflow that didn't include some sort of CSS processor (like LESS or SASS) in about a decade, it seems like somebody working on the standards would have realized that CSS needed variables, at the very least. So, it's cool that it's coming, though it's taken a lot longer than I reckon it…

The CSS team has people like this, who no longer make websites: https://www.w3.org/People/Bos/CSS-variables Thus they're disconnected from current web developers. Meanwhile Smashing says something like 77% of audience uses SASS.

That website is a stunning statement of the author's CSS skills.

Re: CSS Variables landing in Chrome 49

#54
post #42

Earlier quoted context omitted.

you are using reg keys to store properties? is it a chromium app?

He was just explaining how it worked in Windows 95, he will be using CSS variables instead.

She, and yes, that's the idea. I couldn't explain it very clearly.

Re: CSS Variables landing in Chrome 49

#55
post #7

The syntax is verbose and ugly compared to SASS

I think a lot of people agree with you but there is a reason: http://www.xanthir.com/blog/b4KT0

I understand the reasoning, but this new syntax is still kind of verbose and ugly. I think one of the reasons Sass has been so successful is that it is elegant. It adds a lot of functionality to CSS, but does so in a way that feels very much at home. This new syntax doesn't feels very elegant and it doesn't feel at home with current CSS syntax.

Re: CSS Variables landing in Chrome 49

#56
post #4

Ok, that's cool. How long until we're able to use this and not have to worry about browser incompatibilities?

You can use it today with the help of http://cssnext.io

You can use a limited subset. cssnext isn't magic, it's purely a source transformation, there's no runtime. It can't handle the dynamic part of css variables.

Re: CSS Variables landing in Chrome 49

#58
post #16

Just add native support for Sass and call it a day.

SASS encourage developers to build long chains of selectors and it makes them brittle and non-reusable.

CSS offers plenty of ways to hang yourself without resorting to SASS. The people who are dangerous with SASS tend to already be just as dangerous with plain CSS, in my experience.

The additional options for self harm are well offset by the features.

Re: CSS Variables landing in Chrome 49

#59
post #22

For those commenting about SASS having this forever etc, note that this goes a step further: :root { --color: blue; } div { --color: green; } #alert { --color: red; } * { color: var(--color); } You can't accomplish that with SASS today. More info [0]. In fact, this feature isn't even covered with cssnext: The current transformation for custom properties aims to provide a future-proof way of using a limited subset (to…

If you're interested in seeing what happens next with CSS Variables, check out the CSS Houdini project https://drafts.css-houdini.org

It starts with a JS API for more control over CSS Variables (which are actually called Custom Properties), and then goes into APIs for custom renders and even custom layout engines, all controlled via JS + Web Workers

Re: CSS Variables landing in Chrome 49

#60
post #22

For those commenting about SASS having this forever etc, note that this goes a step further: :root { --color: blue; } div { --color: green; } #alert { --color: red; } * { color: var(--color); } You can't accomplish that with SASS today. More info [0]. In fact, this feature isn't even covered with cssnext: The current transformation for custom properties aims to provide a future-proof way of using a limited subset (to…

Also on the topic of things SASS cannot do:

Custom Properties effectively enable "styling APIs" to be declared for Custom Elements that have a shadow root, since Custom Properties cascade across shadow boundaries (detail in parent's [0]).

Post reply on HN