Skip to content

Commit

Permalink
Update Post Template to use auto-fill columns
Browse files Browse the repository at this point in the history
  • Loading branch information
tellthemachines committed Mar 24, 2023
1 parent b266825 commit bec3923
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
7 changes: 3 additions & 4 deletions packages/block-library/src/post-template/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default function PostTemplateEdit( {
} = {},
queryContext = [ { page: 1 } ],
templateSlug,
displayLayout: { type: layoutType = 'grid', columns = 1 } = {},
displayLayout: { type: layoutType = 'grid', columnWidth = 12 } = {},
previewPostType,
},
__unstableLayoutClassNames,
Expand All @@ -108,11 +108,10 @@ export default function PostTemplateEdit( {
setAttributes( {
layout: {
type: updatedLayoutType,
isResponsive: false,
numberOfColumns: columns,
minimumColumnWidth: `${ columnWidth }rem`,
},
} );
}, [ updatedLayoutType, columns, setAttributes ] );
}, [ updatedLayoutType, columnWidth, setAttributes ] );

const [ { page } ] = queryContext;
const [ activeBlockContextId, setActiveBlockContextId ] = useState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,15 @@ export default function QueryInspectorControls( {
<>
<RangeControl
__nextHasNoMarginBottom
label={ __( 'Columns' ) }
value={ displayLayout.columns }
label={ __( 'Minimum Column Width' ) }
value={ displayLayout.columnWidth }
onChange={ ( value ) =>
setDisplayLayout( { columns: value } )
setDisplayLayout( {
columnWidth: value,
} )
}
min={ 2 }
max={ Math.max( 6, displayLayout.columns ) }
max={ 60 }
/>
{ displayLayout.columns > 6 && (
<Notice
Expand Down

0 comments on commit bec3923

Please sign in to comment.