Skip to content

Commit

Permalink
[Emotion] Convert EuiHeaderAlert, EuiHeaderSection, EuiHeaderSectionI…
Browse files Browse the repository at this point in the history
…tem, EuiHeaderSectionItemButton, and EuiHeaderLinks (#7005)
  • Loading branch information
cee-chen authored Aug 1, 2023
1 parent ac996fa commit 3e950bf
Show file tree
Hide file tree
Showing 61 changed files with 1,019 additions and 531 deletions.
10 changes: 2 additions & 8 deletions src-docs/src/components/guide_page/guide_page_header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,14 +147,8 @@ export const GuidePageHeader: React.FunctionComponent<GuidePageHeaderProps> = ({
position="fixed"
theme="dark"
sections={[
{
items: [renderLogo(), renderVersion()],
borders: 'none',
},
{
items: rightSideItems,
borders: 'none',
},
{ items: [renderLogo(), renderVersion()] },
{ items: rightSideItems },
]}
/>
</header>
Expand Down
1 change: 0 additions & 1 deletion src-docs/src/views/collapsible_nav/collapsible_nav_all.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ const CollapsibleNavAll = () => {
sections={[
{
items: leftSectionItems,
borders: 'right',
},
{
items: [
Expand Down
8 changes: 3 additions & 5 deletions src-docs/src/views/header/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,9 @@ export default () => {

return (
<EuiHeader>
<EuiHeaderSection grow={false}>
<EuiHeaderSectionItem border="right">
{renderLogo()}
</EuiHeaderSectionItem>
<EuiHeaderSectionItem border="right">
<EuiHeaderSection>
<EuiHeaderSectionItem>{renderLogo()}</EuiHeaderSectionItem>
<EuiHeaderSectionItem>
<HeaderSpacesMenu />
</EuiHeaderSectionItem>
</EuiHeaderSection>
Expand Down
16 changes: 12 additions & 4 deletions src-docs/src/views/header/header_alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ import {
EuiText,
EuiTitle,
} from '../../../../src/components';
import { useGeneratedHtmlId } from '../../../../src/services';
import { useGeneratedHtmlId, useEuiTheme } from '../../../../src/services';

const HeaderUpdates = () => {
const { euiTheme } = useEuiTheme();

const [isFlyoutVisible, setIsFlyoutVisible] = useState(false);
const [isPopoverVisible, setIsPopoverVisible] = useState(false);
const newsFeedFlyoutId = useGeneratedHtmlId({ prefix: 'newsFeedFlyout' });
Expand Down Expand Up @@ -216,7 +218,13 @@ const HeaderUpdates = () => {
panelPaddingSize="none"
>
<EuiPopoverTitle paddingSize="s">What&apos;s new</EuiPopoverTitle>
<div style={{ maxHeight: '40vh', overflowY: 'auto', padding: 4 }}>
<div
style={{
maxHeight: '40vh',
overflowY: 'auto',
padding: euiTheme.size.s,
}}
>
<EuiSpacer size="s" />
{alerts.map((alert, i) => (
<EuiHeaderAlert
Expand Down Expand Up @@ -341,8 +349,8 @@ export default () => {
<EuiSpacer />

<EuiHeader position={position} theme={theme}>
<EuiHeaderSection grow={false}>
<EuiHeaderSectionItem border="right">
<EuiHeaderSection>
<EuiHeaderSectionItem>
<EuiHeaderLogo>Elastic</EuiHeaderLogo>
</EuiHeaderSectionItem>
</EuiHeaderSection>
Expand Down
2 changes: 0 additions & 2 deletions src-docs/src/views/header/header_animate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ export default () => {
sections={[
{
items: [<EuiHeaderLogo>Elastic</EuiHeaderLogo>],
borders: 'none',
},
{
items: [
Expand All @@ -135,7 +134,6 @@ export default () => {
notificationsNumber={notificationsNumber}
/>,
],
borders: 'none',
},
]}
/>
Expand Down
2 changes: 0 additions & 2 deletions src-docs/src/views/header/header_dark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export default () => {
<EuiHeaderLink iconType="help"> Help</EuiHeaderLink>
</EuiHeaderLinks>,
],
borders: 'right',
},
{
items: [
Expand All @@ -49,7 +48,6 @@ export default () => {
<EuiAvatar name="John Username" size="s" />
</EuiHeaderSectionItemButton>,
],
borders: 'none',
},
]}
/>
Expand Down
4 changes: 0 additions & 4 deletions src-docs/src/views/header/header_elastic_pattern.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,9 @@ export default () => {
</EuiHeaderLogo>,
deploymentMenu,
],
borders: 'none',
},
{
items: [<EuiShowFor sizes={['m', 'l', 'xl']}>{search}</EuiShowFor>],
borders: 'none',
},
{
items: [
Expand All @@ -325,7 +323,6 @@ export default () => {
</EuiHeaderSectionItemButton>,
userMenu,
],
borders: 'none',
},
]}
/>
Expand All @@ -343,7 +340,6 @@ export default () => {
text: 'Users',
},
],
borders: 'right',
},
{
items: [
Expand Down
10 changes: 4 additions & 6 deletions src-docs/src/views/header/header_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ import HeaderElasticPattern from './header_elastic_pattern';
const headerElasticPatternSource = require('!!raw-loader!./header_elastic_pattern');

const headerSnippet = `<EuiHeader>
<EuiHeaderSection grow={false}>
<EuiHeaderSectionItem border="right">
<EuiHeaderSection>
<EuiHeaderSectionItem>
<!-- HeaderSectionItem content -->
</EuiHeaderSectionItem>
</EuiHeaderSection>
Expand All @@ -66,12 +66,10 @@ const headerSectionsSnippet = `<EuiHeader
sections={[
{
items: [...],
borders: 'right',
breadcrumbs: [...],
},
{
items: [...],
borders: 'none',
},
{
items: [...],
Expand All @@ -80,7 +78,7 @@ const headerSectionsSnippet = `<EuiHeader
/>`;

const headerLinksSnippet = `<EuiHeader>
<EuiHeaderSectionItem border="right">
<EuiHeaderSectionItem>
<EuiHeaderLogo
iconType="iconName"
href=""
Expand All @@ -99,7 +97,7 @@ const headerLinksSnippet = `<EuiHeader>
</EuiHeader>`;

const headerAlertSnippet = `<EuiHeader>
<EuiHeaderSection grow={false}>
<EuiHeaderSection>
<EuiHeaderSectionItem>
<!-- HeaderSectionItem content -->
</EuiHeaderSectionItem>
Expand Down
2 changes: 1 addition & 1 deletion src-docs/src/views/header/header_links.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
export default () => {
return (
<EuiHeader>
<EuiHeaderSectionItem border="right">
<EuiHeaderSectionItem>
<EuiHeaderLogo>Elastic</EuiHeaderLogo>
</EuiHeaderSectionItem>

Expand Down
1 change: 0 additions & 1 deletion src-docs/src/views/header/header_position.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default () => {
const sections: EuiHeaderSections[] = [
{
items: [<EuiHeaderLogo>Elastic</EuiHeaderLogo>],
borders: 'right',
},
];

Expand Down
1 change: 0 additions & 1 deletion src-docs/src/views/header/header_sections.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ export default () => {
const sections: EuiHeaderSections[] = [
{
items: [renderLogo, renderSpaces],
borders: 'right',
breadcrumbs: breadcrumbs,
breadcrumbProps: {
'aria-label': 'Header sections breadcrumbs',
Expand Down
4 changes: 0 additions & 4 deletions src-docs/src/views/header/header_stacked.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ export default () => {
items: [
<EuiHeaderLogo iconType="logoElastic">Elastic</EuiHeaderLogo>,
],
borders: 'none',
},
{
items: [
<EuiHeaderSectionItemButton aria-label="Account menu">
<EuiAvatar name="John Username" size="s" />
</EuiHeaderSectionItemButton>,
],
borders: 'none',
},
]}
/>
Expand All @@ -67,7 +65,6 @@ export default () => {
</EuiHeaderSectionItemButton>,
],
breadcrumbs: breadcrumbs,
borders: 'right',
},
{
items: [
Expand All @@ -78,7 +75,6 @@ export default () => {
<EuiIcon type="cheer" size="m" />
</EuiHeaderSectionItemButton>,
],
borders: 'none',
},
]}
/>
Expand Down
4 changes: 2 additions & 2 deletions src-docs/src/views/progress/progress_fixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ export default () => {
<EuiHeader
style={{ position: 'fixed', top: 0, left: 0, width: '100%' }}
>
<EuiHeaderSection grow={false}>
<EuiHeaderSectionItem border="right">
<EuiHeaderSection>
<EuiHeaderSectionItem>
<EuiHeaderLogo
iconType="logoKibana"
href="#"
Expand Down
20 changes: 10 additions & 10 deletions src/components/header/__snapshots__/header.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -63,34 +63,34 @@ exports[`EuiHeader sections render breadcrumbs and props 1`] = `
</div>
`;

exports[`EuiHeader sections render simple items and borders 1`] = `
exports[`EuiHeader sections render simple items 1`] = `
<div
class="euiHeader emotion-euiHeader-static-default"
>
<div
class="euiHeaderSection euiHeaderSection--dontGrow euiHeaderSection--left"
class="euiHeaderSection emotion-euiHeaderSection"
>
<div
class="euiHeaderSectionItem euiHeaderSectionItem--borderRight"
class="euiHeaderSectionItem emotion-euiHeaderSectionItem"
>
Item 1
</div>
<div
class="euiHeaderSectionItem euiHeaderSectionItem--borderRight"
class="euiHeaderSectionItem emotion-euiHeaderSectionItem"
>
Item 2
</div>
</div>
<div
class="euiHeaderSection euiHeaderSection--dontGrow euiHeaderSection--left"
class="euiHeaderSection emotion-euiHeaderSection"
>
<div
class="euiHeaderSectionItem euiHeaderSectionItem--borderLeft"
class="euiHeaderSectionItem emotion-euiHeaderSectionItem"
>
Item A
</div>
<div
class="euiHeaderSectionItem euiHeaderSectionItem--borderLeft"
class="euiHeaderSectionItem emotion-euiHeaderSectionItem"
>
Item B
</div>
Expand All @@ -103,15 +103,15 @@ exports[`EuiHeader throws a warning if both children and sections were passed 1`
class="euiHeader emotion-euiHeader-static-default"
>
<div
class="euiHeaderSection euiHeaderSection--dontGrow euiHeaderSection--left"
class="euiHeaderSection emotion-euiHeaderSection"
>
<div
class="euiHeaderSectionItem euiHeaderSectionItem--borderLeft"
class="euiHeaderSectionItem emotion-euiHeaderSectionItem"
>
Item 1
</div>
<div
class="euiHeaderSectionItem euiHeaderSectionItem--borderLeft"
class="euiHeaderSectionItem emotion-euiHeaderSectionItem"
>
Item 2
</div>
Expand Down
3 changes: 0 additions & 3 deletions src/components/header/_index.scss

This file was deleted.

6 changes: 2 additions & 4 deletions src/components/header/header.a11y.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,8 @@ const Header = () => {
return (
<EuiHeader>
<EuiHeaderSection grow={false}>
<EuiHeaderSectionItem border="right">
{renderLogo()}
</EuiHeaderSectionItem>
<EuiHeaderSectionItem border="right">
<EuiHeaderSectionItem>{renderLogo()}</EuiHeaderSectionItem>
<EuiHeaderSectionItem>
<HeaderSpacesMenu />
</EuiHeaderSectionItem>
</EuiHeaderSection>
Expand Down
56 changes: 56 additions & 0 deletions src/components/header/header.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,18 @@
* Side Public License, v 1.
*/

import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';

import {
EuiHeaderLogo,
EuiHeaderSectionItemButton,
EuiHeaderLinks,
EuiHeaderLink,
EuiIcon,
EuiAvatar,
} from '../../components';

import { EuiHeader, EuiHeaderProps } from './header';

const meta: Meta<EuiHeaderProps> = {
Expand All @@ -24,3 +34,49 @@ export const Playground: Story = {
theme: 'default',
},
};

export const Sections: Story = {
args: {
position: 'fixed',
sections: [
{
items: [
<EuiHeaderLogo
iconType="logoElastic"
href="#"
aria-label="Go to home page"
/>,
<EuiHeaderSectionItemButton aria-label="Spaces menu">
<EuiAvatar type="space" name="Sales Team" size="s" />
</EuiHeaderSectionItemButton>,
],
breadcrumbs: [
{ text: 'Management', href: '#' },
{ text: 'Users', href: '#' },
{ text: 'Create' },
],
breadcrumbProps: {
'aria-label': 'Header sections breadcrumbs',
},
},
{
items: [
<EuiHeaderLinks aria-label="App navigation dark theme example">
<EuiHeaderLink isActive>Docs</EuiHeaderLink>
<EuiHeaderLink>Code</EuiHeaderLink>
<EuiHeaderLink iconType="help"> Help</EuiHeaderLink>
</EuiHeaderLinks>,
<EuiHeaderSectionItemButton aria-label="Account menu">
<EuiAvatar name="John Username" size="s" />
</EuiHeaderSectionItemButton>,
<EuiHeaderSectionItemButton
notification="1"
aria-label="Apps menu with 1 new app"
>
<EuiIcon type="apps" size="m" />
</EuiHeaderSectionItemButton>,
],
},
],
},
};
Loading

0 comments on commit 3e950bf

Please sign in to comment.