@@ -85,7 +85,10 @@ export default class ProductByCategoryBlock extends Component {
8585
8686 return (
8787 < InspectorControls key = "inspector" >
88- < PanelBody title = { __ ( 'Product Category' , 'woo-gutenberg-products-block' ) } initialOpen = { false } >
88+ < PanelBody
89+ title = { __ ( 'Product Category' , 'woo-gutenberg-products-block' ) }
90+ initialOpen = { false }
91+ >
8992 < ProductCategoryControl
9093 selected = { attributes . categories }
9194 onChange = { ( value = [ ] ) => {
@@ -94,7 +97,10 @@ export default class ProductByCategoryBlock extends Component {
9497 } }
9598 />
9699 </ PanelBody >
97- < PanelBody title = { __ ( 'Layout' , 'woo-gutenberg-products-block' ) } initialOpen >
100+ < PanelBody
101+ title = { __ ( 'Layout' , 'woo-gutenberg-products-block' ) }
102+ initialOpen
103+ >
98104 < RangeControl
99105 label = { __ ( 'Columns' , 'woo-gutenberg-products-block' ) }
100106 value = { columns }
@@ -110,33 +116,51 @@ export default class ProductByCategoryBlock extends Component {
110116 max = { wc_product_block_data . max_rows }
111117 />
112118 </ PanelBody >
113- < PanelBody title = { __ ( 'Order By' , 'woo-gutenberg-products-block' ) } initialOpen = { false } >
119+ < PanelBody
120+ title = { __ ( 'Order By' , 'woo-gutenberg-products-block' ) }
121+ initialOpen = { false }
122+ >
114123 < SelectControl
115124 label = { __ ( 'Order products by' , 'woo-gutenberg-products-block' ) }
116125 value = { orderby }
117126 options = { [
118127 {
119- label : __ ( 'Newness - newest first' , 'woo-gutenberg-products-block' ) ,
128+ label : __ (
129+ 'Newness - newest first' ,
130+ 'woo-gutenberg-products-block'
131+ ) ,
120132 value : 'date' ,
121133 } ,
122134 {
123- label : __ ( 'Price - low to high' , 'woo-gutenberg-products-block' ) ,
135+ label : __ (
136+ 'Price - low to high' ,
137+ 'woo-gutenberg-products-block'
138+ ) ,
124139 value : 'price_asc' ,
125140 } ,
126141 {
127- label : __ ( 'Price - high to low' , 'woo-gutenberg-products-block' ) ,
142+ label : __ (
143+ 'Price - high to low' ,
144+ 'woo-gutenberg-products-block'
145+ ) ,
128146 value : 'price_desc' ,
129147 } ,
130148 {
131- label : __ ( 'Rating - highest first' , 'woo-gutenberg-products-block' ) ,
149+ label : __ (
150+ 'Rating - highest first' ,
151+ 'woo-gutenberg-products-block'
152+ ) ,
132153 value : 'rating' ,
133154 } ,
134155 {
135156 label : __ ( 'Sales - most first' , 'woo-gutenberg-products-block' ) ,
136157 value : 'popularity' ,
137158 } ,
138159 {
139- label : __ ( 'Title - alphabetical' , 'woo-gutenberg-products-block' ) ,
160+ label : __ (
161+ 'Title - alphabetical' ,
162+ 'woo-gutenberg-products-block'
163+ ) ,
140164 value : 'title' ,
141165 } ,
142166 {
@@ -155,7 +179,9 @@ export default class ProductByCategoryBlock extends Component {
155179 const { attributes, debouncedSpeak, setAttributes } = this . props ;
156180 const onDone = ( ) => {
157181 setAttributes ( { editMode : false } ) ;
158- debouncedSpeak ( __ ( 'Showing product block preview.' , 'woo-gutenberg-products-block' ) ) ;
182+ debouncedSpeak (
183+ __ ( 'Showing product block preview.' , 'woo-gutenberg-products-block' )
184+ ) ;
159185 } ;
160186
161187 return (
@@ -176,10 +202,7 @@ export default class ProductByCategoryBlock extends Component {
176202 setAttributes ( { categories : ids } ) ;
177203 } }
178204 />
179- < Button
180- isDefault
181- onClick = { onDone }
182- >
205+ < Button isDefault onClick = { onDone } >
183206 { __ ( 'Done' , 'woo-gutenberg-products-block' ) }
184207 </ Button >
185208 </ div >
@@ -191,6 +214,17 @@ export default class ProductByCategoryBlock extends Component {
191214 const { setAttributes } = this . props ;
192215 const { columns, align, editMode } = this . props . attributes ;
193216 const { loaded, products } = this . state ;
217+ const classes = [ 'wc-block-products-category' ] ;
218+ if ( columns ) {
219+ classes . push ( `cols-${ columns } ` ) ;
220+ }
221+ if ( products && ! products . length ) {
222+ if ( ! loaded ) {
223+ classes . push ( 'is-loading' ) ;
224+ } else {
225+ classes . push ( 'is-not-found' ) ;
226+ }
227+ }
194228
195229 return (
196230 < Fragment >
@@ -215,20 +249,26 @@ export default class ProductByCategoryBlock extends Component {
215249 { editMode ? (
216250 this . renderEditMode ( )
217251 ) : (
218- < div className = { `wc-block-products-category cols- ${ columns } ` } >
252+ < div className = { classes . join ( ' ' ) } >
219253 { products . length ? (
220254 products . map ( ( product ) => (
221255 < ProductPreview product = { product } key = { product . id } />
222256 ) )
223257 ) : (
224258 < Placeholder
225259 icon = "category"
226- label = { __ ( 'Products by Category' , 'woo-gutenberg-products-block' ) }
260+ label = { __ (
261+ 'Products by Category' ,
262+ 'woo-gutenberg-products-block'
263+ ) }
227264 >
228265 { ! loaded ? (
229266 < Spinner />
230267 ) : (
231- __ ( 'No products in this category.' , 'woo-gutenberg-products-block' )
268+ __ (
269+ 'No products in this category.' ,
270+ 'woo-gutenberg-products-block'
271+ )
232272 ) }
233273 </ Placeholder >
234274 ) }
@@ -252,7 +292,9 @@ ProductByCategoryBlock.propTypes = {
252292 debouncedSpeak : PropTypes . func . isRequired ,
253293} ;
254294
255- const WrappedProductByCategoryBlock = withSpokenMessages ( ProductByCategoryBlock ) ;
295+ const WrappedProductByCategoryBlock = withSpokenMessages (
296+ ProductByCategoryBlock
297+ ) ;
256298
257299/**
258300 * Register and run the "Products by Category" block.
@@ -301,6 +343,10 @@ registerBlockType( 'woocommerce/product-category', {
301343 const {
302344 align,
303345 } = props . attributes ; /* eslint-disable-line react/prop-types */
304- return < RawHTML className = { align ? `align${ align } ` : '' } > { getShortcode ( props ) } </ RawHTML > ;
346+ return (
347+ < RawHTML className = { align ? `align${ align } ` : '' } >
348+ { getShortcode ( props ) }
349+ </ RawHTML >
350+ ) ;
305351 } ,
306352} ) ;
0 commit comments