-
Notifications
You must be signed in to change notification settings - Fork 844
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
EuiColorPicker
opacity support
#2850
Conversation
Maybe render the color over a repeating checkboard pattern to show the transparency? |
I think that only works for large images. The swatches are so small, that this will just cause noise and confusion as to what's going on. Just a simply applying the opacity to the swatch is ideal. |
No I think we're fine here but I do think the hex value in the input should be the full 8-digit representation. Right now there's no indictor of the opacity value in the input.
No, just the output (indicator in the text input)
Yes but just from the pre-populated swatches which could also contain their own opacity values. |
Thought about this some more after a question from @cchaos. I think this should instead:
We could go with 6- and 8-digit hex support only for now, but I doubt consumers have and can use 8-digiit hex values without further conversion (IE11 support, for instance). rgba input support seems necessary for automatic alpha value parsing. This approach would also prevent the breaking change to |
^ Still have quite a bit of clean-up to do (e.g., validation in the docs), but you can give it a test drive now. Still thinking on:
|
A couple of feedback items from a visual/functional test:
Unrelated |
import { useColorPicker } from './utils'; | ||
|
||
export const Alpha = () => { | ||
const [color, setColor, errors] = useColorPicker('#D36086'); |
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.
Looks like useColorPicker
is probably a service we'll want to document and export if it's this helpful in a consuming application?
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.
Going to open an issue for this. I hadn't thought about it, but it does seem really useful and could be something of a pattern for other relatively simple form-like components.
@cchaos Still working on item No. 1 (see-through color stops handle), but Nos. 2 and 3 are fixed. As for the "Unrelated" items:
|
Yep. This was a valid request from Maps. They have situations where the color doesn't start until a certain point. The best way to illustrate that was to use gray since that felt "disabled" |
I think we should just remove the toggles from the docs. You can pass
Yes I think EuiBadge should still warn, but instead of warn AND show a transparent background (which as you can see also invalidates the contrast), it should at least not respect alpha channels. Chroma might have a function that does this? |
Chroma can help with this, for sure. I'm going to open an issue for it, because we'll want to change validation and error messaging at the same time. Somewhat related to #2804 |
Preview documentation changes for this PR: https://eui.elastic.co/pr_2850/ |
That one, on the other hand, was real! 🎉 |
Preview documentation changes for this PR: https://eui.elastic.co/pr_2850/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_2850/ |
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.
Looks good from my side! 🎉
Preview documentation changes for this PR: https://eui.elastic.co/pr_2850/ |
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.
Have a mix of comments, suggestions, and requests. Haven't yet done a full review of the components' internal changes, as I suspect some of this review will impact that area as well.
Preview documentation changes for this PR: https://eui.elastic.co/pr_2850/ |
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.
Some small suggestions; this looks great though!
Preview documentation changes for this PR: https://eui.elastic.co/pr_2850/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_2850/ |
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.
Changes LGTM; Pulled & tested locally. Thank you @thompsongl for the effort & dedication on this one!
Also: quick changelog entry before merging 🥇 |
Preview documentation changes for this PR: https://eui.elastic.co/pr_2850/ |
Summary
Resolved the primary goal of #2629.
EuiColorPicker
color
prop and text input will now accept hex and RGB(a) values, automatically parsing opacity and format.EuiColorPicker
onChange
now has a second parameter, which is an object containing thergba
andhex
representations of the input (('#hex', [r,g,b,a])
), as well as anisValid
flag.showOpacity
will render the range input selectorComing soon(ish)
I think there will be 1 additional PR after this:
Add the option to render a hex input in the popover, as seen in #2629 (comment). May involve a refactor of
EuiColorStops
.Checklist