From 3d47bf247fa465135e7a6b37e63dbae130a616ab Mon Sep 17 00:00:00 2001 From: Uchechukwu Obasi Date: Wed, 12 May 2021 08:59:21 +0100 Subject: [PATCH] SecretFormField: updates story from knobs to control (#33920) * SecretFormField: updates story from knobs to control * disables knobs in story --- .../SecretFormField.story.internal.tsx | 45 +++++++++++++------ 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/packages/grafana-ui/src/components/SecretFormField/SecretFormField.story.internal.tsx b/packages/grafana-ui/src/components/SecretFormField/SecretFormField.story.internal.tsx index 8292975e160..0fa8337edb8 100644 --- a/packages/grafana-ui/src/components/SecretFormField/SecretFormField.story.internal.tsx +++ b/packages/grafana-ui/src/components/SecretFormField/SecretFormField.story.internal.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { action } from '@storybook/addon-actions'; -import { boolean } from '@storybook/addon-knobs'; +import { Meta, Story } from '@storybook/react'; -import { SecretFormField } from './SecretFormField'; +import { SecretFormField, Props } from './SecretFormField'; import { withCenteredStory } from '../../utils/storybook/withCenteredStory'; import { UseState } from '../../utils/storybook/UseState'; @@ -10,31 +10,48 @@ export default { title: 'Forms/SecretFormField', component: SecretFormField, decorators: [withCenteredStory], -}; + parameters: { + controls: { + exclude: ['onReset'], + }, + knobs: { + disable: true, + }, + }, + argTypes: { + labelWidth: { control: { type: 'range', min: 0, max: 30 } }, + inputWidth: { control: { type: 'range', min: 0, max: 30 } }, + tooltip: { control: { type: 'text' } }, + }, +} as Meta; -const getSecretFormFieldKnobs = () => { - return { - isConfigured: boolean('Set configured state', false), - }; -}; - -export const basic = () => { - const knobs = getSecretFormFieldKnobs(); +export const Basic: Story = (args) => { return ( {(value, setValue) => ( setValue(e.currentTarget.value)} onReset={() => { action('Value was reset')(''); setValue(''); }} + inputWidth={args.inputWidth} + tooltip={args.tooltip} + placeholder={args.placeholder} /> )} ); }; +Basic.args = { + label: 'Secret field', + labelWidth: 10, + isConfigured: false, + inputWidth: 12, + tooltip: 'this is a tooltip', + placeholder: 'Password', +};