Re: [csswg-drafts] [css-properties-values-api] A compact syntax for registering global constants/custom properties (#9206)

I agree with @tabatkins that mass registration and global variables are separate issues. 

It would be good to support a way of declaring global declarations that doesn't just center around custom properties, to address the needs for things like `::document` and friends that keep popping up ([here's one from just the other day](https://github.com/w3ctag/design-reviews/issues/851#issuecomment-1651519458))

An important requirement for these globals is that **they need to be able to express values that depend on other globals**, otherwise their utility for things like design systems will be limited.

For example, consider:

```css
--color-magenta-h: 335;
--color-magenta-s: 90%;
--color-magenta-l: 50%;
--color-magenta: hsl(var(--color-magenta-h) var(--color-magenta-s) var(--color-magenta-l));
--color-accent: var(--color-magenta);
--color-accent-lighter: hsl(from var(--color-accent) h s calc(l * 1.2));
/* etc etc */
```

(sure, wider adoption of CSS Color 5 will reduce the need to specify components separately, but the rest still applies...)

Would the `env()` solution support that?
I suppose it could be defined as basically "`var()` that only draws from properties defined within a `::global` rule (or whatever we call it).

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


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

Received on Tuesday, 22 August 2023 03:39:39 UTC