Skip to content

Space-separated color params and aliases aren't parsed correctly #235

@claviska

Description

@claviska

This is an excellent library!

Thanks to a generous PR by @ajmchambers, TinyColor is now being used to power the color picker in Shoelace. 🎉

While reviewing the PR, I noticed a few small parsing blips that could be improved. On the website, the following space-separated color params fail to parse. All of the following are equivalent and should result in white @ 25% alpha, or #ffffff40.

rgb(255 255 255 / 25%) => #ffffffff
rgb(255 255 255 / .25) => #ffffffff

hsl(0 0% 100% / 25%)   => #ffffffff
hsl(0 0% 100% / .25)   => #ffffffff

The resulting values are all white, but with 100% instead of 25% alpha.

Similarly, rgba and hsla are effectively aliases of rgb and hsl now, but alpha is only considered when the alias is used.

rgb(255, 255, 255, 25%)  => #ffffffff
rgb 255 255 255 .25      => #ffffffff

rgba(255, 255, 255, 25%) => #ffffff40
rgba 255 255 255 .25     => #ffffff40

Let me know if you need any additional info on this!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions