Skip to content

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

Add side navigation for mobile

weronkad6e7b6ee1bc1
diff --git a/saleor/static/js/demo/storefront.js b/saleor/static/js/demo/storefront.js
index 4133e4a154..57ca56921f 100644
--- a/saleor/static/js/demo/storefront.js
+++ b/saleor/static/js/demo/storefront.js
@@ -1,7 +1,25 @@
-/* @flow */
+import '../../scss/demo/storefront.scss'
-import 'bootstrap-sass'
-import $ from 'jquery'
-import 'jquery.cookie'
+// Mobile menu
-import '../../scss/demo/storefront.scss'
\ No newline at end of file
+var $toogleIcon = $('.navbar__brand__menu-toggle');
+var $mobileNav = $('nav');
+
+if ($(window).width() < 768) {
+ $mobileNav.append('<ul class="nav navbar-nav navbar__menu__login"></ul>');
+ $('.navbar__login a').appendTo('.navbar__menu__login')
+ .wrap( '<li class="nav-item login-item"></li>')
+ .addClass('nav-link');
+}
+
+$toogleIcon.click((e) => {
+ $mobileNav.toggleClass('open');
+});
+
+$(document).click((e) => {
+ $mobileNav.removeClass('open');
+});
+
+$toogleIcon.click((e) => {
+ event.stopPropagation();
+});
\ No newline at end of file
diff --git a/saleor/static/scss/demo/components/_header.scss b/saleor/static/scss/demo/components/_header.scss
index e7a204cfb5..ed5c0e2b8d 100644
--- a/saleor/static/scss/demo/components/_header.scss
+++ b/saleor/static/scss/demo/components/_header.scss
@@ -1,8 +1,8 @@
.navbar {
padding: 0;
- @include media-breakpoint-down(md) {
+ @include media-breakpoint-down(sm) {
img {
- max-height: 30px;
+ max-height: 22px;
}
}
&__login {
@@ -48,9 +48,18 @@
height: 30px;
text-align: center;
line-height: 2;
+ @include media-breakpoint-down(sm) {
+ font-size: 0.8rem;
+ width: 25px;
+ height: 25px;
+ line-height: 2.1;
+ }
}
}
}
+ &__menu-toggle {
+ max-height: 22px;
+ }
}
&__menu {
ul {
@@ -69,11 +78,13 @@
+ .nav-item {
margin-left: 0;
}
- &:last-of-type {
- a {
- color: $red;
- &:hover {
- color: rgba($red, 0.6);
+ &:not(.login-item) {
+ &:last-of-type {
+ a {
+ color: $red;
+ &:hover {
+ color: rgba($red, 0.6);
+ }
}
}
}
@@ -86,5 +97,24 @@
}
}
}
+ @include media-breakpoint-down(sm) {
+ .navigation {
+ position: absolute;
+ left: -180px;
+ height: 100vh;
+ width: 180px;
+ z-index: 100;
+ background-color: $white;
+ padding-left: $global-padding * 1.5;
+ transition: 0.3s ease-in-out;
+ li {
+ width: 100%;
+ text-align: left;
+ }
+ &.open {
+ left: 0;
+ }
+ }
+ }
}
}
\ No newline at end of file
diff --git a/templates/demo/base.html b/templates/demo/base.html
index 367a074b25..e43ad661d6 100644
--- a/templates/demo/base.html
+++ b/templates/demo/base.html
@@ -27,9 +27,9 @@
<body itemscope itemtype="http://schema.org/WebPage">
{% block header %}
<header class="navbar navbar-default navbar-inverse navbar-static-top" role="navigation">
- <div class="navbar__login">
+ <div class="navbar__login hidden-sm-down">
<div class="container">
- <p class="float-xs-left hidden-sm-down">{% trans "Test Saleor in Testeor - a sample shop!" %}</p>
+ <p class="float-xs-left">{% trans "Test Saleor in Testeor - a sample shop!" %}</p>
<p class="float-xs-right">
{% if user.is_authenticated %}
{% if user.is_staff %}
@@ -45,12 +45,12 @@
</div>
<div class="navbar__brand">
<div class="container">
- <img class="hidden-md-up" src="{% static "img/mobile-bar.svg" %}">
- <a href="/">
+ <img class="hidden-md-up navbar__brand__menu-toggle closed open" src="{% static "img/mobile-bar.svg" %}">
+ <a href="{% url "demo" %}">
<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" %}">
+ <img class="hidden-md-up " src="{% static "img/search-icon.svg" %}">
<div class="navbar__brand__basket float-xs-right">
<a href="{% url "cart:index" %}">
<span class="hidden-sm-down">{% trans "Your basket" %}</span>
@@ -63,8 +63,7 @@
</div>
<div class="navbar__menu">
<div class="container">
- <nav class="navbar">
- <div class="collapse navbar-toggleable-sm" id="navbarResponsive">
+ <nav class="navigation">
<ul class="nav navbar-nav">
{% for category in categories %}
<li class="nav-item">
@@ -74,7 +73,6 @@
</li>
{% endfor %}
</ul>
- </div>
</nav>
</div>
</div>
@@ -109,7 +107,7 @@
<div class="container">
<div class="row">
<div class="col-md-3">
- <a href="/">
+ <a href="{% url "demo" %}">
<img class="footer__logo" src="{% static "img/testeor-logo-white.svg" %}" alt="Testeor - Saleor demo store">
</a>
</div>
@@ -166,7 +164,8 @@
{% endblock %}
{% block footer_scripts %}
{% render_bundle 'vendor' 'js' %}
- {% render_bundle 'storefront' 'js' %}
+ {% render_bundle 'demo' 'js' %}
{% endblock footer_scripts %}
</body>
</html>
+