From 915a2d16f594fbf6778a6be0f6138b8b17c68807 Mon Sep 17 00:00:00 2001
From: miukimiu
Date: Thu, 14 Jan 2021 12:03:31 +0000
Subject: [PATCH 01/22] Adding animation and hasBackground props to
EuiHeaderSectionItemButton
---
src-docs/src/views/header/header_alert.js | 275 +++++++++++-------
src-docs/src/views/header/header_example.js | 27 +-
src/components/header/_mixins.scss | 8 +-
.../__snapshots__/header_links.test.tsx.snap | 14 +-
.../header_section_item_button.test.tsx.snap | 109 ++++++-
.../header/header_section/_animations.scss | 26 ++
.../header_section/_header_section_item.scss | 53 +---
.../_header_section_item_button.scss | 88 ++++++
.../header/header_section/_index.scss | 2 +
.../header_section_item_button.test.tsx | 16 +
.../header_section_item_button.tsx | 78 +++--
11 files changed, 498 insertions(+), 198 deletions(-)
create mode 100644 src/components/header/header_section/_animations.scss
create mode 100644 src/components/header/header_section/_header_section_item_button.scss
diff --git a/src-docs/src/views/header/header_alert.js b/src-docs/src/views/header/header_alert.js
index 88e440e08b4..c7a1aada581 100644
--- a/src-docs/src/views/header/header_alert.js
+++ b/src-docs/src/views/header/header_alert.js
@@ -3,6 +3,7 @@ import React, { useState } from 'react';
import {
EuiAvatar,
EuiBadge,
+ EuiButton,
EuiButtonEmpty,
EuiFlexGroup,
EuiFlexItem,
@@ -29,42 +30,14 @@ import {
} from '../../../../src/components';
import { htmlIdGenerator } from '../../../../src/services';
-export default () => {
- const [position, setPosition] = useState('static');
-
- return (
- <>
- setPosition(e.target.checked ? 'fixed' : 'static')}
- />
-
-
-
-
- Elastic
-
-
-
-
-
-
-
-
-
-
-
-
- >
- );
-};
-
-const HeaderUpdates = ({ flyoutOrPopover = 'flyout' }) => {
+const HeaderUpdates = ({
+ showNotification,
+ setShowNotification,
+ notificationsNumber,
+ isAnimating,
+}) => {
const [isFlyoutVisible, setIsFlyoutVisible] = useState(false);
- const [showBadge, setShowBadge] = useState(true);
+ const [isPopoverVisible, setIsPopoverVisible] = useState(false);
const alerts = [
{
@@ -146,84 +119,107 @@ const HeaderUpdates = ({ flyoutOrPopover = 'flyout' }) => {
setIsFlyoutVisible(false);
};
+ const closePopover = () => {
+ setIsPopoverVisible(false);
+ };
+
const showFlyout = () => {
- setShowBadge(false);
+ setShowNotification(false);
setIsFlyoutVisible(!isFlyoutVisible);
};
+ const showPopover = () => {
+ setShowNotification(false);
+ setIsPopoverVisible(!isPopoverVisible);
+ };
+
const button = (
showFlyout()}
- notification={showBadge}>
+ onClick={() => showPopover()}
+ notification={showNotification && notificationsNumber}
+ animation={isAnimating}>
);
- let content;
- if (flyoutOrPopover === 'flyout') {
- content = (
- <>
- {button}
- {isFlyoutVisible && (
-
- closeFlyout()}
- size="s"
- id="headerNewsFeed"
- aria-labelledby="flyoutSmallTitle">
-
-
- What's new
-
-
-
- {alerts.map((alert, i) => (
-
- ))}
-
-
-
-
- closeFlyout()}
- flush="left">
- Close
-
-
-
-
- Version 7.0
-
-
-
-
-
-
- )}
- >
- );
- }
+ const alertButton = (
+ showFlyout()}
+ notification={showNotification}
+ animation={isAnimating}
+ hasBackground>
+
+
+ );
+
+ const flyout = (
+
+ closeFlyout()}
+ size="s"
+ id="headerFlyoutNewsFeed"
+ aria-labelledby="flyoutSmallTitle">
+
+
+ What's new
+
+
+
+ {alerts.map((alert, i) => (
+
+ ))}
+
+
+
+
+ closeFlyout()}
+ flush="left">
+ Close
+
+
+
+
+ Version 7.0
+
+
+
+
+
+
+ );
- if (flyoutOrPopover === 'popover') {
- content = (
+ return (
+ <>
+ {alertButton}
+ {isFlyoutVisible && flyout}
From 46a3d77955cca179f011e4e4054367d84dfbfe7a Mon Sep 17 00:00:00 2001
From: cchaos
Date: Mon, 8 Feb 2021 17:57:38 -0500
Subject: [PATCH 11/22] Cleaned up some logic and created a docs example
specifically for the notifications
---
src-docs/src/views/header/header_alert.js | 443 ++++++++----------
src-docs/src/views/header/header_animate.js | 134 ++++++
src-docs/src/views/header/header_example.js | 80 +++-
.../header_section_item_button.tsx | 38 +-
4 files changed, 406 insertions(+), 289 deletions(-)
create mode 100644 src-docs/src/views/header/header_animate.js
diff --git a/src-docs/src/views/header/header_alert.js b/src-docs/src/views/header/header_alert.js
index 46a8595fd0f..c1968b6716c 100644
--- a/src-docs/src/views/header/header_alert.js
+++ b/src-docs/src/views/header/header_alert.js
@@ -1,15 +1,8 @@
-import React, {
- forwardRef,
- useCallback,
- useImperativeHandle,
- useRef,
- useState,
-} from 'react';
+import React, { useState } from 'react';
import {
EuiAvatar,
EuiBadge,
- EuiButton,
EuiButtonEmpty,
EuiFlexGroup,
EuiFlexItem,
@@ -36,211 +29,139 @@ import {
} from '../../../../src/components';
import { htmlIdGenerator } from '../../../../src/services';
-const HeaderUpdates = forwardRef(
- ({ showNotification, setShowNotification, notificationsNumber }, ref) => {
- const [isFlyoutVisible, setIsFlyoutVisible] = useState(false);
- const [isPopoverVisible, setIsPopoverVisible] = useState(false);
+const HeaderUpdates = () => {
+ const [isFlyoutVisible, setIsFlyoutVisible] = useState(false);
+ const [isPopoverVisible, setIsPopoverVisible] = useState(false);
- const alerts = [
- {
- title: 'Control access to features',
- text: 'Show or hide applications and features per space in Kibana.',
- action: Learn about feature controls ,
- date: '1 May 2019',
- badge: 7.1 ,
- },
- {
- title: 'Kibana 7.0 is turning heads',
- text:
- 'Simplified navigation, responsive dashboards, dark mode… pick your favorite.',
- action: (
-
- Read the blog
-
- ),
- date: '10 April 2019',
- badge: 7.0 ,
- },
- {
- title: 'Enter dark mode',
- text:
- 'Kibana now supports the easy-on-the-eyes theme across the entire UI.',
- action: Go to Advanced Settings ,
- date: '10 April 2019',
- badge: 7.0 ,
- },
- {
- title: 'Pixel-perfect Canvas is production ready',
- text: 'Your creative space for visualizing data awaits.',
- action: (
-
- Watch the webinar
-
- ),
- date: '26 March 2019',
- badge: 6.7 ,
- },
- {
- title: '6.7 release notes',
- text: 'Stay up-to-date on the latest and greatest features.',
- action: (
-
- Check out the docs
-
- ),
- date: '26 March 2019',
- badge: 6.7 ,
- },
- {
- title: 'Rollups made simple in Kibana',
- text:
- 'Save space and preserve the integrity of your data directly in the UI.',
- action: (
-
- Read the blog
-
- ),
- date: '10 January 2019',
- badge: 6.5 ,
- },
- ];
+ const alerts = [
+ {
+ title: 'Control access to features',
+ text: 'Show or hide applications and features per space in Kibana.',
+ action: Learn about feature controls ,
+ date: '1 May 2019',
+ badge: 7.1 ,
+ },
+ {
+ title: 'Kibana 7.0 is turning heads',
+ text:
+ 'Simplified navigation, responsive dashboards, dark mode… pick your favorite.',
+ action: (
+
+ Read the blog
+
+ ),
+ date: '10 April 2019',
+ badge: 7.0 ,
+ },
+ {
+ title: 'Enter dark mode',
+ text:
+ 'Kibana now supports the easy-on-the-eyes theme across the entire UI.',
+ action: Go to Advanced Settings ,
+ date: '10 April 2019',
+ badge: 7.0 ,
+ },
+ {
+ title: 'Pixel-perfect Canvas is production ready',
+ text: 'Your creative space for visualizing data awaits.',
+ action: (
+
+ Watch the webinar
+
+ ),
+ date: '26 March 2019',
+ badge: 6.7 ,
+ },
+ {
+ title: '6.7 release notes',
+ text: 'Stay up-to-date on the latest and greatest features.',
+ action: (
+
+ Check out the docs
+
+ ),
+ date: '26 March 2019',
+ badge: 6.7 ,
+ },
+ {
+ title: 'Rollups made simple in Kibana',
+ text:
+ 'Save space and preserve the integrity of your data directly in the UI.',
+ action: (
+
+ Read the blog
+
+ ),
+ date: '10 January 2019',
+ badge: 6.5 ,
+ },
+ ];
- const closeFlyout = () => {
- setIsFlyoutVisible(false);
- };
-
- const closePopover = () => {
- setIsPopoverVisible(false);
- };
-
- const showFlyout = () => {
- setShowNotification(false);
- setIsFlyoutVisible(!isFlyoutVisible);
- };
-
- const showPopover = () => {
- setShowNotification(false);
- setIsPopoverVisible(!isPopoverVisible);
- };
-
- const bellRef = useRef();
- const cheerRef = useRef();
+ const closeFlyout = () => {
+ setIsFlyoutVisible(false);
+ };
- // we're passing passing the `triggerAnimation` callbacks to the `headerUpdatesRef` child components that we want to animate
- const animate = useCallback(() => {
- bellRef.current?.triggerAnimation();
- cheerRef.current?.triggerAnimation();
- }, []);
+ const closePopover = () => {
+ setIsPopoverVisible(false);
+ };
- // we're using the `useImperativeHandle` which allows the child to expose a function to the parent
- // this way we can trigger the animations on both child components: `bellRef` and `cheerRef`
- useImperativeHandle(
- ref,
- () => ({
- animate,
- }),
- [animate]
- );
+ const showFlyout = () => {
+ setIsFlyoutVisible(!isFlyoutVisible);
+ };
- const bellButton = (
- showFlyout()}
- notification={showNotification}>
-
-
- );
+ const showPopover = () => {
+ setIsPopoverVisible(!isPopoverVisible);
+ };
- const cheerButton = (
- showPopover()}
- notification={showNotification && notificationsNumber}>
-
-
- );
+ const bellButton = (
+ showFlyout()}
+ notification={true}>
+
+
+ );
- const flyout = (
-
- closeFlyout()}
- size="s"
- id="headerFlyoutNewsFeed"
- aria-labelledby="flyoutSmallTitle">
-
-
- What's new
-
-
-
- {alerts.map((alert, i) => (
-
- ))}
-
-
-
-
- closeFlyout()}
- flush="left">
- Close
-
-
-
-
- Version 7.0
-
-
-
-
-
-
- );
+ const cheerButton = (
+ showPopover()}
+ notification={6}>
+
+
+ );
- const popover = (
-
- );
+
+
+
+
+ closeFlyout()}
+ flush="left">
+ Close
+
+
+
+
+ Version 7.0
+
+
+
+
+
+
+ );
+
+ const popover = (
+
+ );
- return (
- <>
- {bellButton}
- {popover}
- {isFlyoutVisible && flyout}
- >
- );
- }
-);
-HeaderUpdates.displayName = 'HeaderUpdates';
+ return (
+ <>
+ {bellButton}
+ {popover}
+ {isFlyoutVisible && flyout}
+ >
+ );
+};
const HeaderUserMenu = () => {
const id = htmlIdGenerator()();
@@ -342,19 +305,7 @@ const HeaderUserMenu = () => {
export default () => {
const [position, setPosition] = useState('static');
- const [showNotification, setShowNotification] = useState(true);
- const headerUpdatesRef = useRef();
const [theme, setTheme] = useState('light');
- const [notificationsNumber, setNotificationsNumber] = useState(1);
-
- const notify = () => {
- if (!showNotification) {
- setNotificationsNumber(1);
- setShowNotification(true);
- } else {
- setNotificationsNumber(notificationsNumber + 1);
- }
- };
return (
<>
@@ -374,23 +325,10 @@ export default () => {
onChange={(e) => setTheme(e.target.checked ? 'dark' : 'light')}
/>
-
-
-
- Notify
-
-
-
-
- headerUpdatesRef.current?.animate()}>
- Animate
-
-
+
@@ -399,12 +337,7 @@ export default () => {
- setShowNotification()}
- notificationsNumber={notificationsNumber}
- />
+
diff --git a/src-docs/src/views/header/header_animate.js b/src-docs/src/views/header/header_animate.js
new file mode 100644
index 00000000000..08c5bb584f4
--- /dev/null
+++ b/src-docs/src/views/header/header_animate.js
@@ -0,0 +1,134 @@
+import React, {
+ forwardRef,
+ useCallback,
+ useImperativeHandle,
+ useRef,
+ useState,
+} from 'react';
+
+import {
+ EuiButton,
+ EuiFlexGroup,
+ EuiFlexItem,
+ EuiHeader,
+ EuiHeaderLogo,
+ EuiHeaderSectionItemButton,
+ EuiIcon,
+ EuiSpacer,
+} from '../../../../src/components';
+
+const HeaderUpdates = forwardRef(
+ ({ showNotification, notificationsNumber }, ref) => {
+ const bellRef = useRef();
+ const cheerRef = useRef();
+
+ // we're passing passing the `triggerAnimation` callbacks to the `headerUpdatesRef` child components that we want to animate
+ const animate = useCallback(() => {
+ bellRef.current?.triggerAnimation();
+ cheerRef.current?.triggerAnimation();
+ }, []);
+
+ // we're using the `useImperativeHandle` which allows the child to expose a function to the parent
+ // this way we can trigger the animations on both child components: `bellRef` and `cheerRef`
+ useImperativeHandle(
+ ref,
+ () => ({
+ animate,
+ }),
+ [animate]
+ );
+
+ const bellButton = (
+
+
+
+ );
+
+ const cheerButton = (
+
+
+
+ );
+
+ return (
+ <>
+ {bellButton}
+ {cheerButton}
+ >
+ );
+ }
+);
+HeaderUpdates.displayName = 'HeaderUpdates';
+
+export default () => {
+ const [showNotification, setShowNotification] = useState(false);
+ const headerUpdatesRef = useRef();
+ const [notificationsNumber, setNotificationsNumber] = useState(0);
+
+ const notify = () => {
+ if (!showNotification) {
+ setNotificationsNumber(1);
+ setShowNotification(true);
+ } else {
+ setNotificationsNumber(notificationsNumber + 1);
+ }
+
+ headerUpdatesRef.current?.animate();
+ };
+
+ return (
+ <>
+
+
+
+ Notify & animate
+
+
+
+
+ {
+ setShowNotification(false);
+ setNotificationsNumber(0);
+ }}>
+ Reset
+
+
+
+
+
+
+ Elastic],
+ borders: 'none',
+ },
+ {
+ items: [
+ setShowNotification()}
+ notificationsNumber={notificationsNumber}
+ />,
+ ],
+ borders: 'none',
+ },
+ ]}
+ />
+ >
+ );
+};
diff --git a/src-docs/src/views/header/header_example.js b/src-docs/src/views/header/header_example.js
index 6004ef17d9a..243decfc1a0 100644
--- a/src-docs/src/views/header/header_example.js
+++ b/src-docs/src/views/header/header_example.js
@@ -37,6 +37,10 @@ import HeaderAlert from './header_alert';
const headerAlertSource = require('!!raw-loader!./header_alert');
const headerAlertHtml = renderToHtml(HeaderAlert);
+import HeaderAnimate from './header_animate';
+const headerAnimateSource = require('!!raw-loader!./header_animate');
+const headerAnimateHtml = renderToHtml(HeaderAnimate);
+
import HeaderLinks from './header_links';
const headerLinksSource = require('!!raw-loader!./header_links');
const headerLinksHtml = renderToHtml(HeaderLinks);
@@ -122,7 +126,6 @@ const headerAlertSnippet = `
aria-label="Open portal content"
onClick={() => showPortalConten()}
notification={showNotification}
- animation={isAnimating}
>
@@ -130,6 +133,31 @@ const headerAlertSnippet = `
`;
+const headerAnimateSnippet = `const bellRef = useRef();
+
+// we're passing passing the triggerAnimation callbacks to the EuiHeaderSectionItemButton that we want to animate
+const animate = useCallback(() => {
+ bellRef.current?.triggerAnimation();
+}, []);
+
+// we're using the useImperativeHandle which allows the child to expose a function to the parent
+useImperativeHandle(
+ ref,
+ () => ({
+ animate,
+ }),
+ [animate]
+);
+
+const bellButton = (
+
+
+
+);`;
+
export const HeaderExample = {
title: 'Header',
sections: [
@@ -304,7 +332,7 @@ export const HeaderExample = {
demo: ,
},
{
- title: 'Portal content and buttons in the header',
+ title: 'Portal content in the header',
source: [
{
type: GuideSectionTypes.JS,
@@ -336,18 +364,6 @@ export const HeaderExample = {
in conjunction with a fixed header, be sure to add
the repositionOnScroll prop to the popover.
-
- To alert or notify users about the additional information they are
- receiving, use the EuiHeaderSectionItemButton {' '}
- notification prop. You can pass a{' '}
- node that will render inside a{' '}
- EuiBadgeNotification or pass{' '}
- true to render a simple dot. You can also animate
- the button by calling the triggerAnimation() {' '}
- method on the EuiHeaderSectionItemButton {' '}
- ref .
-
-
The example below shows how to incorporate{' '}
EuiHeaderAlert components to show a list of updates
@@ -359,8 +375,7 @@ export const HeaderExample = {
EuiPopover
{' '}
- . It also shows how to animate and add different types of
- notifications.
+ .
>
),
@@ -371,6 +386,39 @@ export const HeaderExample = {
snippet: headerAlertSnippet,
demo: ,
},
+ {
+ title: 'Header notifications',
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: headerAnimateSource,
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: headerAnimateHtml,
+ },
+ ],
+ text: (
+ <>
+
+ To alert or notify users about the additional information they are
+ receiving, use the EuiHeaderSectionItemButton {' '}
+ notification prop. You can pass a{' '}
+ node that will render inside a{' '}
+ EuiBadgeNotification or pass{' '}
+ true to render a simple dot. You can also animate
+ the button by calling the triggerAnimation() {' '}
+ method on the EuiHeaderSectionItemButton {' '}
+ ref .
+
+ >
+ ),
+ props: {
+ EuiHeaderSectionItemButton,
+ },
+ snippet: headerAnimateSnippet,
+ demo: ,
+ },
{
title: 'Stacked headers',
source: [
diff --git a/src/components/header/header_section/header_section_item_button.tsx b/src/components/header/header_section/header_section_item_button.tsx
index 8517155ac06..526c719ebae 100644
--- a/src/components/header/header_section/header_section_item_button.tsx
+++ b/src/components/header/header_section/header_section_item_button.tsx
@@ -62,6 +62,9 @@ export const EuiHeaderSectionItemButton = forwardRef<
notificationColor = 'accent',
...rest
},
+ /**
+ * Allows for animating with .triggerAnimation()
+ */
ref
) => {
const [buttonRef, setButtonRef] = useState();
@@ -211,24 +214,23 @@ export const EuiHeaderSectionItemButton = forwardRef<
/>
);
- const buttonNotification = (
- <>
- {notification && typeof notification === 'boolean' && notificationDot}
-
- {notification && typeof notification !== 'boolean' && (
- <>
-
-
- {notification}
-
-
- {notificationDot}
- >
- )}
- >
- );
+ let buttonNotification;
+ if (notification === true) {
+ buttonNotification = notificationDot;
+ } else if (notification) {
+ buttonNotification = (
+ <>
+
+
+ {notification}
+
+
+ {notificationDot}
+ >
+ );
+ }
return (
Date: Wed, 10 Feb 2021 11:21:51 -0700
Subject: [PATCH 12/22] re-enable the animation test
---
.../header_section_item_button.test.tsx | 39 ++++++++++++++-----
.../header_section_item_button.tsx | 8 ++--
2 files changed, 35 insertions(+), 12 deletions(-)
diff --git a/src/components/header/header_section/header_section_item_button.test.tsx b/src/components/header/header_section/header_section_item_button.test.tsx
index 97cdf57bedb..cb0f56a9590 100644
--- a/src/components/header/header_section/header_section_item_button.test.tsx
+++ b/src/components/header/header_section/header_section_item_button.test.tsx
@@ -18,10 +18,13 @@
*/
import React from 'react';
-import { render, shallow } from 'enzyme';
+import { mount, render, shallow } from 'enzyme';
import { requiredProps } from '../../../test/required_props';
-import { EuiHeaderSectionItemButton } from './header_section_item_button';
+import {
+ EuiHeaderSectionItemButton,
+ EuiHeaderSectionItemButtonRef,
+} from './header_section_item_button';
describe('EuiHeaderSectionItemButton', () => {
test('is rendered', () => {
@@ -67,13 +70,31 @@ describe('EuiHeaderSectionItemButton', () => {
});
});
- // test('renders animation', () => {
- // const component = render(
- //
- // );
- //
- // expect(component).toMatchSnapshot();
- // });
+ describe('animation', () => {
+ const animate = HTMLElement.prototype.animate;
+ beforeAll(() => {
+ HTMLElement.prototype.animate = jest.fn();
+ });
+ afterAll(() => {
+ HTMLElement.prototype.animate = animate;
+ });
+
+ it('renders animation', () => {
+ expect.assertions(2);
+
+ mount(
+
+ );
+
+ function testAnimation(element: EuiHeaderSectionItemButtonRef) {
+ if (element) {
+ expect(element.animate).toHaveBeenCalledTimes(0);
+ element.triggerAnimation();
+ expect(element.animate).toHaveBeenCalledTimes(1);
+ }
+ }
+ });
+ });
describe('onClick', () => {
test("isn't called upon instantiation", () => {
diff --git a/src/components/header/header_section/header_section_item_button.tsx b/src/components/header/header_section/header_section_item_button.tsx
index 526c719ebae..1b77e9503e3 100644
--- a/src/components/header/header_section/header_section_item_button.tsx
+++ b/src/components/header/header_section/header_section_item_button.tsx
@@ -47,7 +47,9 @@ export type EuiHeaderSectionItemButtonProps = CommonProps &
notificationColor?: EuiNotificationBadgeProps['color'];
};
-export type EuiHeaderSectionItemButtonRef = HTMLButtonElement | null;
+export type EuiHeaderSectionItemButtonRef =
+ | (HTMLButtonElement & { triggerAnimation: () => void })
+ | null;
export const EuiHeaderSectionItemButton = forwardRef<
EuiHeaderSectionItemButtonRef,
@@ -67,7 +69,7 @@ export const EuiHeaderSectionItemButton = forwardRef<
*/
ref
) => {
- const [buttonRef, setButtonRef] = useState();
+ const [buttonRef, setButtonRef] = useState();
const animationTargetRef = useRef(null);
useImperativeHandle<
@@ -192,7 +194,7 @@ export const EuiHeaderSectionItemButton = forwardRef<
duration: 5000,
});
};
- return buttonRef;
+ return buttonRef as EuiHeaderSectionItemButtonRef;
} else {
return null;
}
From f3a8851ef6c008a245ceba96365591a4318f989f Mon Sep 17 00:00:00 2001
From: Elizabet Oliveira
Date: Wed, 10 Feb 2021 18:47:41 +0000
Subject: [PATCH 13/22] Update src-docs/src/views/header/header_animate.js
Co-authored-by: Chandler Prall
---
src-docs/src/views/header/header_animate.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src-docs/src/views/header/header_animate.js b/src-docs/src/views/header/header_animate.js
index 08c5bb584f4..cf7fc93f9c0 100644
--- a/src-docs/src/views/header/header_animate.js
+++ b/src-docs/src/views/header/header_animate.js
@@ -22,7 +22,7 @@ const HeaderUpdates = forwardRef(
const bellRef = useRef();
const cheerRef = useRef();
- // we're passing passing the `triggerAnimation` callbacks to the `headerUpdatesRef` child components that we want to animate
+ // wrapping the `triggerAnimation` methods to make them available through this component's `ref`
const animate = useCallback(() => {
bellRef.current?.triggerAnimation();
cheerRef.current?.triggerAnimation();
From 733ae302ec7f4592a5e18f6325293277e110d425 Mon Sep 17 00:00:00 2001
From: Elizabet Oliveira
Date: Wed, 10 Feb 2021 18:47:55 +0000
Subject: [PATCH 14/22] Update src-docs/src/views/header/header_example.js
Co-authored-by: Chandler Prall
---
src-docs/src/views/header/header_example.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src-docs/src/views/header/header_example.js b/src-docs/src/views/header/header_example.js
index 243decfc1a0..c517c698b16 100644
--- a/src-docs/src/views/header/header_example.js
+++ b/src-docs/src/views/header/header_example.js
@@ -135,7 +135,7 @@ const headerAlertSnippet = `
const headerAnimateSnippet = `const bellRef = useRef();
-// we're passing passing the triggerAnimation callbacks to the EuiHeaderSectionItemButton that we want to animate
+ // wrapping the `triggerAnimation` methods to make them available through this component's `ref`
const animate = useCallback(() => {
bellRef.current?.triggerAnimation();
}, []);
From 46343901967ec109bcfd30d6c63d1b185f16c373 Mon Sep 17 00:00:00 2001
From: Elizabet Oliveira
Date: Wed, 10 Feb 2021 18:48:08 +0000
Subject: [PATCH 15/22] Update src-docs/src/views/header/header_alert.js
Co-authored-by: Chandler Prall
---
src-docs/src/views/header/header_alert.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src-docs/src/views/header/header_alert.js b/src-docs/src/views/header/header_alert.js
index c1968b6716c..eeb5d058b61 100644
--- a/src-docs/src/views/header/header_alert.js
+++ b/src-docs/src/views/header/header_alert.js
@@ -143,7 +143,7 @@ const HeaderUpdates = () => {
aria-expanded={isPopoverVisible}
aria-haspopup="true"
aria-label={"News feed: Updates available'"}
- onClick={() => showPopover()}
+ onClick={showPopover}
notification={6}>
From b4eb4753f1332fa42d942e8f260e04cae70df00d Mon Sep 17 00:00:00 2001
From: Elizabet Oliveira
Date: Wed, 10 Feb 2021 18:48:15 +0000
Subject: [PATCH 16/22] Update src-docs/src/views/header/header_alert.js
Co-authored-by: Chandler Prall
---
src-docs/src/views/header/header_alert.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src-docs/src/views/header/header_alert.js b/src-docs/src/views/header/header_alert.js
index eeb5d058b61..c0e2feca1b3 100644
--- a/src-docs/src/views/header/header_alert.js
+++ b/src-docs/src/views/header/header_alert.js
@@ -201,7 +201,7 @@ const HeaderUpdates = () => {
repositionOnScroll
button={cheerButton}
isOpen={isPopoverVisible}
- closePopover={() => closePopover()}
+ closePopover={closePopover}
panelPaddingSize="none">
What's new
From 10736bd80f152d9f4c97eac8a79951fc7acd9b95 Mon Sep 17 00:00:00 2001
From: Elizabet Oliveira
Date: Wed, 10 Feb 2021 18:48:22 +0000
Subject: [PATCH 17/22] Update src-docs/src/views/header/header_animate.js
Co-authored-by: Chandler Prall
---
src-docs/src/views/header/header_animate.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src-docs/src/views/header/header_animate.js b/src-docs/src/views/header/header_animate.js
index cf7fc93f9c0..b876b244d17 100644
--- a/src-docs/src/views/header/header_animate.js
+++ b/src-docs/src/views/header/header_animate.js
@@ -121,7 +121,7 @@ export default () => {
setShowNotification()}
+ setShowNotification={setShowNotification}
notificationsNumber={notificationsNumber}
/>,
],
From 4b396ac3aeba2916f3a87a0c85d43c54fb38f04e Mon Sep 17 00:00:00 2001
From: Elizabet Oliveira
Date: Wed, 10 Feb 2021 18:48:31 +0000
Subject: [PATCH 18/22] Update src-docs/src/views/header/header_example.js
Co-authored-by: Chandler Prall
---
src-docs/src/views/header/header_example.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src-docs/src/views/header/header_example.js b/src-docs/src/views/header/header_example.js
index c517c698b16..4df5f6bc62e 100644
--- a/src-docs/src/views/header/header_example.js
+++ b/src-docs/src/views/header/header_example.js
@@ -124,7 +124,7 @@ const headerAlertSnippet = `
aria-controls={portalContentId}
aria-expanded={isPortalContentVisible}
aria-label="Open portal content"
- onClick={() => showPortalConten()}
+ onClick={showPortalContent}
notification={showNotification}
>
From 36c586d2480745510443bccdbaf8afc9455ab284 Mon Sep 17 00:00:00 2001
From: miukimiu
Date: Wed, 10 Feb 2021 19:12:37 +0000
Subject: [PATCH 19/22] renaming animate methods to euiAnimate
---
src-docs/src/views/header/header_animate.js | 14 +++++++-------
src-docs/src/views/header/header_example.js | 8 ++++----
.../header_section_item_button.test.tsx | 2 +-
.../header_section/header_section_item_button.tsx | 6 +++---
4 files changed, 15 insertions(+), 15 deletions(-)
diff --git a/src-docs/src/views/header/header_animate.js b/src-docs/src/views/header/header_animate.js
index b876b244d17..fa1711461fb 100644
--- a/src-docs/src/views/header/header_animate.js
+++ b/src-docs/src/views/header/header_animate.js
@@ -22,10 +22,10 @@ const HeaderUpdates = forwardRef(
const bellRef = useRef();
const cheerRef = useRef();
- // wrapping the `triggerAnimation` methods to make them available through this component's `ref`
- const animate = useCallback(() => {
- bellRef.current?.triggerAnimation();
- cheerRef.current?.triggerAnimation();
+ // wrapping the `euiAnimate` methods to make them available through this component's `ref`
+ const euiAnimate = useCallback(() => {
+ bellRef.current?.euiAnimate();
+ cheerRef.current?.euiAnimate();
}, []);
// we're using the `useImperativeHandle` which allows the child to expose a function to the parent
@@ -33,9 +33,9 @@ const HeaderUpdates = forwardRef(
useImperativeHandle(
ref,
() => ({
- animate,
+ euiAnimate,
}),
- [animate]
+ [euiAnimate]
);
const bellButton = (
@@ -83,7 +83,7 @@ export default () => {
setNotificationsNumber(notificationsNumber + 1);
}
- headerUpdatesRef.current?.animate();
+ headerUpdatesRef.current?.euiAnimate();
};
return (
diff --git a/src-docs/src/views/header/header_example.js b/src-docs/src/views/header/header_example.js
index 4df5f6bc62e..cb05d9cc82f 100644
--- a/src-docs/src/views/header/header_example.js
+++ b/src-docs/src/views/header/header_example.js
@@ -135,9 +135,9 @@ const headerAlertSnippet = `
const headerAnimateSnippet = `const bellRef = useRef();
- // wrapping the `triggerAnimation` methods to make them available through this component's `ref`
+ // wrapping the 'euiAnimate' methods to make them available through this component's 'ref'
const animate = useCallback(() => {
- bellRef.current?.triggerAnimation();
+ bellRef.current?.euiAnimate();
}, []);
// we're using the useImperativeHandle which allows the child to expose a function to the parent
@@ -407,8 +407,8 @@ export const HeaderExample = {
node that will render inside a{' '}
EuiBadgeNotification or pass{' '}
true to render a simple dot. You can also animate
- the button by calling the triggerAnimation() {' '}
- method on the EuiHeaderSectionItemButton {' '}
+ the button by calling the euiAnimate() method on
+ the EuiHeaderSectionItemButton {' '}
ref .
>
diff --git a/src/components/header/header_section/header_section_item_button.test.tsx b/src/components/header/header_section/header_section_item_button.test.tsx
index cb0f56a9590..d70d6a26f5e 100644
--- a/src/components/header/header_section/header_section_item_button.test.tsx
+++ b/src/components/header/header_section/header_section_item_button.test.tsx
@@ -89,7 +89,7 @@ describe('EuiHeaderSectionItemButton', () => {
function testAnimation(element: EuiHeaderSectionItemButtonRef) {
if (element) {
expect(element.animate).toHaveBeenCalledTimes(0);
- element.triggerAnimation();
+ element.euiAnimate();
expect(element.animate).toHaveBeenCalledTimes(1);
}
}
diff --git a/src/components/header/header_section/header_section_item_button.tsx b/src/components/header/header_section/header_section_item_button.tsx
index 1b77e9503e3..d9001b486fb 100644
--- a/src/components/header/header_section/header_section_item_button.tsx
+++ b/src/components/header/header_section/header_section_item_button.tsx
@@ -48,7 +48,7 @@ export type EuiHeaderSectionItemButtonProps = CommonProps &
};
export type EuiHeaderSectionItemButtonRef =
- | (HTMLButtonElement & { triggerAnimation: () => void })
+ | (HTMLButtonElement & { euiAnimate: () => void })
| null;
export const EuiHeaderSectionItemButton = forwardRef<
@@ -65,7 +65,7 @@ export const EuiHeaderSectionItemButton = forwardRef<
...rest
},
/**
- * Allows for animating with .triggerAnimation()
+ * Allows for animating with .euiAnimate()
*/
ref
) => {
@@ -79,7 +79,7 @@ export const EuiHeaderSectionItemButton = forwardRef<
ref,
() => {
if (buttonRef) {
- (buttonRef as any).triggerAnimation = () => {
+ (buttonRef as any).euiAnimate = () => {
const keyframes: Keyframe[] = [
{ transform: 'rotate(0)', offset: 0, easing: 'ease-in-out' },
{
From 67d1c48c11599c3f4001ccc0955c1943e5cfa5ba Mon Sep 17 00:00:00 2001
From: miukimiu
Date: Wed, 10 Feb 2021 19:42:08 +0000
Subject: [PATCH 20/22] euiAnimate into header example
---
src-docs/src/views/header/header_example.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src-docs/src/views/header/header_example.js b/src-docs/src/views/header/header_example.js
index cb05d9cc82f..6c4313b3cd7 100644
--- a/src-docs/src/views/header/header_example.js
+++ b/src-docs/src/views/header/header_example.js
@@ -136,7 +136,7 @@ const headerAlertSnippet = `
const headerAnimateSnippet = `const bellRef = useRef();
// wrapping the 'euiAnimate' methods to make them available through this component's 'ref'
-const animate = useCallback(() => {
+const euiAnimate = useCallback(() => {
bellRef.current?.euiAnimate();
}, []);
@@ -144,9 +144,9 @@ const animate = useCallback(() => {
useImperativeHandle(
ref,
() => ({
- animate,
+ euiAnimate,
}),
- [animate]
+ [euiAnimate]
);
const bellButton = (
From c5b041e8aeb4eabd0890db7d63eff48608bb1388 Mon Sep 17 00:00:00 2001
From: miukimiu
Date: Wed, 10 Feb 2021 19:47:13 +0000
Subject: [PATCH 21/22] simplifying onClick closeFlyout
---
src-docs/src/views/header/header_alert.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src-docs/src/views/header/header_alert.js b/src-docs/src/views/header/header_alert.js
index c0e2feca1b3..278e2616da4 100644
--- a/src-docs/src/views/header/header_alert.js
+++ b/src-docs/src/views/header/header_alert.js
@@ -152,7 +152,7 @@ const HeaderUpdates = () => {
const flyout = (
closeFlyout()}
+ onClose={closeFlyout}
size="s"
id="headerFlyoutNewsFeed"
aria-labelledby="flyoutSmallTitle">
@@ -178,7 +178,7 @@ const HeaderUpdates = () => {
closeFlyout()}
+ onClick={closeFlyout}
flush="left">
Close
From d431074f2cf2e475d08bc9b9eb057ccbfff0a8ed Mon Sep 17 00:00:00 2001
From: Elizabet Oliveira
Date: Thu, 11 Feb 2021 16:14:18 +0000
Subject: [PATCH 22/22] Update src-docs/src/views/header/header_example.js
Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com>
---
src-docs/src/views/header/header_example.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src-docs/src/views/header/header_example.js b/src-docs/src/views/header/header_example.js
index 6c4313b3cd7..6143beaa5ef 100644
--- a/src-docs/src/views/header/header_example.js
+++ b/src-docs/src/views/header/header_example.js
@@ -135,7 +135,7 @@ const headerAlertSnippet = `
const headerAnimateSnippet = `const bellRef = useRef();
- // wrapping the 'euiAnimate' methods to make them available through this component's 'ref'
+// wrapping the 'euiAnimate' methods to make them available through this component's 'ref'
const euiAnimate = useCallback(() => {
bellRef.current?.euiAnimate();
}, []);