Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Display dropdown menu
Anna Siwik26735ef253ef
diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.pyindex e2221402d4..2f08972f55 100644--- a/saleor/core/utils/random_data.py+++ b/saleor/core/utils/random_data.py@@ -591,10 +591,16 @@ def create_menu_items_by_schema(menu):category=category)collection = Collection.objects.order_by('?')[0]- menu.items.get_or_create(- name=collection.name,+ item, _ = menu.items.get_or_create(+ name='Collections',collection=collection)+ for collection in Collection.objects.all():+ menu.items.get_or_create(+ name=collection.name,+ collection=collection,+ parent=item)+page = Page.objects.order_by('?')[0]menu.items.get_or_create(name=page.title,diff --git a/saleor/static/scss/components/_header.scss b/saleor/static/scss/components/_header.scssindex 9640f38f27..ccd565c841 100644--- a/saleor/static/scss/components/_header.scss+++ b/saleor/static/scss/components/_header.scss@@ -28,6 +28,103 @@}}++ @include media-breakpoint-up(sm) {+ &__dropdown {+ display: inline-block;+ position: relative;++ &:hover > a {+ border-bottom: 3px solid black;+ }++ & > a {+ padding: 0.5rem;+ margin: 1rem;+ box-sizing: border-box;+ border-bottom: 3px solid $white;+ }+ }++ &__dropdown-content {+ display: none;+ position: absolute;+ z-index: 3;+ border: solid 1px $gray;+ background-color: $white;+ text-align: left;++ .container {+ padding: $global-padding;+ max-height: 28rem;+ }++ a {+ padding: 0;+ font-size: initial;+ text-transform: none;+ text-decoration: none;+ }++ ul {+ min-width: 120px;+ width: 360px;++ li {+ display: inline-block;+ max-width: 110px;++ &:not(:last-child) {+ margin-right: $global-padding * 2;+ }+ }+ }+ }++ &:hover .nav-item__dropdown-content {+ display: block;+ }+ }+ }+ }+}++.menu {+ .menu__item {+ ul {+ border-bottom: none;+ list-style-type: none;+ padding-left: 0;+ text-align: left;+ margin-bottom: 0;++ ul {+ padding-left: $global-padding;+ }++ li {+ text-align: left;+ }+ }++ a {+ text-decoration: none;+ }++ @include media-breakpoint-down(sm) {+ .nav-item__submenu ul {+ text-align: center;+ font-size: 0.8rem;++ ul {+ padding-left: 0;+ font-size: 0.7rem;+ }++ li {+ text-align: center;+ }+ }}}}diff --git a/templates/menu.html b/templates/menu.htmlindex 0851d692a5..3289e4efb3 100644--- a/templates/menu.html+++ b/templates/menu.html@@ -1,10 +1,40 @@{% url 'home' as home_url %}-<ul class="{% if horizontal %}nav mb-4 mb-md-0{% endif %}{% if request.get_full_path == home_url %} no-border{% endif %}">+<ul class="menu {% if horizontal %}nav mb-4 mb-md-0{% endif %}{% if request.get_full_path == home_url %} no-border{% endif %}">{% for item in menu_items %}- <li class="{% if horizontal %}nav-item{% endif %}">+ {% with children=item.get_children %}+ <li class="{% if horizontal %}nav-item{% endif %} {% if children %}nav-item__dropdown{% endif %} menu__item"><a class="{% if horizontal %}nav-link{% endif %}" href="{{ item.get_url }}">{{ item }}</a>+ {% if children %}+ <div class="{% if horizontal %}nav-item__dropdown-content{% else %}nav-item__submenu{% endif %}">+ <div class="container">+ <ul>+ {% for child in children %}+ <li>+ <a href="{{ child.get_url }}">+ <strong>{{ child }}</strong>+ </a>+ </li>+ {% with grandchildren=child.get_children %}+ {% if grandchildren %}+ <ul>+ {% for grandchild in grandchildren %}+ <li>+ <a href="{{ grandchild.get_url }}">+ {{ grandchild }}+ </a>+ </li>+ {% endfor %}+ </ul>+ {% endif %}+ {% endwith %}+ {% endfor %}+ </ul>+ </div>+ </div>+ {% endif %}</li>+ {% endwith %}{% endfor %}</ul>