Legacy Switch: updates story from knobs to controls (#32249)

* Legacy Switch: updates story from knobs to controls

* destructure arguments appropriately
pull/32295/head
Uchechukwu Obasi 4 years ago committed by GitHub
parent 814f194d07
commit 49a5b9f0cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 31
      packages/grafana-ui/src/components/Forms/Legacy/Switch/Switch.story.internal.tsx

@ -1,8 +1,9 @@
import React, { useState } from 'react';
import { Switch } from './Switch';
import { text } from '@storybook/addon-knobs';
import { Props, Switch } from './Switch';
import { Story } from '@storybook/react';
import mdx from './Switch.mdx';
import { NOOP_CONTROL } from '../../../../utils/storybook/noopControl';
const getStory = (title: string, component: any) => ({
title,
@ -11,22 +12,26 @@ const getStory = (title: string, component: any) => ({
docs: {
page: mdx,
},
knobs: {
disable: true,
},
},
argTypes: {
className: NOOP_CONTROL,
labelClass: NOOP_CONTROL,
switchClass: NOOP_CONTROL,
},
});
export default getStory('Forms/Legacy/Switch', Switch);
const getKnobs = () => {
return {
label: text('Label Text', 'Label'),
tooltip: text('Tooltip', ''),
};
};
const SwitchWrapper = () => {
const { label, tooltip } = getKnobs();
const SwitchWrapper: Story<Props> = ({ label, ...args }) => {
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…
Cancel
Save