Category Selection: Always show "selected" section (https://github.com/woocommerce/woocommerce-blocks/pull/192)

* Always show the selected tags section, with a min-height to prevent jumping when selecting tags

* Only show the “clear all” button if there are selected items

* Update snapshot tests

* Update height for sidebar category selection
This commit is contained in:
Kelly Dwan 2018-12-03 16:05:12 -05:00 committed by GitHub
parent 50aa551268
commit f0f62b5caa
4 changed files with 117 additions and 14 deletions

View File

@ -22,6 +22,8 @@
margin: 0 0 $gap; margin: 0 0 $gap;
padding: 0; padding: 0;
border-top: none; border-top: none;
// 54px is the height of 1 row of tags in the sidebar.
min-height: 54px;
} }
.woocommerce-search-list__search { .woocommerce-search-list__search {
margin: 0 0 $gap; margin: 0 0 $gap;

View File

@ -160,10 +160,10 @@ export class SearchListControl extends Component {
return ( return (
<div className={ `woocommerce-search-list ${ className }` }> <div className={ `woocommerce-search-list ${ className }` }>
{ selectedCount > 0 ? ( <div className="woocommerce-search-list__selected">
<div className="woocommerce-search-list__selected"> <div className="woocommerce-search-list__selected-header">
<div className="woocommerce-search-list__selected-header"> <strong>{ messages.selected( selectedCount ) }</strong>
<strong>{ messages.selected( selectedCount ) }</strong> { selectedCount > 0 ? (
<Button <Button
isLink isLink
isDestructive isDestructive
@ -172,17 +172,17 @@ export class SearchListControl extends Component {
> >
{ __( 'Clear all', 'woocommerce' ) } { __( 'Clear all', 'woocommerce' ) }
</Button> </Button>
</div> ) : null }
{ selected.map( ( item, i ) => (
<Tag
key={ i }
label={ item.name }
id={ item.id }
remove={ this.onRemove }
/>
) ) }
</div> </div>
) : null } { selected.map( ( item, i ) => (
<Tag
key={ i }
label={ item.name }
id={ item.id }
remove={ this.onRemove }
/>
) ) }
</div>
<div className="woocommerce-search-list__search"> <div className="woocommerce-search-list__search">
<TextControl <TextControl

View File

@ -7,6 +7,8 @@
.woocommerce-search-list__selected { .woocommerce-search-list__selected {
margin: $gap 0; margin: $gap 0;
padding: $gap 0 0; padding: $gap 0 0;
// 76px is the height of 1 row of tags.
min-height: 76px;
border-top: 1px solid $core-grey-light-500; border-top: 1px solid $core-grey-light-500;
.woocommerce-search-list__selected-header { .woocommerce-search-list__selected-header {

View File

@ -4,6 +4,17 @@ exports[`SearchListControl should render a search box and list of hierarchical o
<div <div
className="woocommerce-search-list " className="woocommerce-search-list "
> >
<div
className="woocommerce-search-list__selected"
>
<div
className="woocommerce-search-list__selected-header"
>
<strong>
0 items selected
</strong>
</div>
</div>
<div <div
className="woocommerce-search-list__search" className="woocommerce-search-list__search"
> >
@ -382,6 +393,17 @@ exports[`SearchListControl should render a search box and list of options 1`] =
<div <div
className="woocommerce-search-list " className="woocommerce-search-list "
> >
<div
className="woocommerce-search-list__selected"
>
<div
className="woocommerce-search-list__selected-header"
>
<strong>
0 items selected
</strong>
</div>
</div>
<div <div
className="woocommerce-search-list__search" className="woocommerce-search-list__search"
> >
@ -760,6 +782,17 @@ exports[`SearchListControl should render a search box and list of options with a
<div <div
className="woocommerce-search-list test-search" className="woocommerce-search-list test-search"
> >
<div
className="woocommerce-search-list__selected"
>
<div
className="woocommerce-search-list__selected-header"
>
<strong>
0 items selected
</strong>
</div>
</div>
<div <div
className="woocommerce-search-list__search" className="woocommerce-search-list__search"
> >
@ -1138,6 +1171,17 @@ exports[`SearchListControl should render a search box and list of options, with
<div <div
className="woocommerce-search-list " className="woocommerce-search-list "
> >
<div
className="woocommerce-search-list__selected"
>
<div
className="woocommerce-search-list__selected-header"
>
<strong>
0 items selected
</strong>
</div>
</div>
<div <div
className="woocommerce-search-list__search" className="woocommerce-search-list__search"
> >
@ -1210,6 +1254,17 @@ exports[`SearchListControl should render a search box and list of options, with
<div <div
className="woocommerce-search-list " className="woocommerce-search-list "
> >
<div
className="woocommerce-search-list__selected"
>
<div
className="woocommerce-search-list__selected-header"
>
<strong>
0 items selected
</strong>
</div>
</div>
<div <div
className="woocommerce-search-list__search" className="woocommerce-search-list__search"
> >
@ -1588,6 +1643,17 @@ exports[`SearchListControl should render a search box and no options 1`] = `
<div <div
className="woocommerce-search-list " className="woocommerce-search-list "
> >
<div
className="woocommerce-search-list__selected"
>
<div
className="woocommerce-search-list__selected-header"
>
<strong>
0 items selected
</strong>
</div>
</div>
<div <div
className="woocommerce-search-list__search" className="woocommerce-search-list__search"
> >
@ -1619,6 +1685,17 @@ exports[`SearchListControl should render a search box with a search term, and no
<div <div
className="woocommerce-search-list " className="woocommerce-search-list "
> >
<div
className="woocommerce-search-list__selected"
>
<div
className="woocommerce-search-list__selected-header"
>
<strong>
0 items selected
</strong>
</div>
</div>
<div <div
className="woocommerce-search-list__search" className="woocommerce-search-list__search"
> >
@ -1652,6 +1729,17 @@ exports[`SearchListControl should render a search box with a search term, and on
<div <div
className="woocommerce-search-list " className="woocommerce-search-list "
> >
<div
className="woocommerce-search-list__selected"
>
<div
className="woocommerce-search-list__selected-header"
>
<strong>
0 items selected
</strong>
</div>
</div>
<div <div
className="woocommerce-search-list__search" className="woocommerce-search-list__search"
> >
@ -1811,6 +1899,17 @@ exports[`SearchListControl should render a search box with a search term, and on
<div <div
className="woocommerce-search-list " className="woocommerce-search-list "
> >
<div
className="woocommerce-search-list__selected"
>
<div
className="woocommerce-search-list__selected-header"
>
<strong>
0 items selected
</strong>
</div>
</div>
<div <div
className="woocommerce-search-list__search" className="woocommerce-search-list__search"
> >