Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add clear filters

Krzysztof Białogłowicz12c763421e1c
diff --git a/saleor/static/js/components/categoryPage/CategoryPage.js b/saleor/static/js/components/categoryPage/CategoryPage.js
index dde3923df5..0088525674 100644
--- a/saleor/static/js/components/categoryPage/CategoryPage.js
+++ b/saleor/static/js/components/categoryPage/CategoryPage.js
@@ -46,6 +46,14 @@ class CategoryPage extends Component {
});
}
+ clearFilters = () => {
+ this.props.relay.setVariables({
+ attributesFilter: [],
+ minPrice: null,
+ maxPrice: null
+ });
+ }
+
updateAttributesFilter = (key) => {
// Create a new attributesFilter array by cloning the current one to make
// Relay refetch products with new attributes. Passing the same array (even
@@ -122,13 +130,13 @@ class CategoryPage extends Component {
</div>
<div className="col-md-4">
<div className="row">
- <div className="col-6 filters-menu">
+ <div className="col-6 col-md-1 filters-menu">
<span className="filters-menu-label hidden-sm-up" onClick={() => this.setMenu(filtersMenu)}>Filters</span>
{variables.attributesFilter.length || variables.minPrice || variables.maxPrice ? (
- <span className="filters-menu-icon"></span>
+ <span className="filters-menu-icon hidden-sm-up"></span>
) : (null)}
</div>
- <div className="col-6">
+ <div className="col-6 col-md-11">
<SortBy sortedValue={variables.sortBy} setSorting={this.setSorting} />
</div>
</div>
@@ -142,7 +150,10 @@ class CategoryPage extends Component {
</div>
{filtersMenu ? (
<div>
- <h2>{gettext('Filters')}</h2>
+ <h2>
+ {gettext('Filters')}
+ <span className="clear-filters float-right" onClick={this.clearFilters}>{gettext('Clear filters')}</span>
+ </h2>
<div className="product-filters">
<ProductFilters
attributes={attributes}
diff --git a/saleor/static/scss/storefront/components/_category-page.scss b/saleor/static/scss/storefront/components/_category-page.scss
index 180c922c24..5e7f474f54 100644
--- a/saleor/static/scss/storefront/components/_category-page.scss
+++ b/saleor/static/scss/storefront/components/_category-page.scss
@@ -46,6 +46,9 @@
.sort-by {
text-align: right;
position: relative;
+ @include media-breakpoint-up(sm) {
+ margin-left: $global-margin*5;
+ }
button {
color: $body-color;
padding-right: $global-padding;
@@ -120,9 +123,13 @@
}
}
}
-
-
-
+ .clear-filters {
+ color: $body-color;
+ font-weight: 400;
+ cursor: pointer;
+ font-size: 0.8rem;
+ line-height: 1.3rem;
+ }
.product-filters {
.hide {
display: none;