Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Load inline svg with js
weronka78a70ff41a74
diff --git a/package.json b/package.jsonindex aff5d7074d..7c1160fc2b 100644--- a/package.json+++ b/package.json@@ -36,6 +36,7 @@"react-relay": "^0.10.0","select2": "^4.0.3","sortablejs": "^1.5.0-rc1",+ "svg-injector-2": "^2.0.35","tether": "^1.4.0","underscore": "^1.8.3"},diff --git a/templates/svg/arrow-down-icon.svg b/saleor/static/images/arrow-down-icon.svgsimilarity index 100%rename from templates/svg/arrow-down-icon.svgrename to saleor/static/images/arrow-down-icon.svgdiff --git a/templates/svg/arrow-left-icon.svg b/saleor/static/images/arrow-left-icon.svgsimilarity index 100%rename from templates/svg/arrow-left-icon.svgrename to saleor/static/images/arrow-left-icon.svgdiff --git a/templates/svg/arrow-up-icon.svg b/saleor/static/images/arrow-up-icon.svgsimilarity index 100%rename from templates/svg/arrow-up-icon.svgrename to saleor/static/images/arrow-up-icon.svgdiff --git a/templates/svg/cart.svg b/saleor/static/images/cart.svgsimilarity index 100%rename from templates/svg/cart.svgrename to saleor/static/images/cart.svgdiff --git a/templates/svg/chevron-down-icon.svg b/saleor/static/images/chevron-down-icon.svgsimilarity index 100%rename from templates/svg/chevron-down-icon.svgrename to saleor/static/images/chevron-down-icon.svgdiff --git a/templates/svg/chevron-up-icon.svg b/saleor/static/images/chevron-up-icon.svgsimilarity index 100%rename from templates/svg/chevron-up-icon.svgrename to saleor/static/images/chevron-up-icon.svgdiff --git a/templates/svg/close-icon.svg b/saleor/static/images/close-icon.svgsimilarity index 100%rename from templates/svg/close-icon.svgrename to saleor/static/images/close-icon.svgdiff --git a/templates/svg/gallery-arrow.svg b/saleor/static/images/gallery-arrow.svgsimilarity index 100%rename from templates/svg/gallery-arrow.svgrename to saleor/static/images/gallery-arrow.svgdiff --git a/templates/svg/github_logo.svg b/saleor/static/images/github_logo.svgsimilarity index 100%rename from templates/svg/github_logo.svgrename to saleor/static/images/github_logo.svgdiff --git a/templates/svg/icon_delete.svg b/saleor/static/images/icon_delete.svgsimilarity index 100%rename from templates/svg/icon_delete.svgrename to saleor/static/images/icon_delete.svgdiff --git a/templates/svg/icon_edit.svg b/saleor/static/images/icon_edit.svgsimilarity index 100%rename from templates/svg/icon_edit.svgrename to saleor/static/images/icon_edit.svgdiff --git a/templates/svg/mobile-bar.svg b/saleor/static/images/mobile-bar.svgsimilarity index 100%rename from templates/svg/mobile-bar.svgrename to saleor/static/images/mobile-bar.svgdiff --git a/templates/svg/sale_bg.svg b/saleor/static/images/sale_bg.svgsimilarity index 100%rename from templates/svg/sale_bg.svgrename to saleor/static/images/sale_bg.svgdiff --git a/templates/svg/saleor-logo.svg b/saleor/static/images/saleor-logo.svgsimilarity index 100%rename from templates/svg/saleor-logo.svgrename to saleor/static/images/saleor-logo.svgdiff --git a/templates/svg/search-icon.svg b/saleor/static/images/search-icon.svgsimilarity index 100%rename from templates/svg/search-icon.svgrename to saleor/static/images/search-icon.svgdiff --git a/templates/svg/twitter_logo.svg b/saleor/static/images/twitter_logo.svgsimilarity index 100%rename from templates/svg/twitter_logo.svgrename to saleor/static/images/twitter_logo.svgdiff --git a/saleor/static/js/components/categoryPage/CategoryFilter.js b/saleor/static/js/components/categoryPage/CategoryFilter.jsindex 8e09e8cf98..f23934bef9 100644--- a/saleor/static/js/components/categoryPage/CategoryFilter.js+++ b/saleor/static/js/components/categoryPage/CategoryFilter.js@@ -1,7 +1,7 @@import React, { Component, PropTypes } from 'react';import InlineSVG from 'react-inlinesvg';-import arrowLeftIcon from '../../../../../templates/svg/arrow-left-icon.svg';+import arrowLeftIcon from '../../../images/arrow-left-icon.svg';export default class CategoryFilter extends Component {diff --git a/saleor/static/js/components/categoryPage/FilterHeader.js b/saleor/static/js/components/categoryPage/FilterHeader.jsindex 60298a3eef..a38302b4b1 100644--- a/saleor/static/js/components/categoryPage/FilterHeader.js+++ b/saleor/static/js/components/categoryPage/FilterHeader.js@@ -2,8 +2,8 @@ import React, { PropTypes } from 'react';import InlineSVG from 'react-inlinesvg';-import chevronUpIcon from '../../../../../templates/svg/chevron-up-icon.svg';-import chevronDownIcon from '../../../../../templates/svg/chevron-down-icon.svg';+import chevronUpIcon from '../../../images/chevron-up-icon.svg';+import chevronDownIcon from '../../../images/chevron-down-icon.svg';const FilterHeader = ({ onClick, title, visibility }) => {const imageSrc = visibility ? (chevronUpIcon) : (chevronDownIcon);diff --git a/saleor/static/js/components/categoryPage/ProductPrice.js b/saleor/static/js/components/categoryPage/ProductPrice.jsindex 4d1c521061..ff65a2c322 100644--- a/saleor/static/js/components/categoryPage/ProductPrice.js+++ b/saleor/static/js/components/categoryPage/ProductPrice.js@@ -2,7 +2,7 @@ import React, { PropTypes } from 'react';import Relay from 'react-relay';import InlineSVG from 'react-inlinesvg';-import SaleImg from '../../../../../templates/svg/sale_bg.svg';+import SaleImg from '../../../images/sale_bg.svg';const ProductPrice = ({ availability, price }) => {const { discount, priceRange } = availability;diff --git a/saleor/static/js/components/categoryPage/SortBy.js b/saleor/static/js/components/categoryPage/SortBy.jsindex 453860b101..3083278466 100644--- a/saleor/static/js/components/categoryPage/SortBy.js+++ b/saleor/static/js/components/categoryPage/SortBy.js@@ -1,8 +1,8 @@import React, { Component, PropTypes } from 'react';import InlineSVG from 'react-inlinesvg';-import arrowUpIcon from '../../../../../templates/svg/arrow-up-icon.svg';-import arrowDownIcon from '../../../../../templates/svg/arrow-down-icon.svg';+import arrowUpIcon from '../../../images/arrow-up-icon.svg';+import arrowDownIcon from '../../../images/arrow-down-icon.svg';export default class sortBy extends Component {diff --git a/saleor/static/js/dashboard.js b/saleor/static/js/dashboard.jsindex 7582255174..4e9d73ee65 100644--- a/saleor/static/js/dashboard.js+++ b/saleor/static/js/dashboard.js@@ -3,6 +3,7 @@ import $ from 'jquery';import 'materialize-css/dist/js/materialize';import 'select2';import Sortable from 'sortablejs';+import SVGInjector from 'svg-injector-2';import '../scss/dashboard/dashboard.scss';@@ -20,6 +21,8 @@ function onScroll(func) {window.addEventListener('scroll', func, supportsPassive ? {passive: true} : false);}+new SVGInjector().inject(document.querySelectorAll('svg[data-src]'));+function openModal() {$('.modal-trigger-custom').on('click', function (e) {let that = this;diff --git a/saleor/static/js/storefront.js b/saleor/static/js/storefront.jsindex 8f814908ae..f13e18eecb 100644--- a/saleor/static/js/storefront.js+++ b/saleor/static/js/storefront.js@@ -3,6 +3,7 @@ import 'jquery.cookie';import React from 'react';import ReactDOM from 'react-dom';import Relay from 'react-relay';+import SVGInjector from 'svg-injector-2';import variantPickerStore from './stores/variantPicker';@@ -36,6 +37,8 @@ Relay.injectNetworkLayer(}));+new SVGInjector().inject(document.querySelectorAll('svg[data-src]'));+let getAjaxError = (response) => {let ajaxError = $.parseJSON(response.responseText).error.quantity;return ajaxError;diff --git a/saleor/static/scss/dashboard/components/_nav.scss b/saleor/static/scss/dashboard/components/_nav.scssindex 33f1925eb3..ee6d50d37a 100644--- a/saleor/static/scss/dashboard/components/_nav.scss+++ b/saleor/static/scss/dashboard/components/_nav.scss@@ -91,10 +91,10 @@ header {}.logo {- img {+ svg {max-height: $navbar-height;width: 140px;- margin: 13px 0;+ margin: 9px 0;@media (max-width: $small-screen) {height: 30px;margin: 17px 0;diff --git a/templates/base.html b/templates/base.htmlindex 92b5298974..b38143b0e7 100644--- a/templates/base.html+++ b/templates/base.html@@ -72,25 +72,25 @@<div class="row no-gutters"><div class="col-8 col-md-4 navbar__logo"><div class="menu-icon-mobile hidden-md-up navbar__brand__menu-toggle closed open">- {% include 'svg/mobile-bar.svg' %}+ <svg data-src="{% static "images/mobile-bar.svg" %}" /><span>{% trans "menu" context "Hamburger button text" %}</span></div><a href="/">- {% include 'svg/saleor-logo.svg' %}+ <svg data-src="{% static "images/saleor-logo.svg" %}" /></a></div><div class="col-2 col-md-4 navbar__search static">{% if SEARCH_IS_ENABLED %}<div class="hidden-md-up mobile-search-icon">- {% include 'svg/search-icon.svg' %}+ <svg data-src="{% static "images/search-icon.svg" %}" /></div><form class="form-inline search-form" action="{% url "search:search" %}"><div class="mobile-close-search hidden-md-up">- {% include 'svg/close-icon.svg' %}+ <svg data-src="{% static "images/close-icon.svg" %}" /></div><input class="form-control" type="text" name="q" value="{% if query %}{{ query }}{% endif %}" placeholder="{% trans "Search for product" %}"><button class="btn btn-link" type="submit">- {% include 'svg/search-icon.svg' %}+ <svg data-src="{% static "images/search-icon.svg" %}" /></button></form>{% endif %}@@ -102,7 +102,7 @@{% trans "Your Cart" context "Main navigation item" %}</span><div class="navbar__brand__cart__icon">- {% include 'svg/cart.svg' %}+ <svg data-src="{% static "images/cart.svg" %}" /></div><span class="badge {% if not cart_counter %}empty{% endif %}">{% if cart_counter %}@@ -113,7 +113,7 @@</span></a><div class="cart-dropdown hidden-md-down">- {% include 'cart-dropdown.html' %}+ {% include 'cart-dropdown.html' %}</div></div></div>@@ -158,7 +158,7 @@<div class="row"><div class="col-md-3"><a href="/" class="footer__logo">- {% include 'svg/saleor-logo.svg' %}+ <svg data-src="{% static "images/saleor-logo.svg" %}" /></a></div><div class="col-md-3 col-sm-6">@@ -217,10 +217,10 @@</div><div class="col-md-3 col-sm-12"><a target="_blank" rel="noopener" class="github-footer" href="https://github.com/mirumee/saleor">- {% include 'svg/github_logo.svg' %}+ <svg data-src="{% static "images/github_logo.svg" %}" /></a><a target="_blank" rel="noopener" href="https://twitter.com/getsaleor">- {% include 'svg/twitter_logo.svg' %}+ <svg data-src="{% static "images/twitter_logo.svg" %}" /></a></div></div>diff --git a/templates/cart/index.html b/templates/cart/index.htmlindex d0a2b7898d..f95475f2ff 100644--- a/templates/cart/index.html+++ b/templates/cart/index.html@@ -56,7 +56,7 @@{% csrf_token %}</form><span class="cart-item-delete">- {% include 'svg/icon_delete.svg' %}+ <svg data-src="{% static "images/icon_delete.svg" %}" /></span><small class="cart__line__quantity-error text-danger"></small></div>diff --git a/templates/category/_items.html b/templates/category/_items.htmlindex 953ab36a5d..9b9a2bc749 100644--- a/templates/category/_items.html+++ b/templates/category/_items.html@@ -27,7 +27,7 @@{% if availability.price_range_undiscounted.min_price != availability.price_range.min_price %}<div class="product-list__sale"><span class="isvg">- {% include 'svg/sale_bg.svg' %}+ <svg data-src="{% static "images/sale_bg.svg" %}" /></span><span>{% comment %}Translators: Layout may break if character length is different than four.{% endcomment %}diff --git a/templates/checkout/details.html b/templates/checkout/details.htmlindex 60d7eb6b2e..9a4061c764 100644--- a/templates/checkout/details.html+++ b/templates/checkout/details.html@@ -13,7 +13,7 @@<header class="checkout__header"><div class="container"><a href="/">- {% include 'svg/saleor-logo.svg' %}+ <svg data-src="{% static "images/saleor-logo.svg" %}" /></a><h1>{% trans "Checkout" context "Checkout title" %}</h1></div>diff --git a/templates/dashboard/base.html b/templates/dashboard/base.htmlindex 24417746a1..605f8632fd 100644--- a/templates/dashboard/base.html+++ b/templates/dashboard/base.html@@ -64,7 +64,7 @@</li><li><a href="{% url 'dashboard:index' %}" class="logo">- <img src="{% static "images/dashboard-logo.svg" %}" alt="Saleor">+ <svg data-src="{% static "images/saleor-logo.svg" %}" /></a></li><li class="search">diff --git a/templates/dashboard/styleguide/index.html b/templates/dashboard/styleguide/index.htmlindex 26cc3764a6..b32eb072c9 100644--- a/templates/dashboard/styleguide/index.html+++ b/templates/dashboard/styleguide/index.html@@ -29,9 +29,7 @@<div class="nav-wrapper"><ul class="left"><li class="logo">- <a href="{% url "dashboard:index" %}">- <img src="{% static "images/dashboard-logo.svg" %}" alt="Saleor">- </a>+ <svg data-src="{% static "images/saleor-logo.svg" %}" /></li><li><span>Style Guide</span>diff --git a/templates/product/details.html b/templates/product/details.htmlindex 1fae4a5827..850bba2499 100644--- a/templates/product/details.html+++ b/templates/product/details.html@@ -52,10 +52,10 @@</div>{% if images|length > 1 %}<a class="carousel-control-prev" href="#carousel-example-generic" role="button" data-slide="prev">- {% include 'svg/gallery-arrow.svg' %}+ <svg data-src="{% static "images/gallery-arrow.svg" %}" /></a><a class="carousel-control-next" href="#carousel-example-generic" role="button" data-slide="next">- {% include 'svg/gallery-arrow.svg' %}+ <svg data-src="{% static "images/gallery-arrow.svg" %}" /></a>{% endif %}<ol class="carousel-indicators hidden-sm-down">diff --git a/templates/search/results.html b/templates/search/results.htmlindex 65f3cd3ec9..639218ace7 100644--- a/templates/search/results.html+++ b/templates/search/results.html@@ -31,7 +31,7 @@<div class="row no-results"><div class="col-12"><h2>{% trans "Search:" %} <strong>{{ query }}</strong></h2>- <img src="{% static 'images/pirate.svg' %}" />+ <svg data-src="{% static "images/pirate.svg" %}" /><p>{% trans "Sorry, no matches found for your request." context "Search without results text" %}</p><p>{% trans "Try again or shop new arrivals." context "Search without results text" %}</p></div>diff --git a/templates/styleguide.html b/templates/styleguide.htmlindex 375f9df732..a700f819ab 100644--- a/templates/styleguide.html+++ b/templates/styleguide.html@@ -11,7 +11,7 @@<header class="checkout__header"><div class="container"><a href="/">- {% include 'svg/saleor-logo.svg' %}+ <svg data-src="{% static "images/saleor-logo.svg" %}" /></a><h1>Style guide</h1></div>@@ -293,15 +293,15 @@</div><div id="icons" class="styleguide__content__block"><h3 class="styleguide__content__block__title">Icons</h3>- <img src="{% static "images/cart.svg" %}">- <img src="{% static "images/chevron-down-icon.svg" %}">- <img src="{% static "images/chevron-up-icon.svg" %}">- <img src="{% static "images/arrow-down-icon.svg" %}">- <img src="{% static "images/arrow-up-icon.svg" %}">- <img src="{% static "images/search-icon.svg" %}">- <img src="{% static "images/gallery-arrow.svg" %}">- <img src="{% static "images/icon_delete.svg" %}">- <img src="{% static "images/loader.svg" %}">+ <svg data-src="{% static "images/cart.svg" %}" />+ <svg data-src="{% static "images/chevron-down-icon.svg" %}" />+ <svg data-src="{% static "images/chevron-up-icon.svg" %}" />+ <svg data-src="{% static "images/arrow-down-icon.svg" %}" />+ <svg data-src="{% static "images/arrow-up-icon.svg" %}" />+ <svg data-src="{% static "images/search-icon.svg" %}" />+ <svg data-src="{% static "images/gallery-arrow.svg" %}" />+ <svg data-src="{% static "images/icon_delete.svg" %}" />+ <svg data-src="{% static "images/loader.svg" %}" /></div><div id="buttons" class="styleguide__content__block"><h3 class="styleguide__content__block__title">Buttons <img src="{% static "images/text-cursor.svg" %}"></h3>@@ -367,7 +367,7 @@<div class="product-filters"><h3 contenteditable="true">Box Size<div class="collapse-filters-icon">- <img src="/static/images/chevron-up-icon.svg">+ <svg data-src="{% static "images/chevron-up-icon.svg" %}" /></div></h3><ul id="box-size">@@ -429,7 +429,7 @@<form class="form-inline search-form" action="{% url "search:search" %}"><input class="form-control" type="text" name="q" value="{% if query %}{{ query }}{% endif %}" placeholder="Search for product"><button class="btn btn-link" type="submit">- <img src="{% static "images/search-icon.svg" %}">+ <svg data-src="{% static "images/search-icon.svg" %}" /></button></form></div>@@ -665,7 +665,7 @@</div><ul class="icons"><li><a href="#" contenteditable="true">Edit</a></li>- <li><a class="delete-icon"><img class="float-right" src="{% static "images/icon_delete.svg" %}"></a></li>+ <li><a class="delete-icon"><svg data-src="{% static "images/icon_delete.svg" %}" /></a></li></ul><div class="address-delete none"><form>@@ -702,7 +702,8 @@<span class="product-list-item-name" contenteditable="true">Johnson-Brown</span></div><div class="panel-footer">- <div class="product-list__sale"><img src="{% static "images/sale_bg.svg" %}">+ <div class="product-list__sale">+ <svg data-src="{% static "images/sale_bg.svg" %}" /><span contenteditable="true">Sale</span></div><span contenteditable="true">FROM $72.25</span>@@ -724,10 +725,10 @@</div></div><a class="carousel-control-prev" href="#carousel-example-generic" role="button" data-slide="prev">- <img class="icon-next" src="{% static "images/gallery-arrow.svg" %}">+ <svg data-src="{% static "images/gallery-arrow.svg" %}" /></a><a class="carousel-control-next" href="#carousel-example-generic" role="button" data-slide="next">- <img class="icon-next" src="{% static "images/gallery-arrow.svg" %}">+ <svg data-src="{% static "images/gallery-arrow.svg" %}" /></a><ol class="carousel-indicators hidden-sm-down"><li data-target="#carousel-example-generic" data-slide-to="0" class="active">diff --git a/templates/userprofile/details.html b/templates/userprofile/details.htmlindex ed52224323..a467de9dea 100644--- a/templates/userprofile/details.html+++ b/templates/userprofile/details.html@@ -115,7 +115,7 @@<li><a href="{% url "profile:address-edit" pk=address.pk %}">{% trans "Edit" context "User address action" %}</a></li>- <li><a class="delete-icon">{% include 'svg/icon_delete.svg' %}</a></li>+ <li><a class="delete-icon"><svg data-src="{% static "images/icon_delete.svg" %}" /></a></li></ul>{% include "userprofile/address-delete.html" with pk=address.pk %}</div>diff --git a/yarn.lock b/yarn.lockindex 4e51ec0825..039b150014 100644--- a/yarn.lock+++ b/yarn.lock@@ -4289,6 +4289,10 @@ supports-color@^3.1.0, supports-color@^3.1.1, supports-color@^3.2.3:dependencies:has-flag "^1.0.0"+svg-injector-2@^2.0.35:+ version "2.0.35"+ resolved "https://registry.yarnpkg.com/svg-injector-2/-/svg-injector-2-2.0.35.tgz#b65c5d9fc17951a30fb6b165668ccbb305da4053"+svgo@^0.7.0:version "0.7.1"resolved "https://registry.yarnpkg.com/svgo/-/svgo-0.7.1.tgz#287320fed972cb097e72c2bb1685f96fe08f8034"