Skip to content

Commit

Permalink
tweak the links ion sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
epugh committed Aug 4, 2023
1 parent a76aff2 commit b75a7f8
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 59 deletions.
9 changes: 9 additions & 0 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# frozen_string_literal: true

module ApplicationHelper

def make_active?(options)
if (options.key?(:path))
request.fullpath.include?(options[:path])
elsif (options.key?(:controller))
controller_name == options[:controller]
end
end

def bootstrap_class_for flash_type
{
success: 'alert-success',
Expand Down
93 changes: 34 additions & 59 deletions app/views/layouts/_sidebar2.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -70,100 +70,75 @@
<div class="sidebar d-flex flex-column flex-shrink-0 bg-body-tertiary" style="width: 3.5rem;">
<ul class="nav nav-pills nav-flush flex-column mb-auto text-center">
<li class="nav-item">
<!-- eliminating this nav-item causes layout issues, so making svg by 0x0 instead :-( -->
<a href="#" class="nav-link active py-3 border-bottom rounded-0" aria-current="page" data-bs-toggle="tooltip" data-bs-placement="right" aria-label="Home" data-bs-original-title="Home">
<svg class="bi pe-none" width="0" height="0" role="img" aria-label="Home"><use xlink:href="#home"></use></svg>
<svg class="bi pe-none" width="24" height="24" role="img" aria-label="Home"><use xlink:href="#home"></use></svg>
</a>
</li>
<li class="nav-item">
<a class="nav-link active py-3 border-bottom rounded-0" href="#" data-bs-toggle="tooltip" data-bs-placement="right" aria-label="Dashboard" data-bs-original-title="Dashboard">
<li>
<%= link_to root_path, class: "nav-link #{make_active?({controller: 'home'}) ? 'active' : ''} py-3 border-bottom rounded-0", 'data-bs-toggle':'tooltip', 'data-bs-placement':'right', 'aria-label':'Dashboard', 'data-bs-original-title':'Dashboard' do %>
<i
class="bi bi-speedometer2"
aria-hidden="true"
title="Dashboard"
alt="Dashboard"
style="font-size: 1.5rem; color: white;"
></i>
</a>
</li>
<li>
<a class="nav-link py-3 border-bottom rounded-0" href="#" data-bs-toggle="tooltip" data-bs-placement="right" aria-label="Relevancy Cases" data-bs-original-title="Relevancy Cases">
<i
class="fa fa-briefcase"
aria-hidden="true"
title="Relevancy Cases"
alt="Relevancy Cases"
style="font-size: 1.5rem; color: cornflowerblue;"
style="font-size: 1.5rem; color: <%= make_active?({controller: 'home'}) ? 'white' : 'cornflowerblue' %>;"
></i>
</a>
</li>
<% end %>
</li>
<li>
<a class="nav-link py-3 border-bottom rounded-0" href="#" data-bs-toggle="tooltip" data-bs-placement="right" aria-label="Judgements" data-bs-original-title="Judgements">
<%= link_to books_path, class: "nav-link #{make_active?({path: 'book'}) ? 'active' : ''} py-3 border-bottom rounded-0", 'data-bs-toggle':'tooltip', 'data-bs-placement':'right', 'aria-label':'Judgements', 'data-bs-original-title':'Judgements' do %>
<i
class="bi bi-book-half"
class="fa fa-book"
aria-hidden="true"
title="Judgements"
alt="Judgements"
style="font-size: 1.5rem; color: cornflowerblue;"
style="font-size: 1.5rem; color: <%= make_active?({path: 'book'}) ? 'white' : 'cornflowerblue' %>;"
></i>
</a>
</li>
<% end %>
</li>
<li>
<a class="nav-link py-3 border-bottom rounded-0" href="#" data-bs-toggle="tooltip" data-bs-placement="right" aria-label="Teams" data-bs-original-title="Teams">
<%= link_to cases_path, class: "nav-link #{make_active?({path: 'case'}) ? 'active' : ''} py-3 border-bottom rounded-0", 'data-bs-toggle':'tooltip', 'data-bs-placement':'right', 'aria-label':'Relevancy Cases', 'data-bs-original-title':'Relevancy Cases' do %>
<i
class="fa fa-people-group"
class="fa fa-briefcase"
aria-hidden="true"
title="Teams"
alt="Teams"
style="font-size: 1.5rem; color: cornflowerblue;"
title="Relevancy Cases"
alt="Relevancy Cases"
style="font-size: 1.5rem; color: <%= make_active?({path: 'case'}) ? 'white' : 'cornflowerblue' %>;"
></i>
</a>
</li>

<% end %>
</li>
<li>
<a class="nav-link py-3 border-bottom rounded-0" href="#" data-bs-toggle="tooltip" data-bs-placement="right" aria-label="Scorers" data-bs-original-title="Scorers">
<%= link_to scorers_path, class: "nav-link #{make_active?({path: 'case'}) ? 'active' : ''} py-3 border-bottom rounded-0", 'data-bs-toggle':'tooltip', 'data-bs-placement':'right', 'aria-label':'Scorers', 'data-bs-original-title':'Scorers' do %>
<i
class="bi bi-list-task"
aria-hidden="true"
title="Scorers"
alt="Scorers"
style="font-size: 1.5rem; color: cornflowerblue;"
style="font-size: 1.5rem; color: <%= make_active?({path: 'case'}) ? 'white' : 'cornflowerblue' %>;"
></i>
</a>
</li>
<li>
<a href="#" class="nav-link py-3 border-bottom rounded-0" data-bs-toggle="tooltip" data-bs-placement="right" aria-label="Dashboard" data-bs-original-title="Dashboard">
<svg class="bi pe-none" width="24" height="24" role="img" aria-label="Dashboard">
<use xlink:href="#speedometer2"></use>
</svg>
</a>
</li>
<li>
<a href="#" class="nav-link py-3 border-bottom rounded-0" data-bs-toggle="tooltip" data-bs-placement="right" aria-label="Orders" data-bs-original-title="Orders">
<svg class="bi pe-none" width="24" height="24" role="img" aria-label="Orders"><use xlink:href="#table"></use></svg>
</a>
<% end %>
</li>
<li>
<a href="#" class="nav-link py-3 border-bottom rounded-0" data-bs-toggle="tooltip" data-bs-placement="right" aria-label="Products" data-bs-original-title="Products">
<svg class="bi pe-none" width="24" height="24" role="img" aria-label="Products"><use xlink:href="#grid"></use></svg>
</a>
</li>
<li>
<a href="#" class="nav-link py-3 border-bottom rounded-0" data-bs-toggle="tooltip" data-bs-placement="right" aria-label="Customers" data-bs-original-title="Customers">
<svg class="bi pe-none" width="24" height="24" role="img" aria-label="Customers"><use xlink:href="#people-circle"></use></svg>
</a>
</li>
<%= link_to cases_path, class: "nav-link #{make_active?({path: 'case'}) ? 'active' : ''} py-3 border-bottom rounded-0", 'data-bs-toggle':'tooltip', 'data-bs-placement':'right', 'aria-label':'Notebooks', 'data-bs-original-title':'Notebooks' do %>
<i
class="bi bi-journal-medical"
aria-hidden="true"
title="Notebooks"
alt="Notebooks"
style="font-size: 1.5rem; color: <%= make_active?({path: 'case'}) ? 'white' : 'cornflowerblue' %>;"
></i>
<% end %>
</li>
</ul>
<div class="dropdown border-top">
<a href="#" class="d-flex align-items-center justify-content-center p-3 link-body-emphasis text-decoration-none dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false">
<%= image_tag current_user.avatar_url, size: '24x24', class: 'rounded-circle' %>
</a>
<ul class="dropdown-menu text-small shadow">
<li><a class="dropdown-item" href="#">New project...</a></li>
<li><a class="dropdown-item" href="#">Settings</a></li>
<li><a class="dropdown-item" href="#">Profile</a></li>
<li><a class="dropdown-item" href="#">New case...</a></li>
<li><%= link_to "Profile", profile_path, class:'dropdown-item' %></li>
<li><hr class="dropdown-divider"></li>
<li><a class="dropdown-item" href="#">Sign out</a></li>
<li><%= link_to "Log out", logout_path, class:'dropdown-item' %></li>
</ul>
</div>
</div>

0 comments on commit b75a7f8

Please sign in to comment.