Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
915a2d1
Adding animation and hasBackground props to EuiHeaderSectionItemButton
elizabetdev Jan 14, 2021
14d5b51
A few improvements
elizabetdev Jan 14, 2021
cc5c874
Docs props
elizabetdev Jan 15, 2021
4f5c09f
Removing hasBackground prop
elizabetdev Jan 18, 2021
e020d7a
Using JS do hide and show on xs breakpoints
elizabetdev Jan 18, 2021
c6f7bc3
Adding a snippet
elizabetdev Jan 18, 2021
41a54c8
refactor animation prop into a ref method
chandlerprall Jan 29, 2021
e4b21e1
Merge pull request #8 from chandlerprall/notification_header_button_m…
elizabetdev Feb 1, 2021
d5923d3
Snapshots. Trigger animation comments.
elizabetdev Feb 1, 2021
4d3c970
Deleting unused css animation
elizabetdev Feb 1, 2021
8253863
triggerAnimation explanation
elizabetdev Feb 1, 2021
46a3d77
Cleaned up some logic and created a docs example specifically for the…
Feb 8, 2021
f88a657
Merge pull request #11 from cchaos/notification_header_button
elizabetdev Feb 10, 2021
aba5d8e
re-enable the animation test
chandlerprall Feb 10, 2021
d13e053
Merge pull request #12 from chandlerprall/notification_header_button_…
elizabetdev Feb 10, 2021
f3a8851
Update src-docs/src/views/header/header_animate.js
elizabetdev Feb 10, 2021
733ae30
Update src-docs/src/views/header/header_example.js
elizabetdev Feb 10, 2021
4634390
Update src-docs/src/views/header/header_alert.js
elizabetdev Feb 10, 2021
b4eb475
Update src-docs/src/views/header/header_alert.js
elizabetdev Feb 10, 2021
10736bd
Update src-docs/src/views/header/header_animate.js
elizabetdev Feb 10, 2021
4b396ac
Update src-docs/src/views/header/header_example.js
elizabetdev Feb 10, 2021
36c586d
renaming animate methods to euiAnimate
elizabetdev Feb 10, 2021
67d1c48
euiAnimate into header example
elizabetdev Feb 10, 2021
c5b041e
simplifying onClick closeFlyout
elizabetdev Feb 10, 2021
d431074
Update src-docs/src/views/header/header_example.js
elizabetdev Feb 11, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
471 changes: 283 additions & 188 deletions src-docs/src/views/header/header_alert.js

Large diffs are not rendered by default.

56 changes: 52 additions & 4 deletions src-docs/src/views/header/header_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ const headerSnippet = `<EuiHeader>
<!-- HeaderSectionItem content -->
</EuiHeaderSectionItem>
</EuiHeaderSection>
</EuiHeader>`;
</EuiHeader>
`;

const headerSectionsSnippet = `<EuiHeader
sections={[
Expand Down Expand Up @@ -105,6 +106,30 @@ const headerLinksSnippet = `<EuiHeader>
</EuiHeaderLinks>
</EuiHeader>`;

const headerAlertSnippet = `<EuiHeader>
<EuiHeaderSection grow={false}>
<EuiHeaderSectionItem>
<!-- HeaderSectionItem content -->
</EuiHeaderSectionItem>
</EuiHeaderSection>

<EuiHeaderSection side="right">
<EuiHeaderSectionItem>
<!-- Button to trigger portal content like a EuiPopover or a EuiFlyout -->
<EuiHeaderSectionItemButton
aria-controls={portalContentId}
aria-expanded={isPortalContentVisible}
aria-label="Open portal content"
onClick={() => showPortalConten()}
Comment thread
elizabetdev marked this conversation as resolved.
Outdated
notification={showNotification}
animation={isAnimating}
>
<EuiIcon type="bell" />
</EuiHeaderSectionItemButton>
</EuiHeaderSectionItem>
</EuiHeaderSection>
</EuiHeader>`;

export const HeaderExample = {
title: 'Header',
sections: [
Expand Down Expand Up @@ -279,7 +304,7 @@ export const HeaderExample = {
demo: <HeaderDark theme={lightColors} />,
},
{
title: 'Portal content in the header',
title: 'Portal content and buttons in the header',
source: [
{
type: GuideSectionTypes.JS,
Expand Down Expand Up @@ -311,16 +336,39 @@ export const HeaderExample = {
in conjunction with a <strong>fixed</strong> header, be sure to add
the <EuiCode>repositionOnScroll</EuiCode> prop to the popover.
</p>
<p>
To alert or notify users about the additional information they are
receiving, use the <strong>EuiHeaderSectionItemButton</strong>{' '}
<EuiCode>notification</EuiCode> prop. You can pass a{' '}
<EuiCode>node</EuiCode> that will render inside a{' '}
<strong>EuiBadgeNotification</strong> or pass{' '}
<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
Copy Markdown
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?

</p>

<p>
The example below shows how to incorporate{' '}
<strong>EuiHeaderAlert</strong> components to show a list of
updates.
<strong>EuiHeaderAlert</strong> components to show a list of updates
inside a{' '}
<Link to="/layout/flyout">
<strong>EuiFlyout</strong>
</Link>{' '}
and a{' '}
<Link to="/layout/popover">
<strong>EuiPopover</strong>
</Link>{' '}
. It also shows how to animate and add different types of
notifications.
</p>
</>
),
props: {
EuiHeaderAlert,
EuiHeaderSectionItemButton,
},
snippet: headerAlertSnippet,
demo: <HeaderAlert />,
Comment thread
elizabetdev marked this conversation as resolved.
},
{
Expand Down
4 changes: 2 additions & 2 deletions src/components/header/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

.euiHeaderLogo__text,
.euiHeaderLink,
.euiHeaderSectionItem__button {
.euiHeaderSectionItemButton {
color: $euiColorGhost;
}

Expand All @@ -20,7 +20,7 @@

.euiHeaderLogo,
.euiHeaderLink,
.euiHeaderSectionItem__button {
.euiHeaderSectionItemButton {
&:hover {
background: transparentize(lightOrDarkTheme($euiColorDarkShade, $euiColorLightestShade), .5);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,16 @@ exports[`EuiHeaderLinks popover props is rendered 1`] = `
>
<button
aria-label="Open menu"
class="euiHeaderSectionItem__button customButtonClass"
class="euiHeaderSectionItemButton customButtonClass"
type="button"
>
<span
data-euiicon-type="bolt"
/>
class="euiHeaderSectionItemButton__content"
>
<span
data-euiicon-type="bolt"
/>
</span>
</button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,39 @@
exports[`EuiHeaderSectionItemButton is rendered 1`] = `
<button
aria-label="aria-label"
class="euiHeaderSectionItem__button testClass1 testClass2"
class="euiHeaderSectionItemButton testClass1 testClass2"
data-test-subj="test subject string"
type="button"
/>
>
<span
class="euiHeaderSectionItemButton__content"
/>
</button>
`;

exports[`EuiHeaderSectionItemButton renders children 1`] = `
<button
class="euiHeaderSectionItem__button"
class="euiHeaderSectionItemButton"
type="button"
>
<span>
Ahoy!
<span
class="euiHeaderSectionItemButton__content"
>
<span>
Ahoy!
</span>
</span>
</button>
`;

exports[`EuiHeaderSectionItemButton renders notification as a badge 1`] = `
<button
class="euiHeaderSectionItem__button"
class="euiHeaderSectionItemButton"
type="button"
>
<span
class="euiHeaderSectionItemButton__content"
/>
<span
class="euiNotificationBadge euiHeaderSectionItemButton__notification euiHeaderSectionItemButton__notification--badge"
>
Expand All @@ -35,9 +46,12 @@ exports[`EuiHeaderSectionItemButton renders notification as a badge 1`] = `

exports[`EuiHeaderSectionItemButton renders notification as a dot 1`] = `
<button
class="euiHeaderSectionItem__button"
class="euiHeaderSectionItemButton"
type="button"
>
<span
class="euiHeaderSectionItemButton__content"
/>
<span
class="euiHeaderSectionItemButton__notification euiHeaderSectionItemButton__notification--dot"
color="accent"
Expand All @@ -48,9 +62,12 @@ exports[`EuiHeaderSectionItemButton renders notification as a dot 1`] = `

exports[`EuiHeaderSectionItemButton renders notification color 1`] = `
<button
class="euiHeaderSectionItem__button"
class="euiHeaderSectionItemButton"
type="button"
>
<span
class="euiHeaderSectionItemButton__content"
/>
<span
class="euiNotificationBadge euiNotificationBadge--subdued euiHeaderSectionItemButton__notification euiHeaderSectionItemButton__notification--badge"
>
Expand Down
53 changes: 2 additions & 51 deletions src/components/header/header_section/_header_section_item.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,6 @@
}
}

.euiHeaderSectionItem__button {
position: relative; // For positioning the notification
height: $euiHeaderChildSize;
min-width: $euiHeaderChildSize;
text-align: center;
font-size: 0; // aligns icons better vertically

&:hover {
background: $euiColorLightestShade;
}

&:focus {
background: $euiFocusBackgroundColor;
}
}

.euiHeaderSectionItem--borderLeft {
&:after {
left: 0;
Expand All @@ -46,25 +30,8 @@
}
}

.euiHeaderSectionItemButton__notification {
position: absolute;
}

.euiHeaderSectionItemButton__notification--badge {
top: 9%;
right: 9%;
box-shadow: 0 0 0 1px $euiHeaderBackgroundColor;
}

.euiHeaderSectionItemButton__notification--dot {
top: 0;
right: 0;
stroke: $euiHeaderBackgroundColor;
}

@include euiBreakpoint('xs') {
.euiHeaderSectionItem,
.euiHeaderSectionItem__button {
.euiHeaderSectionItem {
min-width: $euiHeaderChildSize * .75;
}

Expand All @@ -74,20 +41,4 @@
display: none;
}
}

// On small screens just show a small dot indicating there are notifications
.euiHeaderSectionItemButton__notification--badge {
@include size($euiSizeS);
top: 20%;
min-width: 0;
border-radius: $euiSizeS;
color: $euiColorAccent;
overflow: hidden;
}

// Using specificty to override the default icon size
.euiHeaderSectionItemButton__notification.euiHeaderSectionItemButton__notification--dot {
@include size($euiSize);
top: 9%;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
.euiHeaderSectionItemButton {
position: relative; // For positioning the notification
height: $euiHeaderChildSize;
min-width: $euiHeaderChildSize;
text-align: center;
font-size: 0; // aligns icons better vertically

&:hover {
background: $euiColorLightestShade;
}

&:focus {
background: $euiFocusBackgroundColor;
}
}

.euiHeaderSectionItemButton__notification {
position: absolute;

&--dot {
top: 0;
right: 0;
stroke: $euiHeaderBackgroundColor;
}

&--badge {
top: 9%;
right: 9%;
box-shadow: 0 0 0 1px $euiHeaderBackgroundColor;
}
}


.euiHeaderSectionItemButton__content {
// This element is a span and we're changing the display because inline elements can’t take a transform
display: inline-block;
}

@include euiBreakpoint('xs') {
.euiHeaderSectionItemButton {
min-width: $euiHeaderChildSize * .75;
}

// Using specificity to override the default icon size
.euiHeaderSectionItemButton__notification.euiHeaderSectionItemButton__notification--dot {
@include size($euiSize);
top: 9%;
}
}
1 change: 1 addition & 0 deletions src/components/header/header_section/_index.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@import 'header_section';
@import 'header_section_item';
@import 'header_section_item_button';
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ describe('EuiHeaderSectionItemButton', () => {
});
});

// test('renders animation', () => {
// const component = render(
// <EuiHeaderSectionItemButton animation={true} notification={true} />
// );
//
// expect(component).toMatchSnapshot();
// });

describe('onClick', () => {
test("isn't called upon instantiation", () => {
const onClickHandler = jest.fn();
Expand Down
Loading