Earlier quoted context omitted.
Stupid decision, the should have used $foo (dollar sign for variables) like in Perl and PHP. It remind me decisions of standards based on XML (XLST, XML-Schema, RDF, etc).
Read the linked post. Css variables are nothing like macros like sass's `$foo` and css might support macros with sass's `$foo` syntax in future.
CSS Variables landing in Chrome 49
61–70 of 70 posts
Re: CSS Variables landing in Chrome 49
#62Just add native support for Sass and call it a day.
Re: CSS Variables landing in Chrome 49
#63Re: CSS Variables landing in Chrome 49
#64I'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…
(There's also a large focus, in v1 here, on the variables use-case, because that's what I needed to sell it to the group at the time. The CSS Houdini Task Force is now expanding Custom Properties properly, so they can actually be used for random JS things without a ton of hackery.)
Re: CSS Variables landing in Chrome 49
#65Earlier 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…
This is because it was absorbed into the larger and more fleshed-out Grid specification, which is nearly release-ready in multiple browsers. The ASCII art is actually really useful!
Re: CSS Variables landing in Chrome 49
#66Earlier quoted context omitted.
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.
We could only have used $foo if we hewed very close to Sass's functionality - global macros that operate at the stylesheet's lexical level. That wasn't what we wanted to do, though, either at the time (considering only the variables use-case) or looking forward (to the use of custom properties as the generic "inject info into your page via the CSS engine", a la data attributes for HTML).
By avoiding global macros, we also get context sensitivity - we can actually offer APIs for this stuff that are smarter than "here's the string you set". When we add custom pseudoclasses, custom media queries, etc they'll all get their own useful APIs. Sass is stuck with string manipulation, because you can use a Sass var anywhere, so it's impossible to infer anything about it.
Re: CSS Variables landing in Chrome 49
#67Earlier quoted context omitted.
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.
It's nice if you really want to utilize the current syntax, but it's less powerful than either option it's derived from.
Re: CSS Variables landing in Chrome 49
#68I'm not a fan of this... /* JS */ var styles = getComputedStyle(document.documentElement); var value = String(styles.getPropertyValue('--primary-color')).trim(); // value = 'red' Rather than calling '--primary-color', you should really be able to call 'color' which points to the variable and will still return red. Otherwise you'll have to know the name of each variable being used, which is much more difficult than kn…
If you use an API that gives you the value at an earlier time, like el.style.color (which is "specified value"), you'll see the var().
Re: CSS Variables landing in Chrome 49
#69Just add native support for Sass and call it a day.
We can do lots of amazing things in the ecosystem, but often we're working around missing primitives in the platform. Just "adding native support" for today's hottest library doesn't fix things properly. It's better to figure out what problem they were solving, and then fix that problem more directly.
(jQuery is largely solving "DOM APIs suck". We've fixed that a little bit, with things like query() (née querySelector(), which was an awkward first attempt at it) and fetch(), but are still struggling to work through browser dev apathy at things like event registration or creating elements.)
(Figuring out what problem, precisely, React is solving is exciting and interesting. It's non-obvious - it's not just "some DOM things are slow", as there's lots of DOM things both fast and slow, and you don't need a fancy (read:slow) tree-diffing algo to fix those. There's something fundamental going on that we might be able to do better - maybe it's more fully separating the "display thread" that contains DOM from the rest of your JS, and letting you do a lot of DOM-ish manipulation in threads other than the display thread. Maybe that means actually using an even more lightweight display abstraction, so you can cheaply spam out updates without having to do expensive diffing first. There's a lot of possibilities here.)
Re: CSS Variables landing in Chrome 49
#70Just add native support for Sass and call it a day.
"Just add native support for jQuery and call it a day" "Just add native support for React and call it a day" We can do lots of amazing things in the ecosystem, but often we're working around missing primitives in the platform. Just "adding native support" for today's hottest library doesn't fix things properly. It's better to figure out what problem they were solving, and then fix that problem more directly. (jQuery…
The problem was that every old browser had its own API and feature set. Jquery abstracted over all that, including bugs in specific versions of browsers and continually is updated to handle the case of a browser claiming to implement a feature but lying.
Really if all browsers had the same API and feature set, there'd be no need for jQuery as it is today; you'd have a very different library.