Skip to content

Commit

Permalink
Update stories
Browse files Browse the repository at this point in the history
- Add EuiHeaderLinks story
  - Skipping `EuiHeaderLink` story for now as it really just has one meaningful prop that's already being tested/displayed in `EuiHeaderLinks`

- Update EuiHeader story with everything put together in `sections`

- Expand EuiHeaderLogo stories
  • Loading branch information
cee-chen committed Jul 27, 2023
1 parent 862fbcb commit 7d23ddf
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/components/header/_index.scss
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
@import 'header_links/index';
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>,
],
},
],
},
};
Empty file.
Empty file.
4 changes: 0 additions & 4 deletions src/components/header/header_links/_index.scss

This file was deleted.

Empty file.
43 changes: 43 additions & 0 deletions src/components/header/header_links/header_links.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

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

import { EuiHeader, EuiHeaderSection, EuiHeaderSectionItem } from '../';

import { EuiHeaderLink } from './header_link';
import { EuiHeaderLinks, EuiHeaderLinksProps } from './header_links';

const meta: Meta<EuiHeaderLinksProps> = {
title: 'EuiHeaderLinks',
component: EuiHeaderLinks,
};

export default meta;
type Story = StoryObj<EuiHeaderLinksProps>;

export const Playground: Story = {
render: ({ ...args }) => (
<EuiHeader position="fixed">
<EuiHeaderSection>
<EuiHeaderSectionItem>
<EuiHeaderLinks {...args}>
<EuiHeaderLink isActive>Docs</EuiHeaderLink>
<EuiHeaderLink>Code</EuiHeaderLink>
<EuiHeaderLink iconType="help"> Help</EuiHeaderLink>
</EuiHeaderLinks>
</EuiHeaderSectionItem>
</EuiHeaderSection>
</EuiHeader>
),
args: {
gutterSize: 's',
popoverBreakpoints: ['xs', 's'],
},
};
22 changes: 19 additions & 3 deletions src/components/header/header_logo/header_logo.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import React from 'react';
import type { Meta, StoryObj } from '@storybook/react';

import { EuiHeader } from '../header';
import { EuiHeader, EuiHeaderSectionItem } from '../';
import { EuiHeaderLogo, EuiHeaderLogoProps } from './header_logo';

const meta: Meta<EuiHeaderLogoProps> = {
Expand All @@ -22,12 +22,28 @@ type Story = StoryObj<EuiHeaderLogoProps>;

export const Playground: Story = {
render: ({ ...args }) => (
<EuiHeader>
<EuiHeaderLogo {...args} />
<EuiHeader position="fixed">
<EuiHeaderSectionItem>
<EuiHeaderLogo {...args} />
</EuiHeaderSectionItem>
</EuiHeader>
),
args: {
iconType: 'logoElastic',
iconTitle: 'Elastic',
},
};

export const WithText: Story = {
render: ({ ...args }) => (
<EuiHeader position="fixed">
<EuiHeaderSectionItem>
<EuiHeaderLogo {...args} />
</EuiHeaderSectionItem>
</EuiHeader>
),
args: {
iconType: 'logoElastic',
children: 'Elastic',
},
};
1 change: 1 addition & 0 deletions upcoming_changelogs/7005.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@

- Converted `EuiHeaderAlert` to Emotion; Removed unused `.euiHeaderAlert__dismiss` CSS
- Converted `EuiHeaderSection`, `EuiHeaderSectionItem`, and `EuiHeaderSectionItemButton` to Emotion
- Converted `EuiHeaderLinks` and `EuiHeaderLink` to Emotion; Removed `$euiHeaderLinksGutterSizes` Sass variables

0 comments on commit 7d23ddf

Please sign in to comment.