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 { withKnobs, text, boolean, object, select } from '@storybook/addon-knobs';
import { Story } from '@storybook/react';
import { withCenteredStory } from '../../utils/storybook/withCenteredStory';
import { ButtonCascader } from '@grafana/ui';
import { NOOP_CONTROL } from '@grafana/ui/.storybook/preview';
import { ButtonCascaderProps } from './ButtonCascader';
export default {
title: 'Forms/Cascader/ButtonCascader',
component: ButtonCascader,
decorators: [withKnobs, withCenteredStory],
};
const getKnobs = () => {
return {
disabled: boolean('Disabled', false),
text: text('Button Text', 'Click me!'),
icon: select('Icon', ['plus', 'minus', 'table'], 'plus'),
options: object('Options', [
decorators: [withCenteredStory],
parameters: {
knobs: {
disabled: true,
},
},
args: {
disabled: false,
children: 'Click me!',
options: [
{
label: 'A',
value: 'A',
......@@ -24,24 +27,24 @@ const getKnobs = () => {
],
},
{ 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 { disabled, text, options } = getKnobs();
return (
<ButtonCascader disabled={disabled} options={options} value={['A']}>
{text}
</ButtonCascader>
);
const Template: Story<ButtonCascaderProps> = ({ children, ...args }) => {
return <ButtonCascader {...args}>{children}</ButtonCascader>;
};
export const withIcon = () => {
const { disabled, text, options, icon } = getKnobs();
return (
<ButtonCascader disabled={disabled} options={options} value={['A']} icon={icon}>
{text}
</ButtonCascader>
);
export const simple = Template.bind({});
export const withIcon = Template.bind({});
withIcon.args = {
icon: 'plus',
};
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