Skip to content

[Feature Notification] Add a euiAnimation method on the EuiHeaderSectionItemButton ref#4424

Merged
elizabetdev merged 25 commits intoelastic:feature/notificationfrom
elizabetdev:notification_header_button
Feb 11, 2021
Merged

[Feature Notification] Add a euiAnimation method on the EuiHeaderSectionItemButton ref#4424
elizabetdev merged 25 commits intoelastic:feature/notificationfrom
elizabetdev:notification_header_button

Conversation

@elizabetdev
Copy link
Contributor

@elizabetdev elizabetdev commented Jan 14, 2021

Summary

This PR adds a euiAnimation() method on the EuiHeaderSectionItemButton ref. This new method is required to accomplish the Notifications Template.

It also:

  • improves the docs
  • exposes the EuiHeaderSectionItemButton props table
  • adds a new snippet

Buttons@2x

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@elizabetdev elizabetdev marked this pull request as ready for review January 15, 2021 19:38
@kibanamachine
Copy link

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

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.

Looks great! I like that the animation can be applied to any content within the button.

Design-wise, the one thing I noticed is that mobile version for the notification badge is not lining up with the dot version. Could you fix this? Maybe it means just using the JS breakpoint utility to show/hide on vs the other instead of custom CSS.

Screen Shot 2021-01-15 at 15 15 18 PM

Comment on lines +331 to +333
setTimeout(() => {
setIsAnimating(true);
}, 100);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is an important piece that consumers will not see. This is the only way they'd be able to reset the animation after each go. I think there's a couple paths:

  1. Make sure to document this somewhere, maybe a prop comment will suffice
  2. Is there any way to reset this within the component itself, maybe the prop is a callback function or something that passes back when the animation is done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @cchaos,

  1. I'm not completely sure if this is the best example to set true/false. I'm just trying to avoid a setTimeout of 5s. So the .euiHeaderSectionItemButton__content--isAnimating stays there forever, until the animation is triggered again. It doesn't seem right to have the class there when it's not animating.
  2. Maybe there is.

@chandlerprall can you recommend what you believe is the best way to inject the CSS class .euiHeaderSectionItemButton__content--isAnimating and remove it after the animation is over (5s).

Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of a prop which needs to toggle off/on to animate, we could add a method to the component's ref,

headerRef = useRef();

<HeaderUpdates
  ref={headerRef}
  showNotification={showNotification}
  setShowNotification={() => setShowNotification()}
  notificationsNumber={notificationsNumber}
/>

// trigger animation when notification count changes
useEffect(
  () => headerRef.animateAlertIcon(),
  [notifications.length]
)

If that sounds better I can put that together. Alternatively, we could use the animationend or transitionend events to trigger a callback to the parent, telling it to reset the animation prop back to false. This would avoid any setTimeout, but still requires extra boilerplate code in the consuming app

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cchaos what do you think of this approach?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think that approach works. My only concern would be discoverability. Of course we'd have it hooked up in our docs, but would there be any autocompletion in IDE's that would help surface this option.

Copy link
Contributor

Choose a reason for hiding this comment

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

PR showing the method-based approach at elizabetdev#8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @chandlerprall. I found it a really bit difficult to document/exemplify this solution. So do you think this would work elizabetdev#9?

@elizabetdev elizabetdev changed the title [Feature Notification] Adding animation and hasBackground props to EuiHeaderSectionItemButton [Feature Notification] Adding animation prop to EuiHeaderSectionItemButton Jan 18, 2021
@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

@kibanamachine
Copy link

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

Comment on lines +345 to +348
<EuiCode>true</EuiCode> to render a simple dot. You can also animate
the button by calling the <EuiCode>triggerAnimation()</EuiCode>{' '}
method on the <strong>EuiHeaderSectionItemButton</strong>{' '}
<EuiCode>ref</EuiCode>.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

New explanation on how to animate. Is this enough?

@kibanamachine
Copy link

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

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.

Quick PR for you elizabetdev#11 that just splits off the notification and animation stuff into it's own example for better clarity.

Cleaned up some logic and created a docs example specifically for the notifications
@elizabetdev
Copy link
Contributor Author

Thanks for this PR @cchaos, I merged it. I think @chandlerprall wants to change a few things but hopefully is not going to impact your work.

@kibanamachine
Copy link

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

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.

Handful of small changes to the examples/snippets. I also threw a PR your way to re-enable the animation test. Everything else LGTM!

elizabetdev and others added 8 commits February 10, 2021 18:44
…test

Re-enable the notification header button animation test
Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
Co-authored-by: Chandler Prall <chandler.prall@gmail.com>
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_4424/

@kibanamachine
Copy link

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

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.

Changes LGTM; pulled & tested locally

@elizabetdev elizabetdev requested a review from cchaos February 10, 2021 22:01
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.

Looks great!

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_4424/

@elizabetdev elizabetdev merged commit a8da6d5 into elastic:feature/notification Feb 11, 2021
@elizabetdev elizabetdev mentioned this pull request Feb 11, 2021
10 tasks
@elizabetdev elizabetdev changed the title [Feature Notification] Adding animation prop to EuiHeaderSectionItemButton [Feature Notification] Add a euiAnimation method on the EuiHeaderSectionItemButton ref Feb 11, 2021
@kibanamachine
Copy link

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

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.

4 participants