Commit 0e63dfaf by Uchechukwu Obasi Committed by GitHub

ButtonCascader: updates story from knobs to controls (#31288)

* ButtonCascader: updates story from knobs to controls

* some nit fixes
parent 7f8fb2b5
import React from 'react'; import React from 'react';
import { withKnobs, text, boolean, object, select } from '@storybook/addon-knobs'; import { Story } from '@storybook/react';
import { withCenteredStory } from '../../utils/storybook/withCenteredStory'; import { withCenteredStory } from '../../utils/storybook/withCenteredStory';
import { ButtonCascader } from '@grafana/ui'; import { ButtonCascader } from '@grafana/ui';
import { NOOP_CONTROL } from '@grafana/ui/.storybook/preview';
import { ButtonCascaderProps } from './ButtonCascader';
export default { export default {
title: 'Forms/Cascader/ButtonCascader', title: 'Forms/Cascader/ButtonCascader',
component: ButtonCascader, component: ButtonCascader,
decorators: [withKnobs, withCenteredStory], decorators: [withCenteredStory],
}; parameters: {
knobs: {
const getKnobs = () => { disabled: true,
return { },
disabled: boolean('Disabled', false), },
text: text('Button Text', 'Click me!'), args: {
icon: select('Icon', ['plus', 'minus', 'table'], 'plus'), disabled: false,
options: object('Options', [ children: 'Click me!',
options: [
{ {
label: 'A', label: 'A',
value: 'A', value: 'A',
...@@ -24,24 +27,24 @@ const getKnobs = () => { ...@@ -24,24 +27,24 @@ const getKnobs = () => {
], ],
}, },
{ label: 'D', value: 'D' }, { label: 'D', value: 'D' },
]), ],
}; },
argTypes: {
icon: { control: { type: 'select', options: ['plus', 'minus', 'table'] } },
options: { control: 'object' },
className: NOOP_CONTROL,
value: NOOP_CONTROL,
fieldNames: NOOP_CONTROL,
},
}; };
export const simple = () => { const Template: Story<ButtonCascaderProps> = ({ children, ...args }) => {
const { disabled, text, options } = getKnobs(); return <ButtonCascader {...args}>{children}</ButtonCascader>;
return (
<ButtonCascader disabled={disabled} options={options} value={['A']}>
{text}
</ButtonCascader>
);
}; };
export const withIcon = () => { export const simple = Template.bind({});
const { disabled, text, options, icon } = getKnobs();
return ( export const withIcon = Template.bind({});
<ButtonCascader disabled={disabled} options={options} value={['A']} icon={icon}> withIcon.args = {
{text} icon: 'plus',
</ButtonCascader>
);
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment