Re: [csswg-drafts] [css-values-5] What is the MVP for inline conditionals on custom properties? (#10064)

We are planning a prototype of this in Blink, and it would be great to see some progress here.

As far as I can tell from reading the comments, there are two main syntax proposals:

**A) Comma/else, from @tabatkins / @Loirooriol:**

```
background: if(
    style(--status:error): red,
    style(--status:warning): yellow,
    else: green
);
```

 - Where `else` is a special condition that always evaluates to 'true'.
 - The value following `else:` is optional (i.e. may be empty).
 - IACVT if there is no matching condition.
 - The multiple-comma-separated-values problem is solved by #9539, e.g.:

```
background: if(
    style(--status:error): url(error.png), red;
    style(--status:warning): yellow;
    else: green
);
```

I see earlier proposals from Oriol have a plain `<declaration-value>` as the fallback (no `else:`), but I assume this isn't an option, since we couldn't distinguish a single fallback `<declaration-value>` from a `<cond> ':' <declaration-value>`. (See also #10818).

**B) ?:, from @LeaVerou:**

```
background: if(
    style(--status:error) ? red:
    style(--status:warning) ? yellow:
    green
);
```

 - Where the if-false branch is required to be present (but may be empty).
 - The capability of explicitly becoming IACVT is deferred to a future change.
 - The multiple-comma-separated-values problem is solved by not using commas to separate true/false, e.g.:

```
background: if(
    style(--status:error) ? url(error.png), red:
    style(--status:warning) ? yellow:
    green
);
```
---

I can live with either, but the fact that `<declaration-value>` allows `:` does weigh in favor of (A) in my opinion.

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


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

Received on Monday, 2 September 2024 13:34:15 UTC