-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Added feature isHSL #1159
Added feature isHSL #1159
Conversation
@kurisu-gh, I will review this PR. |
Should values greater than 360 and lesser than 0 be invalid as the first parameter (hue)? Since it's a circle, you just have to account turns in order to get the right value. If you try this out in chrome devtools you'll see that the browser handles turns in the circle. |
You're right. I confirmed this myself in https://www.w3schools.com/colors/tryit.asp?filename=trycolors_hsl I just pushed some modifications to this PR that allows hue values larger than 360 and less than 0. +/- signs are also validated. I added some more test cases considering that modulo 360 is possible. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for the PR 🎉
@ezkemboi -- please have a look at this again. |
Alright, checking @profnandaa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left my feedback here @kurisu-gh, @GuiSchafer, and @profnandaa.
@kurisu-gh -- ping! |
Sorry for the delay! Was bogged down with work. I've pushed some updates and synced with upstream. This PR now handles the test cases that @ezkemboi brought up. But upon further reviewing of the MDM documentation, validating HSL is a bit more involved than I thought. To summarize:
So in short, the PR handles the additional checks requested by @ezkemboi as well as the optional alpha parameter. More work is needed to handle space-separated validation. I can continue development of this feature but it will be slow. If anyone wants to take over development of this, feel free. Also open to suggestions on simplifying my regex patterns. |
@ezkemboi -- ping ^ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good @profnandaa. @kurisu-gh has done even extra research and work which is amazing.
Good work @kurisu-gh and thanks once again.
Thank you for reviewing @ezkemboi and @profnandaa. Let me just update the readme in a little bit to note that an optional alpha parameter is also supported. |
@ezkemboi @profnandaa, updated the |
As suggested in #1156, I made an isHSL validator. It accepts padded zeroes and white spaces. I basically tried playing around with https://www.w3schools.com/colors/tryit.asp?filename=trycolors_hsl and checked what worked and what didn't work.
Summary of changes:
src/lib/isHSL.js
: Source of validatorsrc/index.js
: Modified to recognize newly created isHSLtest/validators.js
: Added test cases for isHSLREADME.md
: Added short description of isHSL