mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Legacy Switch: updates story from knobs to controls (#32249)
* Legacy Switch: updates story from knobs to controls * destructure arguments appropriately
This commit is contained in:
parent
814f194d07
commit
49a5b9f0cb
@ -1,8 +1,9 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
import { Switch } from './Switch';
|
import { Props, Switch } from './Switch';
|
||||||
import { text } from '@storybook/addon-knobs';
|
import { Story } from '@storybook/react';
|
||||||
import mdx from './Switch.mdx';
|
import mdx from './Switch.mdx';
|
||||||
|
import { NOOP_CONTROL } from '../../../../utils/storybook/noopControl';
|
||||||
|
|
||||||
const getStory = (title: string, component: any) => ({
|
const getStory = (title: string, component: any) => ({
|
||||||
title,
|
title,
|
||||||
@ -11,22 +12,26 @@ const getStory = (title: string, component: any) => ({
|
|||||||
docs: {
|
docs: {
|
||||||
page: mdx,
|
page: mdx,
|
||||||
},
|
},
|
||||||
|
knobs: {
|
||||||
|
disable: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
argTypes: {
|
||||||
|
className: NOOP_CONTROL,
|
||||||
|
labelClass: NOOP_CONTROL,
|
||||||
|
switchClass: NOOP_CONTROL,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default getStory('Forms/Legacy/Switch', Switch);
|
export default getStory('Forms/Legacy/Switch', Switch);
|
||||||
|
|
||||||
const getKnobs = () => {
|
const SwitchWrapper: Story<Props> = ({ label, ...args }) => {
|
||||||
return {
|
|
||||||
label: text('Label Text', 'Label'),
|
|
||||||
tooltip: text('Tooltip', ''),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const SwitchWrapper = () => {
|
|
||||||
const { label, tooltip } = getKnobs();
|
|
||||||
const [checked, setChecked] = useState(false);
|
const [checked, setChecked] = useState(false);
|
||||||
return <Switch label={label} checked={checked} onChange={() => setChecked(!checked)} tooltip={tooltip} />;
|
return <Switch {...args} label={label} checked={checked} onChange={() => setChecked(!checked)} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const basic = () => <SwitchWrapper />;
|
export const Basic = SwitchWrapper.bind({});
|
||||||
|
Basic.args = {
|
||||||
|
label: 'Label',
|
||||||
|
tooltip: '',
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user