Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patterns page: enable table layout #60337

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/edit-site/src/components/page-patterns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { usePrevious } from '@wordpress/compose';
import Page from '../page';
import {
LAYOUT_GRID,
LAYOUT_TABLE,
PATTERN_TYPES,
TEMPLATE_PART_POST_TYPE,
PATTERN_SYNC_TYPES,
Expand Down Expand Up @@ -65,6 +66,9 @@ const { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock(
const templatePartIcons = { header, footer, uncategorized };
const EMPTY_ARRAY = [];
const defaultConfigPerViewType = {
[ LAYOUT_TABLE ]: {
primaryField: 'title',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the primary field of a "table" layout? What's different from regular fields?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For styling and announcing selection.

},
[ LAYOUT_GRID ]: {
mediaField: 'preview',
primaryField: 'title',
Expand Down Expand Up @@ -147,6 +151,7 @@ function Preview( { item, categoryId, viewType } ) {
postId: isUserPattern ? item.id : item.name,
categoryId,
categoryType: isTemplatePart ? item.type : PATTERN_TYPES.theme,
canvas: 'edit',
} );

return (
Expand Down Expand Up @@ -197,6 +202,7 @@ function Title( { item, categoryId } ) {
postId: isUserPattern ? item.id : item.name,
categoryId,
categoryType: isTemplatePart ? item.type : PATTERN_TYPES.theme,
canvas: 'edit',
} );
if ( ! isUserPattern && templatePartIcons[ categoryId ] ) {
itemIcon = templatePartIcons[ categoryId ];
Expand Down Expand Up @@ -394,7 +400,7 @@ export default function DataviewsPatterns() {
view={ view }
onChangeView={ onChangeView }
deferredRendering
supportedLayouts={ [ LAYOUT_GRID ] }
supportedLayouts={ [ LAYOUT_GRID, LAYOUT_TABLE ] }
/>
</Page>
</ExperimentalBlockEditorProvider>
Expand Down
Loading