-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
InputControl: Improve type annotations and stories (#40119)
* Fix inaccuracy in readme for `value` prop * Properly export `InputControl` component for TS extraction * Fix placement of `FlexProps` type `InputControl` itself does not accept `Flex` props. Only `InputBase` does. * Add descriptions from readmes into types.ts * Convert stories * Convert stories to TS * Update changelog * Keep type unions inside types.ts * Add description and default for `isFocus` prop
- Loading branch information
Showing
6 changed files
with
161 additions
and
78 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
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
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
This file was deleted.
Oops, something went wrong.
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,63 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import type { ComponentMeta, ComponentStory } from '@storybook/react'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import InputControl from '..'; | ||
|
||
const meta: ComponentMeta< typeof InputControl > = { | ||
title: 'Components (Experimental)/InputControl', | ||
component: InputControl, | ||
argTypes: { | ||
__unstableInputWidth: { control: { type: 'text' } }, | ||
__unstableStateReducer: { control: { type: null } }, | ||
onChange: { control: { type: null } }, | ||
prefix: { control: { type: null } }, | ||
suffix: { control: { type: null } }, | ||
type: { control: { type: 'text' } }, | ||
}, | ||
parameters: { | ||
controls: { expanded: true }, | ||
docs: { source: { state: 'open' } }, | ||
}, | ||
}; | ||
export default meta; | ||
|
||
const Template: ComponentStory< typeof InputControl > = ( args ) => ( | ||
<InputControl { ...args } /> | ||
); | ||
|
||
export const Default = Template.bind( {} ); | ||
Default.args = { | ||
label: 'Value', | ||
placeholder: 'Placeholder', | ||
value: '', | ||
}; | ||
|
||
export const WithPrefix = Template.bind( {} ); | ||
WithPrefix.args = { | ||
...Default.args, | ||
prefix: <span style={ { paddingLeft: 8 } }>@</span>, | ||
}; | ||
|
||
export const WithSuffix = Template.bind( {} ); | ||
WithSuffix.args = { | ||
...Default.args, | ||
suffix: <button style={ { marginRight: 4 } }>Send</button>, | ||
}; | ||
|
||
export const WithSideLabel = Template.bind( {} ); | ||
WithSideLabel.args = { | ||
...Default.args, | ||
labelPosition: 'side', | ||
}; | ||
|
||
export const WithEdgeLabel = Template.bind( {} ); | ||
WithEdgeLabel.args = { | ||
...Default.args, | ||
__unstableInputWidth: '20em', | ||
labelPosition: 'edge', | ||
}; |
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