From 0598ff3743802d70eaabd8b9a12bb534979b1263 Mon Sep 17 00:00:00 2001 From: Tima Gixe <60817786+timagixe@users.noreply.github.com> Date: Fri, 9 Sep 2022 16:40:27 +0300 Subject: [PATCH] Storybook: Add controls to `CollapsableSection` story (#54943) --- .../Collapse/CollapsableSection.story.tsx | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/packages/grafana-ui/src/components/Collapse/CollapsableSection.story.tsx b/packages/grafana-ui/src/components/Collapse/CollapsableSection.story.tsx index 8fd704b000c..eaae54aadb7 100644 --- a/packages/grafana-ui/src/components/Collapse/CollapsableSection.story.tsx +++ b/packages/grafana-ui/src/components/Collapse/CollapsableSection.story.tsx @@ -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 = { 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 = ({ children, ...args }: Props) => { + const [, updateArgs] = useArgs(); + + const onToggle = (isOpen: boolean) => { + action('onToggle fired')({ isOpen }); + updateArgs({ isOpen }); + }; + return ( - -
{"Here's some content"}
-
+
+ + <>{children} + +
); };