[Feature Notification] Add EuiNotificationEventMeta#4433
[Feature Notification] Add EuiNotificationEventMeta#4433elizabetdev merged 25 commits intoelastic:feature/notificationfrom
Conversation
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/ |
fbe7ccd to
f6d2943
Compare
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/ |
cchaos
left a comment
There was a problem hiding this comment.
🎉
Side note: I know that my reviews can be quite long on some of these new components. Let me know if just passing you back a PR is easier than trying to parse through all the comments.
One extra things I would add now instead of later is a playground. While this specific component is still in your head, it's a good candidate for a specific playground setup to check through all the props/combinations.
src-docs/src/views/notification_events/notification_events_example.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/ |
|
Thanks, @cchaos. The comments work well because I have the chance to learn by doing by myself. 👍🏽 |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/ |
|
Thanks, @cchaos! Fixed the badge to grow until 100% of the parent container and truncate. Also fixed the read and unread states to toggle. |
cchaos
left a comment
There was a problem hiding this comment.
The only other thing to test for scalability, is if the date/time is very long as well. I think the wrapping of the date to the next line actually isn't too bad, but I'd think you'd want to ensure the overflow menu to stay in the top right.
Also, I'd still highly suggest adding a Playground for the exported components.
--
The next step is maybe to get an a11y by @myasonik . I'm guessing we'll need some more aria tags hooked up to the buttons so they get described by the event. Unless that's coming later.
myasonik
left a comment
There was a problem hiding this comment.
Thanks for the ping @cchaos – you were spot on!
Just a few minor things that I think you'll need to add a couple more props for but nothing crazy it doesn't seem like.
(Note: I didn't do a full code review. Only reviewed the rendered examples and focused on the areas of code that I needed to target.)
| 'euiNotificationEventReadButton.markAsRead', | ||
| 'euiNotificationEventReadButton.markAsUnread', | ||
| ]} | ||
| defaults={['Mark as read', 'Mark as unread']}> |
There was a problem hiding this comment.
This is tricky... We can expect that users will have a lot of this button on the screen so we should try to avoid duplicate button names.
Usually, I'd recommend something like Mark {eventName} as read but we don't have to available in this component.
So maybe we keep this as a default but also take a new prop called eventName to build this string if possible?
There was a problem hiding this comment.
I added a new prop and added it as required. I think is better if we make sure all the buttons have unique button names.
| button={ | ||
| <EuiI18n | ||
| token="euiNotificationEventMeta.contextMenuButton" | ||
| default="Open menu"> |
There was a problem hiding this comment.
We don't need to specify our action here because we have aria-expanded in place. (If we did want to specify the action anyways, we'd need to toggle it to "Close menu" anyways.)
Though, because we can assume this same button will be rendered many times on one page, we should avoid having the same name for it.
If we accept a new prop called eventName we could build a string like: Menu for {eventName}
There was a problem hiding this comment.
I built the string as you mentioned Menu for {eventName}.
| /> | ||
| )} | ||
|
|
||
| {iconType && <EuiIcon type={iconType} />} |
There was a problem hiding this comment.
Because we don't know if this icon will be purely decorative or provide contextual info, we also need a way to define an aria-label for this icon.
For example, if the cloud icon is going to be rendered here, we'd want to pass in Cloud... Unless we had a tag directly following it which already was labelled with Cloud in which case the icon is purely decorative.
Anyway, that will be up to the consuming app to decide but EUI needs to at least provide the opportunity.
There was a problem hiding this comment.
I added a new prop called iconAriaLabel (it's optional). In case no iconAriaLabel is passed I'm assuming the icon is purely decorative so it receives an aria-hidden: true.
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/ |
|
Jenkins, test this |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/ |
cchaos
left a comment
There was a problem hiding this comment.
Design and design code LGTM! 💯
chandlerprall
left a comment
There was a problem hiding this comment.
Two small suggestions, and a small PR for unit tests elizabetdev#13
EuiNotificationEventMeta unit tests update
Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/ |
chandlerprall
left a comment
There was a problem hiding this comment.
LGTM! Pulled & tested locally
| /** | ||
| * Type of severity (e.g. "Critical", "Warning", etc..). Shows as a text after the `type` following the format "Alert: Critical". | ||
| */ | ||
| severity?: string; |
There was a problem hiding this comment.
Should this severity level be translated according to the user locale? If so, I'd suggest defining a list of supported severity levels: normal, warning, critical.
There was a problem hiding this comment.
The way that I was seeing this, is that this should be decided in the consuming app. The consuming app can translate it and passed as a string. One type of notification can have severities like "critical", "warning". And other types can have "high", "low".
But if you think it makes more sense I can change it to your suggested list: "normal", "warning", "critical".
There was a problem hiding this comment.
Sorry, I didn't know what is better to place the question. It makes sense to keep Kibana specific logic outside of EUI. Kibana can define any severity level and implement any internal mapping to badgeColor.
Does it make sense to you?
There was a problem hiding this comment.
Yes, It makes sense.
| /** | ||
| * Accepts either our palette colors (primary, secondary ..etc) or a hex value `#FFFFFF`, `#000`. | ||
| */ | ||
| badgeColor?: EuiBadgeProps['color']; |
There was a problem hiding this comment.
badgeColor should be derived from severity level?
There was a problem hiding this comment.
It was the first idea. But because we didn't have a list it was difficult to predict the color. So it should be the consumer saying what is the color and create a logic with the severity level. But if we decide to change to a list like "normal", "warning", and "critical" we can derive the color from the severity level.
I'm going to create a list of "Left todo" in #4513. And then we can improve a few things according to feedback.
| /** | ||
| * A unique, human-friendly name for the event to be used in aria attributes (e.g. "alert-critical-01", "cloud-no-severity-12", etc..). | ||
| */ | ||
| eventName: string; |
There was a problem hiding this comment.
so it consists of type-severity-number? It's okay if it's different on every render? In this case, we can implement a unique number as a global counter.
* [Feature Notification] Add EuiNotificationEventMeta (#4433) * Add notification event meta * WIP * adding i18n * Fixing axe error in docs example * Adding context menus items * contetx menu item anchor position * Adding tests * Update src/components/notification/notification_event_meta.tsx Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Improving code based on PR review * More PR review * Better description * Update src/components/notification/notification_event_meta.tsx Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Update src-docs/src/views/notification_events/notification_events.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Badge 100% width * ES lint * Read and unread states * Make sure overflow menu stays in the top right * Improving a11y * Adding playground for event read button * Removing EuiNotificationEventMeta from exported on index * Add a behavior unit test, update context menu test to snapshot the menu items * Update src/components/notification/notification_event_meta.tsx Co-authored-by: Chandler Prall <chandler.prall@gmail.com> * Update src/components/notification/notification_event_read_button.tsx Co-authored-by: Chandler Prall <chandler.prall@gmail.com> Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> Co-authored-by: Chandler Prall <chandler.prall@gmail.com> * [Feature Notification] Adding animation prop to EuiHeaderSectionItemButton (#4424) * Adding animation and hasBackground props to EuiHeaderSectionItemButton * A few improvements * Docs props * Removing hasBackground prop * Using JS do hide and show on xs breakpoints * Adding a snippet * refactor animation prop into a ref method * Snapshots. Trigger animation comments. * Deleting unused css animation * triggerAnimation explanation * Cleaned up some logic and created a docs example specifically for the notifications * re-enable the animation test * Update src-docs/src/views/header/header_animate.js Co-authored-by: Chandler Prall <chandler.prall@gmail.com> * Update src-docs/src/views/header/header_example.js Co-authored-by: Chandler Prall <chandler.prall@gmail.com> * Update src-docs/src/views/header/header_alert.js Co-authored-by: Chandler Prall <chandler.prall@gmail.com> * Update src-docs/src/views/header/header_alert.js Co-authored-by: Chandler Prall <chandler.prall@gmail.com> * Update src-docs/src/views/header/header_animate.js Co-authored-by: Chandler Prall <chandler.prall@gmail.com> * Update src-docs/src/views/header/header_example.js Co-authored-by: Chandler Prall <chandler.prall@gmail.com> * renaming animate methods to euiAnimate * euiAnimate into header example * simplifying onClick closeFlyout * Update src-docs/src/views/header/header_example.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> Co-authored-by: Chandler Prall <chandler.prall@gmail.com> Co-authored-by: cchaos <caroline.horn@elastic.co> Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * [Feature notification] Add EuiNotificationEvent (#4531) * Notification events * Looping through EuiNotificationEvent * Adding props table and more methods * wip * Renaming event notifications to event messages * onClickNoNewsTitles * Toggle mark as read/unread * Initial documentation * Improving examples * Fixing TS error * Refactored EuiEventNotification context menu item creation * improving data * Notifications data * Primary example buttons * Reset data * More docs * snippets * Adding tests * Better messages explanation * Better snippets * Small fixes * Missing prop explanation * Adding heading level * Adding flexible comp section * More a11y * Update src/components/notification/notification_event_messages.tsx Co-authored-by: Michail Yasonik <michail@yasonik.com> * Button messages ay11 * test * Better descriptions * Tests * Adding icon arial label into notifications feed example * i18n token * i18n token * i18 token again * primaryAction description * More description * Update src/components/notification/notification_event_messages.tsx Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Update src/components/notification/notification_event_messages.tsx Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Update src-docs/src/views/notification_event/notification_event_example.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Update src-docs/src/views/notification_event/notification_event_example.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Update src-docs/src/views/notification_event/notification_event_example.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Update src-docs/src/views/notification_event/notification_event_example.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Update src-docs/src/views/notification_event/notification_event_example.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Addressing PR review * More improvements * Adding comment * Excluding `eventName` at top level and changing title vs aria-label on read button * Fix title * Fixing tests and removing evenName from docs usage * Fixing icon margin * More tests and small fixes * Moving read button from event meta comp to event comp * Split primaryAction and primaryActionProps * Exposing EuiPrimaryActionProps in props table * Update src-docs/src/views/notification_event/notification_event_example.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Update src-docs/src/views/notification_event/notification_event_example.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Update src-docs/src/views/notification_event/notification_event_example.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Update src-docs/src/views/notification_event/notification_event_example.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Update src-docs/src/views/notification_event/notification_event_example.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Update src-docs/src/views/notification_event/notification_event_example.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Update src-docs/src/views/notification_event/notification_event_example.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> * Messages length and more * Fixing data test subj * Renaming tsx examples to js Co-authored-by: Chandler Prall <chandler.prall@gmail.com> Co-authored-by: Michail Yasonik <michail@yasonik.com> Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> Co-authored-by: cchaos <caroline.horn@elastic.co> * Adding CL * Fixing CL a11y issue * Reverse logic in the ternary operator * Removed unecessary optional types in EuiNotificationEventMeta Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> Co-authored-by: Chandler Prall <chandler.prall@gmail.com> Co-authored-by: cchaos <caroline.horn@elastic.co> Co-authored-by: Michail Yasonik <michail@yasonik.com>

Summary
This PR adds the EuiNotificationEventMeta, an inner component that will live inside EuiNotificationEvent.
For testing purposes, I'm adding provisory documentation that is going to be replaced on the next PRs.
Checklist