Skip to content

lab, lch, oklab and oklch syntax lowering does not support numeric values for L component #445

Closed
@fpapado

Description

@fpapado

The lab(), lch(), oklab() and oklch() functional notations support a numeric value for the L component. However, lightningcss only supports percentage values for those components, and bails out if a number is used.

In other words, these two declarations should be equivalent and lowered to background: #777:

.lch-percentage {
  background: lch(50% 0 223.97);
}
/* This is a valid representation as well (L [0,100] for lch()) */
.lch-number {
  background: lch(50 0 223.97);
}

But this is the output instead:

.lch-percentage {
  background: #777;
  background: lch(50% 0 223.97);
}

/* Stays intact, instead of being lowered */
.lch-number {
  background: lch(50 0 223.97);
}

Link to the playground, showing the lack of lowering for the numeric L component

Expected behaviour

  • lch() should allow numeric values of [0,100] for the L component
  • lab() should allow numeric values of [0,100] for the L component
  • okch() should allow numeric values of [0,1] for the L component
  • oklab() should allow numeric values of [0,1] for the L component

Note the difference in the numeric range: lch() and lab() define them as [0,100] corresponding to 0% and 100%, while oklch and oklab define them as [0,1.0] corresponding to 0% and 100%.

Reference for lch() and lab() numeric range
Reference for oklch() and oklab() numeric range

Please let me know if there is any other information that I can provide, or whether I missed something! I would be happy to contribute a PR for this :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions