[Feature Notification] Add a euiAnimation method on the EuiHeaderSectionItemButton ref#4424
Conversation
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4424/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4424/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4424/ |
cchaos
left a comment
There was a problem hiding this comment.
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.
| setTimeout(() => { | ||
| setIsAnimating(true); | ||
| }, 100); |
There was a problem hiding this comment.
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:
- Make sure to document this somewhere, maybe a prop comment will suffice
- 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.
There was a problem hiding this comment.
Thanks @cchaos,
- I'm not completely sure if this is the best example to set
true/false. I'm just trying to avoid asetTimeoutof5s. So the.euiHeaderSectionItemButton__content--isAnimatingstays there forever, until the animation is triggered again. It doesn't seem right to have the class there when it's not animating. - 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).
There was a problem hiding this comment.
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
There was a problem hiding this comment.
@cchaos what do you think of this approach?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
PR showing the method-based approach at elizabetdev#8
There was a problem hiding this comment.
Thanks @chandlerprall. I found it a really bit difficult to document/exemplify this solution. So do you think this would work elizabetdev#9?
src/components/header/header_section/header_section_item_button.tsx
Outdated
Show resolved
Hide resolved
src/components/header/header_section/header_section_item_button.tsx
Outdated
Show resolved
Hide resolved
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4424/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4424/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4424/ |
…ethod refactor animation prop into a ref method
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4424/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4424/ |
| <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>. |
There was a problem hiding this comment.
New explanation on how to animate. Is this enough?
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4424/ |
cchaos
left a comment
There was a problem hiding this comment.
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
|
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. |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4424/ |
chandlerprall
left a comment
There was a problem hiding this comment.
Handful of small changes to the examples/snippets. I also threw a PR your way to re-enable the animation test. Everything else LGTM!
…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>
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4424/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4424/ |
chandlerprall
left a comment
There was a problem hiding this comment.
Changes LGTM; pulled & tested locally
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4424/ |
|
Preview documentation changes for this PR: https://eui.elastic.co/pr_4424/ |
* [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 a
euiAnimation()method on the EuiHeaderSectionItemButtonref. This new method is required to accomplish the Notifications Template.It also:
Checklist