Skip to content

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

Add category sibilings list

Krzysztof Białogłowicz87339c33b33a
diff --git a/saleor/static/js/components/CategoryFilter.js b/saleor/static/js/components/CategoryFilter.js
index 8e98d2b688..04d8f4fad1 100644
--- a/saleor/static/js/components/CategoryFilter.js
+++ b/saleor/static/js/components/CategoryFilter.js
@@ -1,5 +1,5 @@
import React, { Component, PropTypes } from 'react'
-
+import Relay from 'react-relay';
export default class CategoryFilter extends Component {
@@ -9,16 +9,26 @@ export default class CategoryFilter extends Component {
render() {
const { category } = this.props;
+ console.log(this.props.category);
return (
- <ul className="categories list-group">
- <li className="list-group-item active">{category.name}</li>
- {category.children && (category.children.map((subcategory) => {
- return (
- <li key={subcategory.pk} className="list-group-item"><a href={subcategory.url}>{subcategory.name}</a></li>
- );
- })
- )}
- </ul>
+ <div className="categories">
+ <h3>Categories:</h3>
+ <ul>
+ <li className="current">
+ <a href={category.url}>{category.name}</a>
+ <span>{category.productsCount}</span>
+ </li>
+ {category.siblings && (category.siblings.map((sibling) => {
+ return (
+ <li key={sibling.pk} className="item">
+ <a href={sibling.url}>{sibling.name}</a>
+ <span>{sibling.productsCount}</span>
+ </li>
+ );
+ })
+ )}
+ </ul>
+ </div>
);
}
}
diff --git a/saleor/static/js/components/CategoryPage.js b/saleor/static/js/components/CategoryPage.js
index bfabee8a95..823301876f 100644
--- a/saleor/static/js/components/CategoryPage.js
+++ b/saleor/static/js/components/CategoryPage.js
@@ -82,10 +82,12 @@ export default Relay.createContainer(CategoryPage, {
pk
name
url
- children {
- pk
+ productsCount
+ siblings {
name
+ pk
url
+ productsCount
}
products (first: $count, attributes: $attributesFilter, priceGte: $minPrice, priceLte: $maxPrice) {
${ProductList.getFragment('products')}
diff --git a/saleor/static/scss/demo/components/_category-page.scss b/saleor/static/scss/demo/components/_category-page.scss
index c55249fa54..55fcb6dd4c 100644
--- a/saleor/static/scss/demo/components/_category-page.scss
+++ b/saleor/static/scss/demo/components/_category-page.scss
@@ -1,43 +1,66 @@
-.product-filters {
- h3 {
+#category-page {
+ h2 {
+ font-weight: bold;
padding-bottom: $global-padding;
}
- ul {
- padding: $global-padding/2 0;
- list-style: none;
- li {
- input {
- margin-right: $global-margin;
- }
+ .product-filters {
+ h3 {
+ padding-bottom: $global-padding;
}
- }
- .price-range {
- input {
- width: 7.6rem;
- display: inline-block;
+ ul {
+ padding: $global-padding/2 0;
+ list-style: none;
+ li {
+ input {
+ margin-right: $global-margin;
+ }
+ }
}
- span {
- margin: 0 $global-margin;
+ .price-range {
+ input {
+ width: 7.6rem;
+ display: inline-block;
+ }
+ span {
+ margin: 0 $global-margin;
+ }
+ button {
+ width: 18rem;
+ margin-top: $global-margin;
+ }
}
- button {
- width: 18rem;
- margin-top: $global-margin;
+ .categories {
+ ul {
+ list-style: circle;
+ padding-left: $global-padding;
+ li {
+ a {
+ font-size: 1.2rem;
+ color: $body-color;
+ padding-right: $global-padding/2;
+ }
+ span {
+ color: $gray;
+ font-size: 1.1rem;
+ }
+ }
+ }
}
}
-}
-.load-more {
- clear: both;
- button {
- width: 20rem;
- margin: 0 auto;
- display: block;
- color: $white;
- font-size: 2rem;
- cursor: pointer;
- outline: 0;
- &:hover {
- background: darken($gray, 10%);
+ .load-more {
+ clear: both;
+ button {
+ width: 20rem;
+ margin: 0 auto;
+ display: block;
+ color: $white;
+ font-size: 2rem;
+ cursor: pointer;
+ outline: 0;
+ &:hover {
+ background: darken($gray, 10%);
+ }
}
}
}
\ No newline at end of file