Skip to content

Commit

Permalink
DataForm: Add a simple story for the DataForm component (#63840)
Browse files Browse the repository at this point in the history
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
  • Loading branch information
3 people authored Jul 23, 2024
1 parent 9506009 commit 271c085
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 5 deletions.
42 changes: 42 additions & 0 deletions packages/dataviews/src/components/dataform/stories/index.story.tsx
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 }
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
/**
* Internal dependencies
*/
import { LAYOUT_TABLE } from '../constants';
import { LAYOUT_TABLE } from '../../../constants';

export const data = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { useState, useMemo } from '@wordpress/element';
/**
* Internal dependencies
*/
import { DataViews } from '../index';
import DataViews from '../index';
import { DEFAULT_VIEW, actions, data, fields } from './fixtures';
import { LAYOUT_GRID, LAYOUT_TABLE } from '../constants';
import { filterSortAndPaginate } from '../filter-and-sort-data-view';
import { LAYOUT_GRID, LAYOUT_TABLE } from '../../../constants';
import { filterSortAndPaginate } from '../../../filter-and-sort-data-view';

const meta = {
title: 'DataViews/DataViews',
Expand Down
2 changes: 1 addition & 1 deletion packages/dataviews/src/test/filter-and-sort-data-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Internal dependencies
*/
import { filterSortAndPaginate } from '../filter-and-sort-data-view';
import { data, fields } from '../stories/fixtures';
import { data, fields } from '../components/dataviews/stories/fixtures';

describe( 'filters', () => {
it( 'should return empty if the data is empty', () => {
Expand Down

0 comments on commit 271c085

Please sign in to comment.