Re: [csswg-drafts] [css-values] A way to dynamically construct custom-ident and dashed-ident values (#9141)

So summarizing the discussion here and in #8320 into a proposal:
- Use `id()` and `data(foo)` functions that generate idents from attributes. (Alternatively `attr()` with an allow-list)
  These can be used directly in `ident` functions, in properties that accept idents, or in custom properties
- Use `ident("literal-string" some-ident-from-attr --some-ident-from-var)` to generate an ident that can be used anywhere that accepts an ident
- If a property accepts a single ident and nothing else, the `ident` function can be implied (like `url()` in certain cases)

So this for example would work:
```css
section {
  --the-id: id();
  --the-name: data(name); /* the data-name attribute value */
}

section .thumbnail {
  view-transition-name: "thumb-" var(--the-id) "-" var(--the-name);
  view-transition-class: any-thumbnail ident("th-" data(some-data-attr));
}
```

This still means that developers would need to figure out how unique IDs are created, but I don't see a way around it yet.


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


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

Received on Thursday, 11 April 2024 08:51:04 UTC