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. 

I think I might be misunderstanding your proposal because I’m not sure how `self()` would get grandparent values without custom properties? (and if custom properties are fair game, `inherit()` on the parent works fine)

> afaik `inherit()` would not solve this, and it would require some long prop-drilling-style implementation.

What do you mean by "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.

It’s not about whether the value is known, if you're specifying the value on an untyped property, it gets passed down as a list of tokens, the same as if you use another known function, e.g.:

```css
.parent { --foo: calc(1em + 10px); }
.parent .child {  font-size: var(--foo); }
```

If `--foo` is untyped here (i.e. not declared via `@property`, it will just pass down `calc(1em + 10px)` as a list of tokens, which will be interpreted on `.child`, and use its own em sizing, even though the function used is typed in itself (if used somewhere else). Tokens only have meaning depending on the place they are used, not independently, and tokens in untyped properties do not have meaning.

> 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.

I was talking about the `self()` proposal, my understanding is we're discussing declarative functions in another issue? This is independent of declarative functions, right? 🤔 

> 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. 🙂

Same!



-- 
GitHub Notification of comment by LeaVerou
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9459#issuecomment-1761554573 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 13:50:11 UTC