-
Notifications
You must be signed in to change notification settings - Fork 121
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
feat(legend): add legend item actions #749
Conversation
|
||
&:not(&--hidden) { | ||
.echLegendItem__color--changable { | ||
cursor: pointer; | ||
} | ||
} | ||
|
||
&__main { |
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.
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.
probably moving the 4px padding of the echLegendItem
to the __main
could solve the issue
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 see what you are saying here but I'm having trouble with solution. You idea of putting the padding on the __main
would work but the blue background would be extended to the added padding and applying it as a margin will not trigger the hover event.
The solution I came up with was to wrap the __main
element in another element to apply the padding and use that elements hover state to trigger the action. Not ideal nesting divs but better than other ideas I think.
The series will still be highlighted on the chart when hovering over the
additionalValue
element but I think that look fine.
Alternatively, I was playing with moving the mouse event from the whole container to the label but this was not a great solution as it made things very clunky, and still didn't fully solve the issue.
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.
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've tested that and I'm not convinced, I think we should ask @miukimiu what she thinks about that.
Few doubts I have:
- I think we should highlight the whole text row, including the value on the left.
- the visual feedback of the series highlight action (the blue highlight), coming from the mouse hovering an element on the legend, should be rendered visually whenever the mouse enters the active area
- the highlight should be consistent and should not turn off and on when moving from a label the other (as it's currently doing)
- the same highlight will be used with when using the keyboard to navigate the legend, probably also @myasonik has some ideas on how it's better to place this focus
In case, at the moment we can add the legend actions without thinking about this visual feedback, and we can reason about it when working on the keyboard navigation, what do you think?
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 think the new design you're proposing much better calls out the ability to interact with it and simplifies the focus management quite a bit. I'm +1 on the new design.
That said, if y'all still really wanted the old design, you could do it with some :focus-within
and +
CSS operator trickiness but it would likely become a really brittle area of the code and wouldn't work the same in all browsers...
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.
Ok I updated to the new design. See screenshot below
The final question I have is how to handle the chart hover over the element. Due to the padding between the text, there is a space between the legend items that would not be clickable but we are still highlighting the series in the chart (i.e. graying out all the other series).
Possible solutions
- remove highlight until over hoverable area
- keep as is, but when hovering below the action there will be no blue highlight and the series will be still be highlighted in the chart.
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.
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 think there still gaps between legend actions that create an epileptic effect, I can jump on a call to describe that
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.
Let's fix this in a subsequent PR
Codecov Report
@@ Coverage Diff @@
## master #749 +/- ##
==========================================
+ Coverage 74.48% 74.89% +0.41%
==========================================
Files 267 282 +15
Lines 9147 9473 +326
Branches 1879 1929 +50
==========================================
+ Hits 6813 7095 +282
- Misses 2329 2368 +39
- Partials 5 10 +5
Continue to review full report at Codecov.
|
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!
🎉 This PR is included in version 19.9.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
# [19.9.0](elastic/elastic-charts@v19.8.1...v19.9.0) (2020-07-17) ### Features * **axis:** formatting different for label vs tooltip and legend ([#750](elastic/elastic-charts#750)) ([027a772](elastic/elastic-charts@027a772)) * **legend:** add legend item actions and margins ([opensearch-project#749](elastic/elastic-charts#749)) ([75ce7b0](elastic/elastic-charts@75ce7b0)), closes [opensearch-project#717](elastic/elastic-charts#717)
Summary
closes #717
Adds actions to legend items
New prop
legendAction
that takes aLegendAction
type defined as...Vertical legend
Horizontal legend
Checklist
src/index.ts
(and stories only import from../src
except for test data & storybook)