-
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.
DataForm: Add a simple story for the DataForm component (#63840)
Co-authored-by: youknowriad <youknowriad@git.wordpress.org> Co-authored-by: oandregal <oandregal@git.wordpress.org>
- Loading branch information
1 parent
9506009
commit 271c085
Showing
4 changed files
with
47 additions
and
5 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
packages/dataviews/src/components/dataform/stories/index.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,42 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { useState } from '@wordpress/element'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import DataForm from '../index'; | ||
|
||
const meta = { | ||
title: 'DataViews/DataForm', | ||
component: DataForm, | ||
}; | ||
export default meta; | ||
|
||
const fields = [ | ||
{ | ||
id: 'title', | ||
label: 'Title', | ||
type: 'text' as const, | ||
}, | ||
]; | ||
|
||
export const Default = () => { | ||
const [ post, setPost ] = useState( { | ||
title: 'Hello, World!', | ||
} ); | ||
|
||
const form = { | ||
visibleFields: [ 'title' ], | ||
}; | ||
|
||
return ( | ||
<DataForm | ||
data={ post } | ||
fields={ fields } | ||
form={ form } | ||
onChange={ setPost } | ||
/> | ||
); | ||
}; |
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