Skip to content

Commit 8696b08

Browse files
jameskosteroandregaldinhtungdu
authored
DataForm: set spacing for regular and card layouts (#72249)
Co-authored-by: jameskoster <jameskoster@git.wordpress.org> Co-authored-by: oandregal <oandregal@git.wordpress.org> Co-authored-by: dinhtungdu <dinhtungdu@git.wordpress.org>
1 parent a56188f commit 8696b08

File tree

5 files changed

+38
-30
lines changed

5 files changed

+38
-30
lines changed

packages/dataviews/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Enhancements
6+
7+
- DataForm: update spacing for regular and card layouts. [#72249](https://github.com/WordPress/gutenberg/pull/72249).
8+
59
## 10.1.0 (2025-10-21)
610

711
### Enhancements

packages/dataviews/src/dataform-layouts/index.tsx

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,8 @@ const FORM_FIELD_LAYOUTS = [
1919
{
2020
type: 'regular',
2121
component: FormRegularField,
22-
wrapper: ( {
23-
children,
24-
layout,
25-
}: {
26-
children: React.ReactNode;
27-
layout: Layout;
28-
} ) => (
29-
<VStack
30-
className="dataforms-layouts__wrapper"
31-
spacing={ ( layout as any )?.spacing ?? 4 }
32-
>
22+
wrapper: ( { children }: { children: React.ReactNode } ) => (
23+
<VStack className="dataforms-layouts__wrapper" spacing={ 4 }>
3324
{ children }
3425
</VStack>
3526
),
@@ -46,17 +37,8 @@ const FORM_FIELD_LAYOUTS = [
4637
{
4738
type: 'card',
4839
component: FormCardField,
49-
wrapper: ( {
50-
children,
51-
layout,
52-
}: {
53-
children: React.ReactNode;
54-
layout: Layout;
55-
} ) => (
56-
<VStack
57-
className="dataforms-layouts__wrapper"
58-
spacing={ ( layout as any )?.spacing ?? 6 }
59-
>
40+
wrapper: ( { children }: { children: React.ReactNode } ) => (
41+
<VStack className="dataforms-layouts__wrapper" spacing={ 6 }>
6042
{ children }
6143
</VStack>
6244
),

packages/dataviews/src/dataform-layouts/normalize-form-fields.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ interface NormalizedFormField {
2121
export const DEFAULT_LAYOUT: NormalizedLayout = {
2222
type: 'regular',
2323
labelPosition: 'top',
24-
};
24+
} as NormalizedRegularLayout;
2525

2626
const normalizeCardSummaryField = (
2727
sum: CardSummaryField

packages/dataviews/src/stories/dataform.story.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1799,6 +1799,7 @@ const LayoutMixedComponent = () => {
17991799
} );
18001800

18011801
const form: Form = {
1802+
layout: { type: 'card' },
18021803
fields: [
18031804
{
18041805
id: 'title-and-status',

packages/dataviews/src/test/normalize-form-fields.ts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,17 @@ describe( 'normalizeFormFields', () => {
2828
expect( result ).toEqual( [
2929
{
3030
id: 'field1',
31-
layout: { type: 'regular', labelPosition: 'top' },
31+
layout: {
32+
type: 'regular',
33+
labelPosition: 'top',
34+
},
3235
},
3336
{
3437
id: 'field2',
35-
layout: { type: 'regular', labelPosition: 'top' },
38+
layout: {
39+
type: 'regular',
40+
labelPosition: 'top',
41+
},
3642
},
3743
] );
3844
} );
@@ -51,12 +57,18 @@ describe( 'normalizeFormFields', () => {
5157
expect( result ).toEqual( [
5258
{
5359
id: 'field1',
54-
layout: { type: 'regular', labelPosition: 'top' },
60+
layout: {
61+
type: 'regular',
62+
labelPosition: 'top',
63+
},
5564
},
5665
{
5766
id: 'field2',
5867
label: 'Field 2',
59-
layout: { type: 'regular', labelPosition: 'top' },
68+
layout: {
69+
type: 'regular',
70+
labelPosition: 'top',
71+
},
6072
},
6173
] );
6274
} );
@@ -72,7 +84,10 @@ describe( 'normalizeFormFields', () => {
7284
expect( result ).toEqual( [
7385
{
7486
id: 'field1',
75-
layout: { type: 'regular', labelPosition: 'top' },
87+
layout: {
88+
type: 'regular',
89+
labelPosition: 'top',
90+
},
7691
},
7792
] );
7893
} );
@@ -86,7 +101,10 @@ describe( 'normalizeFormFields', () => {
86101
expect( result ).toEqual( [
87102
{
88103
id: 'field1',
89-
layout: { type: 'regular', labelPosition: 'side' },
104+
layout: {
105+
type: 'regular',
106+
labelPosition: 'side',
107+
},
90108
},
91109
] );
92110
} );
@@ -245,7 +263,10 @@ describe( 'normalizeFormFields', () => {
245263
expect( result ).toEqual( [
246264
{
247265
id: 'field1',
248-
layout: { type: 'regular', labelPosition: 'top' },
266+
layout: {
267+
type: 'regular',
268+
labelPosition: 'top',
269+
},
249270
},
250271
{
251272
id: 'field2',

0 commit comments

Comments
 (0)