-
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
Add label and valueText props to EuiProgress #3661
Conversation
Preview documentation changes for this PR: https://eui.elastic.co/pr_3661/ |
I've got a few a11y concerns about this... In #2983 I bring up the This is further complicated by looking at some accessible demos of each: In the progress bar code snippets, we can see that he uses a Even ignoring the I realize that this is a lot to bring up for a small PR that's trying to unify a pattern that's found in a couple places in Kibana but once it's in EUI, patterns tend to spread and become more difficult to retrofit accessibility onto. |
Thanks for the detailed explanation @myasonik! Do you have advice on how to actually proceed?
I'm honestly not too worried about this, it doesn't seem like a valid occurrence to begin with. We can always put up a callout in our docs mentioning that EuiProgress should not be contained within an EuiFormRow. |
Sorry if I'm underthinking the problem here. But the visual of the bar isn't needed for a screenreader if the text content is there. Can't we just aria hide the bar in this case? I get the meter concern if it was alone on it's own, but that's sort of a separate PR. For here we're just using it as a visual indicator along with text content, so it's easy enough to just hide it. Agree we should make a separate meter component at a later time though. |
@dave You're right, we could hide the
@cchaos The two options I see are:
|
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.
Accessibility concerns aside for the moment, I think this is a great first pass display/design-wise. Now, what we want to do is evaluate it from a flexibility and code maintenance side. Consider these couple things
- Is using
<EuiText>
necessary? It comes with a lot of baggage that once we get into a more modular structure, won't be necessary for this particular component. Like the fact that.euiText
is a giant blob of selectors and styles. Consider, just using simple spans with classes and using our text mixins. - There are now a lot of wrapping divs, can these be simplified?
- We're continuing to see consumer needs to pass props to inner elements. We should consider alway adding some sort of
labelProps
prop that allows them to pass anything to these elements. - Should
valueText
be created based onvalue
? Instead of asking them for this value again, what if we just spit out${value}%
? Then we'd change the prop to be some sort of enum or boolean. - Thoughts on making the Amsterdam theme display the progress bar with fully rounded corners?
For the accessibility side, let's go with option one for now. Hide the progress bar. I'll add making an |
@cchaos What if they want to show a |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3661/ |
Hmm, good point. We could do something like: /*
* If true, will render the percentage, otherwise pass a custom node
*/
valueText: boolean | React.node Then for the render: let valueRender;
if (typeof valueText === 'boolean' && valueText) {
// valueText is a true boolean
valueRender = `${value}%`
} else if (valueText) {
// valueText exists
valueRender = valueText
} |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3661/ |
Implemented the proposed solutions for a11y and for how to handle @cchaos I also made some adjustments for Amsterdam. Wondering if the |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3661/ |
EDIT: Made this idea into a follow up issue #3678 Trying to think of a way to join the label and value text so there's something more semantic tying them together rather than just proximity... I'm thinking maybe a <dl>
<dt>Men's clothing</dt>
<dd>80%</dd>
<dd aria-hidden="true"><progress /></dd>
</dl> If we introduced an extra prop for how to render the wrapping element, we could even extend this to better work with a whole list of these like in the demo. Something like: <dl>
<EuiProgress as="div" value={20} label={"Men's clothing"} max={100} />
<EuiProgress as="div" value={20} label={"Women's clothing"} max={100} />
<EuiProgress as="div" value={20} label={"Women's shoes"} max={100} />
<EuiProgress as="div" value={20} label={"Men's shoes"} max={100} />
</dl> Where |
I definitely see the benefit of using the
Let's consider just making the elements customizable, or we'll need to create a higher component like EuiListGroup that will create the whole element structure. With the risk of this PR continually expanding greater, let's table this discussion and put it into an issue for follow up. |
Good points! I made a follow up issue (#3678) for this so that we don't have to block this PR. |
I think just fully rounding them using |
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.
A few last comments about the code. I'm going to check out all the permutations/combinations locally now.
Preview documentation changes for this PR: https://eui.elastic.co/pr_3661/ |
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 great! Haha, sorry about the border-radius thing, I think the percentage format is old school thinking... 😊
Just one quick suggestion to your truncation solution, but LGTM
Preview documentation changes for this PR: https://eui.elastic.co/pr_3661/ |
Preview documentation changes for this PR: https://eui.elastic.co/pr_3661/ |
Summary
This PR adds the
label
andvalueText
props to be used with determinateEuiProgress
when creating bar charts layouts.EuiText
does not supportprimary
as a color so I created a helper class to be able to apply$euiColorPrimary
to thelabel
whencolor
is set toprimary
forEuiProgress
.I also added the corresponding example to the docs and a snippet to another example.
Fixes #3652
Checklist
- [ ] Checked Code Sandbox works for the any docs examples- [ ] Checked for breaking changes and labeled appropriately- [ ] Checked for accessibility including keyboard-only and screenreader modes