Skip to content

Commit

Permalink
[EuiCollapsibleNavBeta] Add storybook QA test for ensuring flyouts si…
Browse files Browse the repository at this point in the history
…t above the nav (#7051)
  • Loading branch information
cee-chen authored Aug 8, 2023
1 parent d7f5c92 commit d49b59a
Showing 1 changed file with 41 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
* Side Public License, v 1.
*/

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

import { EuiHeader, EuiHeaderSection } from '../header';
import { EuiHeader, EuiHeaderSection, EuiHeaderSectionItem } from '../header';
import { EuiPageTemplate } from '../page_template';
import { EuiFlyoutBody, EuiFlyoutFooter } from '../flyout';
import { EuiFlyout, EuiFlyoutBody, EuiFlyoutFooter } from '../flyout';
import { EuiButton } from '../button';

import { EuiCollapsibleNavItem } from './collapsible_nav_item';
import {
Expand All @@ -34,6 +35,7 @@ const meta: Meta<EuiCollapsibleNavBetaProps> = {
args: {
side: 'left',
initialIsCollapsed: false,
width: 248,
},
};
export default meta;
Expand Down Expand Up @@ -411,3 +413,39 @@ export const MultipleFixedHeaders: Story = {
</>
),
};

const MockConsumerFlyout: FunctionComponent = () => {
const [flyoutIsOpen, setFlyoutOpen] = useState(false);
return (
<>
<EuiButton size="s" onClick={() => setFlyoutOpen(!flyoutIsOpen)}>
Toggle a flyout
</EuiButton>
{flyoutIsOpen && (
<EuiFlyout onClose={() => setFlyoutOpen(false)}>
<EuiFlyoutBody>
Some other mock consumer flyout that <strong>should</strong> overlap
EuiCollapsibleNav
</EuiFlyoutBody>
</EuiFlyout>
)}
</>
);
};

export const FlyoutInFixedHeaders: Story = {
render: ({ ...args }) => {
return (
<EuiHeader position="fixed">
<EuiHeaderSection>
<EuiCollapsibleNavBeta {...args}>Nav content</EuiCollapsibleNavBeta>
</EuiHeaderSection>
<EuiHeaderSection>
<EuiHeaderSectionItem>
<MockConsumerFlyout />
</EuiHeaderSectionItem>
</EuiHeaderSection>
</EuiHeader>
);
},
};

0 comments on commit d49b59a

Please sign in to comment.