-
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.
FormFileUpload: Add Storybook stories (#38734)
* FormFileUpload: Add Storybook stories * Improve example in readme
- Loading branch information
Showing
2 changed files
with
52 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { upload as uploadIcon } from '@wordpress/icons'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import FormFileUpload from '../'; | ||
|
||
export default { | ||
title: 'Components/FormFileUpload', | ||
component: FormFileUpload, | ||
}; | ||
|
||
export const Default = FormFileUpload.bind( {} ); | ||
Default.args = { | ||
accept: '', | ||
children: 'Select file', | ||
multiple: false, | ||
}; | ||
|
||
export const RestrictFileTypes = FormFileUpload.bind( {} ); | ||
RestrictFileTypes.args = { | ||
...Default.args, | ||
accept: 'image/*', | ||
children: 'Select image', | ||
multiple: false, | ||
}; | ||
|
||
export const AllowMultipleFiles = FormFileUpload.bind( {} ); | ||
AllowMultipleFiles.args = { | ||
...Default.args, | ||
children: 'Select files', | ||
multiple: true, | ||
}; | ||
|
||
export const WithIcon = FormFileUpload.bind( {} ); | ||
WithIcon.args = { | ||
...Default.args, | ||
children: 'Upload', | ||
icon: uploadIcon, | ||
}; | ||
|
||
export const WithCustomRender = FormFileUpload.bind( {} ); | ||
WithCustomRender.args = { | ||
...Default.args, | ||
render: ( { openFileDialog } ) => ( | ||
<button onClick={ openFileDialog }>Custom Upload Button</button> | ||
), | ||
}; |