-
Notifications
You must be signed in to change notification settings - Fork 82
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
Add a new Coral Color Picker component. #179
Conversation
_stepY() { | ||
return 0.01; | ||
} | ||
|
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.
since all these are const values. you can add a getter like
get _minX() { return 0; }
and then you can use it as property rather than function
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.
The major difference I see b/w property and _minX function is:
Property can be changed by the consumer of the class while _minX function always returns the const value.
We want to keep min, max, step values constant.
I don't know any benefit of accessing a property over a function call. Accessing a property is same as calling getter function.
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 corresponds more to a property rather than function. Generally the the property starting with underscore is private and should not be changed, in case consumer is changing its consumer faults.
you can still avoid the change by adding an empty setter
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.
To avoid getter/setter functions , we can simply define these constants in constructor.
e.g.
constructor(){
this._minX= 0;
this._maxX = 100;
}
Properties are meant to be set/get by consumers to change the component's behaviour.
} | ||
if(this.y !== y) { | ||
this.y = y; | ||
this.trigger('change'); |
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.
We will be calling a change event twice in case both value change. If possible can we trigger only one change event, when both or one of the values get changed
The color string | ||
*/ | ||
extractHsv(colorString) { | ||
const exp = /^hsva?\((\d{1,3}),\s*(\d{1,3}%),\s*(\d{1,3}%)/; |
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.
Please add a single line comment explaining the regex, would be useful for future. Please do it for all regex as well.
Thank you
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 didn't tried this visually apart from that LGTM.
@Pareesh You can try this here - http://indra-imac.corp.adobe.com:9001/examples/ |
c9c4ddf
to
b55788a
Compare
@majornista Could you please review this for accessibility? |
192a7f9
to
03e9f43
Compare
1. ColorArea is currently just for Saturation and Brightness/Value. With luminosity, 50% is fully saturated, 100% is white and 0% is black, so its important to be clear about which values the slider controls. 2. We should use `aria-valuetext` to report the value of each slider. 3. The ColorPicker overlay should have aria-live="off", otherwise the value change to the text input announces assertively instead of the value of the slider that changed. 4. I added a degree symbol to the aria-valuetext of the Hue slider.
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 opened a PR with some suggested changes for accessibility: indra2gurjar#2
fix(adobe#179): Suggested changes to ColorArea to improve accessibility
FWIW, I have a PR open for React-Spectrum that implements a ColorArea with support for HSL and RGB in addition to HSV: adobe/react-spectrum#1732. See: https://reactspectrum.blob.core.windows.net/reactspectrum/d02b605cb71505dbf074eb9f3b54c9174538bc8c/storybook/index.html?path=/story/colorarea--default-hsb-xchannel-saturation-ychannel-brightness for an example. |
add translation provided by translation team.
* Add a new Coral Color Picker component. * dependency at tiny * Fix axe * lint * add package-lock * update examples * @trivial * Fixed * Add formats support. * Tests ColorArea * fix(#179): Suggested changes to ColorArea to improve accessibility 1. ColorArea is currently just for Saturation and Brightness/Value. With luminosity, 50% is fully saturated, 100% is white and 0% is black, so its important to be clear about which values the slider controls. 2. We should use `aria-valuetext` to report the value of each slider. 3. The ColorPicker overlay should have aria-live="off", otherwise the value change to the text input announces assertively instead of the value of the slider that changed. 4. I added a degree symbol to the aria-valuetext of the Hue slider. * Tests ColorSliderHue * Test ColorProperties. * test * Test ColorPicker * coverage * large style * support large * Add 1 second debounce for change event. * cleanup * add translation provided by translation team. Co-authored-by: igurjar <igurjar@adobe.com> Co-authored-by: Michael Jordan <mijordan@adobe.com> Co-authored-by: Mohit Arora <mohiaror@adobe.com>
# [4.12.0](v4.11.1...v4.12.0) (2021-09-16) ### Features * **ColorPicker:** Add a new Coral Color Picker component. ([#179](#179)) ([eb1b4d6](eb1b4d6))
🎉 This issue has been resolved in version 4.12.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Description
We are adding a new ColorPicker component which can support multiple formats like - HSL, HSV, RGB, HEX, HEX3, HEX4, HEX8, Name etc.
The component is similar to ColarArea component in Spectrum - https://spectrum.adobe.com/page/color-area/
For color format conversions library '@ctrl/tinycolor' is used.
At some places we are converting hsv/hsl color string since tinycolor doesn't preserve hue at S/L boundaries.
Color conversion in different formats loose details so it's done minimal and at many places color strings are generated for hsl/hsl format.
Related Issue
https://jira.corp.adobe.com/browse/CUI-7445
https://xd.adobe.com/view/4565a1db-3df7-4483-8246-3a0e4882c842-1036/screen/e4cae491-ff98-49ce-9161-264e6abc03ef
https://stock.adobe.com/
Motivation and Context
Existing ColorInput component does support only few formats like - RGBA and color swatches only.
This new Color Picker provides user a way to select colors in the natural way where user can select a fully saturated hue(color) from ColorSlider, then user can change saturation and luminosity.
Color input-output supports most of the formats.
Alpha channel selector isn't added currently and can be added later. This isn't required for CUI-7445.
User can still change alpha manually.
How Has This Been Tested?
Only manually.
Component can be seen in action at - http://indra-imac.corp.adobe.com:9001/examples/
We are planning to add unit test in the PR.
Screenshots (if appropriate):
Types of changes
Checklist: