8000 [css-values] Type conversion functions · Issue #6408 · w3c/csswg-drafts · GitHub
[go: up one dir, main page]

Skip to content

[css-values] Type conversion functions #6408

@SebastianZ

Description

@SebastianZ

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:

    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:

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

Sebastian

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0