diff --git a/lib/compat/wordpress-6.6/post.php b/lib/compat/wordpress-6.6/post.php new file mode 100644 index 00000000000000..42707989fc0828 --- /dev/null +++ b/lib/compat/wordpress-6.6/post.php @@ -0,0 +1,15 @@ + { children } @@ -138,21 +136,8 @@ function PreviewWrapper( { item, onClick, ariaDescribedBy, children } ) { function Preview( { item, categoryId, viewType } ) { const descriptionId = useId(); const isUserPattern = item.type === PATTERN_TYPES.user; - const isNonUserPattern = item.type === PATTERN_TYPES.theme; const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE; const isEmpty = ! item.blocks?.length; - // Only custom patterns or custom template parts can be renamed or deleted. - const isCustomPattern = - isUserPattern || ( isTemplatePart && item.isCustom ); - const ariaDescriptions = []; - if ( isCustomPattern ) { - // User patterns don't have descriptions, but can be edited and deleted, so include some help text. - ariaDescriptions.push( - __( 'Press Enter to edit, or Delete to delete the pattern.' ) - ); - } else if ( item.description ) { - ariaDescriptions.push( item.description ); - } const [ backgroundColor ] = useGlobalStyle( 'color.background' ); const { onClick } = useLink( { @@ -171,16 +156,7 @@ function Preview( { item, categoryId, viewType } ) { - `${ descriptionId }-${ index }` - ) - .join( ' ' ) - : undefined - } + ariaDescribedBy={ item.description ? descriptionId : undefined } > { isEmpty && isTemplatePart && __( 'Empty template part' ) } { isEmpty && ! isTemplatePart && __( 'Empty pattern' ) } @@ -193,16 +169,11 @@ function Preview( { item, categoryId, viewType } ) { ) } - { ! isNonUserPattern && - ariaDescriptions.map( ( ariaDescription, index ) => ( - - ) ) } + { item.description && ( + + ) } ); } @@ -360,6 +331,7 @@ export default function DataviewsPatterns() { ), enableSorting: false, enableHiding: false, + width: '1%', }, { header: __( 'Title' ), diff --git a/packages/edit-site/src/components/page-patterns/style.scss b/packages/edit-site/src/components/page-patterns/style.scss index 6c616426aa3894..c8d23fc1843b17 100644 --- a/packages/edit-site/src/components/page-patterns/style.scss +++ b/packages/edit-site/src/components/page-patterns/style.scss @@ -56,6 +56,16 @@ } } + &.is-viewtype-table { + width: 96px; + flex-grow: 0; + border-radius: 2px; + + .page-patterns-preview-field__button { + border-radius: 2px; + } + } + .page-patterns-preview-field__button { box-shadow: none; border: none; @@ -72,6 +82,10 @@ // Windows High Contrast mode will show this outline, but not the box-shadow. outline: 2px solid transparent; } + + &[aria-disabled="true"] { + cursor: default; + } } } diff --git a/packages/edit-site/src/components/page-patterns/use-patterns.js b/packages/edit-site/src/components/page-patterns/use-patterns.js index 8b6c6f26ddd44b..68c70d9447be89 100644 --- a/packages/edit-site/src/components/page-patterns/use-patterns.js +++ b/packages/edit-site/src/components/page-patterns/use-patterns.js @@ -223,6 +223,7 @@ const convertPatternPostToItem = ( patternPost, categories ) => ( { syncStatus: patternPost.wp_pattern_sync_status || PATTERN_SYNC_TYPES.full, title: patternPost.title.raw, type: patternPost.type, + description: patternPost.excerpt.raw, patternPost, } );