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

hsl() not getting colorized #3625

Closed
PRR24 opened this issue Jun 9, 2021 · 6 comments
Closed

hsl() not getting colorized #3625

PRR24 opened this issue Jun 9, 2021 · 6 comments

Comments

@PRR24
Copy link

PRR24 commented Jun 9, 2021

According to documentation https://lesscss.org/functions/#color-definition-hsl
hsl() function should output a color, but it does not. rgb() and hsv() behave as documented.

$ npx lessc --version
lessc 4.1.1 (Less Compiler) [JavaScript]
$ cat problem.less 
.problem {
  color: rgb(128, 255, 0);
  background-color: hsl(90, 100%, 50%);
  border-color: hsv(90, 100%, 50%);
}
$ npx lessc problem.less 
.problem {
  color: #80ff00;
  background-color: hsl(90, 100%, 50%);
  border-color: #408000;
}
@PRR24
Copy link
Author

PRR24 commented Jun 9, 2021

Triangulated:

$ npx less@3.8.0 problem.less 
.problem {
  color: #80ff00;
  background-color: #80ff00;
  border-color: #408000;
}
$ npx less@3.8.1 problem.less 
.problem {
  color: #80ff00;
  background-color: hsl(90, 100%, 50%);
  border-color: #408000;
}

@matthew-dean
Copy link
Member

Not sure what the issue is. hsl() is a valid color value in CSS. Less, in general, tries to preserve original color formats.

@matthew-dean
Copy link
Member

@PRR24 If the issue is that it doesn't match documentation, it's more an issue of the documentation.

@PRR24
Copy link
Author

PRR24 commented Jun 10, 2021

Well, rgb() is also a valid color, but its gets converted nevertheless...
I don't mind hsl(), but problem is consistency. Currently some color functions return hsl while come return color.

@color-base: hsl(90, 100%, 50%);
@color-dark: darken(@color-base, 20%);
@color-avg: average(@color-base, @color-dark);

.problem {
  color: @color-base;
  background-color: @color-dark;
  border-color: @color-avg;
}
$ npx less@4.1.1 problem.less 
.problem {
  color: hsl(90, 100%, 50%);
  background-color: hsl(90, 100%, 30%);
  border-color: #66cc00;
}

If one has an additional use for the computed values, for example creating a color list for external use, it is bit of a mess.

If you find that hsl() handling in its current form is better (and there are understandable arguments for it), please adjust the documentation and concider adjusting all possible color functions to return computed value according to the format of its parameters, so that average() in the example above would return hsl(90, 100%, 40%)

Thanks.

@iChenLei
Copy link
Member

iChenLei commented Jul 8, 2021

All Color process logic located at packages/less/src/less/tree/color.js and packages/less/src/less/functions/color.js .

If you find that hsl() handling in its current form is better (and there are understandable arguments for it), please adjust the documentation and concider adjusting all possible color functions to return computed value according to the format of its parameters, so that average() in the example above would return hsl(90, 100%, 40%)

If you are interested in this work, please help us to improve less doc. Thanks

less doc repo -> https://github.com/less/less-docs , example PR less/less-docs#551

@arronKler
Copy link

There really have some updates about colors on v3.8.1. hsl() will keep instead of converting to hex color. The document (https://lesscss.org/functions/#color-definition-hsl) is outdated.

Changelog: https://github.com/less/less.js/blob/master/CHANGELOG.md#v381-2018-08-08
Related Pull request: #3291
Related Issue Comment: #3290 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants