Skip to content

Commit

Permalink
polish grid view + change to <ul>
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Nov 20, 2020
1 parent f233734 commit 940e97e
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 36 deletions.
22 changes: 12 additions & 10 deletions packages/block-library/src/query-loop/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default function QueryLoopEdit( {
}

return (
<div { ...blockProps }>
<ul { ...blockProps }>
{ blockContexts &&
blockContexts.map( ( blockContext ) => (
<BlockContextProvider
Expand All @@ -135,18 +135,20 @@ export default function QueryLoopEdit( {
>
{ blockContext ===
( activeBlockContext || blockContexts[ 0 ] ) ? (
<div { ...innerBlocksProps } />
<li { ...innerBlocksProps } />
) : (
<BlockPreview
blocks={ blocks }
__experimentalLive
__experimentalOnClick={ () =>
setActiveBlockContext( blockContext )
}
/>
<li>
<BlockPreview
blocks={ blocks }
__experimentalLive
__experimentalOnClick={ () =>
setActiveBlockContext( blockContext )
}
/>
</li>
) }
</BlockContextProvider>
) ) }
</div>
</ul>
);
}
4 changes: 3 additions & 1 deletion packages/block-library/src/query-loop/editor.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.editor-styles-wrapper .wp-block.wp-block-query-loop {
.wp-block.wp-block-query-loop {
max-width: 100%;
padding-left: 0;
list-style: none;
}
2 changes: 1 addition & 1 deletion packages/block-library/src/query-loop/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function render_block_core_query_loop( $attributes, $content, $block ) {
)->render( array( 'dynamic' => false ) );
}
return sprintf(
'<div %1$s>%2$s</div>',
'<ul %1$s>%2$s</ul>',
$wrapper_attributes,
$content
);
Expand Down
4 changes: 2 additions & 2 deletions packages/block-library/src/query-loop/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import { InnerBlocks } from '@wordpress/block-editor';

export default function QueryLoopSave() {
return (
<div>
<li>
<InnerBlocks.Content />
</div>
</li>
);
}
19 changes: 17 additions & 2 deletions packages/block-library/src/query-loop/style.scss
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
.wp-block-query-loop {
max-width: 100%;
list-style: none;
padding: 0;

li {
clear: both;
}

&.is-flex-container {
flex-direction: row;
display: flex;
flex-wrap: wrap;

li {
margin: 0 1.25em 1.25em 0;
width: 100%;
}

@include break-small {
@for $i from 2 through 6 {
&.is-flex-container.columns-#{ $i } > div {
width: calc((100% / #{$i}));
&.is-flex-container.columns-#{ $i } > li {
width: calc((100% / #{ $i }) - 1.25em + (1.25em / #{ $i }));

&:nth-child( #{ $i }n ) {
margin-right: 0;
}
}
}
}
Expand Down
40 changes: 20 additions & 20 deletions packages/block-library/src/query/edit/query-inspector-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,33 +138,33 @@ export default function QueryInspectorControls( {
}, [ querySearch, onChangeDebounced ] );
return (
<InspectorControls>
{ layout?.type === 'flex' && (
<PanelBody title={ __( 'Display' ) }>
<RangeControl
label={ __( 'Columns' ) }
value={ layout.columns }
onChange={ ( value ) =>
setLayout( { columns: value } )
}
min={ 1 }
max={ Math.max( 6, layout.columns ) }
/>
{ layout.columns > 6 && (
<Notice status="warning" isDismissible={ false }>
{ __(
'This column count exceeds the recommended amount and may cause visual breakage.'
) }
</Notice>
) }
</PanelBody>
) }
<PanelBody title={ __( 'Settings' ) }>
<SelectControl
options={ postTypesSelectOptions }
value={ postType }
label={ __( 'Post Type' ) }
onChange={ onPostTypeChange }
/>
{ layout?.type === 'flex' && (
<>
<RangeControl
label={ __( 'Columns' ) }
value={ layout.columns }
onChange={ ( value ) =>
setLayout( { columns: value } )
}
min={ 1 }
max={ Math.max( 6, layout.columns ) }
/>
{ layout.columns > 6 && (
<Notice status="warning" isDismissible={ false }>
{ __(
'This column count exceeds the recommended amount and may cause visual breakage.'
) }
</Notice>
) }
</>
) }
<QueryControls
{ ...{ order, orderBy } }
onOrderChange={ ( value ) => setQuery( { order: value } ) }
Expand Down

0 comments on commit 940e97e

Please sign in to comment.