Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Add responsive search bar
dominik-zeglen59a0d879adc3
diff --git a/saleor/static/dashboard/js/components/search.js b/saleor/static/dashboard/js/components/search.jsnew file mode 100644index 0000000000..79ac8e2428--- /dev/null+++ b/saleor/static/dashboard/js/components/search.js@@ -0,0 +1,16 @@+const init = $(() => {+ $('#btn-search').on('click', (e) => {+ e.preventDefault();+ const $target = $(e.currentTarget);+ $('.search').toggleClass('expanded', !$target.hasClass('expanded'));+ });+ $('#btn-search-close').on('click', (e) => {+ const $target = $(e.currentTarget);+ const isExpanded = $target.hasClass('expanded');+ $('.search').toggleClass('expanded', isExpanded);+ $target.toggleClass('active', !isExpanded);+ });+});+export {+ init as default+};diff --git a/saleor/static/dashboard/js/dashboard.js b/saleor/static/dashboard/js/dashboard.jsindex 1f24dbcfbd..d75c7cb202 100644--- a/saleor/static/dashboard/js/dashboard.js+++ b/saleor/static/dashboard/js/dashboard.js@@ -10,6 +10,7 @@ import './components/modal';import './components/image-gallery';import './components/misc';import './components/filters';+import './components/search';import './components/side-menu';import './components/styleguide';import './components/tab';diff --git a/saleor/static/dashboard/scss/components/_nav.scss b/saleor/static/dashboard/scss/components/_nav.scssindex 25cd176ff9..d22144f288 100644--- a/saleor/static/dashboard/scss/components/_nav.scss+++ b/saleor/static/dashboard/scss/components/_nav.scss@@ -8,45 +8,6 @@ header {@media (max-width: $small-screen) {margin-right: 0;}- .search {- float: none;- margin-left: 270px;- padding: 10px 0;- .input-field {- input {- background-color: rgba(255, 255, 255, .15);- border-radius: 3px;- box-sizing: border-box;- display: inline-block;- height: 36px;- margin-bottom: 0;- transition: background-color .2s ease-out;- width: 100%;- line-height: 1;- &::placeholder {- color: white;- }- &:hover {- background-color: rgba(255, 255, 255, .25);- }- &:focus {- background-color: white;- border: none;- box-shadow: none;-- ~ label {- svg {- fill: $off-black;- }- }- }- }- label {- transition: color .2s ease-out;- margin-top: 22px;- }- }- }}.user-name {padding: (($dropdown-item-height - 22) / 2) 16px;diff --git a/saleor/static/dashboard/scss/components/_search.scss b/saleor/static/dashboard/scss/components/_search.scssindex d50c4f53c8..a39088dfed 100644--- a/saleor/static/dashboard/scss/components/_search.scss+++ b/saleor/static/dashboard/scss/components/_search.scss@@ -1,24 +1,132 @@-.search-form {- input {- border: none;- color: $primary-color;- margin-bottom: 0;- width: 75%;- padding-left: 5%;- &::placeholder {- color: $primary-color;+//.search {+//+// &-form {+// input {+// border: none;+// color: $primary-color;+// margin-bottom: 0;+// width: 75% !important;+// padding-left: 5%;+// &::placeholder {+// color: $primary-color;+// }+// &:focus:not([readonly]), &.valid, &:focus.valid {+// border: none;+// box-shadow: none;+// }+// }+// button {+// width: 20%;+// padding: 0;+// margin-top: 7px;+// &:hover, &:focus {+// background-color: transparent;+// }+// }+// @media (max-width: $large-screen) {+// padding: 1rem;+// input {+// width: calc(100% - 64px) !important;+// }+// button {+// width: 64px;+// svg {+// margin-top: 8px;+// }+// }+// }+// }+//}++.search {+ float: none;+ margin-left: 270px;+ padding: 10px 0;+ transition: $transition-duration;+ @media (max-width: $small-screen) {+ position: absolute;+ top: 0;+ overflow: hidden;+ width: 100%;+ background: $primary-color;+ transform: translateX(-100%);+ margin: 0;+ height: 64px;+ z-index: 1000;+ &.expanded {+ transform: translateX(0px);}- &:focus:not([readonly]), &.valid, &:focus.valid {- border: none;- box-shadow: none;+ .input-field {+ width: calc(100% - 128px);+ display: inline-block;+ vertical-align: top;+ padding: 5px 0;+ input[type="search"] {+ position: relative;+ padding-left: 1rem;+ }+ }+ a {+ display: inline-block;+ width: 60px;+ height: 64px;+ padding: 0;+ text-align: center;+ line-height: 80px;+ position: relative;+ top: -10px;+ vertical-align: top;+ &#btn-search-close {+ position: relative;+ &:before, &:after {+ content: '';+ position: absolute;+ background: #fff;+ width: 2px;+ height: 22px;+ top: 22px;+ left: 30px;+ }+ &:before {+ transform: rotate(45deg);+ }+ &:after{+ transform: rotate(-45deg);+ }+ }}}- button {- width: 20%;- padding: 0;- margin-top: 7px;- &:hover, &:focus {- background-color: transparent;+ .input-field {+ height: 36px;+ input {+ background-color: rgba(255, 255, 255, .15);+ border-radius: 3px;+ box-sizing: border-box;+ display: inline-block;+ margin-bottom: 0;+ transition: background-color .2s ease-out;+ width: 100% !important;+ line-height: 1;+ &::placeholder {+ color: white;+ }+ &:hover {+ background-color: rgba(255, 255, 255, .25);+ }+ &:focus {+ background-color: white;+ border: none;+ box-shadow: none;+ ~ label {+ svg {+ fill: $off-black;+ }+ }+ }+ }+ label {+ transition: color .2s ease-out;+ margin-top: 22px;}}}diff --git a/templates/dashboard/base.html b/templates/dashboard/base.htmlindex 1f08219537..df52745690 100644--- a/templates/dashboard/base.html+++ b/templates/dashboard/base.html@@ -54,7 +54,7 @@<svg data-src="{% static "/dashboard/images/account_circle.svg" %}" width="24" height="24" fill="#fff" /></a>{% if SEARCH_IS_ENABLED %}- <a href="{% url "dashboard:search" %}" class="hide-on-med-and-up dropdown-button">+ <a href="{% url "dashboard:search" %}" class="dropdown-button hide-on-med-and-up" id="btn-search"><svg data-src="{% static "dashboard/images/search.svg" %}" width="24" height="24" fill="#fff" /></a>{% endif %}@@ -70,15 +70,19 @@<svg data-src="{% static "dashboard/images/logo.svg" %}" height="38px" width="176px" /></a></li>- <li class="search">+ <li class="search expanded">{% if SEARCH_IS_ENABLED %}- <form method="get" action="{% url "dashboard:search" %}" class="hide-on-small-only">- <div class="input-field">+ <form method="get" action="{% url "dashboard:search" %}">+ <a class="hide-on-med-and-up" id="btn-search-close"></a>+ <div class="input-field d-inline"><input id="search" type="search" placeholder="{% trans "Search" context "Dashboard search" %}" name="q" value="{% if query %}{{ query }}{% endif %}">- <label>+ <label class="hide-on-small-only"><svg data-src="{% static "dashboard/images/search.svg" %}" width="24" height="24" fill="#fff" /></label></div>+ <a href="{% url "dashboard:search" %}" class="hide-on-med-and-up" id="btn-search-submit">+ <svg data-src="{% static "dashboard/images/search.svg" %}" width="24" height="24" fill="#fff" />+ </a></form>{% endif %}</li>