Re: [csswg-drafts] Introduce `self()` function [css-values] (#9459)

@LeaVerou Thanks for the added context.

For the example I included, passing down the nested radius to a child is a simpler example. In many cases, someone would add a border-radius on a great-grandparent and need to pass that several layers down to make it visible. afaik `inherit()` would not solve this, and it would require some long prop-drilling-style implementation.

Also, I think it could be possible to use `self(padding-bottom)` as `self()` would only work on known properties, and most if not all native properties have very few possible types. We could restrict this to only work on simpler/primitive types.

I definitely do not intend to down-play the complexity of a proposal like this. I simply do see significant value-add.

One of the primary places I see value is being able to re-use styles more modularly, where styles can work where they are added contextually, without needing to manually create variables every place you want to do something like this.

In the border-radius example, you would need to set up all those different variables each time, but with `self()` (and declarative functions), anywhere you were to use the `--get-nested-radius()` it could dynamically pick up those values without needing to set up multiple variables to pass in as args.

This is just one example. I know there's [an issue](https://github.com/w3c/csswg-drafts/issues/7707) already open to simply nested radii, which is what initially birthed this proposal, but there are countless other use cases for this.

---

Please know—as tone/intent gets lost so easily online—I'm not trying to be stubborn here. I'm just thinking out loud. Thanks for thinking through this with me. 🙂

-- 
GitHub Notification of comment by brandonmcconnell
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9459#issuecomment-1760583799 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Friday, 13 October 2023 00:30:43 UTC