Skip to content

Commit 4dc46ca

Browse files
committed
[Storybook] Add utils for hiding all controls or the entire panel
1 parent 28570dd commit 4dc46ca

3 files changed

Lines changed: 33 additions & 2 deletions

File tree

.storybook/preview.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const preview: Preview = {
9393
parameters: {
9494
actions: { argTypesRegex: '^on[A-Z].*' },
9595
backgrounds: { disable: true }, // Use colorMode instead
96+
options: { showPanel: true }, // default to showing the controls panel
9697
controls: {
9798
expanded: true,
9899
sort: 'requiredFirst',

.storybook/utils.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
* Side Public License, v 1.
77
*/
88

9+
/**
10+
* argTypes configurations
11+
*/
12+
913
/**
1014
* Completely hide props from Storybook's controls panel.
1115
* Should be passed or spread to `argTypes`
@@ -35,3 +39,26 @@ export const disableStorybookControls = <Props>(
3539
);
3640
};
3741
const DISABLE_CONTROL = { control: false };
42+
43+
/**
44+
* parameters configurations
45+
*/
46+
47+
/**
48+
* Will hide all props/controls. Pass to `parameters`
49+
*
50+
* TODO: Figure out some way to not show Storybook's "setup" text?
51+
*/
52+
export const hideAllStorybookControls = {
53+
controls: { exclude: /.*/g },
54+
};
55+
56+
/**
57+
* Will hide the control/addon panel entirely for a specific story.
58+
* Should be passed or spread to to `parameters`.
59+
*
60+
* Note that users can choose to re-show the panel in the UI
61+
*/
62+
export const hidePanel = {
63+
options: { showPanel: false },
64+
};

src/components/collapsible_nav_beta/collapsible_nav_beta.stories.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88

99
import React, { FunctionComponent, PropsWithChildren, useState } from 'react';
1010
import type { Meta, StoryObj } from '@storybook/react';
11+
import {
12+
hideStorybookControls,
13+
hideAllStorybookControls,
14+
} from '../../../.storybook/utils';
1115

1216
import { EuiHeader, EuiHeaderSection, EuiHeaderSectionItem } from '../header';
1317
import { EuiPageTemplate } from '../page_template';
@@ -507,6 +511,5 @@ export const FlyoutOverlay: Story = {
507511
</EuiHeader>
508512
);
509513
},
510-
// Hide all parameters
511-
parameters: { controls: { exclude: /.*/g } },
514+
parameters: hideAllStorybookControls,
512515
};

0 commit comments

Comments
 (0)