functions in stylesheets? That's nuts. The web is developing in the wrong way.
CSS preprocessors like Sass have had functions for, like, ever.
CSS Custom Functions are coming
81–90 of 90 posts
Re: CSS Custom Functions are coming
#82Oh man, and I thought the current JS status-quo was already full of vulnerabilities and privacy risks. If I had mind-boggling amounts of money, one of the things I would do is start an organization to name and shame and give anti-awards to websites that most abuse javascript and whatever-this-will-be. Or a dang mutual fund: "Like an index fund except we don't support companies with websites that require a ridiculous…
Okay you had your FUD, now for the just desserts: This is actually a feature that is likely to reduce the amount of JS that needs to run on the web. It allows for common component-oriented styling patterns to be employed without bloating CSS bundles or using runtime CSS-in-JS functionality to accomplish it. Source: I work on a web development platform (booo, hisss)
Re: CSS Custom Functions are coming
#83Thanks. Looks hideous. @function --light-dark(--light, --dark) { result: var(--light); @media (prefers-color-scheme: dark) { result: var(--dark); } }
Is it more like - result is a variable that can be redefined over and over during the function, and whatever value it is at the end, is what’s returned?
Re: CSS Custom Functions are coming
#84Re: CSS Custom Functions are coming
#85Earlier quoted context omitted.
It’s just a new addition and change, doesn’t dictate you must write that way. I still use as a tag (I know, HTML).
It's not about how they write CSS, it's about how everyone else does, and what browsers will need to be able to process. I don't know how you figured their complaint is somehow compat breakage. From what I know, CSS doesn't really have breaking changes.
Re: CSS Custom Functions are coming
#86Earlier quoted context omitted.
coming to all major browsers Chrome, Chrome, Chrome, and Chrome?
Too many on HN seem to forget that Safari exists and has a large market share. If you break Safari then no one on an iPhone or iPad can use your site. That's an unacceptable level of breakage for almost every site, and is enough to ensure that if Apple doesn't implement it it won't be used. Ironically, Apple's walled garden is the last thing standing between Google and total web dominance.
A CSS issue is not going to break any site unless it causes interactive elements to overlap or be hidden from view. Most sites do not implement bleeding-edge features for this reason. Those that want to set it up will do it in such a way that there's a fallback for browsers that don't support that function.
Re: CSS Custom Functions are coming
#87Was https://en.wikipedia.org/wiki/JavaScript_Style_Sheets right all along?
Re: CSS Custom Functions are coming
#88I'm confused at all the negativity? I am personally very excited for this feature, it's going to enable one to use less JavaScript,and CSS to accomplish things that should be easy.
Re: CSS Custom Functions are coming
#89Oh man, and I thought the current JS status-quo was already full of vulnerabilities and privacy risks. If I had mind-boggling amounts of money, one of the things I would do is start an organization to name and shame and give anti-awards to websites that most abuse javascript and whatever-this-will-be. Or a dang mutual fund: "Like an index fund except we don't support companies with websites that require a ridiculous…
Okay you had your FUD, now for the just desserts: This is actually a feature that is likely to reduce the amount of JS that needs to run on the web. It allows for common component-oriented styling patterns to be employed without bloating CSS bundles or using runtime CSS-in-JS functionality to accomplish it. Source: I work on a web development platform (booo, hisss)
The bulk of JS executed on websites today seem to be for 2 things:
- serving ads and tracking
- running a single-page app framework
Can something like this really derail the React/Vue train?
Re: CSS Custom Functions are coming
#90This 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 is…
Can these be used as mixins? I looks like there’s only a single return value. Edit: Looks like mixins are planned: https://github.com/w3c/csswg-drafts/issues/9350#issuecomment...