mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
SecretFormField: updates story from knobs to control (#33920)
* SecretFormField: updates story from knobs to control * disables knobs in story
This commit is contained in:
parent
a7ea0ca849
commit
3d47bf247f
@ -1,8 +1,8 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { action } from '@storybook/addon-actions';
|
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 { withCenteredStory } from '../../utils/storybook/withCenteredStory';
|
||||||
import { UseState } from '../../utils/storybook/UseState';
|
import { UseState } from '../../utils/storybook/UseState';
|
||||||
|
|
||||||
@ -10,31 +10,48 @@ export default {
|
|||||||
title: 'Forms/SecretFormField',
|
title: 'Forms/SecretFormField',
|
||||||
component: SecretFormField,
|
component: SecretFormField,
|
||||||
decorators: [withCenteredStory],
|
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 = () => {
|
export const Basic: Story<Props> = (args) => {
|
||||||
return {
|
|
||||||
isConfigured: boolean('Set configured state', false),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const basic = () => {
|
|
||||||
const knobs = getSecretFormFieldKnobs();
|
|
||||||
return (
|
return (
|
||||||
<UseState initialState="Input value">
|
<UseState initialState="Input value">
|
||||||
{(value, setValue) => (
|
{(value, setValue) => (
|
||||||
<SecretFormField
|
<SecretFormField
|
||||||
label={'Secret field'}
|
label={args.label}
|
||||||
labelWidth={10}
|
labelWidth={args.labelWidth}
|
||||||
value={value}
|
value={value}
|
||||||
isConfigured={knobs.isConfigured}
|
isConfigured={args.isConfigured}
|
||||||
onChange={(e) => setValue(e.currentTarget.value)}
|
onChange={(e) => setValue(e.currentTarget.value)}
|
||||||
onReset={() => {
|
onReset={() => {
|
||||||
action('Value was reset')('');
|
action('Value was reset')('');
|
||||||
setValue('');
|
setValue('');
|
||||||
}}
|
}}
|
||||||
|
inputWidth={args.inputWidth}
|
||||||
|
tooltip={args.tooltip}
|
||||||
|
placeholder={args.placeholder}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</UseState>
|
</UseState>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
Basic.args = {
|
||||||
|
label: 'Secret field',
|
||||||
|
labelWidth: 10,
|
||||||
|
isConfigured: false,
|
||||||
|
inputWidth: 12,
|
||||||
|
tooltip: 'this is a tooltip',
|
||||||
|
placeholder: 'Password',
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user