Stupid fix für mobile menu -> offcanvas sidebar
This commit is contained in:
parent
b4cfad65c0
commit
42e6efc2a3
2 changed files with 40 additions and 8 deletions
|
|
@ -11,21 +11,48 @@
|
|||
<% if @navbar_items %>
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<% @navbar_items.each do |navbar_item| %>
|
||||
<li class="nav-item">
|
||||
<% dropdown = (navbar_item[:active] || @nav_path.to_s == navbar_item[:path].to_s) && @sidebar_items.any? %>
|
||||
<li class="nav-item<%= " dropdown" if dropdown %>">
|
||||
<% if navbar_item[:method].present? && navbar_item[:method] != :get %>
|
||||
<%= button_to(navbar_item[:path], method: navbar_item[:method], class: "nav-link") do %>
|
||||
<%= button_to(navbar_item[:path], method: navbar_item[:method], class: "nav-link#{" dropdown-toggle" if dropdown }") do %>
|
||||
<% if navbar_item[:icon] %>
|
||||
<span aria-hidden="true" class="bi-<%= navbar_item[:icon] %>"></span>
|
||||
<% end %>
|
||||
<%= navbar_item[:label] %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<a class="nav-link <%= (navbar_item[:active] || @nav_path.to_s == navbar_item[:path].to_s) && "active" %>" <%= @nav_path.to_s == navbar_item[:path].to_s && "aria-current=\"page\"" %> href="<%= url_for(navbar_item[:path]) %>">
|
||||
<div class="d-md-none">
|
||||
<a class="nav-link <%= (navbar_item[:active] || @nav_path.to_s == navbar_item[:path].to_s) && "active#{"" if dropdown }" %>" <%= @nav_path.to_s == navbar_item[:path].to_s && "aria-current=\"page\"" %>
|
||||
href="<%= dropdown ? "#" : url_for(navbar_item[:path]) %>" <%= dropdown ? 'role="button" data-bs-toggle="dropdown" aria-expanded="false"' : "" %>>
|
||||
<% if navbar_item[:icon] %>
|
||||
<span aria-hidden="true" class="bi-<%= navbar_item[:icon] %>"></span>
|
||||
<% end %>
|
||||
<%= navbar_item[:label] %>
|
||||
</a>
|
||||
<% if dropdown %>
|
||||
<ul class="">
|
||||
<% @sidebar_items.each do |sidebar_item| %>
|
||||
<li class="dropdown-item">
|
||||
<a class="nav-link text-truncate <%= ((sidebar_item[:active] || @nav_path.to_s == sidebar_item[:path].to_s) && "active") || "" %>" <%= @nav_path.to_s == sidebar_item[:path].to_s && "aria-current=\"page\"" || "" %> href="<%= url_for(sidebar_item[:path]) %>">
|
||||
<% if sidebar_item[:icon] %>
|
||||
<span aria-hidden="true" class="bi-<%= sidebar_item[:icon] %>"></span>
|
||||
<% end %>
|
||||
<%= sidebar_item[:label] %>
|
||||
</a>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="d-none d-md-block">
|
||||
<a class="nav-link <%= (navbar_item[:active] || @nav_path.to_s == navbar_item[:path].to_s) && "active" || "" %>" <%= @nav_path.to_s == navbar_item[:path].to_s && "aria-current=\"page\"" || "" %>
|
||||
href="<%= url_for(navbar_item[:path]) %>">
|
||||
<% if navbar_item[:icon] %>
|
||||
<span aria-hidden="true" class="bi-<%= navbar_item[:icon] %>"></span>
|
||||
<% end %>
|
||||
<%= navbar_item[:label] %>
|
||||
</a>
|
||||
</div>
|
||||
<% end %>
|
||||
</li>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<div class="col-auto px-0">
|
||||
<div class="col col-auto px-0 d-none d-md-block">
|
||||
<div id="sidebar" class="collapse collapse-horizontal show border-0">
|
||||
<div id="sidebar-nav" class="list-group border-0 rounded-0 text-sm-start" style="min-height: 90vh">
|
||||
<% if @sidebar_items %>
|
||||
|
|
@ -19,6 +19,11 @@
|
|||
</a>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<div class="mt-auto ms-auto me-2">
|
||||
<%= link_to("hide") do %>
|
||||
<span class="bi-chevron-left"></span>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="me-auto"></div>
|
||||
<% end %>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue