-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
packages/components/src/custom-select-control-v2/stories/legacy.story.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
//@ts-nocheck | ||
/** | ||
* External dependencies | ||
*/ | ||
import type { Meta, StoryFn } from '@storybook/react'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useState } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import LegacyCustomSelect from '../legacy-component'; | ||
import { CustomSelect, CustomSelectItem } from '..'; | ||
|
||
const meta: Meta< typeof LegacyCustomSelect > = { | ||
title: 'Components (Experimental)/CustomSelectControl v2/Legacy', | ||
component: LegacyCustomSelect, | ||
argTypes: { | ||
value: { control: { type: null } }, | ||
}, | ||
parameters: { | ||
actions: { argTypesRegex: '^on.*' }, | ||
controls: { expanded: true }, | ||
docs: { | ||
canvas: { sourceState: 'shown' }, | ||
source: { excludeDecorators: true }, | ||
}, | ||
}, | ||
decorators: [ | ||
( Story ) => ( | ||
<div | ||
style={ { | ||
minHeight: '150px', | ||
} } | ||
> | ||
<Story /> | ||
</div> | ||
), | ||
], | ||
}; | ||
export default meta; | ||
|
||
export const Default: StoryFn = () => { | ||
const options = [ | ||
{ | ||
key: 'small', | ||
name: 'Small', | ||
style: { fontSize: '50%' }, | ||
}, | ||
{ | ||
key: 'normal', | ||
name: 'Normal', | ||
style: { fontSize: '100%' }, | ||
}, | ||
{ | ||
key: 'large', | ||
name: 'Large', | ||
style: { fontSize: '200%' }, | ||
}, | ||
{ | ||
key: 'huge', | ||
name: 'Huge', | ||
style: { fontSize: '300%' }, | ||
}, | ||
]; | ||
|
||
return <CustomSelect label="Font Size" options={ options } />; | ||
}; | ||
|
||
export const Controlled: StoryFn = () => { | ||
const options = [ | ||
{ | ||
key: 'small', | ||
name: 'Small', | ||
style: { fontSize: '50%' }, | ||
}, | ||
{ | ||
key: 'normal', | ||
name: 'Normal', | ||
style: { fontSize: '100%' }, | ||
}, | ||
{ | ||
key: 'large', | ||
name: 'Large', | ||
style: { fontSize: '200%' }, | ||
}, | ||
{ | ||
key: 'huge', | ||
name: 'Huge', | ||
style: { fontSize: '300%' }, | ||
}, | ||
]; | ||
|
||
const [ fontSize, setFontSize ] = useState( options[ 0 ] ); | ||
|
||
return ( | ||
<CustomSelect | ||
label="Font Size" | ||
options={ options } | ||
onChange={ ( { selectedItem } ) => { | ||
setFontSize( selectedItem ); | ||
} } | ||
value={ options.find( ( option ) => option.key === fontSize.key ) } | ||
/> | ||
); | ||
}; |