mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Storybook: Add controls to CollapsableSection
story (#54943)
This commit is contained in:
parent
7147d17567
commit
0598ff3743
@ -1,24 +1,50 @@
|
||||
import { ComponentMeta } from '@storybook/react';
|
||||
import { action } from '@storybook/addon-actions';
|
||||
import { useArgs } from '@storybook/client-api';
|
||||
import { ComponentMeta, ComponentStory } from '@storybook/react';
|
||||
import React from 'react';
|
||||
|
||||
import { CollapsableSection } from './CollapsableSection';
|
||||
import { withCenteredStory } from '../../utils/storybook/withCenteredStory';
|
||||
|
||||
import { CollapsableSection, Props } from './CollapsableSection';
|
||||
import mdx from './CollapsableSection.mdx';
|
||||
|
||||
const meta: ComponentMeta<typeof CollapsableSection> = {
|
||||
title: 'Layout/CollapsableSection',
|
||||
component: CollapsableSection,
|
||||
decorators: [withCenteredStory],
|
||||
parameters: {
|
||||
docs: {
|
||||
page: mdx,
|
||||
},
|
||||
controls: {
|
||||
exclude: ['className', 'contentClassName', 'onToggle', 'labelId', 'isOpen'],
|
||||
},
|
||||
},
|
||||
args: {
|
||||
isOpen: false,
|
||||
loading: false,
|
||||
label: 'Collapsable section title',
|
||||
children: 'Collapsed content data',
|
||||
},
|
||||
argTypes: {
|
||||
label: { control: 'text' },
|
||||
},
|
||||
};
|
||||
|
||||
export const simple = () => {
|
||||
export const Basic: ComponentStory<typeof CollapsableSection> = ({ children, ...args }: Props) => {
|
||||
const [, updateArgs] = useArgs();
|
||||
|
||||
const onToggle = (isOpen: boolean) => {
|
||||
action('onToggle fired')({ isOpen });
|
||||
updateArgs({ isOpen });
|
||||
};
|
||||
|
||||
return (
|
||||
<CollapsableSection label="Collapsable section" isOpen>
|
||||
<div>{"Here's some content"}</div>
|
||||
</CollapsableSection>
|
||||
<div>
|
||||
<CollapsableSection {...args} onToggle={onToggle}>
|
||||
<>{children}</>
|
||||
</CollapsableSection>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user