Skip to content

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

Use inlined SVG instead if img's

Marcin Gębalacd5677eff055
diff --git a/saleor/static/js/components/categoryPage/CategoryFilter.js b/saleor/static/js/components/categoryPage/CategoryFilter.js
index 1d9805f1d1..645f9e143c 100644
--- a/saleor/static/js/components/categoryPage/CategoryFilter.js
+++ b/saleor/static/js/components/categoryPage/CategoryFilter.js
@@ -11,21 +11,19 @@ export default class CategoryFilter extends Component {
const parent = category.ancestors ? category.ancestors[category.ancestors.length - 1] : null;
return (
<div className="categories">
-
<h2><strong>{category.name}</strong></h2>
-
- {parent ? (
+ {parent && (
<div className="parents">
<i className="fa fa-arrow-left" aria-hidden="true"></i>
<a href={parent.url}>See all {parent.name}</a>
</div>
- ) : (null)}
+ )}
<ul className={category.parent ? ('childs') : ('childs no-parent')}>
{category.children && (category.children.map((child) => {
return (
- <li key={child.pk} className="item">
- <a href={child.url}>{child.name}</a>
- </li>
+ <li key={child.pk} className="item">
+ <a href={child.url}>{child.name}</a>
+ </li>
);
}))}
</ul>
diff --git a/saleor/static/js/components/categoryPage/NoResults.js b/saleor/static/js/components/categoryPage/NoResults.js
index 4e897cd4b5..9a4a1805db 100644
--- a/saleor/static/js/components/categoryPage/NoResults.js
+++ b/saleor/static/js/components/categoryPage/NoResults.js
@@ -1,4 +1,5 @@
import React from 'react';
+import InlineSVG from 'react-inlinesvg';
import noResultsImg from '../../../images/pirate.svg';
@@ -6,7 +7,7 @@ const NoResults = () => {
return (
<div className="no-results">
<div className="col-12">
- <img src={noResultsImg} />
+ <InlineSVG src={noResultsImg} />
<p>Sorry, no matches found for your request.</p>
<p>Try again or shop new arrivals.</p>
</div>
diff --git a/saleor/static/js/components/categoryPage/PriceFilter.js b/saleor/static/js/components/categoryPage/PriceFilter.js
index b7bba09793..de03e04903 100644
--- a/saleor/static/js/components/categoryPage/PriceFilter.js
+++ b/saleor/static/js/components/categoryPage/PriceFilter.js
@@ -1,4 +1,5 @@
import React, { Component, PropTypes } from 'react';
+import InlineSVG from 'react-inlinesvg';
import chevronUpIcon from '../../../images/chevron-up-icon.svg';
import chevronDownIcon from '../../../images/chevron-down-icon.svg';
@@ -31,19 +32,26 @@ export default class PriceFilter extends Component {
}
changeVisibility = () => {
- this.setState({
- visibility: !this.state.visibility
- });
+ const { minPrice, maxPrice } = this.props;
+ if (!(minPrice || maxPrice)) {
+ this.setState({
+ visibility: !this.state.visibility
+ });
+ }
}
render() {
const { maxPrice, minPrice } = this.props;
const { visibility } = this.state;
+ const imageSrc = visibility ? (chevronUpIcon) : (chevronDownIcon);
+ const key = visibility ? 'chevronUpIcon' : 'chevronDownIcon';
return (
<div className="price-range">
<h3 onClick={this.changeVisibility}>
Price range
- <img className="float-right" src={visibility ? (chevronUpIcon) : (chevronDownIcon)} width="20" />
+ <div className="collapse-filters-icon">
+ <InlineSVG key={key} src={imageSrc} />
+ </div>
</h3>
{visibility || minPrice || maxPrice ? (
<div>
diff --git a/saleor/static/js/components/categoryPage/ProductFilters.js b/saleor/static/js/components/categoryPage/ProductFilters.js
index c0265e391b..e0da584a81 100644
--- a/saleor/static/js/components/categoryPage/ProductFilters.js
+++ b/saleor/static/js/components/categoryPage/ProductFilters.js
@@ -1,12 +1,12 @@
import React, { Component, PropTypes } from 'react';
import Relay from 'react-relay';
+import InlineSVG from 'react-inlinesvg';
import AttributeInput from './AttributeInput';
import chevronUpIcon from '../../../images/chevron-up-icon.svg';
import chevronDownIcon from '../../../images/chevron-down-icon.svg';
-
class ProductFilters extends Component {
constructor(props) {
@@ -51,11 +51,15 @@ class ProductFilters extends Component {
return (
<div className="attributes">
{attributes && (attributes.map((attribute) => {
+ const imageSrc = visibility[attribute.name] ? (chevronUpIcon) : (chevronDownIcon);
+ const key = visibility[attribute.name] ? 'chevronUpIcon' : 'chevronDownIcon';
return (
<div key={attribute.id}>
<h3 className={attribute.name} onClick={() => this.changeVisibility(attribute.name)}>
{attribute.display}
- <img className="float-right" src={visibility[attribute.name] ? (chevronUpIcon) : (chevronDownIcon)} width="20" />
+ <div className="collapse-filters-icon">
+ <InlineSVG key={key} src={imageSrc} />
+ </div>
</h3>
<ul id={attribute.name}>
{attribute.values.map((value) => {
diff --git a/saleor/static/js/components/categoryPage/SortBy.js b/saleor/static/js/components/categoryPage/SortBy.js
index 904e93965a..1531888cd1 100644
--- a/saleor/static/js/components/categoryPage/SortBy.js
+++ b/saleor/static/js/components/categoryPage/SortBy.js
@@ -1,4 +1,5 @@
import React, { Component, PropTypes } from 'react';
+import InlineSVG from 'react-inlinesvg';
import arrowUpIcon from '../../../images/arrow-up-icon.svg';
import arrowDownIcon from '../../../images/arrow-down-icon.svg';
@@ -40,54 +41,66 @@ export default class sortBy extends Component {
sortedValue.search('-') ? (
<div>
<span>Sort by: <strong>{sortedValue}</strong></span>
- <img src={arrowUpIcon} width="15" />
+ <div className="sort-order-icon">
+ <InlineSVG key="arrowUpIcon" src={arrowUpIcon} />
+ </div>
</div>
) : (
<div>
- <span>Sort by: <strong>{sortedValue.replace('-','')}</strong></span>
- <img src={arrowDownIcon} width="15" />
+ <span>Sort by: <strong>{sortedValue.replace('-', '')}</strong></span>
+ <div className="sort-order-icon">
+ <InlineSVG key="arrowDownIcon" src={arrowDownIcon} />
+ </div>
</div>
)
) : (
<span>Sort by: <strong>default</strong></span>
)}
</button>
- {visibility ? (
- <ul className="sort-list">
- <li className="name">
- <div className="row">
- <div className="col-md-6">Sort by <strong>Name</strong></div>
- <div className="col-md-6">
- <span className="name" onClick={this.setSorting}>ascending</span>
- <img className="float-right" src={arrowUpIcon} width="15" />
+ {visibility && (
+ <ul className="sort-list">
+ <li className="name">
+ <div className="row">
+ <div className="col-md-6">Sort by <strong>Name</strong></div>
+ <div className="col-md-6">
+ <span className="name" onClick={this.setSorting}>ascending</span>
+ <div className="float-right sort-order-icon">
+ <InlineSVG src={arrowUpIcon} />
+ </div>
+ </div>
</div>
- </div>
- <div className="row">
- <div className="col-md-6"></div>
- <div className="col-md-6">
- <span className="-name" onClick={this.setSorting}>descending</span>
- <img className="float-right" src={arrowDownIcon} width="15" />
+ <div className="row">
+ <div className="col-md-6"></div>
+ <div className="col-md-6">
+ <span className="-name" onClick={this.setSorting}>descending</span>
+ <div className="float-right sort-order-icon">
+ <InlineSVG src={arrowDownIcon} />
+ </div>
+ </div>
</div>
- </div>
- </li>
- <li className="price">
- <div className="row">
- <div className="col-md-6">Sort by <strong>Price</strong></div>
- <div className="col-md-6">
- <span className="price" onClick={this.setSorting}>ascending</span>
- <img className="float-right" src={arrowUpIcon} width="15" />
+ </li>
+ <li className="price">
+ <div className="row">
+ <div className="col-md-6">Sort by <strong>Price</strong></div>
+ <div className="col-md-6">
+ <span className="price" onClick={this.setSorting}>ascending</span>
+ <div className="float-right sort-order-icon">
+ <InlineSVG src={arrowUpIcon} />
+ </div>
+ </div>
</div>
- </div>
- <div className="row">
- <div className="col-md-6"></div>
- <div className="col-md-6">
- <span className="-price" onClick={this.setSorting}>descending</span>
- <img className="float-right" src={arrowDownIcon} width="15" />
+ <div className="row">
+ <div className="col-md-6"></div>
+ <div className="col-md-6">
+ <span className="-price" onClick={this.setSorting}>descending</span>
+ <div className="float-right sort-order-icon">
+ <InlineSVG src={arrowDownIcon} />
+ </div>
+ </div>
</div>
- </div>
- </li>
- </ul>
- ) : (null)}
+ </li>
+ </ul>
+ )}
</div>
);
}
diff --git a/saleor/static/scss/storefront/components/_category-page.scss b/saleor/static/scss/storefront/components/_category-page.scss
index 1ca91c57b9..7dc7f8beda 100644
--- a/saleor/static/scss/storefront/components/_category-page.scss
+++ b/saleor/static/scss/storefront/components/_category-page.scss
@@ -33,8 +33,10 @@
color: $body-color;
padding-right: $global-padding;
outline: 0;
- img {
+ svg {
+ vertical-align: middle;
margin-left: $global-padding/2;
+ height: 15px;
}
}
ul {
@@ -59,7 +61,7 @@
text-decoration: underline;
}
}
- img {
+ svg {
margin-top: $global-padding/3;
}
&:last-child {
@@ -94,6 +96,10 @@
display: none;
}
}
+ .sort-order-icon {
+ display: inline-block;
+ width: 15px;
+ }
}
}
@@ -210,4 +216,9 @@
}
}
}
+
+ .collapse-filters-icon {
+ float: right !important;
+ width: 20px;
+ }
}
\ No newline at end of file