[csswg-drafts] [css-values] Type conversion functions (#6408)

SebastianZ has just created a new issue for https://github.com/w3c/csswg-drafts:

== [css-values] Type conversion functions ==
In #542 there was already some discussion about whether type conversion for strings should be im- or explicit. And it seems the conclusion was to be explicit about that.

I'd like to go a step further and start the discussion whether other type conversion functions should be introduced, too.

One use case I had today was that I wanted to use a counter within a calculation, i.e. something like `calc(counter(x) * 3)`. Though that currently doesn't work because `counter(x)` doesn't return a numeric value.

This could be approached in two ways:

1. One conversion function that is able to convert any type into any other type. This would require several parameters for the value to convert, the type to convert to and an optional unit.

    Examples:
    ```css
    grid-row-start: calc(convert(counter(x), "<numeric>") * 3);
    height: convert(counter(x), "<length>", "em");
    content: convert(5, "<string>");
    transform: rotate(convert("45", "<angle>", "deg"));
    ```

2. One conversion function for each type.

    Examples:
    ```css
    grid-row-start: calc(number(counter(x)) * 3);
    height: length(counter(x), "em");
    content: string(5);
    transform: rotate(angle("45", "deg"));
    ```

Sebastian

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/6408 using your GitHub account


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

Received on Thursday, 24 June 2021 12:58:42 UTC