Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Convert mobile navigation to use Spree::Menu

Matthew Kennedydbc2e953e2d9
diff --git a/frontend/app/views/spree/shared/_mobile_navigation.html.erb b/frontend/app/views/spree/shared/_mobile_navigation.html.erb
index 5acf3d23ed..142bfb1ab3 100644
--- a/frontend/app/views/spree/shared/_mobile_navigation.html.erb
+++ b/frontend/app/views/spree/shared/_mobile_navigation.html.erb
@@ -1,4 +1,6 @@
-<% if spree_navigation_data.any? %>
+<% main_menu_items = menu_by_name_items('Main Menu') %>
+
+<% if main_menu_items %>
<div class="position-fixed text-uppercase d-xl-none mobile-navigation" role="navigation" aria-label="<%= Spree.t('nav_bar.mobile') %>">
<div class="container d-flex align-items-center justify-content-between header-spree" data-hook>
<button class="m-0 p-0" id="mobile-navigation-back-button" aria-label="<%= Spree.t('nav_bar.go_to_previous_menu') %>">
@@ -18,30 +20,37 @@
</div>
<ul class="list-unstyled position-relative h-100 mobile-navigation-list">
- <% spree_navigation_data.each do |root| %>
- <li class="d-flex justify-content-between align-items-center mobile-navigation-list-item">
- <%= link_to root[:title], root[:url], class: 'w-75' %>
- <% if root[:items].present? %>
- <a class="w-25 text-right mobile-navigation-category-link" data-category="<%= root[:title].parameterize %>" href="#" aria-label="<%= Spree.t('go_to_category') %>">
+ <% main_menu_items.each do |root| %>
+ <% if root.root? %>
+ <li class="d-flex justify-content-between align-items-center mobile-navigation-list-item">
+ <%= link_to root.name, menu_item_link_to(root), class: 'w-75' %>
+ <% if root.children.present? %>
+ <a class="w-25 text-right mobile-navigation-category-link" data-category="<%= root.name.parameterize %>" href="#" aria-label="<%= Spree.t('go_to_category') %>">
<%= icon(name: 'arrow-right',
classes: 'd-inline spree-icon-arrow spree-icon-arrow-right',
width: 14,
height: 27) %>
</a>
- <ul class="list-unstyled position-absolute mobile-navigation-sublist" data-category="<%= root[:title].parameterize %>">
- <li class="text-center font-weight-bold mobile-navigation-sublist-header">
- <%= root[:title] %>
- </li>
- <% root[:items].each do |item| %>
- <li class="d-flex justify-content-between align-items-center mobile-navigation-list-item">
- <%= link_to item[:title], item[:url], class: 'w-75' %>
+ <ul class="list-unstyled position-absolute mobile-navigation-sublist" data-category="<%= root.name.parameterize %>">
+ <li class="text-center font-weight-bold mobile-navigation-sublist-header">
+ <%= root.name %>
</li>
- <% end %>
- </ul>
- <% end %>
- </li>
+
+ <% root.children.each do |child| %>
+ <% if child.code == 'category' && child.item_type == 'Container' %>
+ <% if child.children.present? %>
+ <% child.children.each do |category_link| %>
+ <li class="d-flex justify-content-between align-items-center mobile-navigation-list-item">
+ <%= link_to category_link.name, menu_item_link_to(category_link), class: 'w-75' %>
+ </li>
+ <% end %>
+ <% end %>
+ <% end %>
+ <% end %>
+ </ul>
+ <% end %>
+ </li>
+ <% end %>
<% end %>
- <%= render partial: 'spree/shared/mobile_internationalization_options' %>
</ul>
- </div>
<% end %>