Skip to content

[Feature Notification] Add EuiNotificationEventMeta#4433

Merged
elizabetdev merged 25 commits intoelastic:feature/notificationfrom
elizabetdev:notification-event-meta
Feb 11, 2021
Merged

[Feature Notification] Add EuiNotificationEventMeta#4433
elizabetdev merged 25 commits intoelastic:feature/notificationfrom
elizabetdev:notification-event-meta

Conversation

@elizabetdev
Copy link
Contributor

@elizabetdev elizabetdev commented Jan 20, 2021

Summary

This PR adds the EuiNotificationEventMeta, an inner component that will live inside EuiNotificationEvent.

EuiNotificationEvent@2x

For testing purposes, I'm adding provisory documentation that is going to be replaced on the next PRs.

Screenshot 2021-01-25 at 14 31 19

Checklist

  • Check against all themes for compatibility in both light and dark modes
  • Checked in mobile
  • Checked in Chrome, Safari, Edge, and Firefox
  • Props have proper autodocs
  • Added documentation
  • Checked Code Sandbox works for the any docs examples
  • Added or updated jest tests
  • Checked for breaking changes and labeled appropriately
  • Checked for accessibility including keyboard-only and screenreader modes
  • A changelog entry exists and is marked appropriately

@elizabetdev elizabetdev changed the title [Feature notification] Add notification event meta [Feature Notification] Add notification event meta Jan 20, 2021
@elizabetdev elizabetdev changed the title [Feature Notification] Add notification event meta [Feature Notification] Add EuiNotificationEventMeta Jan 20, 2021
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/

@elizabetdev elizabetdev force-pushed the notification-event-meta branch from fbe7ccd to f6d2943 Compare January 20, 2021 19:00
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/

@elizabetdev elizabetdev marked this pull request as ready for review January 26, 2021 11:25
Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

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.

elizabetdev and others added 2 commits January 27, 2021 11:08
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/

@elizabetdev
Copy link
Contributor Author

Thanks, @cchaos. The comments work well because I have the chance to learn by doing by myself. 👍🏽

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/

@elizabetdev
Copy link
Contributor Author

Thanks, @cchaos! Fixed the badge to grow until 100% of the parent container and truncate. Also fixed the read and unread states to toggle.

@elizabetdev elizabetdev requested a review from cchaos January 29, 2021 17:30
Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Screen Shot 2021-02-02 at 11 11 59 AM

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.

Copy link
Contributor

@myasonik myasonik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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']}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I built the string as you mentioned Menu for {eventName}.

/>
)}

{iconType && <EuiIcon type={iconType} />}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/

@elizabetdev
Copy link
Contributor Author

Hi again 👋🏽 ,

@cchaos I added the playground for the exported component: EuiNotificationEventReadButton. Also, I ensured the overflow menu stays in the top right.

@myasonik, I improved the a11y based on your review.

@cchaos
Copy link
Contributor

cchaos commented Feb 3, 2021

Jenkins, test this

@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/

Copy link
Contributor

@myasonik myasonik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a11y looks good!

Copy link
Contributor

@cchaos cchaos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Design and design code LGTM! 💯

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two small suggestions, and a small PR for unit tests elizabetdev#13

elizabetdev and others added 3 commits February 10, 2021 22:41
EuiNotificationEventMeta unit tests update
Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
@kibanamachine
Copy link

Preview documentation changes for this PR: https://eui.elastic.co/pr_4433/

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Pulled & tested locally

@elizabetdev elizabetdev merged commit 6a1058c into elastic:feature/notification Feb 11, 2021
@elizabetdev elizabetdev mentioned this pull request Feb 11, 2021
10 tasks
/**
* Type of severity (e.g. "Critical", "Warning", etc..). Shows as a text after the `type` following the format "Alert: Critical".
*/
severity?: string;
Copy link

@mshustov mshustov Feb 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, It makes sense.

/**
* Accepts either our palette colors (primary, secondary ..etc) or a hex value `#FFFFFF`, `#000`.
*/
badgeColor?: EuiBadgeProps['color'];

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

badgeColor should be derived from severity level?

Copy link
Contributor Author

@elizabetdev elizabetdev Feb 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

elizabetdev added a commit that referenced this pull request Mar 16, 2021
* [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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants