Skip to content

Commit

Permalink
DataViews: Combine featured image and title in the posts table
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Jul 11, 2024
1 parent e88f8be commit 3cd4478
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/edit-site/src/components/post-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ function useView( postType ) {
if ( isCustom === 'false' && layout ) {
return {
...defaultView,
...defaultLayouts[ layout ],
type: layout,
layout: defaultLayouts[ layout ]?.layout,
};
}
return defaultView;
Expand Down Expand Up @@ -124,7 +124,7 @@ function useView( postType ) {

return {
...storedView,
layout: defaultLayouts[ storedView?.type ]?.layout,
...defaultLayouts[ layout ],
};
}, [ editedViewRecord?.content ] );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,38 @@ export const defaultLayouts = {
[ LAYOUT_TABLE ]: {
layout: {
primaryField: 'title',
combinedFields: [
{
id: 'post',
header: __( 'Title' ),
children: [ 'featured-image', 'title' ],
direction: 'horizontal',
},
],
styles: {
'featured-image': {
width: '1%',
},
title: {
post: {
maxWidth: 300,
},
},
},
fields: [ 'post', 'author', 'status' ],
},
[ LAYOUT_GRID ]: {
layout: {
mediaField: 'featured-image',
primaryField: 'title',
},
fields: [ 'title', 'author', 'status' ],
},
[ LAYOUT_LIST ]: {
layout: {
primaryField: 'title',
mediaField: 'featured-image',
},
fields: [ 'title', 'author', 'status' ],
},
};

Expand All @@ -64,8 +75,8 @@ const DEFAULT_POST_BASE = {
field: 'date',
direction: 'desc',
},
fields: [ 'title', 'author', 'status' ],
layout: defaultLayouts[ LAYOUT_LIST ].layout,
fields: defaultLayouts[ LAYOUT_LIST ].fields,
};

export function useDefaultViews( { postType } ) {
Expand Down

0 comments on commit 3cd4478

Please sign in to comment.