A ruby gem for creating navigations (with multiple levels) for your Rails, Sinatra or Padrino applications. Render your navigation as html list, link list or breadcrumbs.
navigation.items do |primary|
primary.item :events, "Events", events_path, do |events|
events.item :dashboard, "Dashboard", events_dashboard_path
events.item :documents, "Documents", events_documents_path do |documents|
documents.item :invitations, "Invitations", events_documents_path(type: "invitations")
documents.item :rsvps, "RSVPs", events_documents_path(type: "rsvps")
documents.item :unanswered, "Unanswered Invitations", events_documents_path(filter: "unanswered")
end
end
end
When viewing "Invitations", I'd like "Documents" to not get the selected class, but for "Events" to still get the selected class. I passed in a highlights_on lambda, like this:
But this is overridden by the Item#selected? method, which is used for both tree expansion and the call to selected_class.
Is what I'm trying to do possible with some off-the-shelf configuration options? I've worked up a solution with a custom renderer. Using the public API, highlighting for children can only be turned off globally. To get item-level control (i.e., "Events" gets selected but "Documents" does not), I have this method in my renderer:
def should_highlight?(item)
child_highlighting = !item.send(:options)[:no_highlight_for_children]
return false if child_highlighting && !item.selected_class.nil? && item.active_leaf_class.nil?
true
end
Which I'm not in love with, but gets the job done.
TL;DR: I'm trying to get around the sub-navigation rule of the active navigation item highlighting rules.
With this config/navigation.rb file:
When viewing "Invitations", I'd like "Documents" to not get the
selected
class, but for "Events" to still get theselected
class. I passed in ahighlights_on
lambda, like this:But this is overridden by the Item#selected? method, which is used for both tree expansion and the call to
selected_class
.Is what I'm trying to do possible with some off-the-shelf configuration options? I've worked up a solution with a custom renderer. Using the public API, highlighting for children can only be turned off globally. To get item-level control (i.e., "Events" gets
selected
but "Documents" does not), I have this method in my renderer:Which I'm not in love with, but gets the job done.