Storybook: remove `UseState` + add controls support to `TimeZonePicker` story (#53219)

* remove UseState + add controls support to TimeZonePicker story

* remove redundant check
This commit is contained in:
Ashley Harrison 2022-08-03 16:17:42 +01:00 committed by GitHub
parent 643d2bc890
commit 9d6faa7e9a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 23 deletions

View File

@ -1,41 +1,44 @@
import { action } from '@storybook/addon-actions';
import { ComponentMeta } from '@storybook/react';
import { useArgs } from '@storybook/client-api';
import { ComponentMeta, ComponentStory } from '@storybook/react';
import React from 'react';
import { TimeZonePicker } from '@grafana/ui';
import { UseState } from '../../utils/storybook/UseState';
import { withCenteredStory } from '../../utils/storybook/withCenteredStory';
const meta: ComponentMeta<typeof TimeZonePicker> = {
title: 'Pickers and Editors/TimePickers/TimeZonePicker',
component: TimeZonePicker,
decorators: [withCenteredStory],
parameters: {
controls: {
exclude: ['inputId', 'onChange', 'onBlur'],
},
},
args: {
value: 'Europe/Stockholm',
},
argTypes: {
includeInternal: {
control: {
type: 'boolean',
},
},
},
};
export const basic = () => {
export const Basic: ComponentStory<typeof TimeZonePicker> = (args) => {
const [, updateArgs] = useArgs();
return (
<UseState
initialState={{
value: 'Europe/Stockholm',
<TimeZonePicker
{...args}
onChange={(newValue) => {
action('on selected')(newValue);
updateArgs({ value: newValue });
}}
>
{(value, updateValue) => {
return (
<TimeZonePicker
includeInternal={true}
value={value.value}
onChange={(newValue) => {
if (!newValue) {
return;
}
action('on selected')(newValue);
updateValue({ value: newValue });
}}
/>
);
}}
</UseState>
onBlur={action('onBlur')}
/>
);
};