Skip to content

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

Add styles to mobile search form in header

weronka4f0661ba0679
diff --git a/package.json b/package.json
index e47103c8f5..2fccdf1319 100644
--- a/package.json
+++ b/package.json
@@ -20,6 +20,7 @@
"bootstrap-sass": "^3.3.7",
"classnames": "^2.2.5",
"dropzone": "^4.2.0",
+ "font-awesome": "^4.7.0",
"jquery": "^2.1.4",
"jquery-match-height": "^0.7.0",
"jquery-ui": "^1.12.1",
diff --git a/saleor/static/js/storefront.js b/saleor/static/js/storefront.js
index 073de1e741..048029b081 100644
--- a/saleor/static/js/storefront.js
+++ b/saleor/static/js/storefront.js
@@ -47,6 +47,18 @@ $(document).ready((e) => {
})
})
+// Mobile search form
+
+var $searchIcon = $('.mobile-search-icon')
+var $closeSearchIcon = $('.mobile-close-search')
+var $searchForm = $('.navbar__brand__search')
+$searchIcon.click((e) => {
+ $searchForm.animate({left: 0}, {duration: 500})
+})
+$closeSearchIcon.click((e) => {
+ $searchForm.animate({left: '-100vw'}, {duration: 500})
+})
+
// Sticky footer
var navbarHeight = $('.navbar').outerHeight(true)
diff --git a/saleor/static/scss/storefront/components/_header.scss b/saleor/static/scss/storefront/components/_header.scss
index e84cf142ed..086b1bf5bf 100644
--- a/saleor/static/scss/storefront/components/_header.scss
+++ b/saleor/static/scss/storefront/components/_header.scss
@@ -90,6 +90,30 @@
max-height: 1.5rem;
}
}
+ @include media-breakpoint-down(sm) {
+ display: block;
+ left: -100vw;
+ position: absolute;
+ width: 90%;
+ max-width: 90%;
+ float: right;
+ top: -2rem;
+ z-index: 4;
+ margin-top: 0;
+ input {
+ padding: $global-padding * 2 $global-padding * 2 $global-padding * 2 $global-padding * 4;
+ border: 0;
+ min-width: 100vw;
+ }
+ i {
+ position: absolute;
+ padding: $global-padding * 1.7 $global-padding;
+ }
+ .btn {
+ top: 2rem;
+ right: 0;
+ }
+ }
}
}
&__menu {
diff --git a/saleor/static/scss/storefront/storefront.scss b/saleor/static/scss/storefront/storefront.scss
index ec293fb19d..c21efe9730 100644
--- a/saleor/static/scss/storefront/storefront.scss
+++ b/saleor/static/scss/storefront/storefront.scss
@@ -1,5 +1,6 @@
@import "variables";
@import "~bootstrap/scss/bootstrap";
+@import "~font-awesome/scss/font-awesome";
@import "components/fonts";
@import "components/buttons";
diff --git a/saleor/static/scss/storefront/variables.scss b/saleor/static/scss/storefront/variables.scss
index c21570409c..11a44a3a5d 100644
--- a/saleor/static/scss/storefront/variables.scss
+++ b/saleor/static/scss/storefront/variables.scss
@@ -1,4 +1,6 @@
// GLOBAL
+$fa-font-path: "~font-awesome/fonts";
+
$global-padding: 1rem;
$global-margin: 1rem;
diff --git a/templates/base.html b/templates/base.html
index 01ab3dca1a..77039625d7 100644
--- a/templates/base.html
+++ b/templates/base.html
@@ -51,7 +51,9 @@
<img src="{% static "img/testeor-logo.svg" %}" alt="Testeor - Saleor demo store">
</a>
<div class="float-xs-right">
- <img class="hidden-md-up" src="{% static "img/search-icon.svg" %}">
+ {% if SEARCH_IS_ENABLED %}
+ <img class="hidden-md-up mobile-search-icon" src="{% static "img/search-icon.svg" %}">
+ {% endif %}
<div class="navbar__brand__cart float-xs-right">
<a href="{% url "cart:index" %}">
<span class="hidden-sm-down">{% trans "Your cart" %}</span>
@@ -64,7 +66,8 @@
</div>
</div>
{% if SEARCH_IS_ENABLED %}
- <form class="form-inline float-xs-right navbar__brand__search hidden-sm-down" action="{% url "search:search" %}">
+ <form class="form-inline float-xs-right navbar__brand__search" action="{% url "search:search" %}">
+ <i class="fa fa-times fa-2x mobile-close-search hidden-md-up" aria-hidden="true"></i>
<input class="form-control" type="text" placeholder="Search" name="q" value="{% if query %}{{ query }}{% endif %}">
<button class="btn btn-link" type="submit"><img src="{% static "img/search-icon.svg" %}"></button>
</form>
diff --git a/yarn.lock b/yarn.lock
index 22080818bf..a22d0c4c63 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1654,6 +1654,10 @@ flatten@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
+font-awesome@^4.7.0:
+ version "4.7.0"
+ resolved "https://registry.yarnpkg.com/font-awesome/-/font-awesome-4.7.0.tgz#8fa8cf0411a1a31afd07b06d2902bb9fc815a133"
+
for-in@^0.1.5:
version "0.1.6"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-0.1.6.tgz#c9f96e89bfad18a545af5ec3ed352a1d9e5b4dc8"