Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(color): allow all valid CSS colors #2381

Merged
merged 1 commit into from
Jul 17, 2020
Merged

Conversation

WilcoFiers
Copy link
Contributor

@WilcoFiers WilcoFiers commented Jul 15, 2020

Add support for the following notation styles

  • Hex number colors
  • hsl / hsla color functions
  • named colors
  • space separated function notation
  • decimal numbers in colors
  • percentages in colors
  • exponent numbers
  • deg / rad / turn unit in hue

DEPREDATED: Color.parseRgbString() is replaced by Color.parseString()

This PR is a prerequisite for #2334

Reviewer checks

Required fields, to be filled out by PR reviewer(s)

  • Follows the commit message policy, appropriate for next version
  • Code is reviewed for security

Add support for the following notation styles
- Hex number colors
- hsl / hsla color functions
- named colors
- space separated function notation
- decimal numbers in colors
- percentages in colors
- exponent numbers
- deg / rad / turn unit in hue

DEPREDATED: Use Color.parseString() instead of Color.parseRgbString()
@WilcoFiers WilcoFiers requested a review from a team as a code owner July 15, 2020 09:12
Copy link
Contributor

@straker straker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a comment but you can implement it if you'd like

*/
this.parseString = function(colorString) {
// IE occasionally returns named colors instead of RGB(A) values
if (standards.cssColors[colorString] || colorString === 'transparent') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to have transparent be a named color with vales of [0, 0, 0] rather than special casing it three times? (first in the if, again with the color assignment of || [0,0,0], and last with the alpha). We could just only special case the alpha if it's transparent if it was a named color.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought about that, but I don't think that's all that clean of a solution. I had it in a separate if statement at first. I can put that back in if you prefer. Personally, this seems fine to me.

Copy link
Contributor

@straker straker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update pr title to feat as we are deprecating a public API

@WilcoFiers WilcoFiers changed the title fix(color): allow all valid CSS colors feat(color): allow all valid CSS colors Jul 17, 2020
@WilcoFiers WilcoFiers requested a review from straker July 17, 2020 09:00
@WilcoFiers WilcoFiers merged commit 63d69ea into develop Jul 17, 2020
@WilcoFiers WilcoFiers deleted the hsl-color-support branch July 17, 2020 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants