-
Notifications
You must be signed in to change notification settings - Fork 282
fix(ui5-color-picker): add tooltip to sliders #10270
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -366,41 +366,43 @@ class ColorPicker extends UI5Element implements IFormInputElement { | |
| } | ||
|
|
||
| _setMainColor(hueValue: number) { | ||
| if (hueValue <= 255) { | ||
| const hueValueMod = hueValue * 4.251; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this magic number existed before, but this refactoring is an opportunity to set it to a constant. |
||
|
|
||
| if (hueValueMod <= 255) { | ||
| this._mainValue = { | ||
| r: 255, | ||
| g: hueValue, | ||
| g: hueValueMod, | ||
| b: 0, | ||
| }; | ||
| } else if (hueValue <= 510) { | ||
| } else if (hueValueMod <= 510) { | ||
| this._mainValue = { | ||
| r: 255 - (hueValue - 255), | ||
| r: 255 - (hueValueMod - 255), | ||
| g: 255, | ||
| b: 0, | ||
| }; | ||
| } else if (hueValue <= 765) { | ||
| } else if (hueValueMod <= 765) { | ||
| this._mainValue = { | ||
| r: 0, | ||
| g: 255, | ||
| b: hueValue - 510, | ||
| b: hueValueMod - 510, | ||
| }; | ||
| } else if (hueValue <= 1020) { | ||
| } else if (hueValueMod <= 1020) { | ||
| this._mainValue = { | ||
| r: 0, | ||
| g: 765 - (hueValue - 255), | ||
| g: 765 - (hueValueMod - 255), | ||
| b: 255, | ||
| }; | ||
| } else if (hueValue <= 1275) { | ||
| } else if (hueValueMod <= 1275) { | ||
| this._mainValue = { | ||
| r: hueValue - 1020, | ||
| r: hueValueMod - 1020, | ||
| g: 0, | ||
| b: 255, | ||
| }; | ||
| } else { | ||
| this._mainValue = { | ||
| r: 255, | ||
| g: 0, | ||
| b: 1275 - (hueValue - 255), | ||
| b: 1275 - (hueValueMod - 255), | ||
| }; | ||
| } | ||
| } | ||
|
|
@@ -436,7 +438,7 @@ class ColorPicker extends UI5Element implements IFormInputElement { | |
| // and HSL format, the color will be parsed to RGB | ||
| // 0 ≤ H < 360 | ||
| // 4.251 because with 4.25 we get out of the colors range. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment is now obsolete and should be deleted not to cause confusion. |
||
| const h = this._hue / 4.251; | ||
| const h = this._hue; | ||
|
|
||
| // 0 ≤ S ≤ 1 | ||
| const s = 1 - +(Math.round(parseFloat((y / 256) + "e+2")) + "e-2"); // eslint-disable-line | ||
|
|
@@ -497,7 +499,7 @@ class ColorPicker extends UI5Element implements IFormInputElement { | |
| this._isHueValueChanged = false; | ||
| this._hue = this.selectedHue ? this.selectedHue : this._hue; | ||
| } else { | ||
| this._hue = Math.round(hslColours.h * 4.25); | ||
| this._hue = Math.round(hslColours.h); | ||
| } | ||
|
|
||
| this._setMainColor(this._hue); | ||
|
|
||
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.
Usually, assigning to a new variable (
hueValueMod) and using it throughout the function, is necessary when you need both the passed param (hueValue) and the modified one (hueValueMod) at the same time. But if you'll only use the modified one, the best would be to just have:hueValue = hueValue * 4.251;and continue usinghueValuein the function as before.