-
Notifications
You must be signed in to change notification settings - Fork 4k
/
legacy.story.tsx
72 lines (63 loc) · 1.56 KB
/
legacy.story.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/**
* External dependencies
*/
import type { Meta, StoryFn } from '@storybook/react';
/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';
/**
* Internal dependencies
*/
import CustomSelectControl from '../legacy-component';
import * as V1Story from '../../custom-select-control/stories/index.story';
const meta: Meta< typeof CustomSelectControl > = {
title: 'Components (Experimental)/CustomSelectControl v2/Legacy',
component: CustomSelectControl,
argTypes: {
onChange: { control: { type: null } },
value: { control: { type: null } },
},
parameters: {
badges: [ 'wip' ],
actions: { argTypesRegex: '^on.*' },
controls: { expanded: true },
docs: {
source: { excludeDecorators: true },
},
},
decorators: [
( Story ) => (
<div
style={ {
minHeight: '150px',
} }
>
<Story />
</div>
),
],
};
export default meta;
const Template: StoryFn< typeof CustomSelectControl > = ( props ) => {
const [ value, setValue ] = useState( props.options[ 0 ] );
const onChange: React.ComponentProps<
typeof CustomSelectControl
>[ 'onChange' ] = ( changeObject ) => {
setValue( changeObject.selectedItem );
props.onChange?.( changeObject );
};
return (
<CustomSelectControl
{ ...props }
onChange={ onChange }
value={ value }
/>
);
};
export const Default = Template.bind( {} );
Default.args = V1Story.Default.args;
export const WithLongLabels = Template.bind( {} );
WithLongLabels.args = V1Story.WithLongLabels.args;
export const WithHints = Template.bind( {} );
WithHints.args = V1Story.WithHints.args;